This is probably a very simple question, but I am struggling to find the answer.


\begin{equation} y_1 = A \cos(\omega t_1)\\ y_2 = A \cos(\omega t_2)\\ y_3 = A \cos(\omega t_3) \end{equation}

(I can go up to as much as $y_n = A \cos(\omega t_n)$. Using only $y_1$ and $y_2$ is also, probably, fine.)

So I know the $y's$ and $t's$. How do I find $A$ and $\omega$?

I, essentially, want to use that to compute the peak of a discrete signal I'm assuming is a cosine for a very short interval which includes that peak. So I thought if I can obtain the equation of the sinuoid then I can differentiate it, set it to $0$ and then solve for the $t$. That way I can obtain $t$ and $y$ at the maximum/peak.

  • $\begingroup$ You can have infinitely many solutions, even if you have any finite number of points, unless you have bounds for $A$ and $\omega$. $\endgroup$ Jan 21, 2021 at 20:17
  • $\begingroup$ Formatting tip. Your posts will look better and be easier to read if you write \cos, \log and so on for standard functions. If the name you want isn't recognized, you can use \operatorname{name} $\endgroup$
    – saulspatz
    Jan 21, 2021 at 21:10
  • $\begingroup$ Thanks so much for the insight! I do have bounds for $A$ and $\omega$ as I am using this to locate the peaks of an autocorrelation function to determine fundamental frequency of an electrical grid. Anyway, for the signal I'm working with, my bound for $A$ is 4 and for $\omega$ it's 314. But I would be happier if I the solution can be expressed in terms of $A_{bound}$ and $\omega_{bound}$. Thanks for the formatting tip. I'll fix it right away. $\endgroup$ Jan 21, 2021 at 21:16

2 Answers 2


Considering that you have $n$ data points $(t_i,y_i)$, you want to adust $A$ and $\omega$ in order to minimize $$\text{SSQ}=\frac12\sum_{i=1}^n \big[A \cos(\omega t_i)-y_i\big]^2$$ Computing the partial derivatives and setting them equal to $0$ $$\frac{\partial \text{ SSQ}}{\partial A}=\sum_{i=1}^n \cos(\omega t_i)\big[A \cos(\omega t_i)-y_i\big]=0\tag1$$ $$\frac{\partial \text{ SSQ}}{\partial \omega}=-A\sum_{i=1}^n t_i \sin (\omega t_i)\big[A \cos(\omega t_i)-y_i\big]=0\tag2$$

From $(1)$ $$A=\frac {\sum_{i=1}^n y_i \cos(\omega t_i) } {\sum_{i=1}^n \cos^2(\omega t_i) }\tag 3$$ and plugging in $(2)$ you are left with an equation in $\omega$ which can write $$\Big[\sum_{i=1}^n y_i \cos(\omega t_i)\Big]\Big[\sum_{i=1}^n t_i \sin(2\omega t_i)\Big]-2\Big[\sum_{i=1}^n \cos^2(\omega t_i)\Big] \Big[\sum_{i=1}^n t_iy_i \sin(\omega t_i)\Big]=0$$


Let us use the following data $$\left( \begin{array}{cc} t & y\\ 13 & 49 \\ 14 & 90 \\ 15 & 114 \\ 16 & 124 \\ 17 & 112 \\ 18 & 85 \\ 19 & 42 \end{array} \right)$$

I "know" that $0.3 \leq \omega \leq 0.5$. Just plotting the equation fot this range, the solution is close to $0.4$.

Starting Newton iterations, the path to solution is $$\left( \begin{array}{cc} n & \omega_n \\ 0 & 0.4000000000 \\ 1 & 0.3946667642 \\ 2 & 0.3945546651 \\ 3 & 0.3945546065 \end{array} \right)$$

Plug the solution in $(3)$ to get $A=123.17165$. The recomputed values of the $y$'s are

$$\{49.87,89.33,115.1,123.1,112.3,84.14,43.10\}$$ and the peak is at $t=15.9248$


$$ \begin{cases} y_1 = A\cos(\omega t_1)\\ y_2 = A\cos(\omega t_2)\\ \end{cases}\tag{1} $$ If you have two unknowns, $A, \omega$ you need only two equations.

If there is another equation, the risk is that the third is not compatible with the other two, like in this example $$ \begin{cases} a+b=10\\ a-b=4\\ 2a+3b=1\\ \end{cases} $$ first two equations have $a=7,b=3$ as result, but this doesn't satisfy the third equation. The system is inconsistent.

Back to $(1)$.

You get $A$ from the first equation $A=\frac{y_1}{\cos\omega t_1}$ and plug it in the second:

$y_2=\frac{y_1}{\cos\omega t_1}\cos \omega t_2$

$y_2\cos\omega t_1-y_1\cos\omega t_2=0$

which can be solved with numerical methods once you have the actual values.

There is no formula to solve something like

$1.2 \cos (3.6 \omega)-0.75 \cos (2.7 \omega)=0$

Once you get $\omega$ you substitute and find $A$.

  • $\begingroup$ Hello. Thank you for this! May I please find out what you means by solving with numerical methods once you have the actual values. How do I go about doing that? I put the equation in Wolframalpha and while it gives me x, it doesn't give me the steps it used. $\endgroup$ Jan 22, 2021 at 8:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .