Calculate $\displaystyle\sum_{k=1}^n \frac{k^2}{2^k}$ Calculate $\sum _{k=1}^n\:\frac{k^2}{2^k}$
I got $\sum _{k=1}^n\:\frac{k^2}{2^k} = (1+2+ \dots +k + \dots +n-1+n)(1+\frac{1}{2} + \dots +\frac{1}{2^{k-1}}+ \dots +\frac{1}{2}^{(n-1)}-\frac{n}{2^n})$. Not sure how to simplify further. 
 A: From the geometric series formula
$$
\sum_{k=0}^{\infty}x^k=\frac{1}{1-x},
$$
you can differentiate with respect to $x$ to get a formula for
$$
\sum_{k=1}^{\infty}kx^{k-1},
$$
and differentiate again to get a formula for
$$
\sum_{k=1}^{\infty}k(k-1)x^{k-2}.
$$
Now plug in $x=\tfrac12$ and decompose $k^2=k(k-1)+k$ as a sum of the two formulas.
A: Firstly, 
$$\sum_{k=1}^n\ \frac k{2^k}=\sum_{k=1}^n\ \left(\frac k{2^{k-1}}-\frac {k+1}{2^k}+\frac 1{2^k}\right)=1-\frac {n+1}{2^n}+\sum_{k=1}^n\ \frac 1{2^k}=2-\frac {n+2}{2^n}$$ .
On the other hand, 
$$\sum_{k=1}^n\ \frac {k^2}{2^k}=\sum_{k=1}^n\ \left(\frac {k(k+1)}{2^k}-\frac k{2^k}\right)=\sum_{k=1}^n\ \left(\frac {k^2}{2^{k-1}}-\frac {(k+1)^2}{2^k}+\frac {3k+1}{2^k}\right)-\left(2-\frac {n+2}{2^n}\right)=$$
$$=\left(1-\frac {(n+1)^2}{2^n}\right)-\left(2-\frac {n+2}{2^n}\right)+3\sum_{k=1}^n\ \frac k{2^k}+\sum_{k=1}^n\ \frac 1{2^k}=$$
$$=\frac {-n^2-n+1}{2^n}-1+3\cdot\left(2-\frac {n+2}{2^n}\right)+\left(1-\frac 1{2^n}\right) = 6-\frac{n^2+4n+6}{2^n}$$
A: Consider
$$S_n=\sum_{k=1}^n {k^2}{x^k}=\sum_{k=1}^n \big[k(k-1)+k\big]x^k=\sum_{k=1}^n k(k-1)x^k+\sum_{k=1}^n kx^k$$
$$S_n=x^2\sum_{k=1}^n k(k-1)x^{k-2}+x\sum_{k=1}^n kx^{k-1}$$
$$S_n=x^2 \left(\sum_{k=1}^n x^{k} \right)''+x \left(\sum_{k=1}^n x^{k} \right)'$$ When done, make $x=\frac 12$.
