1

I have three data points measured at $-30$, $0$, and $30$ degrees, respectively. I would like to fit these points to a sinusoidal function of the form:

$$f(\theta)≈A\sin(\theta + B) + C$$

Is this possible? If so, what would be the best approach?

I saw a similar post here, however this assumed that the measurements were $90$ degrees apart which helps to simplify things greatly.

Thanks,

2 Answers2

1

Yes, of course it is possible. Proceed in the following way:

Let the three values at $-30,0,30$ be $y_1,y_2,y_3$ repec. Then you get three equations in $A,B,C$ \begin{equation} \begin{split} A\sin (-30+B)+C=&y_1\\ A\sin (B)+C=&y_2\\ A\sin (30+B)+C=&y_3 \end{split} \end{equation} From the first and last equation, after some trigonometric manipulation you get $$2A\sin B \cos 30=y_3-y_1\Rightarrow A\sin B=\frac{y_3-y_1}{\sqrt{3}}$$

Then from second equation you get $$C=y_2-\frac{y_3-y_1}{\sqrt{3}}$$

Now from the last equation you get after using the $\sin(A+B)$ expansion formula $$A\sin B \cos 30+A\cos B \sin 30=y_1\\ \Rightarrow \frac{(y_3-y_1)}{2}+\frac{A\cos B}{2}+y_2-\frac{y_3-y_1}{\sqrt{3}}=y_3$$ So you can find $A\cos B$ from here. So, now you can use $\displaystyle \sin^2B+\cos^2 B=1$ to get $$A=\sqrt{(A\sin B)^2+(A\cos B)^2}$$ Once you get $A$, then you can get $B$ from $$B=\tan^{-1} \left(\frac{A\sin B}{A \cos B}\right)$$ restricting $B$ in $[-\pi/2,\pi/2]$, you can get $B$.

Note: This procedure is valid for arbitrary angles, they need not be necessarily $30^\circ$ apart.

bubba
  • 43,483
  • 3
  • 61
  • 122
  • Great! Thanks! This works perfectly. – user1799178 Jul 23 '13 at 18:21
  • Welcome! @user1799178 – Samrat Mukhopadhyay Jul 23 '13 at 18:21
  • I'm trying to generalize this to arbitrary angles (say $ \theta_1 , \theta_2 & \theta_3 $ ), but am having trouble figuring out those initial "trigonometric manipulations" in the general case. I think you're using a sum expansion and a sum-to-product formula, but I'm getting bit different result. Mind expanding a little? – Gabriel Grant Sep 13 '14 at 15:48
  • @GabrielGrant, just write the three equations with $\theta_1,\ \theta_2,\ \theta_3$ and use the expansion formula for $\sin(\alpha+\beta)$ for equations $(1),(3)$ and subtract them, then you'll get an expression for $\tan B$ which, along with, $(1),(2)$ will give you solutions for $A,B$ – Samrat Mukhopadhyay Sep 16 '14 at 06:23
0

First try to fit $f(\theta) = a\sin\theta+b\sin \theta+c$ (three linear equations in three unknowns), then use $\sin(\theta+B)=\cos B\sin\theta+\sin B\cos\theta$ to bring this into the form desired.