I'm trying to evaluate the integral $$\int_{-\pi}^{\pi} \frac{\sin^2 t}{3+\cos t}dt$$ using complex numbers.
Meaning, instead of calculating $$\int_{-\pi}^{\pi} \frac{\sin^2 t}{3+\cos t}dt,$$ I want to calculate the integral $$\int_\Gamma \frac{\sin^2 z}{3+\cos z}dz$$ where $\Gamma$ is half the circle with center at origin and radius $\pi$ (in the positive direction), and then the straight line on the $x$ axis from $-\pi$ to $\pi$.
We know that this integral is $0$ because $$\frac{\sin^2 z}{3+\cos z}$$ is analytic in the entire area bounded by $\Gamma$. So that's not an issue, but to evaluate our original integral, we need to now calculate $$\int_\gamma \frac{\sin^2 z}{3+\cos z}dz$$ where $\gamma$ is just the upper half of the circle I mentioned above. Without the line that goes from $-\pi$ to $\pi$ on the $x$ axis.
How do I calculate this integral?
Edit: A good parametrization might be $z=\pi e^{i\theta}$ where $0 \leq \theta \leq \pi$. And then we need to calculate the integral $$\int_{0}^{\pi} \frac{\sin^2 (\pi e^{i \theta})}{3+\cos (\pi e^{i\theta})}i\pi e^{i\theta} d\theta.$$ Doesn't seem easy to do.
By setting $z=e^{it}$, we have $dz=i e^{it} dt$, so $dt=-\frac{i}{z}dz$ and:
$$ I = \int_{-\pi}^{+\pi}\frac{\sin^2 t}{3+\cos t}\,dt = -i\oint \frac{\left(\frac{z-1/z}{2i}\right)^2}{z\left(3+\frac{z+1/z}{2}\right)}\,dz=i\oint\frac{(1-z^2)^2}{z^2(1+6z+z^2)}\,dz$$ where the path of integration is the unit circle. The integrand function $f(z)=\frac{(1-z^2)^2}{z^2(1+6z+z^2)}$ has two poles inside the unit disk, in $z=0$ and $z=-3+\sqrt{8}$. The last integral can be computed by applying the residue theorem:
$$ I = -2\pi\cdot\sum_{\xi\in\{0,-3+\sqrt{8}\}}\operatorname{Res}(f(z),z=\xi)=-2\pi(-3+2\sqrt{2})=\color{red}{2\pi(3-\sqrt{8})}.$$