Find the $n$ derivative of $y= e^{2x}\sin^2 x$ We have 
\begin{align*}
y&= e^{2x}\sin^2 x\\
&= e^{2x}\left(\frac{1-\cos 2x}{2}\right)\\
&= \frac{e^{2x}}{2} - \frac{e^{2x}\cos 2x}{2}
\end{align*}
Then
\begin{align*}
y^{(n)} &= \left(\frac{e^{2x}}{2}\right)^{(n)} - \left(\frac{e^{2x}\cos 2x}{2}\right)^{(n)}\\
&= 2^{n-1}e^{2x} - \left(\frac{e^{2x}\cos 2x}{2}\right)^{(n)}
\end{align*}
I don't know how to proceed with the rightmost term. So far I've been applying the Leibniz Rule whenever I've had to find the $n$ derivative of a function of the form $f(x)g(x)$, because is clear that either $f(x)$ or $g(x)$ has a derivative a $k$ derivative ($1<k<n$) equal to zero, which simplifies the expression nicely.
But here
$$\frac{e^{2x}\cos 2x}{2}$$
both functions are infinitely differentiable on $\mathbb{R}$ which makes things a bit different.
My only attempt was to write its n derivative in this form
\begin{align*}
&=\frac{1}{2}\sum_{k=0}^n{n \choose k} \big(2^k e^{2x}\big)\bigg(2^{n-k}\cos \left[2x + \frac{\pi(n-k)}{2}\right]\bigg)\\
&=\sum_{k=0}^n {n \choose k} 2^{n-1}e^{2x}\cos \left[2x + \frac{\pi(n-k)}{2}\right]
\end{align*}
So 
\begin{align*}
y^{(n)} &= 2^{n-1}e^{2x} -\sum_{k=0}^n{n \choose k} 2^{n-1}e^{2x}\cos \left[2x + \frac{\pi(n-k)}{2}\right]\\
&= 2^{n-1}e^{2x}\left(1 -\sum_{k=0}^n{n \choose k} \cos \left[2x + \frac{\pi(n-k)}{2}\right]\right)
\end{align*}
But the textbook's answer is
$$2^{n-1}e^{2x}\left(1 -2^{n/2}\cos \left[2x + \frac{\pi n}{4}\right]\right)$$
For some reason I have the feeling that a little of modular arithmetic has to be applied on $\frac{\pi(n-k)}{2}$

Calculate the fist few derivatives and see if a recognizable pattern shows up.
$f(x) = \frac {e^{2x}}{2} + \frac {e^{2x}\cos2x}{2}\\
f'(x) = e^{2x} + e^{2x} \cos 2x - e^{2x}\sin 2x\\
f''(x) = 2e^{2x} - 2e^{2x}\cos 2x - 2e^{2x}\sin 2x - 2e^{2x}\sin 2x - 2e^{2x} \cos 2x = 2e^{2x} - 4e^{2x}\sin 2x\\
f'''(x) = 4e^{2x} - 8 e^{2x}\sin 2x - 8 e^{2x}\cos 2x\\
f^{(4)} = 8e^{2x} - 16\cos 2x$
Do you see a pattern? Can you prove that the pattern will continue?
If you know a little bit about complex exponential you could say:
$f(x) = \frac {e^{2x}}{2} + Re[\frac {e^{(2+2i)x}}{2}]\\
f^{(n)}(x) = 2^n\frac {e^{2x}}{2} + \frac {(2\sqrt2)^n}{2} Re[\frac {e^{(2+2i)x + \frac {n\pi}{4}i}}{4}]\\
f^{(n)}(x) = 2^n\frac {e^{2x}}{2} + \frac {(2\sqrt2)^n}{2} e^{2x} \cos(2x + \frac {n\pi}{4})\\$
