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

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

$$=-2\left(\frac{n}{n^2-m}\right)\sin{m\pi}\cos{n\pi}+2\left(\frac{m}{n^2-m}\right)\cos{m\pi}\sin{n\pi}$$

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

$$=-2\left(\frac{z}{z^2-z}\right)\sin{z\pi}\cos{z\pi}+2\left(\frac{z}{z^2-z}\right)\cos{z\pi}\sin{z\pi}$$

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

-
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... wolframalpha.com/input/… – 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

HINT:

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$

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

so

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

$$\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=$$

$$=\int\limits_0^\pi\left(\cos(m-n)x-\cos(m+n)x\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.

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

Thus:

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

-