# Difference between Fourier series on $(0,l)$ and Fourier series on $[0,l]$

I'm currently using Strauss's partial differential equations book and there is something that confuses me. The Fourier series of $$f(x)=x$$ on $$(0,l)$$ is not the same on $$[0,l]$$.

For $$(0,l)$$ the Fourier series is $$x=\frac{2l}{\pi} \sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n}\text{sin}\left(\frac{n\pi x}{l}\right)$$ For $$[0,l]$$ the Fourier series is $$x=\frac{l}{2}-\frac{4l}{\pi^{2}}\sum_{n=1,3,5,...}\text{cos}\left(\frac{n\pi x}{l}\right)\frac{1}{n^{2}}$$

Why $$(0,l)$$ has sine series but $$[0,l]$$ has cosine series?

Whether you include the endpoints of the interval or not is immaterial. There are Fourier sine series and Fourier cosine series on any interval. The cosine series is the full Fourier series of the function extended to $$[-l, l]$$ by $$f(-x) = f(x)$$ and then made periodic. The sine series is the full Fourier series of the function extended to $$[-l,l]$$ by $$f(-x) = -f(x)$$ and then made periodic.
BTW: your cosine series should be $$\frac{l}{2} - \frac{4l}{\pi^2} \sum_{n=1,3,5,\ldots} \frac{\cos\left(\frac{n\pi x}{l}\right)}{n^2}$$