Explanation of the orthogonality relation $\int_{-π}^{π}\sin(ax)\sin(bx)\,dx=\int_{-π}^{π}\cos(ax)\cos(bx)\,dx=\begin{cases}π,&a=b\\0,&a≠b\end{cases}$ I stumbled opon the orthogonality relation $$\int_{-π}^{π}\sin(ax)\cos(bx) \,dx = 0$$
and
$$\int_{-π}^{π}\sin(ax)\sin(bx)\,dx = \int_{-π}^{π}\cos(ax)\cos(bx)\,dx = \begin{cases} π & \text{if } a = b \\ 0 & \text{otherwise} \end{cases}$$
where $a,b \in \mathbb{N}$.
I understand the first one, it's because $\sin(ax)\cos(bx)$ is even, so the areas cancel each other out, but what is the explanation for the second one?
Why does $a$ have to be equal to $b$ and why is the integral $0$ otherwise?
 A: $$I=\int_{-π}^{π}\sin(ax)\sin(bx)\,dx = \int_{-π}^{π}\cos(ax)\cos(bx)\,dx $$
$$I+I=\int_{-\pi}^\pi\cos(a-b)x\ dx=?$$
Check with $a-b=0$ and otherwise?
A: Hint.
If $a= b,$ then the integrands are of the form $\sin^2\phi,\,\cos^2\phi.$ If you integrate this over the interval, you should get $π.$
If $a\ne b,$ then for the $\sin$ integral, integrate by parts to obtain $$\sin y\int \sin z+\int \cos y\cos z,$$ where $y=az$ for some appropriate rational $a.$ The first part vanishes since the integrand is odd. The second part becomes the cosine relation. Use the transformation $$2\cos a\cos b=\cos (a+b)+\cos(a-b),$$ so that your integral is now of the form $$\int \cos m+\int\cos n.$$ Thus you have the integral to be $\sin m+\sin n,$ where $m,\,n$ are integral multiples of $x.$ It follows that substituting $\pm π$ will make the integral vanish, since $\sin kπ=0$ for any integer $k.$
A: The symmetry argument is subtler for the second one. Note
$$\int_{-π}^{π}\sin(ax)\sin(bx)\,dx = 2 \int_{0}^{π}\sin(ax)\sin(bx)\,dx
= 2 \int_{-π/2}^{π/2} \sin(\frac π2 a+ at)\sin(\frac π2 b+ bx )\,dx $$
Examine different combinations of $a$ and $b$: In the case of odd $a$ and even $b$,
$$\int_{-π}^{π}\sin(ax)\sin(bx)\,dx =\pm 2 \int_{-π/2}^{π/2} \cos( at)\sin( bx )\,dx =0$$
Other cases of $a$ and $b$ can be analyzed  similarly to obtain vanishing value of the integrals.
