The exercise asked to proof this identity: $$\sum_{n=0}^Ncos(nx) = \frac{1}{2} + \frac{1}{2}\frac{sin((N+\frac{1}{2})x)}{sin(\frac{x}{2})}$$
$$ $$ The solution is using Euler's identity and goes as follows:
$$\sum_{n=0}^Ne^{inx} = \frac{1-e^{i(N+1)x}}{1-e^{ix}}$$ now, taking only the real part:
$$\sum_{n=0}^Ncos(nx) = Re\frac{(1-e^{i(N+1)x})(1-e^{-ix})}{|1-e^{ix}|^2} = Re\frac{1-e^{-x}-e^{i(N+1)x}+e^{iNx}}{(1-cosx)^2+sin^2x} = Re\frac{1-cosx-cos((N+1)x)+cos(Nx)}{2-2cosx} =$$ $$ =^\star \frac{1}{2}+\frac{sin(\frac{2N+1}{2}x)sin\frac{x}{2}}{2-2cosx} =^\star \frac{1}{2}+\frac{1}{2}\frac{sin((N+\frac{1}{2})x)}{sin\frac{x}{2}}$$
Now, I understand everything except the last two equalities (I marked them with $\star$ so it will be clearer). What were the trigonometric identities used in them? I was thinking double angle but I couldn't figure it out exactly. (The $\frac{1}{2}+$ part is understood obviously, since it's just splitting the nominator).
Thanks!