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$$
Example
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$
\cos
,\log
and so on for standard functions. If the name you want isn't recognized, you can use\operatorname{name}
$\endgroup$