<s>[INST] how do i write $y = 2\sin2(x + \frac{\pi}{4}) - \cos2(x + \frac{\pi}{4} )$ in format $y = A\sin(kx) + B\cos(kx)$ The problem is the double angles. I tried to simplify them and change them around but no luck, 
$$\begin{align} y&=A\sin(kx)+B\cos(ky)\\
y&=2\sin2(x+\pi/4)-\cos2(x+\pi/4)\\
&=2\left(2\sin(x+\pi/4)\cos(x+\pi/4)\right)-\cos^2(x+\pi/4)+\sin^2(x+\pi/4)\\
&=4\left(\sin x\cos\frac\pi 4+\cos x\sin\frac\pi4\right)\left(\cos x\cos\frac\pi 4-\sin x\sin\frac\pi4\right)-\cos^2(x+\pi/4)+\sin^2(x+\pi/4)\\
&=4\left(\sin x\frac1{\sqrt2}+\cos x\frac1{\sqrt2}\right)\left(\cos x\frac1{\sqrt2}-\sin x\frac1{\sqrt2}\right)-\cos^2(x+\pi/4)+\sin^2(x+\pi/4)\\
&=\frac 4{\sqrt 2}\left(\sin x+\cos x\right)\left(\cos x-\sin x\right)-\cos^2(x+\pi/4)+\sin^2(x+\pi/4)\\
&=2\sqrt 2(\cos^2x-\sin^2x)+\left(\sin x\frac1{\sqrt2}+\cos x\frac1{\sqrt2}\right)^2-\left(\cos x\frac1{\sqrt2}-\sin x\frac1{\sqrt2}\right)^2\\
&=2\sqrt 2(\cos^2x-\sin^2x)+4\left(\frac1{\sqrt2}\sin x\frac1{\sqrt2}\cos x\right)\\
&=2\sqrt 2(\cos^2x-\sin^2x+\sin x\cos x) \end{align}$$
 [/INST] First, notice that $2(x+\tfrac{\pi}{4}) \equiv 2x+\tfrac{\pi}{2}$. Using this fact, we have
$$y= 2\sin\left(x+\tfrac{\pi}{2}\right) - \cos\left(x+\tfrac{\pi}{2}\right).$$
There are two standard formulae:
$$\begin{eqnarray*}
\sin(A+B) &\equiv& \sin A \cos B + \sin B \cos A \\ \\
\cos(A+B) &\equiv& \cos A \cos B - \sin A \sin B
\end{eqnarray*}$$
Applying these two formulae with $A=2x$ and $B=\tfrac{\pi}{2}$ gives:
$$
\color{blue}{y = 2\left(\sin 2x \cos \tfrac{\pi}{2} + \sin \tfrac{\pi}{2} \cos 2x\right) - \left( \cos 2x \cos \tfrac{\pi}{2} - \sin 2x \sin \tfrac{\pi}{2}\right) \equiv 2\cos 2x + \sin 2x}$$
Moreover, we can simplify $2\cos 2x + \sin 2x$ even further. Consider
$$R\cos(2x-\alpha) \equiv 2\cos 2x + \sin 2x$$
Expanding the left hand side gives
$$(R\cos\alpha)\cos 2x + (R\sin\alpha)\sin 2x \equiv 2\cos 2x + \sin 2x$$
Solving $R\cos\alpha=2$ and $R\sin\alpha=1$ gives $R=\sqrt{5}$ and $\alpha=\arctan(1/2)$. Hence:
$$\color{blue}{2\sin\left[2\left(x+\tfrac{\pi}{4}\right)\right] - \cos\left[2\left(x+\tfrac{\pi}{4}\right)\right] \equiv \sqrt{5}\cos\left(2x-\arctan\tfrac{1}{2}\right)} $$
</s>