Example 4.4 Find the ordinary generating function of the sequence $\left\{n^{2}\right\}_{n \geqslant 0}$.
Solution: Let $A(t)=\sum_{n=0}^{\infty} n^{2} t^{n}$.
Since
$$
\begin{aligned}
n^{2} & =n^{2}+3 n+2-3(n+1)+1 \\
& =2\binom{n+2}{2}-3\binom{n+1}{1}+1,
\end{aligned}
$$

we have
$$
\begin{aligned}
A(t) & =2 \sum_{n=0}^{\infty}\binom{n+2}{2} t^{n}-3 \sum_{n=0}^{\infty}\binom{n+1}{1} t^{n}+\sum_{n=0}^{\infty} t^{n} \\
& =2(1-t)^{-3}-3(1-t)^{-2}+(1-t)^{-1} \\
& =\frac{2-3(1-t)+(1-t)^{2}}{(1-t)^{3}} \\
& =\frac{t^{2}+t}{(1-t)^{3}} .
\end{aligned}
$$