The second term can be expanded to $$\begin{align} 2|a_k|\left(\frac{ e^{i(2\pi f_k t+\angle a_k)} + e^{-i(2\pi f_k t+\angle a_k)}}{2}\right) &= |a_k|e^{i\angle a_k}e^{i(2\pi f_k t)}+|a_k|e^{-i\angle a_k}e^{-i(2\pi f_k t)} \\ &= a_k e^{i(2\pi f_k t)}+a_k^*e^{-i(2\pi f_k t)} \\ \end{align}$$
Since $a_k=|a_k|e^{i\angle a_k}$ and $a_k^*=|a_k|e^{-i\angle a_k}$ and $\cos\theta=\frac{ e^{i\theta} + e^{-i\theta}}{2}$