Example 3 Suppose the annual interest rate is $i$, calculated on a compound interest basis, one wants to withdraw 1 yuan at the end of the first year, 4 yuan at the end of the second year, $\cdots$, and $n^{2}$ yuan at the end of the $n$th year, and to be able to withdraw in this manner indefinitely, what is the minimum principal required?
To solve for the principal amount that will amount to 1 yuan (principal and interest) after $n$ years, the principal should be $(1+i)^{-n}$ yuan; to amount to $n^{2}$ yuan (principal and interest), the principal should be $n^{2}(1+i)^{-n}$ yuan. Therefore, the total principal is $\sum_{n=1}^{\infty} n^{2}(1+i)^{-n}$.

Clearly, the above expression can be viewed as the generating function of the sequence $\left\{n^{2}\right\}$ when $x=\frac{1}{1+i}$. The generating function of the sequence $\left\{n^{2}\right\}$ is
$$
\begin{aligned}
f(x) & =0 \cdot 1+1^{2} \cdot x+2^{2} \cdot x^{2}+3^{2} \cdot x^{3}+\cdots+n^{2} x^{n}+\cdots \\
& =x+\sum_{n=2}^{\infty} n^{2} x^{n}=x+\sum_{n=2}^{\infty}\left(C_{n+1}^{2}+C_{n}^{2}\right) x^{n} \\
& =x+\sum_{n=2}^{\infty} C_{n+1}^{2} x^{n}+\sum_{n=2}^{\infty} C_{n}^{2} x^{n}=\sum_{n=1}^{\infty} C_{n+1}^{2} x+\sum_{n=2}^{\infty} C_{n}^{2} x^{n} \\
& =\sum_{n=0}^{\infty} C_{n+2}^{2} x^{n+1}+\sum_{n=0}^{\infty} C_{n+2}^{2} x^{n+2} \\
& =\frac{x}{(1-x)^{3}}+\frac{x^{2}}{(1-x)^{3}}=\frac{x(1+x)}{(1-x)^{3}} .
\end{aligned}
$$

Noting that $x=\frac{1}{1+i}$, hence $\sum_{n=1}^{\infty} n^{2}(1+i)^{-n}=\frac{(1+i)(2+i)}{i^{3}}$.