Trigonometric Integrals $\int \frac{1}{1+\sin^2(x)}\mathrm{d}x$ and $\int \frac{1-\tan(x)}{1+\tan(x)} \mathrm{d}x$ Any idea of calculating this two integrals $\int \frac{1}{1+\sin^2(x)}\,dx$ and $\int \frac{1-\tan(x)}{1+\tan(x)} \mathrm{d}x$?
I found a solution online for the first one but it requires complex numbers which have not been taught by the professor.
 A: For the first one you may use that trig. 1 $$\frac{1}{1+\sin^{2}(x)} = \frac{1}{\cos^{2}(x)+2\sin^{2}(x)}= \frac{1}{\cos^{2}(t)}\frac{1}{1+2\tan^{2}(x)}$$ Now it is pretty clear that the change of variable $\tan(x)=t$ reduces to a standard arctanget integral $\int{\frac{dt}{1+2t^{2}}}$
For the second one, notice that $$\frac{1-\tan(x)}{1+\tan(x)}= \frac{\cos(x)-\sin(x)}{\sin(x)+\cos(x)} = \frac{d}{dx}\left( \ln(\sin(x)+\cos(x))\right)$$
A: Notice, $$I_1=\int \frac{dx}{1+\sin^2 x}$$
$$=\int \frac{\sec^2 xdx}{\sec^2 x+\sec^2 x\sin^2 x}$$
$$=\int \frac{\sec^2 xdx}{1+\tan^2 x+\tan^2 x}$$
$$=\int \frac{\sec^2 xdx}{1+2\tan^2 x}$$
$$=\frac{1}{2}\int \frac{\sec^2 x dx}{\left(\frac{1}{\sqrt{2}}\right)^2+\tan^2 x}$$
Now, let $\tan x=t\implies \sec^2x dx=dt$ 
$$=\frac{1}{2}\int \frac{dt}{\left(\frac{1}{\sqrt{2}}\right)^2+t^2 }$$
$$=\frac{1}{2}\sqrt{2}\tan^{-1}\left(t\sqrt{2}\right)$$
$$\implies I_1=\frac{1}{\sqrt{2}}\tan^{-1}\left(\sqrt{2}\tan x\right)+C_1$$
Again notice, $$I_2=\int \frac{1-\tan x}{1+\tan x}dx$$
$$=\int \frac{(1-\tan x)(1-\tan x)}{(1+\tan x)(1-\tan x)}dx$$
$$=\int \frac{1+\tan^2 x-2\tan x}{1-\tan^2 x}dx=\int \frac{1+\tan^2 x}{1-\tan^2 x}dx-\int\frac{2\tan x}{1-\tan^2 x}dx$$ $$=\int \sec 2x dx-\int\tan 2xdx$$
$$=\frac{1}{2}\ln(\sec 2x+\tan 2x)-\frac{1}{2}\ln\sec 2x+C_2$$
$$=\frac{1}{2}\ln\left(\frac{\sec 2x+\tan 2x}{\sec 2x}\right)+C_2$$
$$\implies I_2=\frac{1}{2}\ln\left(1+\sin 2x\right)+C_2$$
A: For your second integral, expand $\tan{(\frac{\pi}{4}-x)}$, identify and integrate.
