Using generating functions, Find a closed formula to next expression: $\sum_{k=0}^m{k(k+2)}$ Using generating functions, Find a closed formula to next expression: 
$\sum_{k=0}^m{k(k+2)}$
If i use calculus power series rules, The question is fairly simple. But how can i find the proper relation with generating functions?
 A: First note that
$$\sum_{k=0}^nk(k+2)x^k=\sum_{k=0}^n(k+1)^2x^k-\sum_{k=0}^nx^k\;.$$
The last summation is a geometric series, so you know a closed form for it. Next, check that
$$\sum_{k=0}^n(k+1)^2x^k=\sum_{k=1}^{n+1}k^2x^{k-1}=\left(\sum_{k=1}^{n+1}kx^k\right)'=\left(\sum_{k=0}^{n+1}kx^k\right)'\;.$$
If you can find a closed form for $\displaystyle\sum_{k=0}^{n+1}kx^k$, you can differentiate it to get one for $\displaystyle\sum_{k=0}^n(k+1)^2x^k$. And
$$\sum_{k=0}^{n+1}kx^k=\sum_{k=1}^{n+1}kx^k=x\sum_{k=1}^{n+1}kx^{k-1}=x\left(\sum_{k=1}^{n+1}x^k\right)'=x\left(\sum_{k=0}^{n+1}x^k\right)'\;,$$
for which you can easily find a closed form.
A: Hint: Consider the function
$$
u_m(x)=\sum_{k=0}^mx^k=\frac{1-x^{m+1}}{1-x},
$$
then
$$
u'_m(x)=\sum_{k=0}^mkx^{k-1},\quad
u''_m(x)=\sum_{k=0}^mk(k-1)x^{k-2},
$$
hence
$$
\sum_{k=0}^mk(k+2)=u''_m(1)+3u'_m(1).
$$
Can you compute $u'_m(1)$ and $u''_m(1)$?
A: Let the desired sum be given by 
\begin{align}
S_{m} = \sum_{k=0}^{m} k(k+2).
\end{align}
Using the generating function method it is seen that the expression to calculate is
\begin{align}
\sum_{m=0}^{\infty} S_{m} \, t^{m}.
\end{align}
The calculation of this series is as follows. 
\begin{align}
\sum_{m=0}^{\infty} S_{m} \, t^{m} &= \sum_{m=0}^{\infty} \sum_{k=0}^{m} k(k+2) t^{m} \nonumber\\
&= \sum_{m=0}^{\infty} \sum_{k=0}^{\infty} k(k+2) t^{m+k} \nonumber\\
&= \sum_{m=0}^{\infty} t^{m} \cdot \sum_{k=0}^{\infty} k(k+2) t^{k} 
= \frac{1}{t(1-t)} \sum_{k=0}^{\infty} k(k+2) t^{k+1} \nonumber\\
&= \frac{1}{t(1-t)} \partial_{t} \, \sum_{k=0}^{\infty} k \, t^{k+2} 
= \frac{1}{t(1-t)} \partial_{t} \left[ t^{3} \sum_{k=0}^{\infty} k t^{k-1} \right] \\
&= \frac{1}{t(1-t)} \partial_{t} \left[ t^{3} \partial_{t} \sum_{k=0}^{\infty}
t^{k} \right] 
= \frac{1}{t(1-t)} \partial_{t} \left[ t^{3} \partial_{t} \left( \frac{1}{1-t} \right) \right] \\
&= \frac{1}{t(1-t)} \left[ \frac{2 t^{3}}{(1-t)^{3}} + \frac{3 t^{2}}{(1-t)^{2}} \right] =  \frac{2t^{2}}{(1-t)^{4}} + \frac{3 t}{(1-t)^{3}}. \\
\end{align}
Since $t = 1-(1-t)$ and $t^{2} =1-2(1-t) + (1-t)^{2}$ then the last result becomes
\begin{align}
\sum_{m=0}^{\infty} S_{m} t^{m} = \frac{2}{(1-t)^{4}} - \frac{1}{(1-t)^{3}} - \frac{1}{(1-t)^{2}}.
\end{align}
Now using the standard series
\begin{align}
\frac{1}{(1-t)^{2}} &= \sum_{m=0}^{\infty} (m+1) t^{m} \\
\frac{1}{(1-t)^{3}} &= \frac{1}{2} \sum_{m=0}^{\infty} (m+1)(m+2) t^{m} \\
\frac{1}{(1-t)^{4}} &= \frac{1}{6} \sum_{m=0}^{\infty} (m+1)(m+2)(m+3) t^{m}
\end{align}
then 
\begin{align}
\sum_{m=0}^{\infty} S_{m} t^{m} &= \sum_{m=0}^{\infty} (m+1) \left[ \frac{1}{6}
(m+2)(m+3) - \frac{1}{2} (m+2) - 1 \right] t^{m} \\
&= \sum_{m=0}^{\infty} \left[ \frac{m(m+1)(2m+7)}{6} \right] \, t^{m}
\end{align}
and upon equating the coefficients of both sides it is seen that
\begin{align}
S_{m} = \sum_{k=0}^{m} k(k+2) = \frac{m(m+1)(2m+7)}{6} = \frac{1}{6} (2m^{3}+ 9m^{2} +7m).
\end{align}
This result may be verified by combining the two series,
\begin{align}
\sum_{k=0}^{n} k &= \frac{1}{2}(n^{2} +n) \\
\sum_{k=0}^{n} k^{2} &= \frac{1}{6}(2n^{3}+3n^{2}+n),
\end{align}
in the desired way. This provides
\begin{align}
\sum_{k=0}^{n} k(k+2) = \frac{1}{6} ( 2n^{3}+9n^{2}+7n ).
\end{align}
This example shows that the generating function method yields the desired result.
