Deriving expression for the DTFT of a rectangular window
There's a mistake in the denominator of B. This is the way it should be done:

$$\begin{align}R(\omega)&amp;=\frac{1-e^{-j\omega (M+1)}}{1-e^{-j\omega}}\\&amp;=\frac{e^{-j\omega(M+1)/2}}{e^{-j\omega/2}}\cdot\frac{e^{j\omega(M+1)/2}-e^{-j\omega(M+1)/2}}{e^{j\omega/2}-e^{-j\omega/2}}\\&amp;=e^{-j\omega M/2}\frac{\sin\left(\frac{M+1}{2}\omega\right)}{\sin(\omega/2)}\end{align}$$