# Formula of frequency modulated sine wave from data points

I'm trying to determine the formula of a variable frequency sine wave based on the values of max1, max2, min1 and min2. y(0) isn't necessarily 0 and I can assume the frequency increases or decreases linearly (I only want to plot the first couple oscillations).

I've figured the formula for the non-modulated signal (based only on max1 and min1) as the following:

$y(x) = sin(2π*f*x + C)$ where
$f=\frac{1}{2\left(\max _1-\min _1\right)}$ and $C = -\left(max_1-\frac{\left(max_1-min_1\right)}{2}\right)\cdot \frac{\pi }{\left(max_1-min_1\right)}$

I've also figured that plotting:

$y(x) = sin(2π*(f+M(x))*x)$ where
$M(x)= a*x + b$

results in an increasing frequency signal but I can't figure out the exact formula to have the wave match the data points.

Any help would be much appreciated, my math skills are rusty...

• Is it safe to assume it's actually linear Fm ?
– user28715
Jun 12 '17 at 17:10

## 2 Answers

If your function is $y(x)=\sin(2\pi fx+C)$, and you have data points $\{x_i,y_i\}$, then finding $C$ is easy, if you suppose $x=0$ then $C=\arcsin(y(0))$.

Now, according to your plot your frequency varies with $x$. The first thing you need to do is to know how does your frequency vary with $x$. Supposedly this variation is linear, then you write: $f(x)=ax+b$ and your function model becomes $y(x)=\sin(2\pi f(x)x+C)$.

The problem now is finding (an estimate for) $f(x)$. You have two unknowns to determine $a$ and $b$, you need two data points ($\{x_1,y_1\}, \{x_2,y_2\}$) and you solve a system of two (nonlinear) equations with two unknowns.

$$\begin{cases} y_1=\sin(2\pi (ax_1+b) x_1+C)\\ y_2=\sin(2\pi (ax_2+b) x_2+C) \end{cases}$$

Since frequency is the derivative of phase, a linear frequency curve implies a quadratic phase curve. So we have $y(x)=\cos(\phi(x))$ with $\phi(x)=ax^2+bx+c$ and \begin{aligned}\phi(max_1)&=0\\\phi(min_1)&=\pi\\\phi(max_2)&=2\pi\\\phi(min_2)&=3\pi.\end{aligned} This is actually a simple system of linear equations, but it is over-determined. If we omit $min_2$ and ask Maxima (open-source CAS) to solve it, we get \begin{aligned}a=&\frac{\pi max_2+\pi max_1−2 \pi min_1}{d}\\b=& \frac{2 \pi min_1^2-\pi max_2^2-\pi max_1^2}{d}\\c=&\frac{max_1 (\pi max_2^2−2 \pi min_1^2)+max_1^2 (2 \pi min_1−\pi max_2)}{d}\end{aligned} with $$d=max_2 min_1^2+max_1 (max_2^2−min_1^2)+max_1^2 (min_1−max_2)−max_2^2 min_1.$$