Problem with calculation this integral: $\int_0^\pi \frac{dx}{1+3\sin^2x}$ Question
Calculate this integral: $$\displaystyle\int_0^\pi \frac{dx}{1+3\sin^2x}$$

Solution
$$I=\displaystyle\int \frac{dx}{1+3\sin^2x}=\displaystyle\int \frac{dx}{\cos^2x+4\sin^2x}=\displaystyle\int \frac{\sec^2x\;dx}{1+4\tan^2x}$$ Let's apply substitution $u=2\tan x$, so $du=2\sec^2x\;dx$  $$I=\dfrac12\displaystyle\int \frac{du}{1+u^2}=\frac12\arctan(u)+c=\frac12\arctan(2\tan x)+c$$ In this case; $$\displaystyle\int_0^\pi \frac{dx}{1+3\sin^2x}=\left[\frac12\arctan(2\tan x)\right]_{x=0}^{x=\pi}=0$$.

But we know that: $$\frac{1}{1+3\sin^2 x} \ge \frac14$$ Therefore; $$\displaystyle\int_0^\pi \frac{dx}{1+3\sin^2x} \ge \displaystyle\int_0^\pi \frac{dx}{4}=\frac{\pi}4$$ On the other hand; $$0 \ge \frac{\pi}4$$ which is not true.
1) Where is the problem? (Why?)
2) How we can correct this mistake by applying the same substitution?

HINT: write
$$
\int_0^{\pi}\frac{dx}{1+3\sin^2x}=\frac{1}{2}\int_0^{\pi/2}\frac{dx}{1+3\sin^2x}.
$$
Then, the substitution you suggest is legitimate because $\tan x$ is monotone on $(0,\pi/2)$.
