Find the Fourier Series of $f(x)=\begin{cases} 1 & x \in(-\pi,0) \\ -1 & x \in(0, \pi) \end{cases}$.

I know that: $$f(x)=A_0+\sum_{n=1}^{\infty} \left(A_n \cos \frac {n\pi x}L+B_n \sin \frac {n\pi x}{L} \right)$$ and I understand that since the period $L = \pi$ then $$f(x)=A_0+\sum_{n=1}^{\infty}(A_n\cos(nx)+B_n \sin(nx))$$ and $$A_0=\frac 1{2\pi}\int_{-\pi}^{\pi}f(x) \, dx \\ A_n=\frac 1\pi\int_{-\pi}^{\pi}f(x)\cos(nx) \, dx \\B_n= \frac 1\pi \int_{-\pi}^{\pi}f(x)\sin(nx) \, dx$$

But don't know what to do next, is $f(x)$ odd? Then it has to simplify the integral calculation?

  • $\begingroup$ Have you tried evaluating those integrals? $\endgroup$ – user121330 May 31 '17 at 22:23
  • $\begingroup$ @user121330 that's what confuses me $\endgroup$ – Tel0s May 31 '17 at 22:24
  • $\begingroup$ You don't know how to integrate? $\endgroup$ – user121330 May 31 '17 at 22:25
  • $\begingroup$ i know, but it's not clear to me in this case since $f(x)$ is inside $\endgroup$ – Tel0s May 31 '17 at 22:26
  • $\begingroup$ Inside the integral? $\endgroup$ – user121330 May 31 '17 at 22:26

$$A_0 = \frac 1{2\pi} \left(\int_{-\pi}^0 -1\ dx + \int_{0}^\pi 1\ dx \right)=0$$

Not at all surprising considering $f(x)$ is an odd function. And since $f(x)$ is odd we know: $$A_n = \frac 1{\pi} \left(\int_{-\pi}^0 -\cos nx\ dx + \int_{0}^\pi \cos nx\ dx \right)=0$$


$$B_n = \frac 1{\pi} \left (\int_{-\pi}^0 -\sin nx\ dx + \int_{0}^\pi \sin nx\ dx \right)$$

to keep you busy. Let me know if you still need help


We know that $f(x)$ is odd iff $f(x) = -f(-x)$, i.e. it is symmetric in the origin; hence the function's areas cancel and are equal to zero.

In this case the function is clearly odd, so the integral $A_0=0$. But also the integral $A_n=0$ as $cos(*)$ is an even function and an even function multiplied by an odd function is an odd function.

We are left with just computing the $B_n$ coefficient. Note that it's a piecewise function, so we split the integral

$$B_n = \frac{1}{\pi}\left(\int_{-\pi}^0 \sin(nx) + \int_0^{\pi} -sin(nx)\right).$$

I'll leave you to compute the details.

Note that the Fourier series is an infinite series. We can see that after the first 10 terms the function is resembled. After 60 terms it's beginning to look very similar to $f(x)$ apart from at the discontinuities. This is Gibbs phenomenon!

10 Termsenter image description here


thank u all for the answers, i finally calculated this $$A_0=\frac 1{2\pi}\int_{-\pi}^{\pi}f(x) \, dx = \frac 1{2\pi}\left(\int_{-\pi}^{0}f(x)dx +\int_{0}^{\pi}f(x)dx\right)=\frac 1{2\pi}\left(\int_{-\pi}^{0}-1dx +\int_{0}^{\pi}1dx\right)=0 \\$$

$$A_n=\frac 1\pi\int_{-\pi}^{\pi}f(x)\cos(nx) \, dx=\frac 1{\pi}\left(\int_{-\pi}^{0}-cos(nx)dx +\int_{0}^{\pi}cos(nx)dx\right) = 0\\$$

$$B_n=\frac 1\pi \int_{-\pi}^{\pi}f(x)\sin(nx) \, dx = \frac 1{\pi}\left(\int_{-\pi}^{0}-sin(nx)dx +\int_{0}^{\pi}sin(nx)dx\right) = \frac 1{\pi}\left(\left[\frac 1n cos(nx)\right]_{-\pi}^{0} +\left[\frac {-1}n cos(nx)\right]_{0}^{\pi}\right) = \frac 1\pi\left(\frac 1n-\frac {cos(\pi n)}{n}+\left[-\frac {cos(\pi n)}{n}-\left(-\frac 1n\right)\right]\right) = \frac {2(1-cos(\pi n))}{\pi n}\\$$

  • $\begingroup$ One step further, what is $\cos\pi n$, for odd $n$ and for even $n$ ($n\ne 0$) respectively? Then can you simplify $B_n$ for odd and even $n$ cases? $\endgroup$ – peterwhy Jun 1 '17 at 0:29
  • $\begingroup$ if n is even then $cos(\pi n) = cos(\pi 2k) = 1$, if n is odd then $cos(\pi n) = cos(\pi(2k+1)) = -1$ @peterwhy that's it? $\endgroup$ – Tel0s Jun 1 '17 at 0:38
  • $\begingroup$ so if n is even $B_n=0$, therefore $B_n=\frac {4}{\pi n}$ $\endgroup$ – Tel0s Jun 1 '17 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.