$C$ is a complex number.$f:C\to R$ is defined by $f(z)=|z^3-z+2|.$Find the maximum value of $f(z)$ if $|z|=1.$ $C$ is a complex number.$f:C\to R$ is defined by $f(z)=|z^3-z+2|.$Find the maximum value of $f(z)$ if $|z|=1.$

My try:
I applied $|z^3-z+2|\leq|z|^3+|-z|+|2|$,i got $f(z)\leq 4$ but book says my answer is wrong.
Correct answer is $|f(z)|$ is maximum when $z=w,$where $w$ is cube root of unity and $|f(z)|=\sqrt{13}$.
I do not know how to get correct answer.

Let $\cos\theta=c,\sin\theta=s$ and $z=c+si$.
Then, since
$$\begin{align}z^3-z+2&=(c+si)^3-(c+si)+2\\&=c^3+3c^2si-3cs^2-s^3i-c-si+2\\&=(c^3-3cs^2-c+2)+(3c^2s-s^3-s)i\end{align}$$
we have
$$\begin{align}f(z)&=\sqrt{(c^3-3cs^2-c+2)^2+(3c^2s-s^3-s)^2}\\&=\sqrt{c^6+3 c^4 s^2-2 c^4+4 c^3+3 c^2 s^4+c^2-12 c s^2-4 c+s^6+2 s^4+s^2+4
}\\&=\sqrt{(c^6+3c^4s^2+3c^2s^4+s^6)+(s^2+c^2)-2(c^4-s^4)-12cs^2+4c^3-4c+4}\\&=\sqrt{(c^2+s^2)^3+1-2(c^2+s^2)(c^2-s^2)-12c(1-c^2)+4c^3-4c+4}\\&=\sqrt{1+1-2\cdot 1\cdot (c^2-(1-c^2))-12c(1-c^2)+4c^3-4c+4}\\&=\sqrt{16c^3-4c^2-16c+8}\end{align}$$
Here, let $g(t)=16t^3-4t^2-16t+8$. Then,
$$g'(t)=0\iff t=-\frac 12,\frac 23.$$
Hence, the maximum value of $g(t)$ for $-1\le t\le 1$ is
$$\max\{g(-1/2),g(1)\}=\max\{13,4\}=13.$$
Therefore, the maximum value of $f(z)$ is $f((-1\pm\sqrt 3\ i)/2)=\sqrt{13}$.
