Using trig Identity to show equality of integral and piece-wise function

Using the trig identity $$2\sin A\sin B = \cos(A-B)-\cos(A+b)$$ show that $$\int_0^\pi \sin(mx)\sin(nx)dx = \left\{ \begin{array}{lr}0&\text{when }m\neq n\\\pi/2&\text{when }m=n\end{array}\right.$$ where $m, n >0$

After integration, I came with $$\frac{1}{2}\bigg(\frac{\sin((m-n)x}{m-n}-\frac{\sin((m+n)x)}{m+n}\bigg)\Bigg|_0^\pi$$ which isn't entirly clear as why this holds for the piecewise function. So using a sum trig identity I came to $$\frac{\sin(mx)\cos(nx)-\sin(nx)\cos(mx)}{2(m-n)}-\frac{\sin(mx)\cos(nx)+\sin(nx)\cos(mx)}{2(m+n)}\Bigg|_0^\pi$$ but still have no idea where to go from here.

• Plug in the values $x=\pi$ and $x=0$? Sep 4 '17 at 8:23
• Plunging in the values gives me a zero function. Put why would the function be $\pi/2$ for $m=n$?
– Alex
Sep 4 '17 at 8:24
• When $m=n$ your primitive is false. Sep 4 '17 at 8:30
• So if $m=n$ should I use the integral of $\sin^2(nx)$?
– Alex
Sep 4 '17 at 8:32

For $m\ne n$ you are OK with your expression.

Let $m=n:$

$2 \sin A \sin B =$

$\cos(A-B) - \cos(A+B);$

$\sin(mx)\sin(mx) =$

$(1/2)(1 - cos(2mx));$

Integrate both sides from $0$ to $π$:

Note :

$$\int_{0}^{π} \cos(2mx)dx =$$

$$(1/2m)\sin(2mx)]{_0^π} = 0.$$

Hence:

$$\int_{0}^{π}\sin^2(mx)dx = (1/2)π.$$

When $m=n$, you can write $$\int_0^\pi \sin^2(mx)dx = \int_0^\pi \cos^2(mx)dx$$ because $\sin x$ is periodic and $\cos x = \sin (\pi/2-x)$.

You can also write that $$\int_0^\pi \sin^2(mx)dx+ \int_0^\pi \cos^2(mx)dx = \int_0^\pi (\sin^2(mx)+ \cos^2(mx))dx = \int_0^\pi dx = \pi.$$