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.
 A: 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$
A: Another possibility is a phase shift in the argument.
$$\begin{align}\int\frac{\cos^2x}{1+\tan x}dx&=\int\frac{\cos^3x}{\cos x+\sin x}dx=\int\frac{\cos^3x}{\sqrt2\cos\left(x-\frac{\pi}4\right)}dx\\
&=\frac1{\sqrt2}\int\frac{\cos^3\left(u+\frac{\pi}4\right)}{\cos u}du\\
&=\frac1{\sqrt2}\int\frac{\left(\frac1{\sqrt2}\cos u-\frac1{\sqrt2}\sin u\right)^3}{\cos u}du\\
&=\frac14\int\left[\cos^3 u-3\sin u\cos u+3\sin^2u-\frac{\sin u}{\cos u}+\sin u\cos u\right]du\\&=\frac14\int\left[2-\cos2u-\sin2u-\frac{\sin u}{\cos u}\right]du\\
&=\frac14\left[2u-\frac12\sin2u+\frac12\cos2u+\ln|\cos u|\right]+C_1\\
&=\frac14\left[2x-\frac{\pi}2-\frac12\sin\left(2x-\frac{\pi}2\right)+\frac12\cos\left(2x-\frac{\pi}2\right)+\ln\left|\cos\left(x-\frac{\pi}4\right)\right|\right]+C_1\\
&=\frac14\left[2x-\frac{\pi}2+\frac12\cos2x+\frac12\sin2x+\ln\left|\frac1{\sqrt2}\cos x+\frac1{\sqrt2}\sin x\right|\right]+C_1\\
&=\frac14\left[2x+\cos^2x+\sin x\cos x+\ln\left|\cos x+\sin x\right|\right]+C\end{align}$$
Differentiation confirms this result.
A: $$\int \frac{\cos ^2 x}{1+\tan x}dx=\int\frac{\sec^2x}{(1+\tan x)(1+\tan^2x)^2}dx=\int\frac{du}{(1+u)(1+u^2)^2}$$
Partial fractions might work now?
