# [SOLVED]piecewise fourier

#### dwsmith

##### Well-known member
Find the Fourier series for
$$f(\theta) = \begin{cases} \theta, & 0\leq \theta \leq\pi\\ \pi + \theta, & -\pi\leq \theta < 0 \end{cases}.$$

$$a_0 = \frac{1}{\pi}\int_0^{\pi}\theta d\theta + \frac{1}{\pi}\int_{-\pi}^0\theta d\theta + \int_{-\pi}^0 d\theta$$
The first and second integral together are 0 so the $a_0 = \pi$
$$a_n = \frac{1}{\pi}\int_0^{\pi}\theta\cos n\theta d\theta + \frac{1}{\pi}\int_{-\pi}^0\theta\cos n\theta d\theta + \int_{-\pi}^0 \cos n\theta d\theta$$
The first and second integral together are 0 so the $a_n = 0$
$$b_n = \frac{1}{\pi}\int_0^{\pi}\theta\sin n\theta d\theta + \frac{1}{\pi}\int_{-\pi}^0\theta\sin n\theta d\theta + \int_{-\pi}^0\sin n\theta d\theta$$
The first and second integral together are 0 so the $b_n = \begin{cases}\frac{-2}{n}, & \text{if n is odd}\\0, & \text{if n is even}\end{cases}$

So
$$\frac{\pi}{2} - 2\sum_{n = 1}^{\infty}\frac{1}{2n-1}\sin(2n - 1)\theta$$

Correct?

#### Sudharaka

##### Well-known member
MHB Math Helper
$$b_n = \frac{1}{\pi}\int_0^{\pi}\theta\sin n\theta d\theta + \frac{1}{\pi}\int_{-\pi}^0\theta\sin n\theta d\theta + \int_{-\pi}^0\sin n\theta d\theta$$
The first and second integral together are 0 so the $b_n = \begin{cases}\frac{-2}{n}, & \text{if n is odd}\\0, & \text{if n is even}\end{cases}$

So
$$\frac{\pi}{2} - 2\sum_{n = 1}^{\infty}\frac{1}{2n-1}\sin(2n - 1)\theta$$

Correct?
Hi dwsmith, I think you have made a little error. As you can see $$g(\theta)=\theta\sin n\theta=g(-\theta)$$. Therefore $$g$$ is an even function. Hence,

$b_n = \frac{1}{\pi}\int_0^{\pi}\theta\sin n\theta d\theta + \frac{1}{\pi}\int_{-\pi}^0\theta\sin n\theta d\theta + \int_{-\pi}^0\sin n\theta d\theta= \frac{2}{\pi}\int_0^{\pi}\theta\sin n\theta d\theta + \int_{-\pi}^0\sin n\theta d\theta$

Kind Regards,
Sudharaka.

#### dwsmith

##### Well-known member
So the Fourier series is
$$\frac{\pi}{2} - 2\sum_{n = 1}^{\infty}\frac{1}{2n}\sin(2n)\theta.$$

#### Opalg

##### MHB Oldtimer
Staff member
So the Fourier series is
$$\frac{\pi}{2} - 2\sum_{n = 1}^{\infty}\frac{1}{2n}\sin(2n)\theta.$$
Correct! You can check that this formula works by using the excellent Desmos graphing application that now comes for free with MathHelpBoards. See the graph below. In fact, click on the graph and you will see the formula used to generate it. Use the slider to see the sum of up to 20 terms of this Fourier series, and notice how it converges to the midpoint of each jump in the graph.

[graph]ymrd1ovgce[/graph]