Suppose that a function f (x) is piecewise continuous and defined on the interval [0, π]. To find its Fourier series, we first extend this function to the interval [−π, π]. This can be done in two ways:
We can construct the even extension of f (x):
\[
{f_\text{even}}\left( x \right) =
\begin{cases}
f\left( {-x} \right), & -\pi \le x \lt 0 \\
f\left( {x} \right), & 0 \le x \le \pi
\end{cases},\]
or the odd extension of f (x):
\[
{f_\text{odd}}\left( x \right) =
\begin{cases}
-f\left( {-x} \right), & -\pi \le x \lt 0 \\
f\left( {x} \right), & 0 \le x \le \pi
\end{cases}.\]
For the even function, the Fourier series is called the Fourier Cosine series and is given by
\[{a_n} = \frac{2}{\pi }\int\limits_0^\pi {f\left( x \right)\cos nxdx} ,\;\; n = 0,1,2,3, \ldots\]
Respectively, for the odd function, the Fourier series is called the Fourier Sine series and is given by
\[{f_\text{odd}}\left( x \right) = \sum\limits_{n = 1}^\infty {{b_n}\sin nx} ,\]
where the Fourier coefficients are
\[{b_n} = \frac{2}{\pi }\int\limits_0^\pi {f\left( x \right)\sin nxdx} ,\;\; n = 1,2,3, \ldots\]
We can also define the Fourier Sine and Cosine series for a function with an arbitrary period \(2L.\) Let \(f\left( x \right)\) be defined on the interval \(\left[ {0,L } \right].\) Using even extension of the function to the interval \(\left[ {-L,L } \right],\) we obtain