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

Show that $$\int_{-\pi}^{\pi}\sin{mx}\,\sin{nx}\, d x =\begin{cases} 0&\text{if }m\neq n,\\ \pi&\text{if }m=n. \end{cases}$$ by using integration by parts.

I've done the following, but I'm not sure if I went the wrong direction, if I messed up some calculation, or if I'm almost there and just can't see what to do next...

$$\int_{-\pi}^{\pi}\sin{mx}\,\sin{nx} \, d x=-\left(\frac{n}{n^2-m}\right)\sin{mx}\cos{nx}+\left(\frac{m}{n^2-m}\right)\cos{mx}\sin{nx}+C$$


Now ... I figure that if $n=m$, then I can just as well replace them all with a 3rd variable... say $z$...


Wouldn't that equal 0? Or am I completely mistaken?


By following the suggestions below and using the product-to-sum forumulas, I got the following:

$$\frac{1}{2}\int\cos{((n-m)x)}\ dx-\frac{1}{2}\int\cos{((n+m)x)}\ dx=\frac{\sin{((n-m)x)}}{2(n-m)}-\frac{\sin{((n+m)x)}}{2(n+m)}$$

So now if $n=m$, then the first quotient will end up dividing by 0...

share|cite|improve this question
Do you have to use int. by parts? It looks easier with the complex exponential... – DonAntonio Mar 11 '13 at 3:11
I don't suppose I have to... but the hint on the assignment says to do so. – agent154 Mar 11 '13 at 3:11
check out this wolfram page...… – Learner Mar 11 '13 at 3:12
Then don't! And use the product-to-sum formula. See here. You'll get Wolfram's formula in a minute. – 1015 Mar 11 '13 at 3:12
@DonAntonio I accepted a solution a couple of weeks ago... It was the right one. I didn't open the bounty; somebody else is looking for an alternate solution to the one I accepted. – agent154 Mar 31 '13 at 19:03
up vote 6 down vote accepted


We don't really need Integration by parts

We know, $$2\sin mx\sin nx=\cos(m-n)x-\cos(m+n)x$$

$$\cos(m-n)x-\cos(m+n)x=\begin{cases} 1-\cos2nx&\text{ if }m=n,\\ \cos2nx-1&\text{if }m+n=0. \end{cases} $$

Now use $\int\cos axdx=\frac{\sin ax}a$

share|cite|improve this answer
I'm not quite sure I understand how you got where you did - is that a typo? Shouldn't it be $\cos{(x(m-n))}$? Also, when I follow that procedure, like what wolfram alpha does, I get to a scenario where if $m=n$, then when I plug into the formula, I end up dividing by 0. – agent154 Mar 11 '13 at 3:33
@agent154, please pin point your doubt. Also, for $m=n$ and $m+n=0$ use the identity before integration. – lab bhattacharjee Mar 11 '13 at 3:55

First, since $\,\sin kx\,$ is an odd function, $\,\sin mx\sin nx\,$ is even, so

$$\int\limits_{-\pi}^\pi\sin mx\sin nx\,dx=2\int\limits_0^\pi\sin mx\sin nx\,dx$$

Now, by parts:

$$u=\sin mx\;,\;\;u'=m\cos mx\\v'=\sin nx\;,\;\;v=-\frac{1}{n}\cos nx$$


$$\text{J:}=2\int\limits_0^\pi\sin mx\sin nx\,dx=\stackrel{\text{this is zero}}{\overbrace{\left.-\frac{2}{n}\sin mx\cos nx\right|_0^\pi}}+\frac{2m}{n}\int\limits_0^\pi\cos mx\cos nx\,dx$$

Again, by parts:

$$u=\cos mx\;,\;\;u'=-m\sin mx\\v'=\cos nx\;,\;\;v=\frac{1}{n}\sin nx\;\;\;\Longrightarrow$$

$$\text{J}=\left.-\frac{2m}{n^2}\sin nx\cos mx\right|_0^\pi+\frac{2m^2}{n^2}\int\limits_0^\pi\sin mx\sin nx\,dx\Longrightarrow$$

$$\left(\frac{n^2-m^2}{n^2}\right)\text{J}=0\;,\;\text{and thus} \;n\neq m\Longrightarrow \text{J}\,=0\,$$

If $\,n=m\,$ , then after the line where J first appears we get

$$2\int\limits_0^\pi\sin mx\sin mx\,dx=2\int\limits_0^\pi\cos mx\cos mx\,dx\Longrightarrow$$ $$2\text{ J}\,=2\int\limits_0^\pi\left(\cos mx\cos mx+\sin mx\sin mx\right)\,dx=2\int\limits_0^\pi \cos[(m-m)x]\,dx=$$

$$=2\int\limits_0^\pi dx=2\pi\Longrightarrow\,\text{ J}\,=\pi$$

Addedd: Using the complex exponential:

$$\sin kx:=\frac{e^{ikx}-e^{-ikx}}{2i}\;,\;\;k,x\in\Bbb R\Longrightarrow$$

$$\text{ J}\,=2\int\limits_0^\pi\sin mx\sin nx\,dx=-\frac{1}{2}\int\limits_0^\pi\left(e^{imx}-e^{-imx}\right)\left(e^{inx}-e^{-inx}\right)dx=$$

$$-\frac{1}{2}\int\limits_0^\pi\left[\left(e^{ix(m+n)}+e^{-ix(m+n)}\right)-\left(e^{ix(m-n)}+e^{-ix(m-n)}\right)\right] dx=$$


$$=\begin{cases}\int\limits_0^\pi(dx-\cos2mx)dx=\pi-\left.\frac{1}{2m}\sin 2mx\right|_0^\pi=\pi\;\;,\;\;\;\;m=n\\{}\\{}\\ \left.\left(\frac{1}{m-n}\sin(m-n)x-\frac{1}{m+n}\sin(m+n)x\right)\right|_0^\pi=0\;\;,\;\;\;\;m\neq n\end{cases}$$

Of course, the use of the complex exponential in this case is a lame excuse to "forget" the basic trigonometric identity we got here and get it in a rather easy way.

share|cite|improve this answer
Why is $\sin{kx}$ and "odd" function? – agent154 Mar 11 '13 at 3:47
I'm in kind of a problem to answer because there are many ways to do...for example, because its McClaurin series contains only odd powers...? Or because, if you use the exponential definition $$\sin x=\frac{e^{ix}-e^{-ix}}{2i}\,,\,\,x\in\Bbb R$$ we get at once $\,\sin(-x)=-\sin x\,$ , or because we easily see this in the trigonometric circle... – DonAntonio Mar 11 '13 at 4:26
(+1) I think this is the answer. It was required partial integration and it was done. – vesszabo Apr 4 '13 at 18:13

Use $\sin nx = \frac{1}{2i}(e^{inx} - e^{-inx})$ to get:

\begin{align} \sin nx \sin mx &= -\frac{1}{4}\left(e^{inx} - e^{-inx}\left)\right(e^{imx} - e^{-imx}\right) \\ &= -\frac{1}{4}\left(e^{i(n+m)x} - e^{i(n-m)x} - e^{i(m-n)x} + e^{-i(n+m)x}\right) \end{align}


\begin{align} I = \int_{-\pi}^\pi \sin nx \sin mx \,dx = -\frac{1}{4} &\left(\int_{-\pi}^\pi e^{i(n+m)x} \,dx - \int_{-\pi}^\pi e^{i(n-m)x} \,dx \right. \\ & \left. - \int_{-\pi}^\pi e^{i(m-n)x} \,dx + \int_{-\pi}^\pi e^{-i(n+m)x} \,dx\right) \end{align}

Note that: $$ \int_{-\pi}^\pi e^{ikx} \,dx = \begin{cases}0 &\text{ if } k \ne 0 \\ 2\pi & \text{ if } k = 0\end{cases} $$

This follows by direct computation.

Thus, if $n \ne m$ and $n \ne -m$, all integrals in $I$ are $0$.

If $n = m$, we have:

$$ I = -\frac{1}{4}(-2\pi -2\pi) = \pi $$

If $n = -m$, we have: $$ I = -\frac{1}{4}(2\pi + 2\pi) = -\pi $$

If you assume that $n, m \ge 0$, you can ignore the last case.

share|cite|improve this answer

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.