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}$

We know that $$\sin^2(x) =  \dfrac{1 - \cos(2x)}{2}= \dfrac{1}{2} -\dfrac{1}{2}\Re(\exp(2ix)), $$ where $\Re$ is the real part of a complex number.
It follows that
$$y =\exp(2x)\sin^2(x) = \dfrac{\exp(2x)}{2} - \dfrac{1}{2}\Re(\exp(zx)), $$ with $z = 2+2i.$  
Using complex-valued derivatives:
$$\dfrac{dy}{dx} = \exp(2x)- \dfrac{z}{4}\exp(zx)- \dfrac{z^{*}}{4}\exp(z^{*}x),$$ which leads to
$$\dfrac{d^ny}{dx^n} = 2^{n-1}\exp(2x) - \dfrac{z^n}{4}\exp(zx) - \dfrac{z^{*n}}{4}\exp(z^{*}x) = 2^{n-1}\exp(2x) - \dfrac{1}{2}\Re (z^n \exp(zx)).$$
