# Need help with this integral using trig identities

I am trying to integrate the function $$\int_{-\pi/2}^0 \sin(2x)\cos(nx) \, \mathrm{d} x.$$

My professor has an answer of $$\frac{-2\cos(\frac{n \pi}{2})+1}{n^{2}-4}.$$

When I do this problem, I first notice that it can be broken into its trig identity and the new integral is written as $$\frac{1}{2}\int_{-\pi/2}^0 \sin((2+n)x \, \mathrm{d} x + \frac{1}{2}\int_{-\pi/2}^0 \sin((2-n)x \, \mathrm{d} x$$

Once I integrate both of these, I end up getting $$\frac{-1}{2+n}\left[1-\cos\left(\frac{(2+n)\pi}{2}\right)\right]+\frac{-1}{2-n}\left[1-\cos\left(\frac{(2-n)\pi}{2}\right)\right]$$

I can't seem to manipulate the above equation to get what my professor got

-

$$\cos\left(\frac{(2\pm n)\pi}2\right)=\cos(\pi\pm \frac{n\pi}2)=-\cos\frac{n\pi}2$$ as $\cos(\pi\pm y)=\cos y\cos\pi\mp\sin y\sin\pi=-\cos y$ using $\cos(A\pm B)=\cos A\cos B\mp\sin A\sin B$ and $\cos\pi=-1,\sin\pi=0$
The correct answer is $$2\frac{1+\cos(\frac{n \pi}{2})}{n^{2}-4}.$$ After integrate you should get $$\dfrac12\left\{\frac{-1}{2+n}\left[1-\cos\left(\frac{(2+n)\pi}{2}\right)\right]+\frac{-1}{2-n}\left[1-\cos\left(\frac{(2-n)\pi}{2}\right)\right]\right\}.$$ The rest is in lab bhattacharjee's answer.