# 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 ? – Stanley Pawlukiewicz Jun 12 '17 at 17:10

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.$$
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://dsp.stackexchange.com/questions/41673/formula-of-frequency-modulated-sine-wave-from-data-points/41704", "fetch_time": 1566259607000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2019-35/segments/1566027315132.71/warc/CC-MAIN-20190819221806-20190820003806-00302.warc.gz", "warc_record_offset": 421169546, "warc_record_length": 30509, "token_count": 839, "char_count": 2422, "score": 3.984375, "int_score": 4, "crawl": "CC-MAIN-2019-35", "snapshot_type": "longest", "language": "en", "language_score": 0.8783733248710632, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00026-of-00064.parquet"}