TITLE: Finding $\sum\limits_{k=0}^n k^2$ using summation by parts
QUESTION [6 upvotes]: Sorry to bother you guys again, but I still have some doubts. I do think I'm making some progress, though.
So, again, the formula that I'm using for summation by parts is

$\sum\limits_{k=o}^n f(k)g(k) = g(n)(\sum\limits_{k=0}^n f(k)) - \sum\limits_{k=0}^{n-1} [\Delta g(k) \sum\limits_{i=0}^k f(i)]$

Using this, I'm trying to find $\sum\limits_{k=0}^n k^2$. I think I almost got it, but there are some problems that I still can't get around.
Plugging in $g(k) = k$ and $f(k)=k$, we end up with the following equations:
\begin{align}
\sum\limits_{k=0}^n k^2 &= \sum\limits_{k=0}^n kk\\
\sum\limits_{k=0}^n k^2 &= n (\sum\limits_{k=0}^n k) - \sum\limits_{k=0}^{n-1}[\sum\limits_{i=0}^k i]\\
\sum\limits_{k=0}^n k^2 &= n(\frac{n(n+1)}{2}) - \sum\limits_{k=0}^{n-1}[\frac{k(k+1)}{2}]\\
\sum\limits_{k=0}^n k^2 &= \frac{n^3 + n^2}{2} - \frac{\sum\limits_{k=0}^{n-1} k^2+k}{2}\\
2\sum\limits_{k=0}^n k^2 &= n^3 + n^2 - \sum\limits_{k=0}^{n-1} k^2+k\\
2\sum\limits_{k=0}^n k^2 &= n^3 + n^2 - \sum\limits_{k=0}^{n-1} k^2+ \sum\limits_{k=0}^{n-1}k
\end{align}
Anyway, my problem is, I need the upper indexes of the sums in the right hand side to be $n$, not $n-1$ (I've already checked that, if the indexes are $n$, then I can find the desired result). Is there any trick I'm missing to make those indexes go up by $1$? Or am I missing an obvious step?

REPLY [2 votes]: I would solve it like this: $p_3(n+1)^3 + p_2(n+1)^2 + p_1(n+1) + p_0 - (p_3n^3 + p_2n^2 + p_1n + p_0) = 1n^2$
Then treat the polynomial as a vector space, applying binomial theorem and writing on matrix form solving a linear equation system, we get:
$${\bf p} = \left[\begin{array}{r}p_3\\p_2\\p_1\\p_0\end{array}\right] = \left(\left[\begin{array}{cccc}1&0&0&0\\3&1&0&0\\3&2&1&0\\1&1&1&1\end{array}\right] - \left[\begin{array}{cccc}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&1\end{array}\right]\right)^{-1}
\left[\begin{array}{c}0\\1\\0\\0\end{array}\right] = 
\left[\begin{array}{r}1/3\\-1/2\\1/6\\0\end{array}\right]$$
Now I "cheated" ( let octave solve this equation system for me ) so I'm sure it should be -1/2 on the square factor and not 1/2. 

EDIT: It turns out that I calculated $n+1$ and not $n$. If I had started with $P(n) - P(n-1) = n^2$ instead of $P(n+1)-P(n) = n^2$ we would have gotten 1/2 for the second degree. To check that this is the case we have the perfect excuse to make another matrix exercise, this time using the binomial expansion of $(n-1)^k$:
$$\left[\begin{array}{rrrr}
1&0&0&0\\
-3&1&0&0\\
3&-2&1&0\\
-1&1&-1&1
\end{array}\right]^{-1}\left[\begin{array}{r}1/3\\-1/2\\1/6\\0\end{array}\right] = \left[\begin{array}{r}1/3\\1/2\\1/6\\0\end{array}\right]$$