Hello I am having some issues the following fourier series $$f(x)=e^{x}, -\pi<x<\pi $$ I have no issues with the immediate steps, solving for $a_n$ and $ b_n $, i believe that I am having some algebra simplification.
for the $a_n$ term I get
$$ \int e^{x}\cos(nx)= \frac {1}{n^{2}+1}({(-1)^{n}}(e^{\pi}-e^{-\pi})$$
where as the answer should be $$ \int e^{x}\cos(nx)= \frac {{(-1)^{n}}(e^{\pi}-e^{-\pi})}{\pi(n^{2}+1)}$$
here is the work i did, i not one term because it is equal to zero
$$\frac{1}{\pi}e^{x}\cos(nx)= \frac{1}{\pi}[e^{x}\cos(nx) -n^{2}\int e^{x}\cos(nx)] $$
now when i simplify it
$$ \frac{1+n^{2}}{\pi} \int e^{x}\cos(nx) = \frac{1}{\pi}[e^{x}\cos(nx)] $$ can you see where i went wrong?