TITLE: Finding the $n$-th derivative of $f(x) =e^x \sin x$, solving the recurrence relation
QUESTION [7 upvotes]: I was given a homework assignment to find a closed solution for the nth derivative of the function:
$f(x) = e^x \sin x$
So far I have been able to obtain the derivative as:
$f^{(n)}(x) = e^x S_n \sin x + e^x C_n \cos x$
The sequences S and C are defined as below:
$S_n = S_{n-1} - C_{n-1}$
$C_n = S_{n-1} + C_{n-1}$ 
$S_0 = 1$,
$C_0 = 0$
I have been able to further simply this by combining the two equations and obtaining:
$C_n = 2S_{n-2}$
$S_n = S_{n-1} - 2 S_{n-3}$
However, I have no idea what to do now. Can anyone help me find the closed form solution?

REPLY [4 votes]: Here's a nice way that makes use of complex exponentials and involves no nasty recurrence relations.
Start by noticing that $\sin x$ is the imaginary part of $e^{ix}$.
Define a function $F$ as follows:
$F(x)=e^xe^{ix}=e^x\cos x+i e^x \sin x$
The function $f(x)=e^x\sin x$ can now be expressed as the imaginary part of $F$:
$f(x)=Im(F(x))$
If you write $F$ as $F(x)=e^{(1+i)x}$ you can easily find its $nth$ derivative:
$F^{(n)}(x)=(1+i)^ne^{(1+i)x}=e^x \cdot(1+i)^ne^{ix}$
To make the extraction of the imaginary part of the above expression easier we can rewrite $1+i$ in polar form:
$1+i=\sqrt2 e^{i\pi /4}$
With this we  finally write $F^{(n)}(x)$ as:
$F^{(n)}(x)=e^x\cdot 2^{n/2}e^{in\pi /4}e^{ix}=2^{n/2}e^x e^{i(x+n\pi /4)}$
If you now take the imaginary part you find:
$f^{(n)}(x)=Im(F^{(n)}(x))=2^{n/2}e^x \sin (x+n\pi /4)$