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$.
 A: You have
$$\sin\frac{n\pi}{2} = \frac{1-(-1)^n}{2}(-1)^{\lfloor n/2\rfloor}.$$
So that's one way.  But often, if there are no $\cos$'s messing things up, you can re-index your sum.  All the terms for even $n$ are zero, you can rewrite
$$\sum_{n=1}^{\infty}  \sin\frac{n\pi}{2}\mbox{crud} = \sum_{k=1}^{\infty} \sin\frac{(2k-1)\pi}{2}\mbox{crud}= \sum_{k=1}^{\infty}(-1)^k \mbox{crud}.$$
Whatever the crud is, replace all occurrences of $n$ with $2k-1.$
A: 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.
A: You have a sequence with period $4$ (specifically $0,1,0,-1,0,1,\cdots$), but $(-1)^n$ has period $2$, so it can't be used in this form.
However, $(-1)^{\binom n2}=(-1)^{n(n-1)/2}$ does have period $4$:
$$(-1)^0=1,\quad(-1)^1=-1,\quad(-1)^3=-1,\quad(-1)^6=1,$$
$$(-1)^{10}=1,\quad(-1)^{15}=-1,\quad(-1)^{21}=-1,\quad(-1)^{28}=1,$$
$$\cdots$$
To prove periodicity:
$$(-1)^{(n+4)(n+3)/2}=(-1)^{(n^2+7n+12)/2}=(-1)^{4n+6+(n^2-n)/2}\\=((-1)^2)^{2n+3}(-1)^{n(n-1)/2}=(-1)^{n(n-1)/2}$$
Now let's try shifting and combining these:
$$\begin{matrix}n&=&(0,&1,&2,&3,&\cdots) \\ (-1)^n&=&(1,&-1,&1,&-1,&\cdots) \\ (-1)^{n(n-1)/2}&=&(1,&1,&-1,&-1,&\cdots) \\ (-1)^{n(n+1)/2}&=&(1,&-1,&-1,&1,&\cdots) \\ (-1)^{n(n-1)/2}-(-1)^{n(n+1)/2}&=&(0,&2,&0,&-2,&\cdots)\end{matrix}$$
And there's your answer:
$$\sin(n\pi/2)=\frac{(-1)^{n(n-1)/2}-(-1)^{n(n+1)/2}}{2}$$
In fact any $4$-periodic sequence can be expressed in this way:
$$f_n=\frac{1+(-1)^n+(-1)^{n(n-1)/2}+(-1)^{n(n+1)/2}}{4}=(1,0,0,0,1,0,0,0,1,\cdots)$$
$$(a_0,a_1,a_2,a_3,a_0,a_1,a_2,a_3,a_0,\cdots)=a_0f_n+a_1f_{n-1}+a_2f_{n-2}+a_3f_{n-3}$$
$$=a_0\frac{1+(-1)^n+(-1)^{n(n-1)/2}+(-1)^{n(n+1)/2}}{4} \\ +a_1\frac{1-(-1)^n+(-1)^{n(n-1)/2}-(-1)^{n(n+1)/2}}{4} \\ +a_2\frac{1+(-1)^n-(-1)^{n(n-1)/2}-(-1)^{n(n+1)/2}}{4} \\ +a_3\frac{1-(-1)^n-(-1)^{n(n-1)/2}+(-1)^{n(n+1)/2}}{4}$$
See also What is a mathematical expression for the sequence $\{1,1,-1,-1,1,1,-1,-1,\dots\}$? and the linked posts.
A: If you are multiplying by that sin term, even terms fall out
$$
\sum_{n=1}^{2N} f(n)\sin \left(\frac{n\pi}{2}\right) = \sum_{k=1}^N (-1)^{k-1} f(2k-1)
$$
