In the course reader of the EE261 class of Standford University, there's the integration of this function:
$f(t) = \begin{cases} +1 & \text{ if } -1/2 \leq t < 1/2\\ -1 & \text{ if } +1/2 \leq t < 1 \end{cases}$
Here's the steps.
\begin{align} c_n &= \int_0^1 e^{-2\pi int} f(t) \,dt\\ &= \int_0^{1/2} e^{-2\pi int} \,dt - \int_{1/2}^1 e^{-2\pi int} \,dt \\ &= \left[-\frac{1}{2\pi in}e^{-2\pi int}\right]_{0}^{1/2} - \left[-\frac{1}{2\pi in}e^{-2\pi int}\right]_{1/2}^{1} \tag{1}\\ &= \frac{1}{\pi in}(1 - e^{-\pi in})\tag{2}. \end{align}
I'm not able to go from (1) to (2). My question is in the algebra, not in the integration. Here's what I get.
\begin{align} c_n &= \int_0^1 e^{-2\pi int} f(t) \,dt\\ &= \int_0^{1/2} e^{-2\pi int} \,dt - \int_{1/2}^1 e^{-2\pi int} \,dt \\ &= \left[-\frac{1}{2\pi in}e^{-2\pi int}\right]_{0}^{1/2} - \left[-\frac{1}{2\pi in}e^{-2\pi int}\right]_{1/2}^{1}\\ &= -\frac{1}{2\pi in}e^{\pi in} + \frac{1}{2\pi in}e^0 - \left( -\frac{1}{2\pi in}e^{-2\pi in} + \frac{1}{2\pi in}e^{\pi in} \right)\\ &= \frac{1}{2\pi in}\left(-e^{\pi in} + 1 + e^{-2\pi in} - e^{\pi in}\right)\\ &= \frac{1}{2\pi in}\left(-2e^{\pi in} + 1 + e^{-2\pi in} \right) \end{align}
I'm not sure how I could simplify this further to as to match the text's answer. Can you show me what I could do here to get there? Thank you.
Using Euler's formula we get $e^{2\pi in}=\cos(2\pi n)+\sin(2\pi n)i=1$ for all $n\in\mathbb Z$.
Then can deduce $$ \frac1{2\pi in}\left(-2e^{\pi in}+1+e^{-2\pi in}\right)=\frac1{2\pi in}\left(-2e^{\pi in}+1+1\right)=\frac1{2\pi in}\left(2-2e^{\pi in}\right)=\frac1{\pi in}\left(1-e^{\pi in}\right) $$