I try to set up the Fourier series of $e^x$ in $[-\pi, \pi) $
By definition: $ a_n = \int\limits_{-\pi}^{\pi} e^x* cos(nx) = {e^x (cos(n x)+n* sin(n x)) \over (1+n^2)}|_{-\pi}^{\pi} $
Now I simplify the term as I know $sin(n*\pi) = 0 \ \forall n \in \mathbb{N} $
Similarly $cos(n \pi)$ simplifies to $ (-1)^n $
The values of b_n follow a similar computation and process of simplifying:
$ b_n = (e^x (-n cos(n x)+sin(n x)))/(1+n^2) $
The result for the series then is: $a_0 + {1 \over \pi} \sum\limits_{n = 1}^{N} {e^x (-1)^n(1-n) \over n^2+1} $
However this seems to be utterly wrong as the graphs plotted in Desmos look completely different from the one expected.
I would be really happy, if someone could point at the error and explain its wrongness. Any constructive comment or answer is appreciated.
The coefficients of the complex Fourier series for $e^x$ are given by
$$\begin{align} c_n&=\frac{1}{2\pi}\int_{-\pi}^{\pi}e^xe^{-inx}dx\\\\ &=\frac{1}{2\pi}\left.\frac{e^{(1-in)x}}{1-in}\right|_{-\pi}^{\pi}\\\\ &=\frac{(-1)^n\sinh(\pi)}{\pi(1-in)} \end{align}$$
Thus, the complex Fourier Series for $e^x$ is given by
$$\bbox[5px,border:2px solid #C0A000]{e^x\sim \frac{\sinh \pi}{\pi}\sum_{n=-\infty}^{\infty}\frac{(-1)^n}{(1-in)}e^{inx}} \tag 1$$
Now, we can express $(1)$ in terms of the sine and cosine series by simply folding the series in $(1)$. We have
$$\begin{align} e^x&\sim \frac{\sinh \pi}{\pi}+\sum_{n=-\infty}^{-1}\frac{(-1)^n}{(1-in)}e^{inx}+\sum_{n=1}^{\infty}\frac{(-1)^n}{(1-in)}e^{inx}\\\\ & =\frac{\sinh \pi}{\pi}+\sum_{n=1}^{\infty}\left(\frac{(-1)^n}{(1-in)}e^{inx}+\frac{(-1)^n}{(1+in)}e^{-inx}\right)\\\\ &=\frac{\sinh \pi}{\pi}+\sum_{n=1}^{\infty}(-1)^n2\text{Re}\left(\frac{e^{inx}}{1-in}\right) \end{align}$$
The real part of $\frac{e^{inx}}{1-in}$ is easily seen to be $\frac{\cos nx -n\sin nx}{n^2+1}$.
Thus, Fourier Series for $e^x$ is given by
$$\bbox[5px,border:2px solid #C0A000]{e^x\sim \frac{\sinh \pi}{\pi}+\frac{2\sinh(\pi)}{\pi}\sum_{n=1}^{\infty}\frac{(-1)^n}{n^2+1}\cos nx-\frac{2\sinh(\pi)}{\pi}\sum_{n=1}^{\infty}\frac{(-1)^n\,n}{n^2+1}\sin nx}$$