### Introduction

In this article, we will look at several proofs for a famous formula.

#### Formula: Sum of the squares

$$\sum_{r=1}^{n}r^2=\frac{n}{6}(n+1)(2n+1)$$

### Mathematical induction

We begin with the base case, \(n=1\). The formula then becomes

$$ 1 = \frac{1}{6} \times 2 \times 3 $$

which the reader can verify! Now for the induction step, we assume that the formula is true when \(n = k\), and we need to prove that the formula is therefore true for \(n = k + 1\). So, we assume that

$$ \sum_{r=1}^{k}r^2=\frac{k}{6}(k+1)(2k+1) $$

is true. The formula for \(n = k + 1\) then becomes

\begin{align*}

\sum_{r=1}^{k+1}r^2 & = (k+1)^{2} + \sum_{r=1}^{k}r^2 \\

& = (k+1)^{2}+ \frac{k}{6}(k+1)(2k+1)\\

& = \frac{1}{6}(k+1)[6(k+1)+k(2k+1)]\\

& = \frac{k+1}{6}[6k+6+2k^{2}+k]\\

& = \frac{k+1}{6}(2k^{2}+7k+6)\\

& =\frac{k+1}{6}(2k+3)(k+2)

\end{align*}

According to Mathematical induction, the formula holds for all value \( n\in\mathbb{Z} \)

### An algebraic proof

This proof relies on two facts:

#### Formulas: The sum of two squares

Firstly,

$$a^2+b^2=a(a+b)-b(a-b)$$

Also,

$$n(n+1) = \frac{1}{3}[n(n+1) (n+2)-(n-1) n (n+1)]$$

Using the above two formulae (which the reader may check),

\begin{align*}

S_{n} = & \sum_{r=1}^{n}r^2 \\

= & 1^2+2^2+3^2+4^2+\ldots+n^2 \\

= & 1\times 1 + 2\times 2 + 3\times 3 + 4\times 4 +…+ n\times n\\

= & 1(2-1) + 2(3-1) + \ldots + n(n+1-1) \\

= & 1\times 2 + 2\times 3 + \ldots + n\times (n+1)-\frac{n(n+1)}{2}\\

= & \frac{1}{3} [1\times 2\times 3 – 0\times 1\times 2] + \frac{1}{3} [2\times 3\times 4 -1\times 2\times 3]+\ldots \\ & + \frac{1}{3} [n (n+1) (n+2) – (n-1) n(n+1)] + \frac{n(n+1)}{2}\\

= & \frac{n(n+1)(2n+1)}{6}\\

\end{align*}

as required.

### Extending Gauss’ method

First, we should remember that

$$(n+1)^3=n^3+3n^2+3n+1$$

$$1+2+3+\ldots+n= \frac{n(n+1)}{2}$$

Therefore, $$n^3-(n-1)^3 = 3(n-1)^2 + 3(n-1) + 1$$

and

$$2^3 – 1^3 = 3\times 1^2 + 3\times 1 +1, \qquad 3^3 – 2^3 = 3\times 2^2 +3\times 2 + 1, \ldots$$

and so on. This gives us

\begin{align*}

(n+1)^3 -1 = & 3( 1^2+ 2^2+ 3^2 + \ldots + n^2) + 3\times ( 1+ 2+ 3+ \ldots +n) +n \\

n^3 +3n^2 + 3n + 1 = & 3( 1^2 + 2^2+ 3^2+ \ldots + n^2) + 3\times \frac{n(n+1)}{2}+n\\

1^2 +2^2 + 3^2 +\ldots + n^2 = & \frac{n(n+1)(2n+1)}{6}\\

\end{align*}