- #1
batnas
- 1
- 0
Hey everybody
I'm developing a computer program that can take a series of data-points and estimate the next local maximum(top) of a sine-curve.
My approach to this is to take the formula for a sine-function([itex]f(x)=Asin(\omega x - \phi) + B[/itex]), and isolate all the variables, and that way I'll get a series of (more or less) simple equations, that I can use in my program.
(I'm not entirely sure this is the right approach, let me know otherwise...)
To do this we're using 4 equations with 4 unknown like this:
Then we isolate B in (1) and substitute into (2), (3) & (4):
[itex]y_1 = Asin(\omega x_1 - \phi) + B \Leftrightarrow[/itex]
[itex]B = y_1 - Asin(\omega x_1 - \phi)[/itex]
and
Next, we isolate A from (2.2) and substitute into the other 2:
[itex]y_2 = Asin(\omega x_2 - \phi) + y_1 - Asin(\omega x_1 - \phi) \Leftrightarrow[/itex]
[itex]y_2 - y_1= Asin(\omega x_2 - \phi) - Asin(\omega x_1 - \phi) \Leftrightarrow[/itex]
[itex]y_2 - y_1= A(sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)) \Leftrightarrow[/itex]
[itex]A = \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}[/itex]
and
Next we want to isolate [itex]\omega[/itex] from (3.3):
[itex]y_3 = \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_3 - \phi) + y_1 - \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_1 - \phi) \Leftrightarrow[/itex]
[itex]y_3 - y_1= \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_3 - \phi) - \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_1 - \phi)[/itex]
And this is where I get stuck...
I would think I could take [itex]sin^{-1}()[/itex] of everything, but I'm not sure if it's that simple.
Any help is appreciated
Thanks
\\Batnas
I'm developing a computer program that can take a series of data-points and estimate the next local maximum(top) of a sine-curve.
My approach to this is to take the formula for a sine-function([itex]f(x)=Asin(\omega x - \phi) + B[/itex]), and isolate all the variables, and that way I'll get a series of (more or less) simple equations, that I can use in my program.
(I'm not entirely sure this is the right approach, let me know otherwise...)
To do this we're using 4 equations with 4 unknown like this:
- (1) [itex]y_1 = Asin(\omega x_1 - \phi) + B[/itex]
- (2) [itex]y_2 = Asin(\omega x_2 - \phi) + B[/itex]
- (3) [itex]y_3 = Asin(\omega x_3 - \phi) + B[/itex]
- (4) [itex]y_4 = Asin(\omega x_4 - \phi) + B[/itex]
Then we isolate B in (1) and substitute into (2), (3) & (4):
[itex]y_1 = Asin(\omega x_1 - \phi) + B \Leftrightarrow[/itex]
[itex]B = y_1 - Asin(\omega x_1 - \phi)[/itex]
and
- (2.2) [itex]y_2 = Asin(\omega x_2 - \phi) + y_1 - Asin(\omega x_1 - \phi)[/itex]
- (3.2) [itex]y_3 = Asin(\omega x_3 - \phi) + y_1 - Asin(\omega x_1 - \phi)[/itex]
- (4.2) [itex]y_4 = Asin(\omega x_4 - \phi) + y_1 - Asin(\omega x_1 - \phi)[/itex]
Next, we isolate A from (2.2) and substitute into the other 2:
[itex]y_2 = Asin(\omega x_2 - \phi) + y_1 - Asin(\omega x_1 - \phi) \Leftrightarrow[/itex]
[itex]y_2 - y_1= Asin(\omega x_2 - \phi) - Asin(\omega x_1 - \phi) \Leftrightarrow[/itex]
[itex]y_2 - y_1= A(sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)) \Leftrightarrow[/itex]
[itex]A = \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}[/itex]
and
- (3.3) [itex]y_3 = \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_3 - \phi) + y_1 - \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_1 - \phi)[/itex]
- (4.3) [itex]y_4 = \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_4 - \phi) + y_1 - \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_1 - \phi)[/itex]
Next we want to isolate [itex]\omega[/itex] from (3.3):
[itex]y_3 = \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_3 - \phi) + y_1 - \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_1 - \phi) \Leftrightarrow[/itex]
[itex]y_3 - y_1= \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_3 - \phi) - \frac{y_2 - y_1}{sin(\omega x_2 - \phi) - sin(\omega x_1 - \phi)}sin(\omega x_1 - \phi)[/itex]
And this is where I get stuck...
I would think I could take [itex]sin^{-1}()[/itex] of everything, but I'm not sure if it's that simple.
Any help is appreciated
Thanks
\\Batnas