Completion for this proof that $\sum_{k=0}^n {n \choose k} \cos\left((k+1)x\right) = 2^n \cos^n\frac x 2 \cos\frac{(n+2)x}{2}$ There's this exercise in a textbook:
$$\sum_{k=0}^n {n \choose k} \cos\left((k+1)x\right) = 2^n \cos^n\frac x 2 \cos\frac{(n+2)x}{2}$$
I've been missing from some classes at school and I copied the notes from one of my classmates, but this proof given by my teacher seems incomplete to me, because it only considers certain cases for x. However, I ploted both sides of the equality in the title and it works for every x. So how can this proof be completed?
Proof:
$$ S_1 = \sum_{k=0}^n {n \choose k} \cos\left((k+1)x\right) \\
S_2 = \sum_{k=0}^n {n \choose k} \sin\left((k+1)x\right) \\
S_1 + iS_2 = \sum_{k=0}^n {n \choose k}\cos\left((k+1)x\right) + i\sin\left((k+1)x\right) \\
z = \cos x + i\sin x \\
z^k = \cos kx + i\sin kx \hspace{1in}\text{(Moivre)} \\
\begin{align*} S_1 + iS_2 & = \sum_{k=0}^n {n \choose k}z^{k+1} \\ &= z\sum_{k=0}^n{n \choose k}z^k \\ &= z(1+z)^n \hspace{1in} \text{(Newton)}\end{align*}$$
$$|z| = 1, \varphi_1 = arg(z) = x \\
\begin{align*}
|1+z| &= \sqrt{(1+\cos x)^2 + \sin^2 x} \\ &= \sqrt{1 + 2\cos x + \cos^2 x + \sin^2 x} \\ &= \sqrt{2 + 2\cos x} \\ &= \sqrt{2(1+\cos x)} \\ &= \sqrt{2\cdot 2\cos^2 \frac x 2} \\ &= 2\left|\cos\frac x 2\right| \\ &= \color{red}{2\cos\frac x 2} \end{align*}$$
$$ 1+z = |1+z|\left(\cos \varphi_2 + i\sin\varphi_2\right) \\
\begin{align*}
\color{red}{\varphi_2 } &\color{red}{= \arctan\frac{\sin x}{1 + \cos x}} \\
&=\arctan\frac{2\sin\frac x 2\cos\frac x 2}{2\cos^2\frac x 2} \\ &= \arctan\left(\tan\frac x 2\right) \\ 
&= \color{red}{\frac x 2}\end{align*}$$
$$ z(1+z)^n = \left(\cos x + i\sin x\right)\left[2\cos\frac x 2\left(\cos\frac x 2 + i\sin\frac x 2\right)\right]^n = 2^n\cos^n\frac x 2 \left[\cos\left(x + \frac{nx}{2}\right) + i\sin\left(x + \frac{nx}{2}\right)\right] = S_1 + iS_2 \\
S_1 = {\rm Re}(S_1 + iS_2) = 2^n\cos^n\frac x 2 \cos \frac {(n+2)x}{2}$$
In red, I put the parts where the teacher only considered certain cases for x.

You’re right when writing $|\cos{\frac{x}{2}}|=\cos{\frac{x}{2}}$ the teacher consider only the cas where $\cos\frac{x}{2}\ge 0$. This does not anyway change the structure of the proof in all cases. By the way you can use the fact that $$1+e^{ix}= 2\cos{\frac{x}{2}}e^{i\frac{x}{2}}$$ to avoid the use of cases. 
To prove you can do it this way:
$$e^{ix}+1=e^{i\frac{x}2}\times e^{i\frac{x}2}+ e^{i\frac{x}2}\times e^{-i\frac{x}2}= e^{i\frac{x}2}(e^{i\frac{x}2}+ e^{-i\frac{x}2})=2\cos\frac{x}2 e^{i\frac{x}2}$$
