# Fourier Series Representation for piecewise function

I've been posed the following question:

$$f(x)= \begin{cases} 1-x^2, & 0 \leqslant|x|<1,\\ 0, & 1\leqslant|x|<2\\ \end{cases}$$

I'm trying to find the Fourier series representation but I am having trouble with $$a_n$$ and $$b_n$$ coefficients.

For reference, I obtained $$a_0 = \frac{4}{3}$$ and I'm pretty sure this is correct.

For $$a_n$$, I have tried solving the following

$$\frac{1}{2} \int_{-2}^{2} (1-x^2)\cos \left(\frac{\pi m x}{2} \right) dx$$

to obtain

$$\frac{16}{\pi^2 m^2} \cos(2 \pi m) \cos \left(\frac{\pi n x}{2} \right)$$

but am fairly certain I did not obtain the correct answer.

For $$b_n$$, the function $$1-x^2$$ is even and hence $$b_n = 0$$. However, I'm not sure if this is right either.

Any help will be much appreciated!

• f(x) is only defined in [0, 2] so you need to consider its odd or even extension (with period 4) to get a Fourier series. If you choose the even extension then $b_n = 0$ as you say (though not for quite the right reason) and for $a_n$ the integral you wrote down will only be from -1 to 1. You can simplify this integral too since your extension is even - look in your notes. – Paul May 25 at 9:16

As you said $$a_0=\dfrac43$$ and $$b_n=0$$. Also integrating by parts shows $$a_n=\dfrac{1}{2}\int_{-2}^{2} (1-x^2)\cos\dfrac{m\pi x}{2}\ dx = \dfrac{1}{2} \left[ (1-x^2)\left(\dfrac{2}{m\pi}\right)\sin\dfrac{m\pi x}{2} -2x\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi x}{2} +2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi x}{2} \right]_{-1}^{1} = \dfrac{1}{2} \left[ -2\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi}{2} -2\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi}{2} +2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi}{2} +2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi}{2} \right] = \color{blue}{ -2\left(\dfrac{2}{m\pi}\right)^2\cos\dfrac{m\pi}{2} +2\left(\dfrac{2}{m\pi}\right)^3\sin\dfrac{m\pi}{2} }$$

• thanks for the reply! – lohboys May 26 at 4:55

All the odd terms disappear.

Note that $$f$$ doesn't take value of $$1-x^2$$ from $$1$$ to $$2$$.

\begin{align} \frac12 \int_{-2}^2 f(x) \cos \left( \frac{m\pi x}{2}\right) \, dx &= \int_0^1 (1-x^2) \cos \left( \frac{m\pi x}{2}\right) \, dx\\ &= \frac{2}{m \pi}\sin \left( \frac{m \pi x}{2} \right)(1-x^2)\big|_0^1 +\frac{4}{m \pi} \int_0^1 x\sin \left(\frac{m \pi x}2 \right) \, dx \\ &= \frac{4}{m \pi} \int_0^1 x\sin \left(\frac{m \pi x}2 \right) \, dx \\ &=\frac4{m \pi} \left[-\frac{2x}{m \pi} \cos \left( \frac{m \pi x}2\right)\big|_0^1 + \int_0^1 \, \frac2{m \pi}\cos \left(\frac{m \pi x}2 \right) dx\right]\\ &=\frac4{m \pi} \left[\frac{-2}{m \pi}\cos\left(\frac{m \pi}{2} \right) + \int_0^1 \, \frac2{m \pi}\cos \left(\frac{m \pi x}2 \right) dx\right]\\ &= \frac4{m \pi} \left[\frac{-2}{m \pi}\cos\left(\frac{m \pi}{2} \right) + \left(\frac2{m \pi}\right)^2\sin \left(\frac{m \pi }2 \right) \right]\\ &=\begin{cases} \frac{16}{((4k-3)\pi)^3} & ,m=4k-3\\ \frac{8}{((4k-2)\pi)^2}& ,m = 4k-2\\ -\frac{16}{((4k-3)\pi)^3}& , m = 4k-1\\ -\frac{8}{(4k\pi)^2} & ,m=4k \end{cases} \end{align}

Also,

$$a_0 = \frac12 \int_{-1}^1 1-x^2\, dx = \int_0^11-x^2 \, dx =1-\frac13=\frac23$$

The fourier series is

\begin{align}\frac13 + \sum_{k=1}^\infty&\left[\frac{16}{((4k-3)\pi)^3} \cos\left( \frac{(4k-3)\pi x}{2}\right) + \frac{8}{((4k-2)\pi)^2} \cos\left( \frac{(4k-2)\pi x}{2}\right)\right. \\&\left.-\frac{16}{((4k-3)\pi)^3}\cos\left( \frac{(4k-1)\pi x}{2}\right)-\frac{8}{(4k\pi)^2}\cos\left( \frac{(4k)\pi x}{2}\right) \right] \end{align}

Here is a second order approximation:

• Student asked for help, not a full answer. This does not really help them in the end. – Paul May 25 at 11:43
• thanks for the reply! @siong – lohboys May 26 at 4:56