<s>[INST] 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.
 [/INST] 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|}
$$
</s>