Find the Fourier cosine coefficients of $\displaystyle e^x $

$\displaystyle e^x = \frac{1}{2}a_0 + \displaystyle\sum_{n=1}^\infty a_n cos \frac{n \pi x}{L} $

Differentiating yields:

$\displaystyle e^x = - \displaystyle\sum_{n=1}^\infty \frac{n \pi}{L}a_n sin \frac{n \pi x}{L}$,

the Fourier sine series of e^x. Differentiating again yields

$\displaystyle e^x = - \displaystyle\sum_{n=1}^\infty (\frac{n \pi}{L})^2 a_n cos \frac{n \pi x}{L}$,

Since equations 1 and 3 both give Fourier cosine series of e^x, they must be identical. Thus,

$\displaystyle a_o = 0 $ and $\displaystyle a_n = 0. $

Can anyone please explain step by step what is wrong with this? I'm supposed to correct the mistakes and then find $\displaystyle a_n$ without using the typical technique but I'm so confused!

Any mistakes at all you can see, please point them out!

Thanks in advance