$\int\dfrac{\cos^2 x}{1+\sin^2 x}dx$ I have trouble finding the integral of
$$\int_0^{\frac{\pi}{2}}\dfrac{\cos^2 x}{1+\sin^2 x}dx$$
But the answer I'm getting is the negative value of the correct answer. I substituted $\tan x=t$; 
 A: $$\int\dfrac{\cos^2 x}{1+\sin^2x}dx=\int\dfrac{\cos^2 x}{\cos^2x+2\sin^2x}dx=\int\dfrac{dx}{1+2\tan^2x}=\int\dfrac{(2+2\tan^2 x)-(1+2\tan^2 x)}{1+2\tan^2x}dx=\int\dfrac{2\sec^2x}{1+2\tan^2x}dx-\int dx$$
$$=\int\dfrac{d(\tan x)}{\left(\frac{1}{\sqrt{2}}\right)^2+\tan^2 x}-\int dx=\sqrt{2}\tan^{-1}(\sqrt{2}\tan x)-x+C$$
A: $$\int_{0}^{\frac{\pi}{2}}\frac{\cos^2(x)}{1+\sin^2(x)}\space\text{d}x=$$
$$\int_{0}^{\frac{\pi}{2}}\frac{\sec^2(x)}{\sec^4(x)+\sec^2(x)\tan^2(x)}\space\text{d}x=$$
$$\int_{0}^{\frac{\pi}{2}}\frac{\sec^2(x)}{1+3\tan^2(x)+2\tan^4(x)}\space\text{d}x=$$

Substitute $u=\tan(x)$ and $\text{d}u=\sec^2(x)\space\text{d}x$
This gives a new lower bound $u=\tan(0)=0$ and upper bound $u=\lim_{x\to\left(\frac{\pi}{2}\right)^-}\tan\left(x\right)=\infty$:

$$\int_{0}^{\infty}\frac{1}{2u^4+3u^2+1}\space\text{d}u=$$
$$\int_{0}^{\infty}\left(\frac{2}{2u^2+1}-\frac{1}{u^2+1}\right)\space\text{d}u=$$
$$\int_{0}^{\infty}\frac{1}{2u^4+3u^2+1}\space\text{d}u=$$
$$2\int_{0}^{\infty}\frac{1}{2u^2+1}\space\text{d}u-\int_{0}^{\infty}\frac{1}{u^2+1}\space\text{d}u=$$

Substitute $s=u\sqrt{2}$ and $\text{d}s=\sqrt{2}\space\text{d}u$
This gives a new lower bound $s=0\sqrt{2}=0$ and upper bound $s=\lim_{u\to\infty}u\sqrt{2}=\infty$:

$$\sqrt{2}\int_{0}^{\infty}\frac{1}{s^2+1}\space\text{d}s-\int_{0}^{\infty}\frac{1}{u^2+1}\space\text{d}u=$$
$$\sqrt{2}\lim_{b\to\infty}\left[\arctan(s)\right]_{0}^{b}-\int_{0}^{\infty}\frac{1}{u^2+1}\space\text{d}u=$$
$$\sqrt{2}\lim_{b\to\infty}\arctan(b)-\int_{0}^{\infty}\frac{1}{u^2+1}\space\text{d}u=$$
$$\frac{\pi\sqrt{2}}{2}-\int_{0}^{\infty}\frac{1}{u^2+1}\space\text{d}u=$$
$$\frac{\pi\sqrt{2}}{2}-\lim_{c\to\infty}\left[\arctan(u)\right]_{0}^{c}=$$
$$\frac{\pi\sqrt{2}}{2}-\lim_{c\to\infty}\arctan(c)=$$
$$\frac{\pi\sqrt{2}}{2}-\frac{\pi}{2}=\frac{\pi}{\sqrt{2}}-\frac{\pi}{2}$$
