integration making cases $$\int_{0}^{2\pi}|\sin x - \cos x|\,dx.$$
now we will  try to make cases  , what i did   i put  sin x - cos x = 0
this  gives tan x = 0  , but iam stuck here 
I applied above logic  by taking below in consideration 
$$\int_{0}^{6}|x - 3|\,dx.$$
 x -3 = 0  , x =3 
$$\int_{0}^{6}|x - 3|\,dx.$$ = $$\int_{0}^{3}3-x\,dx.$$       + $$\int_{3}^{6}x - 3\,dx.$$
 A: I can't understand what you tried to do, but
$$x\in\left[0,\,2\pi\right]\;,\;\;\cos x-\sin x\ge0\iff x\in\left[0,\,\frac\pi4\right]\cup\left[\frac{5\pi}4,\,2\pi\right]$$
so
$$\int_0^{2\pi}|\cos x-\sin x|dx=\int_0^{\pi/4}(\cos x-\sin x)dx+\int_{5\pi/4}^{2\pi}(\cos x-\sin x)dx+$$
$$+\int_{\pi/4}^{5\pi/4}(\sin x-\cos x)dx=4\sqrt2$$
A: Begin with simplifying the integrand:
$$\sin x-\cos x=\sqrt{2\rule{0pt}{2ex}}\sin\Bigl(x-\dfrac\pi4\Bigr),$$
so that by substitution ($u=x-\frac\pi4$):
$$\int_{0}^{2\pi}|\sin x - \cos x|\,\mathrm dx=\sqrt{2\rule{0pt}{2ex}}\int_{-\tfrac\pi4}^{\tfrac{7\pi}4}|\sin u|\,\mathrm du=\sqrt{2\rule{0pt}{2ex}}\int_{0}^{2\pi}|\sin u|\,\mathrm du=2\sqrt{2\rule{0pt}{2ex}}\int_{0}^{\pi}\sin u\,\mathrm du.$$
A: You do not need to separate cases. For any $C>0$ and any $\theta\in\mathbb{R}$ we have
$$ \int_{0}^{2\pi}\left|C\sin(x+\theta)\right|\,dx = 4C $$
since both $\left|\sin x\right|$ and $\left|\sin (x+\theta)\right|$ are $\pi$-periodic and their integral over a period equal $2$.
Your problem can be solved by considering $C=\sqrt{2}$ and $\theta=-\frac{\pi}{4}$.
