# Fourier series on general interval $[a,b]$

Currently I'm studying Fourier series and the first thing I've read is the definition of the series for a function $f : [-\pi,\pi]\to \mathbb{R}$. In that case the Fourier series is

$$F_{[-\pi,\pi]}[f](x) = \dfrac{a_0}{2} + \sum_{n=1}^\infty a_n \cos (nx) + b_n \sin (nx)$$

with coefficients

$$a_0 = \dfrac{1}{\pi}\int_{-\pi}^{\pi} f(x)dx, \qquad a_n = \dfrac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos (nx) dx, \qquad b_n=\dfrac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin (nx)dx.$$

As I know, the idea behind this is that defining $f_n(x) = \cos(nx)$ and $g_n(x)=\sin (nx)$ the set of functions $\{1,f_n,g_n : n\in \mathbb{N}\}\subset L^2[-\pi,\pi]$ is complete and orthogonal with respect to the inner product

$$\langle f,g\rangle = \int_{-\pi}^{\pi} f(x)g(x)dx.$$

Now, the text I'm reading also delas with extending this to one interval $[-L,L]$. The text just states that the Fourier series of a function $f : [-L,L]\to \mathbb{R}$ would be

$$F_{[-L,L]}[f](x) = \dfrac{a_0}{2} + \sum_{n=1}^\infty a_n \cos \left(\dfrac{n\pi x}{L}\right) + b_n \sin \left(\dfrac{n\pi x}{L}\right)$$

with the new coefficients

$$a_0 = \dfrac{1}{L}\int_{-L}^{L} f(x)dx, \qquad a_n = \dfrac{1}{L}\int_{-L}^{L} f(x)\cos \left(\dfrac{n\pi x}{L}\right) dx, \qquad b_n=\dfrac{1}{L}\int_{-L}^{L}f(x)\sin \left(\dfrac{n\pi x}{L}\right)dx.$$

I didn't understand however, how to get to this. There are also some exercises which asks to compute the series of a function $f : [0,2\pi]\to \mathbb{R}$ for example.

In that case, given a general interval $[a,b]$ and $f : [a,b]\to \mathbb{R}$, what is the Fourier series of $f$, and how does it relate to the usual Fourier series defined on $[-\pi,\pi]$?

Try replacing $L$ with $\pi$ in the definition you have for the interval $[-L,L]$. Notice that you get back the original definition for $[-\pi,\pi]$. The generalization comes from wanting the cosine and sine parts to still be periodic over the interval $[-L,L]$, just as they were over $[-\pi,\pi]$.
For the series on the interval $[0,2\pi]$, a useful trick is to look at a new function, $g:[-\pi,\pi]\rightarrow\mathbb{R}$ defined by $g(x)=f(x+\pi)$. Then compute the Fourier series for $g(x)$ instead of $f(x)$, using the formula you already know.
If you apply the change of variables $x = tL/\pi$ (or $t = \pi x/L$) to the integral over $[-\pi,\pi]$, you get $$\frac{1}{2\pi}\int_{-\pi}^{\pi}f(t)\overline{g(t)}dt = \frac{1}{2L}\int_{-L}^{L} f(\pi x/L)\overline{g(\pi x/L)}dx.$$
For a general interval $[a,b]$, first use a periodic extension to get a periodic function F. Then set $L=\frac{b-a}{2}$, and compute the Fourier coefficients of F on $[-L, L]$ (the integration of a periodic function is the same on any period). Finally, constraint the Fourier series on the interval $[a,b]$.