# Alternating sign Nth derivative

Say I have a function

$$f(x) = \dfrac 1x$$

and I'm looking at its $n^{th}$ derivative and trying to come up with a formula.

I can easily get it because if forms a very consistent pattern and it somewhat reminds me of harmonic series.

The formula is

$$f'^n (x) = (-1)^n {n! \over n^{n+1}}$$

However, for the following example I can't come up with a general formula

$$f(x) = e^x \cos(x)$$

I calculated the first 5 derivatives for it and there's a pattern that repeats every subsequent $4^{th}$ derivative

$f'(x) = e^x (\cos x -\sin x)$

$f''(x) = -2e^x (\sin x)$

$f'''(x) = -2e^x (\cos x +\sin x)$

$f''''(x) = -4e^x (\cos x)$

So, there's an alternating sign pattern and the $\sin x$ and $\cos x$ patterns which I just can't seem to account for in a general formula for the $n^{th}$ derivative.

Any help would go a long way!

Besides the excellent approach by @Element118, you can simply split in four cases, noting that $f''''(x)=-4f(x)$,

\begin{align}f^{(4n)}(x)&=(-4)^ne^x\cos(x),\\ f^{(4n+1)}(x)&=(-4)^ne^x(\cos(x)-\sin(x)),\\ f^{(4n+2)}(x)&=(-4)^ne^x(-2\sin(x)),\\ f^{(4n+3)}(x)&=(-4)^ne^x(-2\sin(x)-2\cos(x)). \end{align}

Alternatively, you can use the complex representation of the trigonometric functions and consider the real part of

$$g(x)=e^x(\cos(x)+i\sin(x))=e^xe^{ix}=e^{(1+i)x}.$$

Then

$$g'(x)=\left(e^{(1+i)x}\right)'=(1+i)e^{(1+i)x}=(1+i)g(x)$$

and

$$g^{(n)}(x)=(1+i)^ng(x).$$

So the general formula is

$$f^{(n)}(x)=\Re((1+i)^ne^x(\cos(x)+i\sin(x)).$$

Using the polar form

$$1+i=\sqrt2{e^{i\pi/4}},$$ and

$$f^{(n)}(x)=\Re\left(\sqrt2^ne^{(1+i)x}e^{in\pi/4)}\right)=\sqrt2^ne^x\cos\left(x+\frac{n\pi}4\right)=\sqrt2^ne^x\left(\cos(x)\cos\left(\frac{n\pi}4\right)-\sin(x)\sin\left(\frac{n\pi}4\right)\right).$$

The plot of the cosine/sine coefficients forms a nice logarithmic spiral. Notice a pattern?

$f(x) = e^x\cos x$

$f'(x) = e^x(\cos x-\sin x) = \sqrt{2}e^x\cos\left(x-\frac{\pi}{4}\right)$

$f''(x) = -2e^x\sin x = 2e^x\cos\left(x-\frac{\pi}{2}\right)$

$f'''(x) = -2e^x(\cos x+\sin x) = 2\sqrt{2}e^x\cos\left(x-\frac{3\pi}{4}\right)$

$f^{(4)}(x) = -4e^x\sin x = 4e^x\cos\left(x-\pi\right)$

As you wrote it, $f''''=-4f$

It should be easy from here