For example, find the value of $\cos \theta+2 \cos 2 \theta+3 \cos 3 \theta+\cdots+n \cos n \theta$.
Let $S_{1}=\cos \theta+2 \cos 2 \theta+3 \cos 3 \theta+\cdots+n \cos n \theta$,
$$
S_{2}=\sin \theta+2 \sin 2 \theta+3 \sin 3 \theta+\cdots+n \sin n \theta,
$$

then $S_{1}+\mathrm{i} S_{2}=(\cos \theta+\mathrm{i} \sin \theta)+2(\cos \theta+\mathrm{i} \sin \theta)^{2}+3(\cos \theta+\mathrm{i} \sin \theta)^{3}+\cdots+n(\cos \theta+\mathrm{i} \sin \theta)^{n}$,
$$
\begin{aligned}
(\cos \theta+\mathrm{i} \sin \theta)\left(S_{1}+\mathrm{i} S_{2}\right)= & (\cos \theta+\mathrm{i} \sin \theta)^{2}+2(\cos \theta+\mathrm{i} \sin \theta)^{3} \\
& +\cdots+(n-1)(\cos \theta+\mathrm{i} \sin \theta)^{n}+n(\cos \theta+\mathrm{i} \sin \theta)^{n+1}
\end{aligned}
$$
From (1) and (2), we get
$$
\begin{aligned}
& {[1-(\cos \theta+i \sin \theta)]\left(S_{1}+\mathrm{i} S_{2}\right) } \\
= & (\cos \theta+i \sin \theta)+(\cos \theta+\mathrm{i} \sin \theta)^{2}+\cdots+(\cos \theta+i \sin \theta)^{n}-n(\cos \theta+i \sin \theta)^{n+1} \\
= & \frac{(\cos \theta+i \sin \theta)\left[1-(\cos \theta+i \sin \theta)^{n}\right]}{1-(\cos \theta+i \sin \theta)}-n(\cos \theta+i \sin \theta)^{n+1}
\end{aligned}
$$

By comparing the real and imaginary parts on both sides, we get
$$
\cos \theta+2 \cos 2 \theta+\cdots+n \cos n \theta=\frac{(n+1) \cos n \theta-n \cos (n+1) \theta-1}{4 \sin ^{2} \frac{\theta}{2}} .
$$