$$f(x) = \begin{cases}0 & \text{if }-\pi<x<0, \\ \sin(x) & \text{if }0<x<\pi. \end{cases}$$

My attempt:

I went the route of expanding this function with a complex Fourier series.

$$f(x) = \sum_{n=-\infty}^{+\infty} C_{n}e^{inx}$$

$$C_{n} = \frac {1}{2\pi} \int_{0}^{\pi} \frac {e^{ix}-e^{-ix}}{2i} e^{-inx} \,\mathrm dx = \frac {1}{\pi}\left(\frac {1}{1-n^2}\right)$$

because only even $n$ terms survive, odd $n$ are 0

$$ C_0 = \frac {1}{2\pi} \int_{0}^{\pi} \sin(x)\, \mathrm dx = \frac {1}{\pi} $$


$$ f(x) = \frac{1}{\pi} + \frac {1}{\pi} \left(\frac {e^{i2x}}{1-2^2} + \frac {e^{i4x}}{1-4^2}+\frac {e^{i6x}}{1-6^2}+\cdots\right) + \frac {1}{\pi} \left(\frac {e^{-i2x}}{1-2^2} + \frac {e^{-i4x}}{1-4^2}+\frac {e^{-i6x}}{1-6^2}+\cdots\right) $$

In sine and cosine terms,

$$ f(x) = \frac{1}{\pi} + \frac {2}{\pi} \left(\frac {\cos(2x)}{1-2^2} + \frac {\cos(4x)}{1-4^2}+\frac {\cos(6x)}{1-6^2}+\cdots\right) $$

But the answer in my book is given as

$$ f(x) = \frac{1}{\pi} + \frac{1}{2} \sin(x)+ \frac {2}{\pi} \left(\frac {\cos(2x)}{2^2-1} + \frac {\cos(4x)}{4^2-1}+\frac {\cos(6x)}{6^2-1}+\dotsb\right)$$

I don't understand how there is a sine term and the denominator of the cosines has $-1$.

  • $\begingroup$ I've improved the LaTeX formatting on your question; apologies if I changed your intended meaning in any way. You can find some good starting points on how to format mathematics on the site here. This AMS reference is very useful. $\endgroup$ Commented Mar 7, 2013 at 22:05
  • $\begingroup$ A related problem. $\endgroup$ Commented Mar 7, 2013 at 22:11
  • $\begingroup$ @karanveersingh what's the book name? $\endgroup$
    – alhelal
    Commented Nov 16, 2017 at 12:46
  • $\begingroup$ my teacher asked me to prove $π/4=1/2+1/1*3−1/3*5+1/5*7−1/7*9$ when $n=1$ for this same problem. But I can't yet. $\endgroup$
    – alhelal
    Commented Nov 16, 2017 at 17:01
  • $\begingroup$ This is solved. When $x=π/2$. $\endgroup$
    – alhelal
    Commented Nov 16, 2017 at 17:02

3 Answers 3


The $\sin$ term comes form $n=1$ you can't devide by zero.

mh I calculated again, your $\cos(x)$ terms are right, there shouldn't be a $-$ in the denominator

For $$\int_0^\pi \sin(x) e^{inx}\, \mathrm{d} x = \frac{1+ e^{i \pi n}}{1-n^2}$$ we have to check the case $n=1$ seperate as we can't devide by zero.

The case $n=1$ give $$\int_0^\pi \sin(x) \exp(x)\, \mathrm{d}x=\frac{i \pi }{2}$$

  • $\begingroup$ How do I introduce a sine term for n = 1 case? Is my answer incomplete or am I just missing simplification? $\endgroup$ Commented Mar 7, 2013 at 22:18
  • $\begingroup$ @KaranveerSingh your work was incomplete $\endgroup$ Commented Mar 7, 2013 at 22:25
  • $\begingroup$ When computing the result with the real fourier series, how did you integrate $\frac {1}{\pi} sin(x)cos(nx)dx$ from 0 to $\pi$ $\endgroup$ Commented Mar 7, 2013 at 22:29
  • 1
    $\begingroup$ with the good old trigonometric theorems, $2 \sin(\alpha)\cdot \cos(\beta)= \sin(\alpha+\beta) + \sin(\alpha-\beta)$ $\endgroup$ Commented Mar 7, 2013 at 22:31
  • $\begingroup$ AH! I keep forgetting those. $\endgroup$ Commented Mar 7, 2013 at 22:33

Note that, $C_1$ is a special case and you need to handle separately as

$$ C_1 = \frac {1}{2\pi} \int_{0}^{\pi} \sin(x) e^{-ix} dx \neq 0. $$

  • $\begingroup$ wouldn't it be $e^{-inx}dx$? $\endgroup$ Commented Mar 7, 2013 at 22:20
  • $\begingroup$ @KaranveerSingh: I copied your formula. Yes it should be $e^{-inx}$. $\endgroup$ Commented Mar 7, 2013 at 22:25
  • $\begingroup$ Oh, there was supposed to be one there. Sorry for that. $\endgroup$ Commented Mar 7, 2013 at 22:27
  • 1
    $\begingroup$ @KaranveerSingh: No problem. Anyways, as I said $C_1$ is a special case. That means you have to handle it separtly. $\endgroup$ Commented Mar 7, 2013 at 22:29

Since the function $\phi(t)$ is defined on $-L=-\pi<t<\pi=L$ , the Fourier series can be expressed as shown below :

enter image description here

The numerical tests of the formula are well consistent with a good accuracy.

On the figure below, small values of $m$ are taken in order to make clear the deviations in case of series limited to not enough terms.

enter image description here

  • $\begingroup$ Which software you use to plot that? @JJacquelin. $\endgroup$ Commented Nov 19, 2021 at 19:36
  • $\begingroup$ @WhyMeasureTheory. Software implemented with "Delphi" from Borland. $\endgroup$
    – JJacquelin
    Commented Nov 21, 2021 at 21:02

You must log in to answer this question.

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