Change of variable in integrals I am trying to solve a definite integral of a positive function, but I keep getting 0.

 A: On using $ \int^a_{-a} f(x) dx = 2 \int^a_0 f(x) dx$ and $ \int^{2a}_0 f(x) dx = \int^a_0 f(x) dx + \int^a_0 f(2a - x) dx$
$$I = \int^{\pi}_{-\pi} \dfrac{1}{1 + \sin^2 (x)} dx = 4 \int^{\pi /2}_0 \dfrac{1}{1 + \sin^2 (x) } dx $$
Multiply, both denominator and numerator by $\sec^2 (x)$ , Use $\sec^2 (x) = \tan^2 (x) + 1$, and substitute $\sqrt{2} \tan x = u$, Following integral would be obtained
$$ I = 2 \sqrt{2} \int^{\infty}_0  \dfrac{du}{1 + u^2} = 2 \sqrt{2} \cfrac{\pi}{2} = \sqrt{2} \pi $$
The problem with your substition is that, you've took $du = \cos(x) dx = \color{red} {+}  \sqrt{1 - \sin^2 x} dx $, but the right way is $du = \cos(x) dx = \color{red} {\pm}  \sqrt{1 - \sin^2 x} dx $ and then substitute the required limits.
A: You can also note that 
$$\int_{-\pi}^{\pi}\frac{dx}{1+\sin^2 x}=2\int_0^\pi\frac{dx}{1+\sin^2 x}$$
because 
$$\int_{-\pi}^0\frac{dx}{1+\sin^2x}$$
becomes $$\int_0^\pi \frac{dt}{1+\sin^2t}$$
when you use the substitution $x=-t$.
Then, you can feel free to proceed with the integral as you desire.
