Evaluate: $$\int_0^{\pi} \frac{x}{1+\sin^2{x}}dx$$
My attempt:
Let $I = \int_0^{\pi} \frac{x}{1+\sin^2{x}}dx$
Using Identity: $$\int_0^af(x)dx=\int_0^af(a-x)dx$$ I got: $$I=\int_0^{\pi} \frac{\pi -x}{1+\sin^2{(\pi -x})}dx$$
$$I=\frac{\pi}{2}\int_0^{\pi} \frac{dx}{1+\sin^2{x}}$$
Dividing numerator and denominator by $\cos^2x$
$$I=\frac{\pi}{2}\int_0^{\pi} \frac{\sec^2x}{\sec^2x+\tan^2x}dx$$
$$I=\frac{\pi}{2}\int_0^{\pi} \frac{\sec^2x}{1+2\tan^2x}dx$$ Using Substitution method, let: $$t =\sqrt2\tan x$$ $$\frac{dt}{\sqrt2} =\sec^2xdx$$ The limits also change upon substitution, so the integral I get is: $$I=\frac{\pi}{2\sqrt2}\int_0^{0} \frac{1}{1+t^2}dt$$ But the answer isn't $I(0)-I(0)=0$.
So where did my solution go wrong? I do know that I could have changed the upper limit of the integral to be $\frac{\pi}{2}$, and somehow it all works out. But why doesn't the integral work in the way I did?