Example 2. For what value of the real number $\mathrm{x}$, does $\sqrt{4 \mathrm{x}^{2}-4 \mathrm{x}+1}$ $-\sqrt{x^{2}-2 x+1}(0 \leqslant x \leqslant 2)$ attain its maximum and minimum values? And find the maximum and minimum values.
Let $y=\sqrt{4 x^{2}-4 x+1}-\sqrt{x^{2}-2 x+1}$
$$
\begin{aligned}
x & \sqrt{(2 x-1)^{2}}=\sqrt{(x-1)^{2}} \\
\text { Then } y & =|2 x-1|-|x-1|, \quad(0 \leqslant x \leqslant 2)
\end{aligned}
$$
$$
\therefore y=\left\{\begin{array}{ll}
-x, & \text { (when } 0 \leqslant x \leqslant \frac{1}{2} \text { ) } \\
3 x-2, & \text { (when } \frac{1}{2}<x<1 \text { ) } \\
x . & \text { (when } 1 \leqslant x \leqslant 2 \text { ) }
\end{array}\right.
$$

Figure 1
From Figure 1, $v^{\prime} 4 x^{2}-4 x+1 \sqrt{x^{2}-2 x+1}$ $(0 \leqslant x \leqslant 2)$

When $z=\frac{1}{2}$, it achieves the minimum value $-\frac{1}{2}$; when $x=2$, it achieves the maximum value 2.