integration of definite integral involving sinx and cos x Evaluate $\int_0^{\pi}\frac{dx}{a^2\cos^2x +b^2 \sin^2x}$
I got numerator $\sec^2 x$ and denominator $b^2 ( a^2/b^2 + \tan^2x)$.
I made substitution $u= \tan x$. That way $\sec^2 x$ got cancelled and the answer was of form $1/ab$ ($\tan^{-1} (bu/a)$)
And then if I put limits answer is $0$ but answer is wrong. Where did I go wrong?
 A: Hint: Try $~t=\pi-x,~$ simplify the integrand, then add the two equivalent integral expressions together, and use the Weierstrass substitution.

The problem lies with the fact that $\tan x$ is not bijective on $[0,\pi],~$ since $\tan0=\tan\pi=0,$ so you're ultimately evaluating $\displaystyle\int_0^0f(t)~dt=0$. My advice would be to split the integral with regard to $~\dfrac\pi2~$ first, before making any substitutions.
A: Are you talking about this?:

$$\small\int\frac{dx}{a^2\cos^2x +b^2 \sin^2x}=\int\frac{\sec^2xdx}{a^2+b^2 \tan^2x}\stackrel{u=\tan x}=\frac1{b^2}\int\frac{du}{a^2/b^2+u^2}=\frac1{b^2}\frac1{a/b}\arctan\frac{\tan x}{a/b}$$
  So:
  $$\int_0^{\pi}\frac{dx}{a^2\cos^2x +b^2 \sin^2x}=\frac1{ab}\arctan\frac{b\tan x}a\Bigg|_0^{\pi}=0$$

This is wrong because at $\pi/2$, $\cos x=0\iff \sec x\to\infty$!! Or you can say because $\tan x$(=u) misbehaves at $x=\pi/2$.It should rather be done like:

$$\int_0^{\pi}\frac{dx}{a^2\cos^2x +b^2 \sin^2x}=\frac1{ab}\arctan\frac{b\tan x}a\Bigg|_0^{\displaystyle\pi/2^-}+\frac1{ab}\arctan\frac{b\tan x}a\Bigg|_{\displaystyle\pi/2^+}^{\displaystyle\pi}$$

A: $$\begin{eqnarray*}\color{red}{I}&=&\int_{0}^{\pi}\frac{dx}{a^2\cos^2 x+b^2\sin^2 x}=2\int_{0}^{\pi/2}\frac{dx}{a^2\cos^2 x+b^2\sin^2 x}\\&=&2\int_{0}^{+\infty}\frac{dt}{(1+t^2)\left(a^2\frac{1}{1+t^2}+b^2\frac{t^2}{t^2+1}\right)}=2\int_{0}^{+\infty}\frac{dt}{a^2+b^2 t^2}\\&=&\frac{2}{ab}\int_{0}^{+\infty}\frac{du}{1+u^2}=\color{red}{\frac{\pi}{ab}}.\end{eqnarray*}$$
Here we replaced $x$ with $\arctan t$, then $t$ with $\frac{a}{b}\,u$.
A: Hint:
The problem is that you divide the numerator and the denominator of the integrand by $\cos^2 x$, but this can be done only for $\cos^2 x \ne 0$ i.e. $x\ne \pi/2$. So you have to divide your integral in two improper integrals as:
$$
\int_0^\pi = \int_0^{(\pi/2)^-}-\int_\pi^{(\pi/2)^+}
$$
Your substutition is correct, so you have the limit:
$$
\lim_{x \rightarrow (\pi/2)^{\pm}} \arctan \left(\frac{b}{a} \tan x \right)
$$
that is $\pm \pi/2$.
