How this exponential function converted into cosine function including phase shift? In my text book I have found this two line in an example:
$$
y(t)=\frac{2}{1+j}e^{jt}+\frac{2}{1-j}e^{-jt}-\frac{1}{1+j2}e^{j2t}-\frac{1}{1-j2}e^{-j2t}$$
$$=2\sqrt{2}cos(t-45^\circ)-\frac{2}{\sqrt{5}}cos(2t-63^\circ)$$
How this mathematical calculation done directly? What procedure it is? What is it called ?  
FYI: I tried to find something about it by googling but only get complex exponential to sine/cosine conversion. 
 A: Let us look at the first term $$A=\frac{2}{1+i}e^{it}+\frac{2}{1-i}e^{-it}$$ First of all $$\frac{1}{1+i}=\frac{1}{1+i}\frac{1-i}{1-i}=\frac{1-i}{1-i^2}=\frac{1-i}{2}$$ Similarly,$$\frac{1}{1-i}=\frac{1}{1-i}\frac{1+i}{1+i}=\frac{1+i}{1-i^2}=\frac{1+i}{2}$$ Now, remember Euler formula $$e^{it}=\cos(t)+i\sin(t)$$ $$e^{-it}=\cos(t)-i\sin(t)$$ Replacing, we then have $$A=2 \frac{1-i}{2}\big(\cos(t)+i\sin(t)\big)+2 \frac{1+i}{2}\big(\cos(t)-i\sin(t)\big)$$ Now expand and simplify to get $$A=2 \big(\sin (t)+ \cos (t)\big)$$ Now remember what are $\sin(x+\frac \pi 4)$ and $\cos(x+\frac \pi 4)$
A: $$y(t)=\frac{2}{1+i}e^{it}+\frac{2}{1-i}e^{-it}-\frac{1}{1+2i}e^{2ti}-\frac{1}{1-2i}e^{-2ti}=$$
$$y(t)=(1-i)e^{it}+(1+i)e^{-it}-\frac{1}{1+2i}e^{2ti}-\frac{1}{1-2i}e^{-2ti}=$$
$$y(t)=2(\sin(t)+\cos(t))+\frac{2}{5}i(2\cos(2t)-\sin(2t))=$$
$$y(t)=2\sin(t)+2\cos(t)+\frac{4}{5}i\cos(2t)-\frac{2}{5}i\sin(2t)=$$
$$y(t)=2\sin(t)-\frac{2}{5}i\sin(2t)+2\cos(t)+\frac{4}{5}i\cos(2t)=$$
$$y(t)=2\cos\left(t-\frac{\pi}{2}\right)-\frac{2}{5}i\cos\left(2t-\frac{\pi}{2}\right)+2\cos(t)+\frac{4}{5}i\cos(2t)=$$
$$y(t)=2\cos\left(t-\frac{\pi}{2}\right)+2\cos(t)+\left(\frac{4}{5}\cos(2t)-\frac{2}{5}\cos\left(2t-\frac{\pi}{2}\right)\right)i$$
