<s>[INST] How could I find the partial sum of this function? $$\displaystyle\sum_{k = 0}^{n}\dfrac{k^2}{2^k}$$ 
What are the steps to finding the partial sum formula?
 [/INST] Let $S = \displaystyle\sum_{k = 0}^{n}\dfrac{k^2}{2^k}$. 
Multiply by $\dfrac{1}{2}$ and shift indices: $\dfrac{1}{2}S = \displaystyle\sum_{k = 0}^{n}\dfrac{k^2}{2^{k+1}} = \displaystyle\sum_{k = 1}^{n+1}\dfrac{(k-1)^2}{2^k}$. 
Subtract the 2nd equation from the 1st to get: $\dfrac{1}{2}S = -\dfrac{n^2}{2^{n+1}} + \displaystyle\sum_{k = 1}^{n}\dfrac{2k-1}{2^k}$
Multiply by $\dfrac{1}{2}$ and shift indices: $\dfrac{1}{4}S = -\dfrac{n^2}{2^{n+2}} + \displaystyle\sum_{k = 1}^{n}\dfrac{2k-1}{2^{k+1}} = -\dfrac{n^2}{2^{n+2}} + \displaystyle\sum_{k = 2}^{n+1}\dfrac{2k-3}{2^k}$. 
Subtract the 4th equation from the 3rd: $\dfrac{1}{4}S = -\dfrac{n^2}{2^{n+2}}+\dfrac{1}{2}-\dfrac{2n-1}{2^{n+1}} + \displaystyle\sum_{k = 2}^{n}\dfrac{2}{2^k}$. 
The last summation is a geometric series, so $\displaystyle\sum_{k = 2}^{n+1}\dfrac{2}{2^k} = \dfrac{\dfrac{2}{2^2} - \dfrac{2}{2^{n+1}}}{1-\dfrac{1}{2}} = 1 - \dfrac{1}{2^{n-1}}$. 
Hence, $\dfrac{1}{4}S = -\dfrac{n^2}{2^{n+2}}+\dfrac{1}{2}-\dfrac{2n-1}{2^{n+1}} + 1 - \dfrac{1}{2^{n-1}}$. 
Multiply by $4$ and simplify to get $S = 6 - \dfrac{n^2+4n+6}{2^n}$
</s>