Calculating the integral is not giving the same simplified function I calculated this integral below :
$$
\int_{-\pi/2}^{\pi/2} \cos(x)\cos(nx) dx
$$
And I got this result :
$\dfrac{\left(\left(n-1\right)\sin\left(\frac{{\pi}n+{\pi}}{2}\right)+\left(n+1\right)\sin\left(\frac{{\pi}n-{\pi}}{2}\right)\right)}{n^2-1}$
I had a check at the end at the solution :
$-\dfrac{2\cos\left(\frac{{\pi}n}{2}\right)}{n^2-1}$
So apparently there is some kind of simplification to do but I don't actually know how .
 A: $\sin (\frac {n\pi} 2+\frac {\pi} 2)=\cos (\frac {n \pi} 2)$  and $\sin (\frac {n\pi} 2-\frac {\pi} 2)=-\cos (\frac {n \pi} 2)$.
[$\sin (\frac {\pi} 2+\theta)=\cos (\theta)$ and $\sin (\theta -\frac {\pi} 2)=-\sin (\frac {\pi} 2-\theta)=-\cos (\theta)$]
A: Observe that
$$\sin\left(\frac{\pi n+ \pi}{2}\right)=\sin\left(\frac{\pi n}{2}\right)\cos\left(\frac{\pi}{2}\right)+ \sin\left(\frac{\pi}{2}\right)\cos\left(\frac{\pi n}{2}\right) = \cos\left(\frac{\pi n}{2}\right)$$
$$\sin\left(\frac{\pi n- \pi}{2}\right)=\sin\left(\frac{\pi n}{2}\right)\cos\left(\frac{\pi}{2}\right)- \sin\left(\frac{\pi}{2}\right)\cos\left(\frac{\pi n}{2}\right) = -\cos\left(\frac{\pi n}{2}\right)$$
when $n\in\mathbb{N}$.
Then,
\begin{equation*}
\begin{split}
(n-1)\sin\left(\frac{\pi n+ \pi}{2}\right) & + (n+1)\sin\left(\frac{\pi n- \pi}{2}\right) = (n-1)\cos\left(\frac{\pi n}{2}\right) - (n+1)\cos\left(\frac{\pi n}{2}\right) \\
& = -2\cos\left(\frac{\pi n}{2}\right)
\end{split}
\end{equation*}
A: Use Prosthaphaeresis Formulas,
$$n\left(\sin\dfrac{(n+1)\pi}2+\sin\dfrac{(n-1)\pi}2\right)-\left(\sin\dfrac{(n+1)\pi}2-\sin\dfrac{(n-1)\pi}2\right)$$
$$=2n\sin\dfrac{n\pi}2\cos\dfrac\pi2-2\cos\dfrac{n\pi}2\sin\dfrac\pi2$$
Alternatively,
like Evaluate the integral $\int^{\frac{\pi}{2}}_0 \frac{\sin^3x}{\sin^3x+\cos^3x}\,\mathrm dx$.,
as $\cos x\cdot\cos(nx)$ is an even function using Werner Formulas,
$$\int_{-a}^a\cos x\cdot\cos(nx)\ dx=2\int_0^a\dfrac{\cos(n-1)x+\cos(n+1)x}2\ dx$$
