\hspace{-16}$Given $\bf{y=\frac{x^2-2x\cos A+1}{x^2-2x\cos B+1} = \frac{\left(x^2-2x\cos B+1\right)+\left(2x\cos B-2x\cos A\right)}{x^2-2x\cos B+1},}$ \\\\\\ $\bf{y=1+\frac{2x\cdot \left(\cos B-\cos A\right)}{x^2-2x\cos B+1}=1+\frac{2\left(\cos B-\cos A\right)}{\left(x^2+\frac{1}{x^2}\right)-2\cos B}}\;\; $, where $\bf{x\in \mathbb{R}-\{0\}}$\\\\\\ Now we will find Range of $\bf{\left(x^2+\frac{1}{x^2}\right)}$ for $\bf{x\in \mathbb{R}-\{0\}}$\\\\\\ $\bullet $ If $\bf{x>0}$, Then $\bf{\left(x^2+\frac{1}{x^2}\right)\geq 2}$ using $\bf{A.M\geq G.M}$\\\\\\ So $\bf{y_{Max.} = 1+\frac{2\left(\cos B-\cos A\right)}{2-2\cos B} = \frac{1-\cos A}{1-\cos B}=\frac{\sin ^2 \frac{A}{2}}{\sin ^2 \frac{B}{2}}}$\\\\\\ $\bullet $ If $\bf{x<0}$, Then $\bf{\left(x^2+\frac{1}{x^2}\right)\leq -2}$ using $\bf{A.M\geq G.M}$\\\\\\ So $\bf{y_{Min.} = 1+\frac{2\left(\cos B-\cos A\right)}{-2-2\cos B} = \frac{1+\cos A}{1+\cos B}=\frac{\cos ^2 \frac{A}{2}}{\cos ^2 \frac{B}{2}}}$\\\\\\
\hspace{-16}$So $\bf{\frac{\cos ^2 \frac{A}{2}}{\cos ^2 \frac{B}{2}} \leq y \leq \frac{\sin ^2 \frac{A}{2}}{\sin ^2 \frac{B}{2}}}$\\\\\\ and at $\bf{x=0}$, we get $\bf{y=1}$,\\\\\\ which is possible when $\bf{A = B}$