<s>[INST] $\frac{\cos(xM)-\cos(xM+x)}{1-\cos(x)}=\frac{x\sin(M+\frac{1}{2})}{\sin(\frac{x}{2})}$ I am trying to prove the identity

$$
\frac{\cos(xM)-\cos(xM+x)}{1-\cos(x)}=\frac{x\sin(M+\frac{1}{2})}{\sin(\frac{x}{2})}
$$

I start with$$
\frac{\cos(xM)-\cos(xM+x)}{1-\cos(x)}=\frac{2\sin\left(Mx+\frac{x}{2}\right)\sin\left(\frac{x}{2}\right)}{1-\cos(x)}
$$
$$
\Longrightarrow\frac{2\sin\left(Mx+\frac{x}{2}\right)\sin\left(\frac{x}{2}\right)}{\cos^2(\frac{x}{2})+\sin^2(\frac{x}{2})-(\cos^2(\frac{x}{2})-\sin^2(\frac{x}{2}))}
$$
$$
\Longrightarrow
\frac{\sin\left(Mx+\frac{x}{2}\right)\sin\left(\frac{x}{2}\right)}{\sin^2(\frac{x}{2})}
$$
$$
\Longrightarrow
\frac{\sin\left(Mx+\frac{x}{2}\right)}{\sin(\frac{x}{2})}
$$
How do I proceed from here?

Context:
This problem arose when I solve for the Discrete-time Fourier Transform (DTFT) of the function $f[n]=1$ for $-M≤ n≤M$
Let $F_1(x)$ be the DTFT of $f_1[n]=1$ where $n=0,1\cdots M$ and $F_2(x)$ be thr DTFT of $f_1[n]=1$ where $n=-1,-2\cdots -M$
$$
F(x)=F_1(x)+F_2(x)
$$
$$
F(x)=\frac{1-e^{-ix(M+1)}}{1-e^{-ix}}+\frac{1-e^{-ix(M)}}{1-e^{ix}}e^{ix}
$$
$$
F(x)=\frac{e^{ixM}+e^{-ixM}-e^{ix(M+1)}-e^{-ix(M+1)}}{2-e^{-ix}-e^{ix}}
$$
leading to the equation above:
$$
\frac{\cos(xM)-\cos(xM+x)}{1-\cos(x)}
$$
which, according to the book, should yield $$
\frac{x\sin(M+\frac{1}{2})}{\sin(\frac{x}{2})}
$$
 [/INST] The correct answer is $$\frac{\sin\left(Mx+\frac{x}{2}\right)}{\sin(\frac{x}{2})}$$
This is a bit embarrassing but I misunderstood the book on its written formula as seen below
$$
X(\omega ) = A\frac{{\sin (M + \frac{1}{2})\omega }}{{\sin (\omega /2)}}
$$
</s>