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.
 A: Hint
$\binom nk\cos(k+1)x$ is the real part of
$e^{ix}\binom nk(e^{ix})^k$
which is 
$=e^{ix}(1+e^{ix})^n$
$=e^{ix(1+n/2)}\left(2\cos \dfrac x2\right)^n$
Using How to prove Euler's formula: $e^{i\varphi}=\cos(\varphi) +i\sin(\varphi)$?
$2\cos y=e^{iy}+e^{-iy}$
A: 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}$$
A: $$
\begin{aligned}
S=& \sum_{k=0}^{n}\left(\begin{array}{l}
n \\
k
\end{array}\right) \cos((k+1) x)+i \sum_{k=0}^{n}\left(\begin{array}{l}
n \\
k
\end{array}\right) \sin (k+1) x \\
=& \sum_{k=0}^{n}\left(\begin{array}{l}
n \\
k
\end{array}\right) e^{(k+1) x i}=e^{x i} \sum_{k=0}^{n}\left(\begin{array}{l}
n \\
k
\end{array}\right)\left(e^{x i}\right)^{k}
\end{aligned}
$$
By Binomial Theorem, $$
\begin{aligned}
S &=e^{x i}\left(1+e^{x i}\right)^{n} \\
&=e^{x i}\left(e^{\frac{x i}{2}}\left(e^{\frac{x i}{2}}+e^{-\frac{x}{2} i}\right) \right) ^{n}\\
&=e^{x i} \cdot e^{\frac{n x}{2} i}\left(2 \cos \frac{x}{2}\right)^{n} \\
&=2^{n} \cos ^{n} \frac{x}{2} e^{\frac{(n+2)x}{2} i}
\end{aligned}
$$
Comparing the real parts on both sides yields
$$\sum_{k=0}^{n}\left(\begin{array}{l}
n \\
k
\end{array}\right) \cos((k+1) x)= 2^{n} \cos ^{n} \frac{x}{2} \cos \frac{(n+2)x}{2} $$
As a bonus, $$\sum_{k=0}^{n}\left(\begin{array}{l}
n \\
k
\end{array}\right) \sin((k+1) x)= 2^{n} \cos ^{n} \frac{x}{2} \sin \frac{(n+2)x}{2} $$
