I am learning introductory quantum mechanics from the Introduction to Quantum Mechanics by David J. Griffiths.
I stumbled upon this proof for orthogonality of two different solutions regarding the infinite well problem on the page 33:

I have some problems understanding the passage from the first line to the second line. Why is $$\frac{2}{a}\sin{\left(\frac{m\pi}{a}x\right)}\sin{\left(\frac{n\pi}{a}x\right)}=\frac 1 a \cos{\left(\frac{m-n}{a}\pi x\right)}-\cos{\left(\frac{m+n}{a}\pi x\right)}$$ true? I haven't yet found any way to solve it using trigonometric identities.
There are lots of physics variables here, but this is Mathematics Stack Exchange. That's why I can ask it in the generalised way:
In general, why is $$2\sin{(akx)}\sin{(bkx)}=\cos{((a-b)kx)}-\cos{((a+b)kx)}$$ true?
Refer to product to sum identity
which can be proved by angle sum and difference identities.
Refer to the related