How to solve this absolute value equation I have the following integral $$\int_0^{\pi/2} |\sin x-\cos x|dx. $$It's a simple integral but when I try to solve the module I get stuck. I took $\sin x-\cos x>0$ and squaring this I found that $\sin 2x<1$. When I apply $\arcsin$ it would mean $$2x<\frac\pi2 \implies x<\frac\pi4$$ but the interval is wrong from the one in my book. When I apply $\arcsin$ does the sign change? Why?

Well, we can use the relation:
$$\sin\left(x\right)-\cos\left(x\right)=-\sqrt{2}\cdot\sin\left(\frac{\pi}{4}-x\right)\tag1$$
So, for the integral we get:
$$\mathscr{I}:=\int_0^\frac{\pi}{2}\left|\sin\left(x\right)-\cos\left(x\right)\right|\space\text{d}x=\int_0^\frac{\pi}{2}\left|-\sqrt{2}\cdot\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x=$$
$$\int_0^\frac{\pi}{2}\left|-\sqrt{2}\right|\cdot\left|\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x=\sqrt{2}\int_0^\frac{\pi}{2}\left|\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x\tag2$$
Now, for the integral we can write:
$$\int_0^\frac{\pi}{2}\left|\sin\left(\frac{\pi}{4}-x\right)\right|\space\text{d}x=\int_0^\frac{\pi}{4}\sin\left(\frac{\pi}{4}-x\right)\space\text{d}x-\int_\frac{\pi}{4}^\frac{\pi}{2}\sin\left(\frac{\pi}{4}-x\right)\space\text{d}x\tag3$$
