# How to find the solution of nonlinear least square (NLS) equation for freqeuncy estimation

I am struggling to understand the theory of parametric methods for power spectral estimations of line spectra.

And I want to find the solution of nonlinear least square (NLS) method for estimating the frequencies of line spectra. For example,

$$Let,$$ $$f(\omega, \alpha, \phi) = \sum_{t=1}^{N} |y(t) - \sum_{k=1}^{n} \alpha_{k} e^{i(\omega_{k}t+\phi_{k})}|^2,$$

$$then,$$

$$f = (Y-B\beta)^*(Y-B\beta) \\= [\beta-(B^*B)^{-1}B^*Y]^*[B^*B][\beta (B^*B)^{-1}B^*Y]+Y^*Y-Y^*B(B^*B)^{-1}B^*Y$$

$$where$$ $$Y = [y(1) ~y(2) ~... ~y(N)]^T$$ $$\beta = [\beta_{1}~...~\beta_{n}]^T$$ $$B =\begin{bmatrix} e^{i\omega_{1}} & ... & e^{i\omega_{n}} \\ \vdots & & \vdots \\ e^{iN\omega_{1}} & ... & e^{iN\omega_{n}} \\ \end{bmatrix}.$$

The best choice of the $$\omega = [\omega_{1}, \cdots, \omega_{n}]^T$$ to minimize $$f$$ is,

$$\hat \omega = \underset{\omega}{\operatorname{argmax}} [Y^*B(B^*B)^{-1}B^*Y]$$

I have two questions for the above equations.

1)How can we derive $$f = [\beta-(B^*B)^{-1}B^*Y]^*[B^*B][\beta (B^*B)^{-1}B^*Y]+Y^*Y-Y^*B(B^*B)^{-1}B^*Y ?$$ 2)How can we solve the $$\operatorname{argmax}$$ problem for $$n$$ different parameters of $$\omega$$?