[Math] Finding the Fourier series of a piecewise function

fourier analysisfourier series

I'm s little confused about Fourier series of functions that are piecewise. Here’s an example of such a function:
$$f(x) = \begin{cases}
x & -\frac\pi2 < x < \frac\pi2 \\[5pt]
\pi – x & \frac\pi2 < x < \frac{3\pi}2
\end{cases}$$
Please can you explain this example to me?

Best Answer

Your function is defined on the interval $\left(-\dfrac \pi 2, \dfrac \pi 2 \right)\cup \left( \dfrac \pi 2 , \dfrac {3\pi} 2\right) $. That means the length of the interval is $\boxed{L= 2\pi}$.

Now, how to compute the coefficients:

$a_0=\displaystyle \dfrac 1 L \cdot\int_{-\frac \pi 2}^ \frac {3\pi} 2 f(x) \, dx=\dfrac 1 L\cdot \bigg(\int_{-\frac \pi 2}^ \frac {\pi} 2 x \, dx +\int_{\frac \pi 2}^ \frac {3\pi} {2} (\pi- x) \, dx\bigg)$

$a_n=\displaystyle \dfrac 2 L \cdot\int_{-\frac \pi 2}^ \frac {3\pi} 2 f(x)\cdot \cos\left(\dfrac {2n\pi x} {L}\right) \, dx$

$b_n=\displaystyle \dfrac 2 L \cdot\int_{-\frac \pi 2}^ \frac {3\pi} 2 f(x)\cdot \sin\left(\dfrac {2n\pi x} {L}\right) \, dx$

The Fourier series of $f$ is:

$$ \displaystyle a_0+\sum_{n=1}^\infty \Big[a_n\cdot \cos\left(\dfrac {2n\pi x} {L}\right)+b_n \cdot \sin\left(\dfrac {2n\pi x} {L}\right)\Big]$$