<s>[INST] Integral of the function $\frac{\cos ^2 x}{1+\tan x}$ Evaluate $$\int \frac{\cos ^2 x}{1+\tan x}dx$$ I tried converting in double angle and making the derivative of the denominator in the numerator. But, it didn't work out. Some help please. Thanks.
 [/INST] Let $$I = \int\frac{\cos^2 x}{1+\tan x}dx = \int\frac{\cos^3 x}{\sin x+\cos x}dx = \frac{1}{2}\int\frac{2\cos^3 x}{\sin x+\cos x}dx$$
So we get $$I = \frac{1}{2}\left[\int\frac{\left(\cos^3 x+\sin^3 x\right)+(\cos^3 x-\sin^3 x)}{\sin x+\cos x}\right]dx$$
So we get $$I = \frac{1}{4}\int (2-\sin 2x)dx+\frac{1}{4}\int \frac{(2+\sin 2x)(\cos x-\sin x)}{\cos x+\sin x}dx$$
Now In SEcond Integral Put $(\cos x+\sin x)=t\;,$ Then $(\cos x-\sin x)dx = dt$
and $1+\sin 2x=t^2\Rightarrow \sin 2x = t^2-1$
So Our Second Integral Convert into $\displaystyle \frac{1}{4}\int\frac{t^2+1}{t}dt$
</s>