To solve the integral \( \int_0^2 ||x-1|-x| \, dx \), we will break it down step by step.
### Step 1: Analyze the expression inside the integral
We need to simplify the expression \( ||x-1|-x| \).
1. **Identify the inner absolute value**:
- \( |x-1| \) can be expressed in piecewise form:
- \( x-1 \) when \( x \geq 1 \)
- \( -(x-1) = 1-x \) when \( x < 1 \)
2. **Now consider the outer absolute value**:
- We need to analyze \( ||x-1|-x| \) based on the values of \( x \).
### Step 2: Determine intervals for \( x \)
We will break the integral into intervals based on the critical points where the expressions change, which are at \( x = 0, 1, 2 \).
- **Interval 1: \( [0, 1) \)**
- Here, \( |x-1| = 1-x \)
- Thus, \( ||x-1|-x| = |(1-x)-x| = |1-2x| \)
- **Interval 2: \( [1, 2] \)**
- Here, \( |x-1| = x-1 \)
- Thus, \( ||x-1|-x| = |(x-1)-x| = |-1| = 1 \)
### Step 3: Set up the integral
Now we can express the integral as:
\[
\int_0^2 ||x-1|-x| \, dx = \int_0^1 |1-2x| \, dx + \int_1^2 1 \, dx
\]
### Step 4: Evaluate the integral on each interval
1. **Evaluate \( \int_0^1 |1-2x| \, dx \)**:
- For \( x \in [0, 1/2] \), \( 1-2x \geq 0 \) so \( |1-2x| = 1-2x \)
- For \( x \in [1/2, 1] \), \( 1-2x < 0 \) so \( |1-2x| = -(1-2x) = 2x-1 \)
Thus, we split this integral:
\[
\int_0^{1/2} (1-2x) \, dx + \int_{1/2}^1 (2x-1) \, dx
\]
- **Calculate \( \int_0^{1/2} (1-2x) \, dx \)**:
\[
= \left[ x - x^2 \right]_0^{1/2} = \left( \frac{1}{2} - \left(\frac{1}{2}\right)^2 \right) = \frac{1}{2} - \frac{1}{4} = \frac{1}{4}
\]
- **Calculate \( \int_{1/2}^1 (2x-1) \, dx \)**:
\[
= \left[ x^2 - x \right]_{1/2}^1 = \left( 1 - 1 \right) - \left( \left(\frac{1}{2}\right)^2 - \frac{1}{2} \right) = 0 - \left( \frac{1}{4} - \frac{1}{2} \right) = \frac{1}{4}
\]
Therefore,
\[
\int_0^1 |1-2x| \, dx = \frac{1}{4} + \frac{1}{4} = \frac{1}{2}
\]
2. **Evaluate \( \int_1^2 1 \, dx \)**:
\[
= [x]_1^2 = 2 - 1 = 1
\]
### Step 5: Combine the results
Now we can combine the results from both intervals:
\[
\int_0^2 ||x-1|-x| \, dx = \frac{1}{2} + 1 = \frac{3}{2}
\]
### Final Answer
The value of the integral is:
\[
\boxed{\frac{3}{2}}
\]