Example 3 Solve the equation $8 \cos ^{3} x-6 \cos x+\sqrt{2}=0$.

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly.
Let $z=\cos x+i \sin x$, then $\cos x=\frac{z+\bar{z}}{2}=\frac{1}{2}\left(z+\frac{1}{z}\right)$, substituting into the original equation, we get $\left(z+\frac{1}{z}\right)^{3}-3\left(z+\frac{1}{z}\right)+\sqrt{2}=0$.

Expanding and simplifying, we get $z^{3}+\frac{1}{z^{3}}+\sqrt{2}=0$. That is, $z x^{6}+\sqrt{2} z^{3}+1=0$.
That is, $z^{3}=-\frac{\sqrt{2}}{2} \pm \frac{\sqrt{2}}{2} \mathrm{i}$, $\cos 3 x+\mathrm{i} \sin 3 x=-\frac{\sqrt{2}}{2} \pm \frac{\sqrt{2}}{2} \mathrm{i}$.
By the equality of two complex numbers, we get $\left\{\begin{array}{l}\cos 3 x=-\frac{\sqrt{2}}{2}, \\ \sin 3 x= \pm \frac{\sqrt{2}}{2},\end{array}\right.$
$3 x=2 k \pi \pm \frac{3 \pi}{4}$, so $x=\frac{2 k \pi}{3} \pm \frac{\pi}{4}(k \in \mathbf{Z})$.
Therefore, the solution to the original equation is $x=\frac{2 k \pi}{3} \pm \frac{\pi}{4}(k \in \mathbf{Z})$.