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!


3 Answers 3


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






So the general formula is


Using the polar form

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


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

enter image description here


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


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .