Evaluting: $\int\frac{1}{(1+\tan x)^2} dx$ I can solve this integral 
$$
\int\frac{1}{(1+\tan x)^2} dx
$$
using the substitution $t=\tan x$ i.e $x=\arctan t$. Does anyone know another way to solve this integral?
 A: $$\frac{1}{(1+\tan x)^{2}} = \frac{(\cos x)^{2}}{(\sin x+\cos x)^{2}}$$ 
$$= \frac{(\cos x)^{2}(\sin x - \cos x)^{2}}{(\cos 2x)^{2}}$$ 
$$= \frac{(\cos 2x - 1)(1-\sin 2x)}{2(\cos 2x)^{2}}$$ 
$$= 1/2 (\sec 2x)-(\sec 2x)^{2}-(\tan 2x)+(\sec 2x)(\tan 2x) $$
$$\int (\sec 2x) = 1/2\ln (\sec 2x + \tan 2x)$$ 
$$\int(\sec 2x)^{2}=1/2\cdot \tan 2x$$ 
$$\int(\tan 2x) = 1/2 \ln (\cos 2x)$$ 
$$\int (\sec 2x)(\tan 2x)=1/2 \sec 2x$$ 
A: Using J.M.'s suggestion
$$ \int \frac{1}{( 1 + \tan x)^2} dx  = \int \frac{\frac 12 (1 + \cos 2x)}{ \sin ^2x +2 \sin x \cos 2 + \cos ^2 x} dx = \frac 12 \int \frac{1 + \cos 2x}{1 + \sin 2x}dx$$
$$ = \frac 12 \left [ \int \frac 1 {1 + \sin 2x} dx + \int \frac{\cos 2x}{1 + \sin 2x}dx\right ]$$
$$ = \frac 1 2 \frac{\sin x}{\sin x + \cos x} +  \frac 1 4 \ln (1 + \sin 2x) + C$$
$$ = \frac 12 \left [ \frac{-1}{1 + \tan x} + \ln(\sin x + \cos x)\right  ] + C $$
EDIT:: first half of split up integral
$$ \int \frac{1}{1 + \sin 2x} dx = \frac 1 2 \int \frac{1}{1 + \sin u} du $$
and Weierstrass substitution $$ \frac 12 \int \frac{1}{1 + \frac{2t}{1 + t^2}}\frac{2dt}{1 + t^2} =  \int \frac{1}{(1 + t)^2} dt $$
$$ \implies \frac{-1}{1 + t} = \frac{-1}{1 + \tan x} = \frac{-\cos x}{\sin x + \cos x}$$
From wolfram I got $ \int \frac{\sin x}{ \sin x + \cos x} $ 
Using Weierstrass substitution I got $ \frac{-\cos x}{\sin x + \cos x} $ And it seems $$ \frac{\sin x}{ \sin x + \cos x} - \frac{-\cos x}{\sin x + \cos x} = 1 $$
Hence both are vaid :D :D
And by clicking show steps at Wolframalpha
 
