Proof that $\frac{e^{\frac{\pi i}{4}}}{\sqrt{2}}\left(1+e^{-(2n+1)\frac{\pi i}{2}}\right)-e^{\frac{n^2\pi i}{2}}=0$ How should I prove
$$\forall n\in\mathbb{N}:\, \frac{e^{\frac{\pi i}{4}}}{\sqrt{2}}\left(1+e^{-(2n+1)\frac{\pi i}{2}}\right)-e^{\frac{n^2\pi i}{2}}=0?$$
My attempt:
$$\begin{align}\frac{e^{\frac{\pi i}{4}}}{\sqrt{2}}\left(1+e^{-(2n+1)\frac{\pi i}{2}}\right)-e^{\frac{n^2\pi i}{2}}&=\frac{1}{\sqrt{2}}\left(e^{\frac{\pi i}{4}}+e^{-n\pi i-\frac{\pi i}{2}+\frac{\pi i}{4}}\right)-e^{\frac{n^2\pi i}{2}}\\&=\frac{1}{\sqrt{2}}\left(e^{\frac{\pi i}{4}}+e^{-i\left(n\pi +\frac{\pi}{4}\right)}\right)-e^{\frac{n^2\pi i}{2}}\\&=\frac{1}{\sqrt{2}}\left(\cos\frac{\pi}{4}+i\sin\frac{\pi}{4}+\frac{1}{\cos\left(n\pi +\frac{\pi}{4}\right)+i\sin\left(n\pi +\frac{\pi}{4}\right)}\right)-e^{\frac{n^2\pi i}{2}}\\&=\frac{1+i}{2}+\frac{1}{\sqrt{2}}\frac{1}{\frac{1}{\sqrt{2}}(\cos n\pi -\sin n\pi )+\frac{i}{\sqrt{2}}(\cos n\pi +\sin n\pi)}-e^{\frac{n^2\pi i}{2}}\\&=\frac{1+i}{2}+\frac{1}{\cos n\pi +i\cos n\pi}-e^{\frac{n^2\pi i}{2}}\\&=\frac{1+i}{2}+\frac{1}{i^{2n}+i^{2n+1}}-i^{n^2}\end{align}$$
How should I proceed?
 A: HINT: from your last line, consider the two different cases, according with $n$ odd and even.
A: To proceed:
$$\begin{align}
\frac{1+i}{2}+\frac{1}{i^{2n}+i^{2n+1}}-i^{n^2}&=\frac{1+i}{2}+\frac{1}{i^{2n}(1+i)}-i^{n^2}\\
&=\frac{1+i}{2}+\frac{(-1)^n}{1+i}\frac{1-i}{1-i}-i^{n^2}\\
&=\frac{1+i}{2}+\frac{(-1)^n(1-i)}{2}-i^{n^2}\\
&=\frac{1+(-1)^n}{2}+i\frac{1-(-1)^n}{2}-i^{n^2}
\end{align}$$
For $n$ even, $4\mid n^2$ and so $i^{n^2}=1$, and for $n$ odd, $4\mid n^2-1$ and so $i^{n^2}=i\cdot i^{n^2-1}=i$.
A: Let $f=\frac{e^{\frac{\pi i}{4}}}{\sqrt{2}}\left(1+e^{-(2n+1)\frac{\pi i}{2}}\right)-e^{\frac{n^2\pi i}{2}}$. Then
$$\begin{align}f&=\frac{1}{\sqrt{2}}\left(e^{\frac{\pi i}{4}}+e^{-(2n+1)\frac{\pi i}{2}+\frac{\pi i}{4}}\right)-e^{\frac{n^2\pi i}{2}}\\&=\frac{1}{\sqrt{2}}\left(e^{\frac{\pi i}{4}}+e^{-i\left(n\pi +\frac{\pi}{2}-\frac{\pi}{4}\right)}\right)-e^{\frac{n^2\pi i}{2}}\end{align}$$
and
$$\begin{align}\operatorname{Re}f&=\frac{1}{\sqrt{2}}\left(\cos\frac{\pi}{4}+\cos\left(n\pi +\frac{\pi}{4}\right)\right)-\cos\frac{n^2\pi}{2}\\&=\frac{1}{\sqrt{2}}\left(\frac{\sqrt{2}}{2}+\frac{1}{\sqrt{2}}\left(\cos n\pi -\sin n\pi \right)\right)-\cos \frac{n^2\pi}{2}\\&=\frac{1}{2}+\frac{1}{2}\cos n\pi -\cos\frac{n^2\pi}{2}\\&=\frac{1+(-1)^n}{2}-\cos \frac{n^2\pi}{2}.\end{align}$$
Since $\frac{1+(-1)^n}{2}=0$ for odd $n$ and $\frac{1+(-1)^n}{2}=1$ for even $n$ and $\cos\frac{n^2\pi}{2}=0$ for odd $n$ and $\cos\frac{n^2\pi}{2}=1$ for even $n$, $\operatorname{Re}f=0$ for $n\in\mathbb{N}$.
Similarly for $\operatorname{Im}f$:
$$\operatorname{Im}f=\frac{1-(-1)^n}{2}-\sin\frac{n^2\pi}{2}.$$
Since $\frac{1-(-1)^n}{2}=1$ for odd $n$ and $\frac{1-(-1)^n}{2}=0$ for even $n$ and $\sin\frac{n^2\pi}{2}=1$ for odd $n$ and $\sin\frac{n^2\pi}{2}=0$ for even $n$, $\operatorname{Im}f=0$ for $n\in\mathbb{N}$. Therefore $f=0$ for all $n\in\mathbb{N}$.
A: I tried what @Joe suggested on the problem statement itself. I'm getting the right answer for even $n$ but the answer for odd $n$ is equal upto a sign.
