I am trying to solve this definite integral problem. $$\int_0^\pi \frac{dx}{1+\cos^{2} x}$$
dividing numerator and denomenator by $\cos^{2} x$, the integrand becomes, $$\int_0^\pi \frac{\sec^{2} x \ dx}{\sec^{2} x+1} = \int_0^\pi \frac{\sec^{2} x \ dx}{\tan^{2} x+2}$$
Now with a substitution like - $$u = \tan x$$
The definite integral reduces to, $$\int_0^0 \frac{du}{u^{2}+2} = 0 \ ?$$
But using the property of definite integral we know, $$\int_0^{2a} f(x) \ dx = \ \int_0^{a} (f(x) + f(2a-x))\ dx $$
Applying this property to our function, the integral becomes, $$2\int_0^{\pi/2} \frac{\sec^{2} x \ dx}{\tan^{2} x+2} \ dx = 2\int_0^{\infty} \frac{du}{u^{2}+2} = \frac{\pi}{\sqrt{2}} \ !!$$
Getting different answers in both cases. What am I doing wrong? Please advice.
*I am new to MathJax. Any syntax error is regretted.