Fourier Cosine Series, Sine Series, Fourier Coefficients of Even and Odd Functions
Definition
Let’s say $f$ is a piecewise smooth function on the interval $[0,L)$. The following defined $f_{e}$ on the interval $[-L, L)$ is called the even extension of $f$.
$$ f_{e}(t) := \begin{cases} f(t) & -L \le t <0 \\ f(-t) & 0 \le t <L\end{cases} $$
Similarly, the following defined $f_{o}$ on the interval $[-L, L)$ is called the odd extension of $f$.
$$ f_{o}(t) := \begin{cases} -f(-t) & -L \le t <0 \\ f(t) & 0 \le t <L\end{cases} $$
Explanation
$f_{e}$ and $f_{o}$ are each the extension of the domain of $f$ to make it an even function and odd function respectively. $f_{e}$ and $f_{o}$ can be used to express the Fourier series of $f$ such that only cosine or sine terms appear.
Fourier Cosine Series
$$ f_{e}(t)=\dfrac{1}{2}a_{0} + \sum \limits_{n=1}^{n} ( a_{n} \cos \frac{n \pi t}{L} + b_{n} \sin \frac{n\pi t}{L}) $$
$f_{e}$ is an even function and because of $t \in [0,L)$, $f_{e}(t)=f(t)$ holds, so the following equation is valid.
$$ a_{0}=\dfrac{1}{L}\displaystyle \int_{-L}^{L} f_{e}(t)dt=\dfrac{2}{L}\int_{0}^{L}f(t)dt $$
$$ a_{n}=\dfrac{1}{L}{\displaystyle \int_{-L}^{L} }f_{e}(t)\cos \frac{n\pi t}{L}dt=\dfrac{2}{L}{\displaystyle \int_{0}^L } f(t)\cos \frac{n \pi t}{L}dt $$
$$ b_{n}=\dfrac{1}{L}{\displaystyle \int_{-L}^{L} }f_{e}(t)\sin \frac{n\pi}{L}tdt=0 $$
Therefore, the Fourier series of $f_{e}(t)$ is
$$ f_{e}(t)=\dfrac{1}{2}a_{0} + \sum \limits_{n=1}^{n} a_{n} \cos \frac{n \pi t}{L} $$
And since $t \in [0,L)$ implies $f_{e}(t)=f(t)$,
$$ \begin{equation} f(t)=\dfrac{1}{2}a_{0} + \sum \limits_{n=1}^{n} a_{n} \cos \frac{n \pi t}{L} \label{eq1} \end{equation} $$
At this point, $a_{0}=\dfrac{2}{L}{\displaystyle \int_{0}^{L} }f(t)dt$, $a_{n}=\dfrac{2}{L}{\displaystyle \int_{0}^{L} }f(t)\cos \frac{n\pi t}{L} dt$ are given. The equation $(1)$ is referred to as the Fourier cosine series of $f$.
Fourier Sine Series
$$ f_{o}(t)=\dfrac{1}{2}a_{0} + \sum \limits_{n=1}^{n} ( a_{n} \cos \frac{n \pi t}{L} + b_{n} \sin \frac{n\pi t}{L}) $$
$f_{o}$ is an odd function and because of $t \in [0,L)$, $f_{e}(t)=f(t)$ holds, so the following equation is valid.
$$ \begin{align*} a_{0} &= \dfrac{1}{L}\displaystyle \int_{-L}^{L} f_{o}(t)dt=0 \\ a_{n} &= \dfrac{1}{L}{\displaystyle \int_{-L}^{L} }f_{o}(t)\cos \frac{n\pi t}{L}dt=0 \\ b_{n} &= \dfrac{1}{L}{\displaystyle \int_{-L}^{L} }f_{o}(t)\sin \frac{n\pi t}{L}dt=\dfrac{2}{L}{\displaystyle \int_{0}^L } f(t)\sin \frac{n \pi t}{L} \end{align*} $$
Therefore, the Fourier series of $f_{o}(t)$ is
$$ f_{o}(t)=\sum \limits_{n=1}^{n} b_{n} \sin \frac{n \pi t}{L} $$
And since $t \in [0,L)$ gives $f_{o}(t)=f(t)$,
$$ \begin{equation} f(t)=\sum \limits_{n=1}^{n} b_{n} \sin \frac{n \pi t}{L} \label{eq2} \end{equation} $$
At this point, $b_{n}=\dfrac{2}{L}{\displaystyle \int_{0}^{L} }f(t)\sin \frac{n\pi t}{L} dt$ is given. The equation $(2)$ is called the Fourier sine series of $f$.
Fourier Coefficients of Even and Odd Functions
To summarize the above content, let’s assume $f$ is a function defined in the interval $[-L,L)$. If $f$ is an even function, the Fourier coefficients of $f$ are as follows.
$$ \begin{align*} a_{0} &= \dfrac{2}{L} {\displaystyle \int_{0}^{L} } f(t)dt \\ a_{n} &= \dfrac{2}{L} {\displaystyle \int_{0}^{L} } f(t) \cos \frac{n \pi t}{L}dt \\ b_{n} &= 0 \end{align*} $$
If $f$ is an odd function, the Fourier coefficients of $f$ are as follows.
$$ \begin{align*} a_{0} &= 0 \\ a_{n} &= 0 \\ b_{n} &= \dfrac{2}{L} {\displaystyle \int_{0}^{L} } f(t) \sin \frac{n \pi t}{L}dt \end{align*} $$