Example 9 If $z$ is a complex number, $|z|=1$ and $u=z^{4}-z^{3}-3 z^{2} \mathrm{i}-z+1$. Find the maximum and minimum values of $|u|$, and the complex number $z$ when these values are obtained.
The high degree of $u$ makes further computation difficult. From $|z|=1$, we get $\frac{1}{z}=\bar{z}$, and combining this with the properties of the modulus of complex numbers, we have $|u|=\left|z^{2}\left(z^{2}-z-3 \mathrm{i}-\frac{1}{z}+\frac{1}{z^{2}}\right)\right|=\left|\left(z^{2}+\bar{z}^{2}\right)-(z+\bar{z})-3 \mathrm{i}\right|$, which provides a possibility for further computation.

Solution: From $|z|=1$, we get $\bar{z}=\frac{1}{z}$, so $|u|=\left|z^{2}\left(z^{2}-z-3 \mathrm{i}-\frac{1}{z}+\frac{1}{z^{2}}\right)\right|=\mid\left(z^{2}+\bar{z}^{2}\right)-(z+\bar{z})-3 i 1$.

Let $z=x+y \mathrm{i}, x, y \in \mathbf{R}$, then $x^{2}+y^{2}=1$, and $z^{2}=x^{2}-y^{2}+2 x y \mathrm{i}=\left(2 x^{2}-1\right)+2 x y \mathrm{i}$, thus $|u|=\left|2\left(2 x^{2}-1\right)-2 x-3 \mathrm{i}\right|=\left|\left(4 x^{2}-2 x-2\right)-3 \mathrm{i}\right|$.
Let $t=4 x^{2}-2 x-2$. Since $x \in[-1,1]$, it is easy to see that $t \in\left[-\frac{9}{4}, 4\right]$, and $|u|=|t-3 \mathrm{i}|=\sqrt{t^{2}+9}$.
Therefore, when $t=0$, i.e., $z=1$ or $-\frac{1}{2} \pm \frac{\sqrt{3}}{2} \mathrm{i}$, $|u|_{\text {min}}=3$;
when $t=4$, i.e., $z=-1$, $|u|_{\text {max}}=5$.