I'm given a question for my Partial Differential Equations course and I see this step and I can't wrap my head around it. I've been drawing graphs for the past hour and I can't understand how to integrate it and how to see how the coefficients interact. So if someone could explain it to me I'd be very grateful.
My lecturer tried to help by saying "In problems involving series of trigonometric functions, you may assume orthogonality over [better: of] relevant intervals".

One way to see it is with the identity $$ 2\sin(A)\sin(B) = \cos(A-B) - \cos(A+B),$$ which itself follows from the angle addition formula $\cos(A\pm B) = \cos(A)\cos(B) \mp \sin(A)\sin(B)$.
If $n=m$, then we are integrating $\frac{1}{2} - \frac{1}{2}\cos\left(\frac{(2m+1)\pi}{a}x\right)$ over $[0,a]$. This is easily seen to be $a/2$. In a similar fashion, for $n≠m$ we see that we are integrating $\frac{1}{2}\cos\left(\frac{(m-n)\pi}{a}x\right) - \frac{1}{2}\cos\left(\frac{(m+n+1)\pi}{a}x\right)$, and both of these integrate to $0$.