5.1 $\cos \left(\frac{\pi}{3}-3 x\right)=-\frac{1}{2}$.

5.2 $(\cos x-1)\left(3-\operatorname{ctg}^{2} \frac{x}{2}\right)=0$.
5.1 Writing the equation in the form $\cos \left(3 x-\frac{\pi}{3}\right)=-\frac{1}{2}$ and using formula (5.2), we have

$$
3 x-\frac{\pi}{3}= \pm \arccos \left(-\frac{1}{2}\right)+2 \pi n
$$

Since $\arccos \left(-\frac{1}{2}\right)=\frac{2 \pi}{3}$, we obtain two series of roots:

1) $3 x-\frac{\pi}{3}=\frac{2 \pi}{3}+2 \pi n$, i.e., $x_{1}=\frac{\pi}{3}+\frac{2 \pi n}{3}$;
2) $3 x-\frac{\pi}{3}=-\frac{2 \pi}{3}+2 \pi n$, i.e., $x_{2}=-\frac{\pi}{9}+\frac{2 \pi n}{3}$.

Answer: $x_{1}=\frac{\pi}{3}+\frac{2 \pi n}{3} ; x_{2}=-\frac{\pi}{9}+\frac{2 \pi n}{3}, n \in \boldsymbol{Z}$.