2

Is there any way to find the parameters of a sine wave ($A$, $w$, and $ \phi $ for $A \sin(wt+\phi)$ ) using just three points (samples)?

Thank you in advance for your help.

Mohsen
  • 23

1 Answers1

1

Sort of. The problem is this:

Suppose you tell me that

$$ f(0) = 0\\ f(\pi) = 0\\ f(2\pi) = 0\\ $$

That's 3 data points, right? One answer is that $f(x) = \sin(x)$, but another, equally good answer, is that $f(x) = \sin(2x)$. The problem is that these two functions happen to take on the same values at the same points, so from the point of view of just this small sample, they "look the same". This is called "Aliasing".

If you're willing to say that you want to find the solution with $w$ as small as possible, then there's some hope for you. But in general the problem's not solvable.

There's a second problem not addressed even by limiting to the Nyquist frequency: your Fourier series doesn't have enough terms. Suppose that your three values are $y_1 = y_2 = y_3 = 4$. What band-limited function fits these? Answer: $4 \cos(0 t)$. You need that constant term, or the problem's still unsolvable.

I'm now going to talk about how I'd solve the problem, assuming that the values of $f$ are given at the points $t_1 = 0$, $t_2 = 1$, and $t_3 = 2$ and that the constant term in the Fourier series is zero.

If your arguments for the known points are at the equispaced points $s_1, s_2, s_3$, then you can take the solution $f$ that I find and transform it by $g(s) = f( \frac{s - s_1}{s_2 - s_1})$, which will alter the values of $\omega$ and $\phi$, but not $A$.

Let's suppose that the known values are $y_1, y_2,$ and $y_3$. So we want to have $$ A\sin(\omega \cdot 0 + \phi) = y_1 \\ A\sin(\omega \cdot 1 + \phi) = y_2 \\ A\sin(\omega \cdot 2 + \phi) = y_3, $$ right? Let's rewrite that slightly:

$$ A\sin(\phi) = y_1 \\ A\sin(\omega+ \phi) = y_2 \\ A\sin(2\omega + \phi) = y_3. $$ Apply the addition formula for sine to get

$$ A\sin(\phi) = y_1 \\ A\sin(\omega ) \cos(\phi) + A\cos(\omega ) \sin(\phi) = y_2 \\ A\sin(2\omega ) \cos(\phi) + A\cos(2\omega ) \sin(\phi) = y_3. $$ Note that $A\sin(\phi)$ appears in the second term of the last two equations; we can replace it with $y_1$ in these to get

$$ A\sin(\phi) = y_1 \\ A\sin(\omega ) \cos(\phi) + y_1 \cos(\omega ) = y_2 \\ A\sin(2\omega ) \cos(\phi) + y_1 \cos(2\omega ) = y_3. $$

Now apply the double-angle formulas to the third equation to get

$$ A\sin(\phi) = y_1 \\ A\sin(\omega ) \cos(\phi) + y_1 \cos(\omega ) = y_2 \\ 2A\sin(\omega )\cos(\omega) \cos(\phi) + y_1 (2\cos^2(\omega ) - 1) = y_3. $$ Multiply the second equation by $2 \cos(\omega)$ to get

$$ A\sin(\phi) = y_1 \\ 2A\sin(\omega ) \cos(\omega) \cos(\phi) + 2 y_1 \cos^2(\omega ) = 2y_2 \cos(\omega) \\ 2A\sin(\omega )\cos(\omega) \cos(\phi) + y_1 (2\cos^2(\omega ) - 1) = y_3. $$

Subtract the third from the second to get

$$ A\sin(\phi) = y_1 \\ 2 y_1 \cos^2(\omega ) - y_1 (2\cos^2(\omega ) - 1) = 2y_2 \cos(\omega) - y_3. . $$

Now notice that in the last equation, $\phi$ has disappeared, as has $A$. The only remaining variable is $\omega$. Denoting $\cos(\omega)$ by $c$ for a moment, that last equation now reads

$$ 2 y_1 c^2 - 2y_1 c^2 + y_1 = 2y_2 c - y_3. . $$

or

$$ \frac{y_1 + y_3}{2y_2} = \cos(\omega). $$

From this you can determine the cosine of $\omega$, and hence can find $\omega$ (up to sign, which shouldn't surprise you: a solution $(A, \omega, \phi)$ to the original equation leads to an alternative solution $(-A, -\omega, -\phi)$ that works equally well).

[Note: this requires that the quotient $(y_1 + y_3) / (2y_2)$ be between $-1$ and $1$; I suspect that this is a consequence of the "no DC term" assumption, but I might also have made an algebra mistake.]

You then can use $\sin(\omega)$ and the second equation (in its second form) to determine $A \cos(\phi)$. Once you know $A \sin(\phi)$ and $A \cos(\phi)$, you can either determine $\phi$ using the "atan2" function, or you can compute $(A \sin \phi)^2 + (A \cos \phi)^2$, which is just $A^2$, and thus compute $A$, up to sign, and hence compute (from the first equation) $\phi$, up to sign.

This can probably all be expressed more elegantly with complex exponentials, but I figured that in this case I'd go through the algebra instead.

John Hughes
  • 93,729
  • well, actually in this problem, we know that the samples satisfy the Niquist condition to avoid alasing and thus we know that the frequency is less that 1/(2*dT) in which dT is the difference between samples in time which equals dt=t3-t2=t2-t1. – Mohsen Dec 16 '13 at 19:13
  • So, what are the analytic solutions of A, w and phi ? – Mohsen Dec 16 '13 at 19:19
  • 1
    May I suggest that you rephrase your question to precisely include this additional constraint, and then I'll attempt an answer. – John Hughes Dec 16 '13 at 20:18
  • Thank you so much John. It is supposed that there is no DC offset in the input sine wave signal. Even so, it can be easily computed and subtracted from y1,y2 and y3. About the -1 < (y_1 + y_3) / (2y_2) <1 issue, I think that in this case, for every three equispaced points, it can be shown that is always true. – Mohsen Dec 18 '13 at 15:17
  • By the way, the solution process I went through can be untangled a bit and seen as an instance of the fast fourier transform on 3 points, I believe. In general, if I had to solve a problem like this, that's the approach I'd take: you've got equispaced data from a band-limited signal, so compute the fourier transform, which will be periodic, and look at the lowest-frequency period to read off the coefficients needed to create your signal. I hope that's not too terse a summary. – John Hughes Dec 18 '13 at 15:23