Computing an indefinite integral(2) $$\int \sqrt{1- \sin(2x)}dx =?$$
My attempt:
$$\int \sqrt{1- \sin(2x)}dx = \int \sqrt{(\cos x - \sin x)^{2}} dx = \int|\cos x- \sin x| dx = ??$$

Notice,  $$\cos x-\sin x=\sqrt 2\left(\frac{1}{\sqrt 2}\cos x-\frac{1}{\sqrt 2}\sin x\right)=\sqrt 2\sin\left(\frac{\pi}{4}-x\right)$$
but $\sin \theta\ge 0\iff 2k\pi\le \theta\le 2k\pi+\pi$
hence, solving the inequality 


*

*$$2k\pi\le \left(\frac{\pi}{4}-x\right)\le 2k\pi+\pi$$
$$ 2k\pi\le \left(\frac{\pi}{4}-x\right)\implies x\leq -\left(2k\pi-\frac{\pi}{4}\right)$$

*$$\left(\frac{\pi}{4}-x\right)\le 2k\pi+\pi\implies x\ge -\left(2k\pi+\frac{3\pi}{4}\right)$$
hence, we get
$$\color{red}{|\cos x-\sin x|}=\cases{\color{blue}{\cos -\sin x}\ \ \ \ \ \ \ \ \  \ \  \ \  \forall\ \ -\left(2k\pi+\frac{3\pi}{4}\right)\le x\le -\left(2k\pi-\frac{\pi}{4}\right)\\ \color{blue}{-(\cos -\sin x)}\ \ \ \ \ \ \  \forall\ \ -\left(2k\pi-\frac{\pi}{4}\right)\le x\le -\left(2k\pi-\frac{5\pi}{4}\right)}$$
where, $\color{red}{k}$ is any integer

