9. Given a complex number $z$ satisfying $|z|=1$, find the maximum value of $u=\left|z^{3}-3 z+2\right|$.

Translate the above text into English, please keep the original text's line breaks and format, and output the translation result directly.
Let $z=\cos \theta+\mathrm{i} \sin \theta$, then $z^{3}-3 z+2=\cos 3 \theta-3 \cos \theta+2+(\sin 3 \theta-3 \sin \theta) \mathrm{i}$,
thus $u^{2}=(\cos 3 \theta-3 \cos \theta+2)^{2}+(\sin 3 \theta-3 \sin \theta)^{2}$
$$
\begin{array}{l}
=(\cos 3 \theta-3 \cos \theta)^{2}+(\sin 3 \theta-3 \sin \theta)^{2}+4(\cos 3 \theta-3 \cos \theta)+4 \\
=14+4 \cos 3 \theta-6 \cos 2 \theta-12 \cos \theta=16 \cos ^{3} \theta-12 \cos ^{2} \theta-24 \cos \theta+20 \\
=4\left(4 \cos ^{3} \theta-3 \cos ^{2} \theta-6 \cos \theta+5\right), \text { let } t=\cos \theta \in[-1,1], \\
g(t)=4 t^{3}-3 t^{2}-6 t+5, g^{\prime}(t)=12 t^{2}-6 t-6=6(2 t+1)(t-1),
\end{array}
$$

Thus, $g(t)$ is monotonically increasing on $\left(-1,-\frac{1}{2}\right)$ and monotonically decreasing on $\left(-\frac{1}{2}, 1\right)$, which implies $g(t)_{\max }=g\left(-\frac{1}{2}\right)=\frac{27}{4}$, so $u_{\max }^{2}=27 \Rightarrow u_{\max }=3 \sqrt{3}$, equality holds when $z=-\frac{1}{2} \pm \frac{\sqrt{3}}{2} \mathrm{i}$.