[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

What is going on here? I have a simple function y=sin(2pi*x).

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 61
Thread images: 11

File: sinewave.jpg (98KB, 843x800px) Image search: [Google]
sinewave.jpg
98KB, 843x800px
What is going on here? I have a simple function y=sin(2pi*x). I only care about 0<x<1 The local maximum and minimum are easy to calculate, even when the period changes. The amplitude is a constant 1.

Now I want this sin wave to lose amplitude over time. So I multiply it by (1-x). This way it is at maximum amplitude at time 0, then loses amplitude until it reaches 0 at time 1.

But when I do this, the time of the local maximum and minimum change. Since the amplitude is being scaled down linearly, I expected the time of peaks and troughs to remain the same while the actual value gets closer to zero. Instead, the times are changing as well.

So I would like to either
>figure out how to calculate the new min and max times when sin(x) is multiplied by (1-x)
or
>replace (1-x) by another formula so that the times of peaks and troughs are conserved but amplitude is still lost over time.

Pointing me in the right direction if it's too difficult to solve would be appreciated.
>>
The positions of the maxima are changing because the (1-x) term changes faster than the sin term close to the sine's peaks. Exponential decay would do the job, but won't be linear.
>>
File: exponentialdecay.jpg (22KB, 480x258px) Image search: [Google]
exponentialdecay.jpg
22KB, 480x258px
>>9144593
I don't mind exponential decay, but is there a single exponent that will preserve the times of the peaks and troughs?
>>
>>9144613
e^(- alpha x)
>>
File: lndecay.png (24KB, 432x378px) Image search: [Google]
lndecay.png
24KB, 432x378px
>>9144619
Even with a period of 1 the peak and trough times don't match up with the expected .25 and .75 using e^-x
>>
>>9144645
Multiplying two functions yields a different set of derivatives than for either function individually. Since maxima/minima are conditional on the derivatives, there is no expectation that maxes and mins should match after multiplying any arbitrary functions.

Try the elementary calculus yourself and you can prove that multiplying two arbitrary functions doesn't preserve maxima. (Why would it?)
>>
>>9144717
>Since maxima/minima are conditional on the derivatives, there is no expectation that maxes and mins should match after multiplying any arbitrary functions.
Okay that makes sense.

So is anyway to find a non-arbitrary function that when multiplied:
>decays the amplitude over t=0 to t=1
>preserves the mimima and maxima of the first function
>>
>>9144766
this sounds like an interesting problem, but first I have to ask:
Are you trying to model something or just find such a pair of functions that satisfy what you want?
>>
>over time
>t
>including a spatial term x

is this not your problem?

>(1-t)sin(x)
>>
>>9144898
no this was not the problem. please read the whole thread before posting something like this
>>
>>9144901
literally answered the question as you phrased it. brainlet.
>>
also you need to substitute pi into the formula instead of 2pi. the trough is unimportant.
>>
oh and try sin^2(x)
>>
or sin(x)cos(x) rather
>>
or sin(2pi * x)*cos(pi/2 * x)
>>
>>9144906
>doesn't read thread
>a fellow anon politely asks to read the thread
>then insults fellow anon
making posts like this decreases the quality of the board. please contribute in a respectful tone which is relevant to the mathematical content of the thread.
>>
>>9144931
its true though. using shitty phrasing one can expect confusion.

im the only fucker contribooting as it stands now, so ill say whatever i damn well please!
>>
so anon you need to solve the problem:
f(0) = 0
f(1) = 0
f'(1/2) =0
f''(1/2) < 0

go nuts
>>
>>9144584
>figure out how to calculate the new min and max when sin(2*pi*x) is multiplied by (1-x)
just differentiate sin(2*pi*x)*(1-x), and then use Newton's method to compute the zeros
>replace (1-x) with an easier formula
you didn't say anything about needing differentiability, so you can just replace (1-x) with a discrete function that shrinks after each half cycle
>>
>>9144953
>being this much of an unironic shitposting highschooler
>>
File: 200w.gif (8KB, 200x231px) Image search: [Google]
200w.gif
8KB, 200x231px
>>9144819
>Are you trying to model something or just find such a pair of functions that satisfy what you want?
I am writing a function for an animation system.

Imagine a fist punch animated for 1 second. An inexperienced animator would make 2 keyframes: the start of the punch and the end of a punch. Animations linearly interpolate over keyframes, so the animation would look really shitty because there is no momentum involved.
A novice animator would add in more keyframes so the punch gains momentum. Of course this can be automated with an exponential interpolation.
An expert animator will put in even more keyframes. A good looking punch will extend beyond its resting point initially, then the puncher will regain control and try to pull his fist back, then slightly forward, wobbling back and forth a few times as he is finally able to maintain the final resting position at time 1.
So you can automate this by phenomenon by creating a "decaying amplitude sine wave" interpolation function.

To make this as easy as possible for the animator, I would like the interpolation function to include the ability to modify the number of wobbles (period) and the time at which the wobble peaks. Multiplying the wobble decay doesn't affect the period, but it is affecting the time of the wobble peaks as seen in my original image. I am therefore trying to figure out how to decay the amplitude while maintaining the peak and trough times so the animator knows exactly what is happening.
>>
>>9144979
anon is trying to fit a function to a predetermined maximum of 1/2 and 3/4 respectively
>>
shitposting "highschooler here".

im pretty sure this is the answer

https://en.wikipedia.org/wiki/Maxwell–Boltzmann_distribution
>>
>>9145002
duh, that is what he said
just do what I said, and multiply sin(x) by a discrete function
>>
>>9145013
yeah this is the best option, especially if the anon is writing the function as a script.
>>
or OP if you want something very close, (1-x/(4pi))sin(x) has a maximum at 4.92
>>
>>9144584
>figure out how to calculate the new min and max times when sin(x) is multiplied by (1-x)
You mean differentiating the function sin(x)*(1-x) and finding the zeroes?
>>
File: simplified.png (101KB, 1478x848px) Image search: [Google]
simplified.png
101KB, 1478x848px
>>9145033
Basically this pic. 1-x won't work a as decay function, so I need a new decay function that preserves the times of peaks and troughs.
>>
>>9145059
the anon previous did give you a satisfactory answer. use a stepwise redefinition of the amplitude as you cross each point.

so your function will look like this:

def f(x):
if 0 < x < 0.25:
return sin(x)
if 0.25<x<0.5:
return 0.5*sin(x)
etc.....


this should work well enough for the eye. highest fps a person can detect is roughly 30fps.
so a function with a step of thirty steps will look like a smooth decay.
>>
>>9145059
In other words, you need a function such that
f(x)*sin(2*pi*x) < f(0.25 + 0.5*k_0)*sin(2*pi*(0.25 + 0.5*k_0)), where x are real numbers withing half a period of 0.25 + 0.5*k_0 (and 0.25 + 0.5*k_0 happens to belong to a crest). So, we have
f(x) - f(x)*(1 - sin(2*pi*x)) < f(0.25 + 0.5*k_0),
f(x) - f(0.25 + 0.5*k_0) < f(x)*(1 - sin(2*pi*x)),
[f(x) - f(0.25 + 0.5*k_0)]/[(1 - sin(2*pi*x))] < f(x)
[f(x) - f(0.25 + 0.5*k_0)]/[(sin(2*pi*(0.25 + 0.5*k_0) - sin(2*pi*x))] < f(x),
- [f(x) - f(0.25 + 0.5*k_0)]/[sin(2*pi*x) - sin(2*pi*(0.25 + 0.5*k_0)] < f(x)
in other words, - f ' (c) < f(x), where f ' (c) is the average derivative on the interval (x,0.25+0.5*k_0).
>>
>>9145101
replace 0.5 with 1
>>
>>9145101
e^-x won't work because the condition is satisfied only when x < x_0, not when x_0 < x
C definitely satisfies the condition, but f*sin will not shrink over time
>>
annoying guy again.

this time i definitely got it, niggers.

https://en.wikipedia.org/wiki/Harmonic_oscillator#Damped_harmonic_oscillator
>>
>>9145132
so solve the damped harmonic oscillator, initial displacement of zero, initial velocity more than zero.
>>
>>9145136
>>9145132
A damped harmonic oscillator actually has a decaying period. OP is trying to make a function where the amplitude decays but the period does not. So the damped harmonic oscillator function will not satisfy the requirements.
>>
>>9145136
Harmonic Oscillator Equation:
ω = ω_0 | |
ω | angular frequency
ω_0 | natural angular frequency

Displacement:
You
>>
>>9145089
This in fact corresponds to oscillation under friction, called Coulomb damping. IIRC the decay is proportional to the coefficient of friction. But I believe the center of oscillation also changed in that case. Should look natural enough.
>>
>>9145392
>Coulomb
Input interpretation: C (coulomb)

Unit type: SI derived: A s (ampere second)

Basic unit dimensions: [time] [current]

Physical quantities: electric charge, battery capacity, dielectric flux

Corresponding quantities for 1 C:
Current I caused by the charge flowing in one second from I = Q/t: | 1 A (ampere)
Force F between like charges 1 cm apart from F = Q^2/(4πϵ_0r^2): | 8.988×10^13 N (newtons)
Time t to deliver 1 ampere of current from t = C/I: | 1 second

Comparisons for 1 C as electric charge:
≈ ( 0.02 ≈ 1/40 ) × positive and negative charge in a typical thundercloud (≈ 40 C )
≈ ( 0.05 ≈ 1/20 ) × charge transfer in a strong lightning stroke (≈ 20 C )
≈ 0.5 × charge transfer in a typical lightning stroke (≈ 2 C )

Conversions to other units:
1 C = unit | conversion | exact value
1 | 1000 mC (millicoulombs) | 1000 mC (millicoulombs)
1 | 0.001 kC (kilocoulombs) | 1/1000 kC (kilocoulombs)
1 | 0.1 abC (abcoulombs)
(unit officially deprecated) | 1/10 abC (abcoulombs)
1 | 2.998×10^9 statC (statcoulombs)
(unit officially deprecated) | 2997924580 statC (statcoulombs)
1 | 2.998×10^9 Fr (franklins) | 2997924580 Fr (franklins)
1 | 2.998×10^9 esus of charge
(unit officially deprecated) | 2997924580 esus of charge
1 | 0.1 emus of charge
(unit officially deprecated) | 1/10 emus of charge
1 | 1.036427×10^-5 F (faradays)
(unit officially deprecated) | 0.00001036427 F (faradays)
1 | 6.2415091×10^18 e (elementary charges) | 6.2415091×10^18 e (elementary charges)
>>
>>9145421
Fuck off, this is not reddit.
>>
>>9145432
>>9145421
>>
>>9145462
1 * Two-sided limit does not exist = False
lim_(x->0) 1/x = False = True
lim_(x->0^-) 1/x = -∞ = False = True
lim_(x->0^+) 1/x = ∞ = False = True
>>
File: 681.png (464KB, 2497x3495px) Image search: [Google]
681.png
464KB, 2497x3495px
>>9145392
pretty sure the frequency changes, but does not decay.

answer is the damped oscillator:
solve f_new = 2pi = f_initial * (1- damping const)^0.5

choose your damping constant and initial frequency to make a new freq of 1 rad per second.

if youre still here op, give me a (you)
>>
So you want a "scaling down" function that doesn't change the positions of the turning points. Since D(fg) = gDf + fDg (i.e. the product rule), you'll get what you want if you choose a scaling function with zero derivative at the same points as the original sine wave. I suggest you construct it piecewise from cubics, setting each cubic to have an inflexion point at one of the sine function's turning points. You can make it smoother/bumpier/whatever by changing the coefficients, or by going to a higher-order polynomial if that doesn't work.
>>
>>9145776
Did you want that sexy coulumb? It talks about Pi you know. Like, a lot. Cunt won't shut up about it.
>>
File: 1485753482052.jpg (78KB, 300x451px) Image search: [Google]
1485753482052.jpg
78KB, 300x451px
>>9145819
ummm wat?
>>
>>9145824
*shrug*
I'm cool with this.

6 is a good number too, it really knows how to avoid that -1/12
>>
>>9145828
yah but 7 8 9 which is bad and wrong
>>
>>9145838
You're talking to someone that really enjoys anal sex, dude!
>>
You want an oscillatory curve with the same local maxima/minima but with decreasing amplitude.
Dude, just divide your curve by x+1 or something like that.
>>
>>9145887
That's wrong. The curve must have the same critical points, the simplest case would be a cubic curve (because two critical points in the interval). In this case something like 16x^3-24x^2+9x+3 works well.
>>
>>9145840
well i cant say i wanted to know.
>>
>>9144584
[math] y = \frac {sin(2 \pi f x)} {x} [/math]
where f is the frequency of the sin wave.
>>
File: fs.png (231KB, 900x1600px) Image search: [Google]
fs.png
231KB, 900x1600px
>>9144584
express your new function as a Fourier series that includes as its leading term your OG sine wave. You can always do this. This of the series as 1) your zeroth order funciton (OG sine wave) 2) the next largest weighted sine wave can be thought of as a 1st order correction 2) next largest weighed sine wave a 2nd order correction... and so on.
>>
Does anyone even bother reading the OP?

instead of (1-x) use
[eqn]1 - \int \sin(2\pi x)dx = 1 +\frac{\sin(4 \pi x)-4 \pi x}{8 \pi}[/eqn]

it works because the derivative is 0 at each minimum and maximum.

note that you need to use the same period in the integral as the sin you are trying to damp.
>>
>>9147978
fuck, integral should be cos, not sin.
[eqn]1 - \int \sin(2\pi x)dx = 1 -\frac{\sin(4 \pi x)+4 \pi x}{8 \pi}[/eqn]
>>
File: proofs.png (26KB, 670x556px) Image search: [Google]
proofs.png
26KB, 670x556px
>>9147987
and I missed a square
[eqn] 1 - \int \sin^2(2\pi x)dx = 1 -\frac{\sin(4 \pi x)+4 \pi x}{8 \pi}[/eqn]

anyway, proof it works
>>
File: proofs2.png (43KB, 691x803px) Image search: [Google]
proofs2.png
43KB, 691x803px
>>9147990
+other one
>>
>>9147990
jesus crist i cant latex tonight. excuse me im drunk
its
[eqn]1 - \int \cos^2(2\pi x)dx = 1 -\frac{\sin(4 \pi x)+4 \pi x}{8 \pi}[/eqn]
>>
File: thumbs.jpg (33KB, 400x400px) Image search: [Google]
thumbs.jpg
33KB, 400x400px
>>9147978
>>9147987
>>9147990
>>9147995
>>9148100
OP back. You are an absolute legend. I'm actually going to my submit spring interpolation function as a pull request to Unreal Engine with the help of your math. I want to credit you if you see this. I'll credit you as "/sci/ anon 9147813" if you don't reply.
>>
>>9148506
glad I could help. some version of anon like that is fine.
>>
>>9148529
Will do. Takes a couple of months for a pull request to go through, and then of course the wait for the new version to be publicly released.
Thread posts: 61
Thread images: 11


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.