Could you tell me if the following Fourier series of the function $f(x)=x^2, -\frac{L}{2} \leq x \leq \frac{L}{2}$ is correct?? $$$$ $$a_0=\frac{2}{L} \int_{-\frac{L}{2}}^{\frac{L}{2}}{x^2}dx=\frac{L^2}{6}$$ $$a_n=\frac{2}{L} \int_{-\frac{L}{2}}^{\frac{L}{2}}{x^2 \cos(\frac{2 n \pi x }{L})}dx=\frac{L^2}{n^2 \pi^2}(-1)^n$$ $$b_n=\frac{2}{L} \int_{-\frac{L}{2}}^{\frac{L}{2}}{x^2 \sin(\frac{2 n \pi x }{L})}dx=0$$
So the Fourier series is: $$f(x) \sim \frac{L^2}{12}+\frac{L^2}{\pi^2} \sum_{n=1}^{\infty}{\frac{(-1)^n}{n^2} \cos(\frac{2 n \pi x}{L})}$$
The gnuplot command sequence (for $L=1$)
results in the plot
which looks right.