4. Let the complex number $z$ satisfy $|z|=1$. Try to find the maximum and minimum values of $\left|z^{3}-3 z-2\right|$.

 untranslated text remains as:
将上面的文本翻译成英文，请保留源文本的换行和格式，直接输出翻译结果。
4. From $\left|z^{2}-3 z-2\right| \geqslant 0$, when $z=-1$, $\left|z^{2}-3 z-2\right|_{\text {min }}=0$; also $\left|z^{2}-3 z-2\right|=\mid(z+1)^{2}$. $(z-2)|=| z+\left.1\right|^{2} \cdot|z-2|$, and $|z+1|^{2}=(z+1)(\bar{z}+1)=2+2 \operatorname{Re}(z),|z-2|^{2}=(z-2)(\bar{z}$ $-2)=5-4 \operatorname{Re}(z)$. Let $z=x+y \mathrm{i}, x, y \in \mathbf{R}, x \in[-1,1]$, hence
$$
\left|z^{3}-3 z-2\right|=(2+2 x) \sqrt{5-4 x} \leqslant\left[\frac{(2+2 x)+(2+2 x)+(5-4 x)}{3}\right]^{\frac{3}{2}}=3 \sqrt{3},
$$

only when $z=\frac{1 \pm \sqrt{3} i}{2}$, $1 z^{3}-3 z-\left.2\right|_{\text {min }}=3 \sqrt{3}$.