Given the function $f ( x ) = \left| x - a ^ { 2 } \right| + | x - 2 a + 1 |$ . (1) When $a = 2$, find the solution set of the inequality $f ( x ) \geqslant 4$; (2) If $f ( x ) \geqslant 4$ for all $x$, find the range of values of $a$.
(1) When $a = 2$, $f(x) = \begin{cases} 7 - 2x, & x \leqslant 3 \\ 1, & 3 < x \leqslant 4 \\ 2x - 7, & x > 4 \end{cases}$. The solution set of $f(x) \geqslant 4$ is $\left\{x \mid x \leqslant \frac{3}{2} \text{ or } x \geqslant \frac{11}{2}\right\}$. (2) Since $f(x) = \left|x - a^2\right| + |x - 2a + 1| \geqslant \left|a^2 - 2a + 1\right| = (a-1)^2$, when $(a-1)^2 \geqslant 4$, i.e., $|a-1| \geqslant 2$, we have $f(x) \geqslant 4$. When $-1 < a < 3$, $f(a^2) = (a-1)^2 < 4$. Therefore, the range of values of $a$ is $(-\infty, -1] \cup [3, +\infty)$.
Given the function $f ( x ) = \left| x - a ^ { 2 } \right| + | x - 2 a + 1 |$ .
(1) When $a = 2$, find the solution set of the inequality $f ( x ) \geqslant 4$;
(2) If $f ( x ) \geqslant 4$ for all $x$, find the range of values of $a$.