How to derive the formula for the sum of the first $n$ perfect squares?

This question already has an answer here:

  • Prove that $\sum\limits_{k=1}^nk^2 = \frac{n(n+1)(2n+1)}{6}$?

    30 answers

Solutions Collecting From Web of "How to derive the formula for the sum of the first $n$ perfect squares?"

Here’s your table of finite differences:

$$\begin{array}{rcc}
n:&1&&2&&3&&4&&5&&6\\
S_n:&1&&5&&14&&30&&55&&91\\
&&4&&9&&16&&25&&36\\
&&&5&&7&&9&&11\\
&&&&2&&2&&2
\end{array}$$

The third differences are (at least so far) constant, so we expect the formula to be cubic in $n$, i.e., of third degree. Depending on what you’ve already learned, there are more and less efficient ways to get the actual cubic polynomial from here. The most elementary is to write it out with unknown coefficients: $S_n=an^3+bn^2+cn+d$. Then make a table of finite differences from that general equation. I’ll have to orient this one vertically in order to make it fit:

$$\begin{array}{l|ll}
n&S_n\\ \hline
1&a+b+c+d\\
&&7a+3b+c\\
2&8a+4b+2c+d&&12a+2b\\
&&19a+5b+c&&&&6a\\
3&27a+9b+3c+d&&18a+2b\\
&&37a+7b+c&&&&6a\\
4&64a+16b+4c+d&&24a+2b\\
&&61a+9b+c\\
5&125a+25b+5c+d
\end{array}$$

Now match them up:

$$\begin{align*}
6a&=2\\
12a+2b&=5\\
7a+3b+c&=4\\
a+b+c+d&=1
\end{align*}$$

You have a simple system of linear equations to solve for the coefficients $a,b,c$, and $d$.

You will find much easier but somewhat less elementary approaches in the answers to this question.

sum_of_squares

Following the (extraordinary accurate) drawing I tried to draw you can show that
$$ \sum ^{n}_{j=1}j^{2}+\sum ^{n-1}_{k=1}T_{k}=n\cdot \dfrac {n\left( n+1\right) }{2} $$
where $ \sum ^{n-1}_{k=1}T_{k} $ is the sum of the triangular numbers (the rectangles $T_1$ , $T_2$ and $T_3$).
We know that
$$ \sum ^{n}_{k=1}T_{k}=\dfrac {1}{6}n\left( n+1\right) \left( n+2\right) $$
So
$$
\sum ^{n}_{i=1}J^{2}=n\cdot \dfrac {n\left( n+1\right) }{Z}-\sum ^{n-1}_{k=1}T_{k}= n\cdot \dfrac {n\left( n+1\right) }{2}-\dfrac {1}{6}n\left( n-1\right) \left( n+1\right) =\dfrac {n\left( n+1\right) \left( 2n+1\right) }{6}
$$