7. Find the sum:
$$\begin{array}{l}
A_{n}=1+r \cos \theta+r^{2} \cos 2 \theta+\cdots+r^{n-1} \cos (n-1) \theta, \\
B_{n}=r \sin \theta+r^{2} \sin 2 \theta+\cdots+r^{n-1} \sin (n-1) \theta .
\end{array}$$
7. Solution: Consider the complex number $A_{n}+i B_{n}$.
$$\begin{aligned}
A_{n}+i B_{n}=1 & +r(\cos \theta+i \sin \theta)+r^{2}(\cos 2 \theta \\
& +i \sin 2 \theta)+\cdots \\
& +r^{n-1}[\cos (n-1) \theta+i \sin (n-1) \theta] \\
=1 & +r e^{i \theta}+r^{2} e^{i 2 \theta}+\cdots+r^{n-1} e^{i(n-1) \theta}
\end{aligned}$$

Let $z=r e^{i \theta}$, and by Lemma 3 we get
$$\begin{aligned}
A_{n} & +i B_{n}=1+z+z^{2}+\cdots+z^{n-1}=\frac{1-z^{n}}{1-z} \\
& =\frac{1-r^{n} e^{i n \theta}}{1-r e^{i \theta}}=\frac{\left(1-r^{n} e^{i n \theta}\right)\left(1-r e^{-i \theta}\right)}{\left(1-r e^{i \theta}\right)\left(1-r e^{-i \theta}\right)} \\
& =\frac{1-r e^{-i \theta}-r^{n} e^{i n \theta}+r^{n+1} e^{i(n-1) \theta}}{1-r\left(e^{i \theta}+e^{-i \theta}\right)+r^{2}} \\
& =\frac{1-r \cos \theta-r^{n} \cos n \theta+r^{n+1} \cos (n-1) \theta}{1-2 r \cos \theta+r^{2}} \\
& +\frac{r \sin \theta-r^{n} \sin n \theta+r^{n+1} \sin (n-1) \theta}{1-2 r \cos \theta+r^{2}} i
\end{aligned}$$

By comparing the real and imaginary parts, we get
$$\begin{array}{l}
A_{n}=\frac{1-r \cos \theta-r^{n} \cos n \theta+r^{n+1} \cos (n-1) \theta}{1-2 r \cos \theta+r^{2}},
\end{array}$$