TITLE: Integrating $\int \frac{\sin x-\cos x}{(\sin x+\cos x)\sqrt{(\sin x \cos x + \sin^2x\cos^2x)}}\,dx$
QUESTION [6 upvotes]: I came across a question today...

Integrate $\int \dfrac{\sin x-\cos x}{(\sin x+\cos x)\sqrt{(\sin x \cos x + \sin^2x\cos^2x)}}\,dx$

How to do it? I tried
1. to take $\sin x \cos x =t$ but no result
2. to convert the thing in the square root into $\sin x +\cos x$ so that I could take $\sin x + \cos x = t$ but then something I got is $\int\frac{-2}{t|t+1|\sqrt{t-1}}\,dt$. Now I don't know how to get past through it.

REPLY [4 votes]: Notice, $$\int\frac{\sin x-\cos x}{(\sin x+\cos x)\sqrt{\sin x\cos x+\sin^2 x\cos^2x}}\ dx$$
$$=\int\frac{\sin x-\cos x}{(\sin x+\cos x)\sqrt{\frac{(\sin x+\cos x)^4-1}{4}}}\ dx$$
$$=2\int\frac{(\sin x-\cos x)dx}{(\sin x +\cos x)\sqrt{(\sin x+\cos x)^4-1}}$$
let $\sin x+\cos x=t\implies (\cos x-\sin x)\ dx=dt$, 
$$=-2\int\frac{dt}{t\sqrt{t^4-1}}$$
let $t^4-1=u^2\implies 4t^3\ dt=2u\ du$, $$=-2\int\frac{udu}{2u(u^2+1)} $$
$$=-\int\frac{du}{1+u^2}$$$$=-\tan^{-1}(u)+C$$
$$=-\tan^{-1}\left(\sqrt{t^4-1}\right)+C$$
$$=-\tan^{-1}\left(2\sqrt{\sin x\cos x+\sin^2x\cos^2 x}\right)+C$$