Find the Fourier Trigonometric series for:

$$f(x)= \begin{cases} \sin(x) & 0\leq x \leq \pi \\ 0 & \pi\leq x \leq 2\pi, \\ \end{cases}\quad f(x+2\pi)=f(x).$$

I tried to find the series of this function, but when I plot up to 50 terms with Wolfram, it doesn't resemble the function so I guess I made a mistake finding the Fourier series.

This is what I did:

The length of the interval is $\boxed{L= 2\pi}$.

I calculated the coefficients as follows

$$ \begin{align*} a_0&=\displaystyle \dfrac 1 L \int_{0}^ {2\pi} f(x) \, dx=\dfrac 1 L \left(\int_{0}^ {\pi} \sin(x) \, dx +\int_{\pi}^ {2\pi} 0 \, dx\right)\\ \\ a_n&= \dfrac 2 L \int_{0}^ {2\pi} f(x) \cos\left(\dfrac {2n\pi x} {L}\right) \, dx\\ &=\dfrac 2 L \left(\int_{0}^ {\pi} \sin(x) \cos\left(\dfrac {2n\pi x} {L}\right) \, dx +\int_{\pi}^ {2\pi} 0 \, dx\right)\\ &=\dfrac 1 \pi \cdot \dfrac {\cos(n \pi)+1} {(1-n^2)}\\ \\ b_n&= \frac 2 L \int_{0}^ {2\pi} f(x) \sin\left(\frac {2n\pi x} {L}\right) \, dx\\ &=\frac{2}{L} \left(\int_{0}^ {\pi} \sin(x) \sin\left(\frac {2n\pi x} {L}\right) \, dx +\int_{\pi}^ {2\pi} 0 \, dx\right)\\ &=\dfrac 1 \pi \cdot \dfrac {- \sin(n \pi)} {(n^2-1)}\\ &=0 \end{align*} $$

I computed the series using

$$ \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]$$

Finally, the wrong Fourier series of $f(x)$ that I found is:

$$ \displaystyle \dfrac {1} {\pi} +\sum_{n=2}^\infty \Big[\displaystyle \dfrac 1 \pi \cdot \dfrac {\cos(n \pi)+1} {(1-n^2)}\cdot \cos\left( n x\right)+0 \Big]$$

*I took initial $n=2$ to avoid an undetermined series at $n=1$

Any ideas on where my mistakes are?


1 Answer 1


\begin{align} a_0 &= \frac{1}{2\pi}\int_{0}^{2\pi} \sin x \cdot \mathbf{I}_{[0,\pi]}\, dx = \frac{1}{2\pi}\int_{0}^{\pi} \sin x \, dx = \frac{1}{\pi}\\ a_n &= \frac{2}{2\pi}\int_{0}^{2\pi} \sin x \cdot \mathbf{I}_{[0,\pi]} \cdot \cos\tfrac{2\pi n x}{2\pi}\, dx = \frac{1}{\pi} \int_{0}^{\pi} \sin x \cdot \cos nx \, dx = \frac{1}{\pi} \frac{\cos (\pi n) + 1}{1-n^2}\\ &= \frac{1}{\pi}\frac{1 + (-1)^n}{1-n^2} = \begin{cases} \frac{2}{\pi}\frac{1}{1-n^2} & \text{if $n$ even}\\ 0 & \text{if $n$ odd}\end{cases}\\ b_n &= \frac{2}{2\pi}\int_{0}^{2\pi} \sin x \cdot \mathbf{I}_{[0,\pi]} \cdot \sin\tfrac{2\pi n x}{2\pi}\, dx = \frac{1}{\pi} \int_{0}^{\pi}\sin x \cdot \sin (nx)\,dx\\ &= \frac{1}{\pi}\cdot\begin{cases}\tfrac{\pi}{2} & \text{if $n=1$}\\0 & \text{if $n>1$}\\\end{cases} = \begin{cases}\tfrac{1}{2} & \text{if $n=1$}\\0 & \text{if $n>1$}\\\end{cases} \end{align}

Hence the Fourier series of $f(x)$ over $(0,2\pi)$ is given by \begin{align} f(x) &\sim a_0+\sum_{n=1}^{\infty}\left [a_n \cos (nx) + b_n\sin(nx)\right]\\ &= \frac{1}{\pi} + \sum_{n=1}^{\infty}\frac{2}{\pi}\frac{1}{1-(2n)^2}\cos((2n)x) + \frac{1}{2}\sin((1)x)\\ &= \frac{1}{\pi} + \frac{2}{\pi}\sum_{n=1}^{\infty}\frac{\cos(2nx)}{1-4n^2} + \frac{1}{2}\sin(x) \end{align}

Plotted with 20 terms using Wolfram Alpha:Fourier Partial Series

Note I used Wolfram Alpha to compute these integrals, but it skipped the special case of $b_1$. This is likely to do with a symbolic division that implicitly assumed $n\neq 1$. Either way, this special case follows near-directly from the principle of orthogonality, i.e., $$ \frac{1}{\pi}\int_0^{2\pi} \sin(nx)\sin(mx)\,dx = \begin{cases}1 &\text{if $n=m$}\\ 0 & \text{if $n\neq m$}\end{cases} $$ So in our case, $$\frac{1}{\pi} \int_0^{2\pi} \sin(x)\mathbf{I}_{(0,\pi)}\sin(nx)\,dx = \frac{1}{\pi} \begin{cases} \int_0^{\pi} \sin(x)^2\,dx & \text{for $n=1$}\\ \int_0^{\pi} \sin(x)\sin(nx)\,dx & \text{for $n>1$}\end{cases}$$

This latter point highlights why I knew that Wolfram Alpha hadn't given me everything, $$\int_{0}^a \sin(x)^2 \,dx > 0,\quad\text{for $a>0$}$$ so we wouldn't expect the corresponding coefficient to be zero. If, on the other hand, the function were something like $f(x)=\sin(5x)\cdot \mathbf{I}_{(0,\pi)}$ or $f(x)=\cos(2x)\cdot \mathbf{I}_{(0,\pi)}$, then we'd know to check $b_5$ or $a_2$ respectively.

If you have learned about vector spaces, then you can think of the integral as an dot (inner) product over vectors $1, \sin(nx),\cos(nx)$ for $n=1,\dotsc,\infty$. The inner product measures similarity. In this case we are asking about amount of "$sin(x)$"-ness if we take a $\sin(x)$ function and lop off the latter half. The answer, perhaps unsurprisingly, is a half.

  • $\begingroup$ Hello. It seems to me that you are leaving behind the piecewise function. $sin(x)$ is only defined in $(0,\pi)$. The function takes value $0$ for $\pi < x < 2\pi$ $\endgroup$
    – Tomas
    Apr 4, 2017 at 4:21
  • $\begingroup$ @Tomas I missed that, this should work now. It seems you just missed computation of $b_1$ $\endgroup$
    – adfriedman
    Apr 4, 2017 at 6:12
  • $\begingroup$ Thank you very much. Honestly, I did all the integrals on Wolfram and it didn't split the result of the integral for $b_n$ in two cases $n=1$ and $n>1$. How did you notice that subtle difference? Did you use another program? Or was it just experience that led you to consider the two cases? $\endgroup$
    – Tomas
    Apr 4, 2017 at 16:20
  • $\begingroup$ @Tomas I'd say it was mostly about having a good understanding as well as intentionally being overly careful when calculating Fourier coefficients. I added a note to my answer that might shed a bit more light. $\endgroup$
    – adfriedman
    Apr 4, 2017 at 16:57
  • $\begingroup$ I read the note and now I find it very clear. Thank you very much, indeed! $\endgroup$
    – Tomas
    Apr 4, 2017 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .