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?

\begin{align}
\int_0^{\pi/2} |\sin(x)-\cos(x)|dx &= \int_0^{\pi/4} |\sin(x)-\cos(x)|dx+\int^0_{\pi/4} |\sin(x)-\cos(x)|dx\\
&=-\int_0^{\pi/4} \sin(x)-\cos(x)dx+\int_{\pi/4}^{\pi/2} \sin(x)-\cos(x)dx\\
&=..
\end{align}
