Evaluate $\int\limits_0^\pi \frac{\sin^2x}{2-\cos x}\ \mathrm dx$ by complex methods find integral $$\int\limits_0^\pi  \frac{\sin^2x}{2-\cos x}dx$$
what I had in mind is to use Euler formula, to turn it into a complex integral and change the limits of integration from $ -\pi$  to  $\pi$ so that any odd parts of the integrand would go to zero. But does not seem to make problem easier. Substitution of $u=\tan(x/2)$ would work but the computation is very tedious. Any suggestions for a nicer approach?  
 A: Hint: Let $\gamma\colon [-\pi, \pi]\to \Bbb C, \theta \mapsto e^{i\theta}$. It is true that $\displaystyle \int \limits_0^ \pi\frac{(\sin(x))^2}{2-\cos(x)}\mathrm dx=\dfrac 1{4i}\int _\gamma \dfrac{z^4-2z^2+1}{z^4-4z^3+z^2}\mathrm dz$.
Further details: Note that for all $t\in \Bbb R$, $$\sin(t)=\dfrac{e^{it}-e^{-it}}{2i}\land \cos(t)=\dfrac{e^{it}+e^{-it}}{2}.$$
The map $x\mathop\longmapsto\dfrac{(\sin(x))^2}{2-\cos(x)}$ defined on $[-\pi, \pi]$ is even, thus $$\displaystyle \int \limits_{-\pi}^\pi\dfrac{(\sin(x))^2}{2-\cos(x)}\mathrm dx=2\int \limits_{0}^\pi\dfrac{(\sin(x))^2}{2-\cos(x)}\mathrm dx.$$
So,
$$\begin{align} \int \limits_{0}^\pi\dfrac{(\sin(x))^2}{2-\cos(x)}\mathrm dx&=\dfrac 1 2\int \limits_{-\pi}^\pi\dfrac{(\sin(x))^2}{2-\cos(x)}\mathrm dx\\
&=\dfrac 12\int \limits_{-\pi}^\pi\dfrac{\left(\frac{e^{ix}-e^{-ix}}{2i}\right)^2}{2-\frac{e^{ix}+e^{-ix}}{2}}\mathrm dx\\
\\&=\dfrac 12\int \limits_{-\pi}^\pi 1\cdot \dfrac{\frac{1}{-4}\left(e^{2ix}-2+e^{-2ix}\right)}{\frac{1}{2}\left(4-e^{ix}-e^{-ix}\right)}\mathrm dx\\
&=-\dfrac 1 {4}\int \limits_{-\pi}^\pi \dfrac{ie^{ix}}{ie^{ix}}\cdot \dfrac{e^{2ix}-2+e^{-2ix}}{4-e^{ix}-e^{-ix}}\mathrm dx\\
&=-\dfrac 1 {4i}\int \limits_{-\pi}^\pi \dfrac{\left(e^{2ix}-2+e^{-2ix}\right)ie^{ix}}{4e^{ix}-e^{2ix}-1}\mathrm dx\\ &=\dfrac 1 {4i}\int \limits_{-\pi}^\pi \dfrac{\left((e^{ix})^2-2+(e^{ix})^{-2}\right)ie^{ix}}{(e^{ix})^2-4e^{ix}+1}\mathrm dx\\ 
&=\dfrac 1 {4i}\int \limits_\gamma \dfrac{z^2-2+z^{-2}}{z^2-4+1}\mathrm dz\\
&=\dfrac 1 {4i}\int \limits_\gamma \dfrac{z^4-2z^2+1}{z^4-4z^3+z^2}\mathrm dz.\end{align}$$
The integral $\displaystyle \dfrac 1 {4i}\int \limits_\gamma \dfrac{z^4-2z^2+1}{z^4-4z^3+z^2}\mathrm dz$ can be found using residues.
It holds that for all $z\in \Bbb C$, $z^4-4z^3+z^2=z^2\left(z-(2-\sqrt 3)\right)\left(z-(2+\sqrt 3)\right)$.
Wolfram Alpha yields
$$\begin{align} &\operatorname{Res}\left(z\mapsto \dfrac{z^4-2z^2+1}{z^4-4z^3+z^2}, 0\right)&=4\\
&\operatorname{Res}\left(z\mapsto \dfrac{z^4-2z^2+1}{z^4-4z^3+z^2}, 2-\sqrt 3\right)&=-2\sqrt 3\\
&\operatorname{Res}\left(z\mapsto \dfrac{z^4-2z^2+1}{z^4-4z^3+z^2}, 2+\sqrt 3\right)&=2\sqrt 3.\end{align}$$
Since the winding numbers of the poles $2+\sqrt 3, 2-\sqrt 3$ and $0$ with respect to $\gamma$ are respectively $0, 1$ and $1$ it comes
$$\dfrac 1 {4i}\int \limits_\gamma \dfrac{z^4-2z^2+1}{z^4-4z^3+z^2}\mathrm dz=\dfrac 1{4i}\cdot 2\pi i\left(4-2\sqrt 3\right)=\pi(2-\sqrt 3).$$
A: $\newcommand{\+}{^{\dagger}}%
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\fermi}{\,{\rm f}}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert #1 \right\vert}%
 \newcommand{\yy}{\Longleftrightarrow}$
$\ds{\int_{0}^{\pi}{\sin^{2}\pars{x} \over 2-\cos\pars{x}}\,\dd x:\ {\large ?}}$

\begin{align}
&\int_{0}^{\pi}{\sin^{2}\pars{x} \over 2 - \cos\pars{x}}\,\dd x
=
\int_{0}^{\pi}{\sin^{2}\pars{x}\bracks{2 + \cos\pars{x}}
               \over
               4 - \cos^{2}\pars{x}}\,\dd x
=
\int_{0}^{\pi}{\sin^{2}\pars{x}\bracks{2 + \cos\pars{x}}
               \over
               3 + \sin^{2}\pars{x}}\,\dd x
\\[3mm]&=
2\int_{0}^{\pi}{3 + \sin^{2}\pars{x} - 3 \over 3 + \sin^{2}\pars{x}}\,\dd x
+
\overbrace{\int_{-\pi/2}^{\pi/2}
{\cos\pars{x + \pi/2} \over 3 + \sin^{2}\pars{x + \pi/2}}\,\dd x}^{\ds{=\ 0}}
=
2\pi - 6\int_{0}^{\pi}{\dd x \over 3 + \sin^{2}\pars{x}}
\\[3mm]&=
2\pi - 6\int_{0}^{\pi}{\dd x \over 3 + \bracks{1 - \cos\pars{2x}}/2}
=
2\pi - 12\int_{0}^{\pi}{\dd x \over 7 - \cos\pars{2x}}
=
2\pi - 6\int_{0}^{2\pi}{\dd x \over 7 - \cos\pars{x}}
\\[3mm]&=
2\pi - 6\oint_{\verts{z} = 1}{1 \over 7 - \pars{z + 1/z}/2}
\pars{-\ic\,{\dd z \over z}}
=
2\pi - 12\ic\oint_{\verts{z} = 1}{\dd z \over z^{2} - 14z + 1}
\end{align}

The roots $z_{\pm}$ of $z^{2} - 14z + 1 = 0$ are given by
$z_{\pm} = \pars{14 \pm \root{196 - 4}}/2 = 7 \pm 4\root{3}$ where
$\verts{z_{+}} > 1$ and $\verts{z_{-}} < 1$.
Then,

\begin{align}
&\int_{0}^{\pi}{\sin^{2}\pars{x} \over 2 - \cos\pars{x}}\,\dd x
=
2\pi - 12\ic\pars{2\pi\ic}\lim_{z \to z_{-}}\pars{z - z_{-} \over z^{2} - 14z + 1}
=
2\pi + 24\pi\,{1 \over 2z_{-} - 14}
\\[3mm]&=
2\pi + 24\pi\,{1 \over 2\pars{7 - 4\root{3}} - 14}
=
2\pi - {3\pi \over  \root{3}}
\end{align}

$$\color{#0000ff}{\large%
\int_{0}^{\pi}{\sin^{2}\pars{x} \over 2 - \cos\pars{x}}\,\dd x
=
\pars{2 - \root{3}}\pi}\quad \approx\quad 0.8418
$$
