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.

  • $\begingroup$ Yeah, I used it as you can see, twice. $\endgroup$ – Jozef Feb 5 '12 at 20:44
  • $\begingroup$ It should be noted that the above equality (and subsequently the answers) hold so long as $n \neq 0$. $\endgroup$ – JavaMan Feb 6 '12 at 1:21

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$.


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...


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.