# Maximum Likelihood carrier phase estimation of $A\cos(2\pi f_ct)$

This question refers to the example 5.2-1 of the book "Digital Communications, 5th Edition by John Proakis, Masoud Salehi" (example 6.2-1 in the 4th edition of the book) which asks for the estimate carrier phase $\phi$ that maximizes the log-likelihood function and equivalently the likelihood function.

The received signal is:

$r(t)=A\cos(2\pi f_ct+\phi)+n(t)$

where $A$ is the amplitude of the transmitted signal (known), $f_c$ is the carrier frequency (known) and $n(t)$ is the AWGN noise added.

The log-likelihood function is given as:

$\Lambda_L(\phi)=\frac{2A}{N_0}\int_{T_0}r(t)\cos(2\pi f_ct+\phi)dt$

where $\frac{N_0}{2}$ is the power spectral density of AWGN (known constant for all frequencies) In order to get the maximum value of this we require:

$\frac{d\Lambda_L(\phi)}{d\phi}=0 \\ \Rightarrow \int_{T_0}r(t)\sin(2\pi f_ct+\hat{\phi}_{ML})dt=0 \\ \Rightarrow \hat{\phi}_{ML}=-\tan^{-1}\Bigg[\frac{\int_{T_0}r(t)\sin(2\pi f_ct)dt}{\int_{T_0}r(t)\cos(2\pi f_ct)dt}\Bigg]$

Everything OK until the last line. I don't understand how this equation is solved.

for the last line $$\sin(2 \pi f_{c}t + \phi_{ML} ) =\sin(2 \pi f_{c}t)\cos (\phi_{ML}) +\cos(2 \pi f_{c}t)\sin(\phi_{ML})$$ so the integral could be written as:
Therefore, $$\tan(\phi_{ML})= -\frac{\int_ {T_{0}} r(t)\sin(2 \pi f_{c}t)}{\int_ {T_{0}} r(t) \cos(2 \pi f_{c}t)}$$