Integration of absolute value function: $\int_0^2 ||x-1|-x|dx$? $$\int_0^2 ||x-1|-x|dx$$
How to see what this integral is in a quick way?
 A: $$I=\int_0^2 ||x-1|-x|dx$$
HINT
Break the modulus by taking $x\ge 1$ and $x<1$
$$I_1=\int_0^1 |-x+1-x|dx$$
$$I_1=\int_0^1 |1-2x|dx$$
This should be easy. Plot $y=1-2x$ and make all O/P positive by reflecting everything below x-axis above and find the area.


$$I_2=\int_1^2 |x-1-x|dx$$
$$I_2=\int_1^2 dx$$

$$\boxed{I=I_1+I_2}$$
A: Imagine $x$ to be any number on real line. $|x-1|$ represents the distance of $x$ from the number $1$. Plotting this in the region $0$ to $2$ gives a "V" kind of shape. Plot $x$ as well. $||x-1| - x|$ represents the vertical distance between these two plots. As can be seen in the region $x>1$ this distance is constant and equal to $1$. In the region $x \in [0,1]$ it can be seen the distance first decreases from $1$ at $x=0$ to $0$ till $x = 1/2$ and increases back to $1$ at $x=1$. These increase and decrease are linear since both the plots are linear. This way you can quickly plot the graph and see that the integral amounts to area of two triangles plus the area of a square.
A: look at the possible value of the functions in the different regions:
$$0<x<1\rightarrow ||x-1|-x|=|(1-x)-x|=|1-2x|$$
You can now go either one of two ways:

*

*recognise that your function is symmetrical around the line $x=\frac 12$

*split the function further

If we split it further we get:
$$f(x)=\begin{cases}1-2x& 0<x<\frac12\\2x-1& \frac12<x<1\end{cases}$$
Now finally we look at $x\in[1,2]$:
$$1<x<2\Rightarrow||x-1|-x|=|(x-1)-x|=|-1|=1$$
and so we get:
$$x\in[0,2],f(x)=||x-1|-x|\Rightarrow f(x)=\begin{cases}1-2x& 0<x<\frac12\\2x-1&\frac12<x<1\\1&1<x<2\end{cases}$$
so we can say that:
$$\int_0^2||x-1|-x|dx=\int_0^{1/2}(1-2x)dx+\int_{1/2}^1(2x-1)dx+\int_1^2dx$$
