Finding the $n$-th derivative of $f(x)=e^{x}\sin(x)$

I am trying to find the general form for the $n$-th derivative of $f(x)=e^{x}\sin(x)$.

I have calculated the derivatives up to $5$, but I am having trouble coming up with a general rule. Here is my work so far:

$$\begin{align}
f^{(1)}(x)&=e^{x}\cos(x) + e^{x} \sin(x)\\
f^{(2)}(x)&= 2e^{x}\cos(x)= e^{x}(\sin(x)+ \cos(x)) + e^{x}(\cos(x)- \sin(x))\\
f^{(3)}(x)&=2e^{x}\cos(x) -2e^{x} \sin(x)\\
f^{(4)}(x)&=-4e^{x}\sin(x)\\
f^{(5)}(x)&=-4e^{x}\cos(x) -4e^{x} \sin(x)\\
\end{align}$$

I am having trouble spotting the pattern to derive the formula for the nth derivative of this function. Any help would be greatly appreciated.

Solutions Collecting From Web of "Finding the $n$-th derivative of $f(x)=e^{x}\sin(x)$"

The pattern is already visible —
observe that $f^{4}(x)=-4f(x)$, thus

$$f^{(n)}(x)=(-4)^{[n/4]}f^{(n \bmod 4)}(x)$$

You can also observe that
$$ e^x\sin x = e^x\frac{e^{ix}-e^{-ix}}{2i} = \tfrac12 i e^{(1-i)x} – \tfrac12 i e^{(1+i)x} $$
which is easy to differentiate $n$ times term for term.

Write $$f(x) = e^x \sin x = \frac{1}{2i} e^x (e^{ix} – e^{-ix}) = \frac{1}{2i} (e^{(1+i)x} – e^{(1-i)x}).$$ Then we immediately have $$f^{(n)}(x) = \frac{d^n}{dx^n}\left[e^x \sin x\right] = \frac{1}{2i} \left((1+i)^n e^{(1+i)x} – (1-i)^n e^{(1-i)x}\right).$$ All that remains is to rewrite this in terms of real valued functions. We note $1 + i = \sqrt{2} e^{\pi i/4}$ and $1-i = \sqrt{2} e^{-\pi i /4}$, so $$f^{(n)}(x) = \frac{e^x}{2i} 2^{n/2} \left( e^{ix + \pi i n/4} – e^{-(ix + \pi i n/4)} \right) = e^x 2^{n/2} \sin \left(x + \frac{n\pi}{4}\right).$$

All these expressions are of the form

$$(c_n\cos(x)+s_n\sin(x))e^x.$$

Let us establish a recurrence relation.

$$(c_{n+1}\cos(x)+s_{n+1}\sin(x))e^x=\left((c_n\cos(x)+s_n\sin(x))e^x\right)’\\
=\left((c_n+s_n)\cos(x)+(s_n-c_n)\sin(x)\right)e^x.$$

So $$c_{n+1}=c_n+s_n,\\s_{n+1}=s_n-c_n.$$

We can eliminate $s$ by

$$c_{n+2}=c_{n+1}+s_{n+1}=c_{n+1}+s_n-c_n=2c_{n+1}-c_n,$$ or

$$c_{n+2}=2c_{n+1}-c_n.$$

We know that such recurrences have geometric sequences for solutions, and after finding the roots of the characteristic polynomial, $a=\sqrt2-1$ and $b=-\sqrt2-1$,

$$c_n=Aa^n+Bb^n.$$

From there,

$$s_n=c_{n+1}-c_n=A(a-1)a^n+B(b-1)b^n.$$

With the given starting conditions,

$$c_0=0,s_0=1,$$ we find

$$A=-B=\frac1{a-b}.$$

Finally, the general expression

$$\left(\left(a^n-b^n\right)\cos(x)+\left((a-1)a^n-(b-1)b^n\right)\sin(x)\right)\frac{e^x}{a-b}.$$