Integrating an equation with sin squared on top and cos plus constant on bottom I am trying to integrate an equation of the form 
\begin{equation}
\int_0^\pi \frac{\sin^2(x)}{\cos(x)+C}dx
\end{equation}
I can't think of a way to do it and Mathematica tells me that it is undefined at limits, is this impossible?
 A: Hint : Try the substitution $t=tan(\frac{x}{2})$
If I did not make a mistake, this leads to 
$$\int_0^\infty \frac{8t^2}{(c-1)t^6+(3c-1)t^4+(3c+1)t^2+(c+1)}dt=$$
$$\int_0^\infty -\frac{2(c^2-1)}{(c-1)t^2+c+1}+\frac{2(c+1)}{t^2+1}-\frac{4}{(t^2+1)^2}dt=$$
$$\pi(c-\sqrt{c^2-1)}$$ for $c\ge 1$
For $c\le -1$, I get $$\pi(c+\sqrt{c^2-1}$$
For $-1<c<1$, the integral does not seem to exist.
A: Use the eveness of the integrand and the subsitution $z=e^{i x}$, $dx =1/(i z)$ to get
$$
I(C)=\int_{|z|=1}dz\frac{-1}{4iz}\frac{(z-1/z)^2}{(z+1/z)+C} 
$$
This leads to 
$$
I(C)=\int_{|z|=1}dz\frac{-1}{4i}\frac{z^4-2z^2+1}{(z^2+1+2 Cz)(z^2)} 
$$
Now you can use Residue theorem, but be careful! Depending on the Sign of $C$ different poles will lie inside the unit circle. The poles are $p_{\pm}(C)=-C\pm\sqrt{C^2-1}$ and $p_0(C)=0$
and therefore the Residues are given by $r_{\pm}(C)=\pm2\sqrt{C^2-1}$, and $r_0(C)=-2C$.
It's easy to see that if $C>1$, $p_+$ is inside the circle. In contrast if $C<-1$ we have to choose $p_-$. $p_0$ have to be picked up in both cases (for $|C|<1$, please note my comment at the end). 
We therefore obtain:
$$
I(C)=C\pi- \text{sign}(C)\sqrt{C^2-1} \pi
$$
PS:
Do you assume that $|C|>1$? Otherwise we run into trouble (Because the square root gets imaginary, and the poles will reside on the integration contour) and have really to think how to correctly analytical continuing into the region of smaller $|C|$ and how to interpret our integral in the sense of a principal value.  
