How to simplify $\sin(n\frac{\pi}{2})$ as we do with $\cos(n\pi)$ When calculating Fourier series we almost always get some expression that look like:
\begin{equation} ...\left[\cos(nx) \right]_0^\pi.
\end{equation}
Then we use $\cos(n\pi) = (-1)^n$.
However, lately I have come across expressions like this:
\begin{equation} ...\left[\sin(nx) \right]_0^{\pi/2}.
\end{equation}
Which is equal to:
\begin{array}{|c|c|c|c|}
\hline
n& 1 & 2 & 3 & 4 \\ \hline
\sin(nx)&\sin(\frac{\pi}{2}) & \sin(\pi) & \sin(\frac{3\pi}{2})& \sin(2\pi)\\ \hline
 val &1 &0 &-1 &0\\ \hline
\end{array}
How do we simplify this so that it looks like the $\cos(n\pi) = (-1)^n$.

Note that $e^{\pm in\pi / 2} = \cos n\pi/2 \pm i\sin n\pi/2$, so
$$\sin n\pi/2 = \tfrac{1}{2i}(e^{in\pi / 2} - e^{-in\pi / 2})$$
$$= \tfrac{1}{2i}(i^n - i^{-n})$$
$$=\frac{i^{2n}-1}{2i^{n+1}}$$
$$= \frac{(-1)^n - 1}{2i^{n+1}}$$
$$= \boxed{\frac{1 - (-1)^n}{2i^{n-1}}}\tag{mult top/bottom by $i^{-2} = -1$}$$
This expression vanishes for even $n$, and for odd $n = 2k+1$ it becomes
$$\frac{1 - (-1)^{2k+1}}{2i^{2k+1-1}} = \frac{2}{2(-1)^k} = (-1)^k$$
as desired.
