Definite integration of a trigonometric function 
How to integrate $$\int_0^{\pi/2}\!\dfrac{2a \sin^2 x}{a^2
\sin^2 x +b^2 \cos^2 x}\,dx $$

my first step is $$\frac{2}{a} \int_0^{\pi/2}\!\dfrac{a^2 \sin^2 x}{a^2 +(b^2 - a^2) \cos^2 x}\, dx $$
I would kind of want to do some sort of $u=\cos x$ substitution, to get at $\arctan u $ but no idea what to do with the sine in the numerator.
 A: Essentially, we want to integrate
$$I = \int_0^{\pi/2} \dfrac{\sin^2(t)dt}{1+c \sin^2(t)}$$
where $c<1$.
We have
$$I = \sum_{k=0}^{\infty} (-c)^k\int_0^{\pi/2}\sin^{2k+2}(t)dt = \dfrac{\pi}8 \cdot\sum_{k=0}^{\infty}\left(\dfrac{-c}4 \right)^k \dbinom{2k+2}{k+1} = \color{red}{\dfrac{\pi}{2c} \left(\dfrac{\sqrt{1+c}-1}{\sqrt{1+c}}\right)}$$
$\dfrac1{1+r} = \displaystyle \sum_{k=0}^{\infty}(-r)^k$; $\displaystyle \int_0^{2\pi} \sin^{2k}(x) dx = \dbinom{2k}k \dfrac{2\pi}{2^{2k}}$; $ \dfrac1{\sqrt{1-4x}} = \displaystyle\sum_{k=0}^{\infty} \dbinom{2k}k x^k \,\, \forall x \in \left[-\dfrac14,\dfrac14 \right)$
The integral you have is
$$J = \dfrac{2a}{b^2} \int_0^{\pi/2} \dfrac{\sin^2(x)}{1+ \underbrace{\left(\dfrac{a^2-b^2}{b^2}\right)}_{c} \sin^2(x)}dx = \dfrac{2a}{b^2} \cdot \frac{\pi}{2c} \left(\dfrac{\vert a/b \vert-1}{\vert a/b \vert}\right) = \dfrac{a \pi}{a^2-b^2}\dfrac{\vert a \vert - \vert b \vert}{\vert a \vert}$$
This gives you
$$\boxed{\color{blue}{J = \dfrac{\text{sign}(a)}{\vert a \vert + \vert b \vert} \pi}}$$
A: Actually $$\int_0^{\pi/2}\!\dfrac{2a}{a^2 +b^2 cot^2 x}\, dx $$ is also the way. Then $u = \cot x $ and $du = - \csc^2x = -(1+u^2)$ which will lead you to partial fractions.
A: Often, this type of integral is workable using the substitution
$$
z=\tan(x/2)\quad\text{and}\quad\mathrm{d}x=\frac{\mathrm{2\,d}z}{1+z^2}\\
\sin(x)=\frac{2z}{1+z^2}\quad\text{and}\quad\cos(x)=\frac{1-z^2}{1+z^2}
$$
A couple of identities that simplify this integral are
$$
\sin^2(x)=\frac{1-\cos(2x)}{2}\quad\text{and}\quad\cos^2(x)=\frac{1+\cos(2x)}{2}
$$
Then, assuming $a,b\gt0$,
$$
\begin{align}
\int_0^{\pi/2}\frac{2a\sin^2(x)}{a^2\sin^2(x)+b^2\cos^2(x)}\,\mathrm{d}x
&=\int_0^{\pi/2}\frac{2a(1-\cos(2x))}{a^2(1-\cos(2x))+b^2(1+\cos(2x))}\,\mathrm{d}x\\
&=\int_0^\pi\frac{a(1-\cos(x))}{(b^2+a^2)+(b^2-a^2)\cos(x)}\,\mathrm{d}x\\
&=\int_0^\infty\frac{az^2}{b^2+a^2z^2}\frac{2\mathrm{d}z}{1+z^2}\\
&=\int_{-\infty}^\infty\frac{az^2}{b^2+a^2z^2}\frac{\mathrm{d}z}{1+z^2}\\
&=2\pi i\left(\frac1{2i}\frac{a}{a^2-b^2}-\frac1{2i}\frac{b}{a^2-b^2}\right)\\
&=\frac\pi{a+b}
\end{align}
$$
where we use the contour running along the real axis from $-\infty$ to $\infty$, circling back in the upper half-plane. The residue at $z=i$ is $\dfrac1{2i}\dfrac{a}{a^2-b^2}$ and at $z=i\dfrac{b}{a}$ is $-\dfrac1{2i}\dfrac{b}{a^2-b^2}$. 
Removing the assumption on the signs of $a$ and $b$, we get
$$
\int_0^{\pi/2}\frac{2a\sin^2(x)}{a^2\sin^2(x)+b^2\cos^2(x)}\,\mathrm{d}x
=\mathrm{sgn}(a)\frac\pi{|a|+|b|}
$$
A: $$\displaystyle \int_0^{\dfrac{\pi}{2}} \dfrac{2a \sin^2 x}{a^2\sin^2 x +b^2 cos^2 x} dx$$
$$\displaystyle 2a\int_0^{\dfrac{\pi}{2}} \dfrac{\csc^2x }{a^2\csc^2 x +b^2 \cot^2 x \csc^2 x} dx$$
$$\displaystyle 2a\int_0^{\dfrac{\pi}{2}} \dfrac{\csc^2x }{(\cot^2 x+1)(a^2+b^2\cot^2 x)} dx$$
Let $u=\cot x$
$$\displaystyle 2a\int_0^{\infty} \dfrac{du }{(u^2 +1)(a^2+b^2u^2)} $$
$$\displaystyle 2a\int_0^{\infty} \left(\dfrac{1}{(u^2+1)(a^2-b^2)}-\dfrac{b^2 }{(a^2 -b^2)(a^2+b^2u^2)}\right) du $$
$$\displaystyle \frac{2a}{a^2-b^2}\int_0^{\infty} \left(\dfrac{1}{(u^2+1)}-\dfrac{b^2 }{(a^2+b^2u^2)}\right) du $$
And I hope you'll take it from here...
