Example 5. Find the value of $\cos \frac{\pi}{7}+\cos \frac{3 \pi}{7}+\cos \frac{5 \pi}{7}$.
Let $z=\cos \frac{\pi}{7}+i \sin \frac{\pi}{7}$. Then
$$
\begin{array}{l}
\left(\cos \frac{\pi}{7}+\cos \frac{3 \pi}{7}+\cos \frac{5 \pi}{7}\right) \\
+i\left(\sin \frac{\pi}{7}+\sin \frac{3 \pi}{7}+\sin \frac{5 \pi}{7}\right) \\
=z+z^{3}+z^{5}=\frac{z^{7}-z}{z^{2}-1}=\frac{1}{1-z} \\
=\frac{1}{1-\cos \frac{\pi}{7}+i \sin \frac{\pi}{7}} \\
=\frac{1}{2}+\frac{i}{2} \operatorname{ctg} \frac{\pi}{14} \\
\therefore \cos \frac{\pi}{7}+\cos \frac{3 \pi}{7}+\cos \frac{5 \pi}{7}=\frac{1}{2} .
\end{array}
$$

As a side result: $\sin \frac{\pi}{7}+\sin \frac{3 \pi}{7}+\sin \frac{5 \pi}{7}$
$$
=\frac{1}{2} \operatorname{ctg} \frac{\pi}{14} .
$$