Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried couple of times to compute $\int_{-\pi}^{\pi}\sin(nx)e^{inx}$. According to W.A it should be $-\pi i$, I'm losing my mind trying to understand where I got wrong.

Assuming the whole process that $e^{-in \pi}=\cos(n \pi)-i \sin(n\pi)=(-1)^{n}$, and $[\cos(nx)e^{-inx}]_{-\pi}^{\pi}$=0.

Here is what I did:


I'd really love to understand what is wrong with that.

Thank you very much.

share|cite|improve this question
Yeah, I used it as you can see, twice. – Jozef Feb 5 '12 at 20:44
It should be noted that the above equality (and subsequently the answers) hold so long as $n \neq 0$. – JavaMan Feb 6 '12 at 1:21
up vote 6 down vote accepted

You should use

$$\sin(n x)=\frac{e^{inx}-e^{-inx}}{2i}.$$


$$\int_{-\pi}^\pi \frac{e^{inx}-e^{-inx}}{2i} e^{inx}dx=\frac{1}{2i}\int_{-\pi}^\pi(e^{2inx}-1)dx$$


$$\frac{1}{2i}\int_{-\pi}^\pi e^{2inx}dx=0$$

and you are left with $i\pi$.

share|cite|improve this answer
Thank you @Jon! – Jozef Feb 6 '12 at 8:04

For what it's worth, and just for kicks, let's try to use the "integrate by parts twice and solve for the integral trick":

$$\eqalign{ \int \underbrace{\vphantom{(}e^{Bx}}_u \underbrace{\sin (Ax)\, dx}_{dv} &= \underbrace{-A^{-1}\cos(Ax)}_v \underbrace{e^{Bx}\vphantom{(}}_u -\int \underbrace{-A^{-1}\vphantom{(}}_v \underbrace{B\cos(Ax)e^{Bx}\,dx}_{du}\cr &= -A^{-1}\cos(Ax)e^{Bx}+A^{-1}B\Bigl[ \int \underbrace{e^{Bx}\vphantom{(}}_s \underbrace{ \cos(Ax)\,dx}_{dw}\Bigr] \cr &= -A^{-1}\cos(Ax) e^{Bx} +A^{-1}B\Bigl[ \underbrace{ A^{-1}\sin(Ax)}_w \underbrace{e^{Bx}\vphantom{(}}_s - \int \underbrace{A^{-1} \sin(Ax)}_w\underbrace{Be^{Bx}\vphantom{(}}_{ds} \Bigr] \cr &= -A^{-1}\cos(Ax)e^{Bx}+A^{-2}B \sin(Ax)e^{Bx} - A^{-2}B^2\int \sin(Ax)e^{Bx} . \cr } $$ Whence $$\eqalign{\int \sin (nx)e^{inx}\, dx &= -n^{-1}\cos(nx)e^{inx}+n^{-2}(in) \sin(nx)e^{inx} - n^{-2}(in)^2\int \sin(nx)e^{inx} \cr &= {-e^{inx} ( \cos(nx)- i \sin(nx)) \over n } -i^2 \int \sin(nx)e^{inx} \cr &= {-e^{inx} e^{-inx} \over n } -i^2 \int \sin(nx)e^{inx} \cr &= {-1 \over n } + \int \sin(nx)e^{inx}. } $$ So, the trick used in the real case (solving for the original integral) breaks down here. Note the above is true because there are constants attached to to general antiderivatives...

share|cite|improve this answer
Thanks a lot David! – Jozef Feb 6 '12 at 8:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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