Integration of $1/((1+\cos x)(1+\sin x))$ How do you integrate $\displaystyle \frac 1{(1+\cos x)(1+\sin x)}$? I've tried $u$ substitution and manipulation and have got nowhere. I cannot think of any other methods that would work.
 A: Let $$\displaystyle I = \int\frac{1}{(1+\sin x)\cdot (1+\cos x)}dx = \frac{1}{2}\int\frac{1}{\left(\sin \frac{x}{2}+\cos \frac{x}{2}\right)^2\cdot \cos^2 \frac{x}{2}}dx$$
Above we used $$\displaystyle \bullet\; 1+\sin x = \sin^2 \frac{x}{2}+\cos^2 \frac{x}{2}+2\sin \frac{x}{2}\cdot \cos \frac{x}{2}$$
And $$\displaystyle \bullet\; 1+\cos x = 2\cos^2 \frac{x}{2}.$$
So we get $$\displaystyle I = \frac{1}{2}\int\frac{\sec^2 \frac{x}{2}}{\left(\sin \frac{x}{2}+\cos \frac{x}{2}\right)^2}dx = \frac{1}{2}\int\frac{\sec^2 \frac{x}{2}\cdot \left(1+\tan^2 \frac{x}{2}\right)}{\left(\tan \frac{x}{2}+1\right)^2}$$
Now Put $\displaystyle \tan \frac{x}{2} = t\;,$ Then $\displaystyle \frac{1}{2}\sec^2 \frac{x}{2}dx = dt$
So we get $$\displaystyle I = \int\frac{1+t^2}{(1+t)^2}dx = \int\frac{1+t^2+2t-2t}{(1+t)^2}dt=\int1dt-2\int\frac{t}{(1+t)^2}dt$$
Now $(1+t) = u\;,$ Then $dt = du$
So we get $$\displaystyle I = t-2\int\frac{u-1}{u^2}du=t-2\ln |u|-\frac{2}{u}+\mathcal{C}$$
So we get $$\displaystyle I =t-2\ln |1+t|-\frac{2}{1+t}+\mathcal{C}$$
So we get $$\displaystyle I =\tan \frac{x}{2}-2\ln \left|1+\tan \frac{x}{2}\right|-\frac{2}{1+\tan \frac{x}{2}}+\mathcal{C}$$
A: HINT:
$$\dfrac1{(1+\cos x)(1+\sin x)}=\dfrac{(1-\sin x)(1-\cos x)}{\cos^2x\sin^2x}$$
$$=\sec^2x\csc^2x+2\csc2x-\dfrac{\sin x+\cos x}{\cos^2x\sin^2x}$$
Now, $\sec^2x\csc^2x=\sec^2x+\csc^2x$
For $\displaystyle\int\dfrac{\sin x}{\cos^2x\sin^2x}dx=\int\dfrac{\sin x}{\cos^2x(1-\cos^2x)}dx$
set $\cos x=u$
Similarly for $\displaystyle\int\dfrac{\cos x}{\cos^2x\sin^2x}dx$
