# How do you find the integral of int 1/(1 + tan(x))?

$\int \cos \frac{x}{\cos + \sin x} \mathrm{dx} = \frac{1}{2} \left(x + \ln \left(\cos x + \sin x\right)\right) + c$

#### Explanation:

Let

$I = \int \frac{1}{1 + \tan x} \mathrm{dx}$

$I = \int \cos \frac{x}{\cos + \sin x} \mathrm{dx}$

$\cos x = l \left(\cos x + \sin x\right) + m \left(- \sin x + \cos x\right) + n$

$\cos x = \left(l + m\right) \cos x + \left(l - m\right) \sin x + n$

Equating the coefficients of cosx sinx and constants

$l + m = 1 , l - m = 0 , n = 0$

$l = \frac{1}{2} , n = \frac{1}{2}$

$\cos x = \frac{1}{2} \left(\cos x + \sin x\right) + \frac{1}{2} \left(- \sin x + \cos x\right) + 0$

$I = \int \cos \frac{x}{\cos + \sin x} \mathrm{dx}$

$I = \frac{1}{2} \int \frac{\cos x + \sin x}{\cos x + \sin x} \mathrm{dx} + \frac{1}{2} \int \frac{- \sin x + \cos x}{\cos x + \sin x} \mathrm{dx}$

$I = \frac{1}{2} \left({I}_{1} + {I}_{2}\right)$

where,

${I}_{1} = \int \frac{\cos x + \sin x}{\cos x + \sin x} \mathrm{dx} = \int 1 \mathrm{dx} = x$

${I}_{1} = x$

${I}_{2} = \int \frac{- \sin x + \cos x}{\cos x + \sin x} \mathrm{dx}$

let

$t = \cos x + \sin x$

$\frac{\mathrm{dt}}{\mathrm{dx}} = - \sin x + \cos x$

$\mathrm{dt} = \left(- \sin x + \cos x\right) \mathrm{dx}$

$\int \frac{- \sin x + \cos x}{\cos x + \sin x} \mathrm{dx} = \int \frac{\left(- \sin x + \cos x\right) \mathrm{dx}}{\cos x + \sin x} = \int \frac{\mathrm{dt}}{t} = \ln t$

${I}_{2} = \ln \left(\cos x + \sin x\right)$

$I = \frac{1}{2} \left({I}_{1} + {I}_{2}\right)$

$\int \cos \frac{x}{\cos + \sin x} \mathrm{dx} = \frac{1}{2} \left(x + \ln \left(\cos x + \sin x\right)\right) + c$