Sum of First $n$ Squares Equals $\frac{n(n+1)(2n+1)}{6}$

Another way (by Euler, I think), from the geometric sum:

$$1 + x + x^2 + \cdots + x^n = \frac{x^{n+1}-1}{x-1} \tag{1}$$

Differentiate both sides and multiply by $x$:

$$x + 2 x^2 + 3 x^3 + \cdots + n x^{n} = \frac{n x^{n+2}-(n+1) x^{n+1} +x}{(x-1)^2} \tag{2}$$

Differentiating once more, we get on the LHS

$$1 + 2^2 x + 3^2 x^2 + \cdots + n^2 x^{n-1} \tag{3}$$

which, evaluated at $x=1$ gives our desired sum $\sum_{k=1}^n k^2$. Hence, we just need to compute the derivative on the RHS in $(2)$ (eg, with L'Hopital rule) and evaluate it at $x \to 1$.

It should be evident that this procedure also can be applied (though it also turns more cumbersome) for sums of higher powers.


(Update) here's a concrete computation, applying the binomial theorem on the RHS of $(1)$ and doing a series expansion around $x=1$. Let

$$\begin{align} g(x)&=\frac{x^{n+1}-1}{x-1}\\ &=\frac{\left(1+(x-1)\right)^{n+1}-1}{x-1}\\ &={n+1 \choose 1}+{n+1 \choose 2}(x-1)+{n+1 \choose 3}(x-1)^2+O\left((x-1)^3\right) \tag{4} \end{align}$$

Deriving, multiplying by $x$ and deriving again: $$(g'(x) \, x)'={n+1 \choose 2}+{n+1 \choose 3}2 \, x + O(x-1) \tag{5}$$ which evaluated at $x=1$ gives the desired answer: $${n+1 \choose 2}+2{n+1 \choose 3} =\frac{n(n+1)(2n+1)}{6} $$

We can apply the same procedure for higher powers. For example:
$$ \sum_{k=1}^n k^3={n+1 \choose 2}+{n+1 \choose 3}6+{n+1 \choose 4}6$$


I like this visual proof, due to Man-Keung Siu. It appeared in the March 1984 issue of Mathematics Magazine.

enter image description here

See also two more proofs (as well as this one) in Roger Nelson's Proofs Without Words: Exercises in Visual Thinking.


You can easily prove it by induction.

One way to find the coefficients, assuming we already know that it's a degree $3$ polynomial, is to calculate the sum for $n=0,1,2,3$. This gives us four values of a degree $3$ polynomial, and so we can find it.

The better way to approach it, though, is through the identity $$ \sum_{t=0}^n \binom{t}{k} = \binom{n+1}{k+1}. $$ This identity is true since in order to choose a $(k+1)$-subset of $n+1$, you first choose an element $t+1$, and then a $k$-subset of $t$.

We therefore know that $$ \sum_{t=0}^n A + Bt + C\binom{t}{2} = A(n+1) + B\binom{n+1}{2} + C\binom{n+1}{3}. $$ Now choosing $A=0,B=1,C=2$, we have $$ A+Bt + C\binom{t}{2} = t^2. $$ Therefore the sum is equal to $$ \binom{n+1}{2} + 2\binom{n+1}{3}. $$


Notice that $(k+1)^3 - k^3 = 3k^2 + 3k + 1$ and hence

$$(n+1)^3 = \sum_{k=0}^n \left[ (k+1)^3 - k^3\right] = 3\sum_{k=0}^n k^2 + 3\sum_{k=0}^n k + \sum_{k=0}^n 1$$

which gives you

$$\begin{align} \sum_{k=1}^n k^2 & = \frac{1}{3}(n+1)^3 - \frac{1}{2}n(n+1) - \frac{1}{3}(n+1) \\ & = \frac{1}{6}(n+1) \left[ 2(n+1)^2 - 3n - 2\right] \\ & = \frac{1}{6}(n+1)(2n^2 +n) \\ & = \frac{1}{6}n(n+1)(2n+1) \end{align}$$


Proof (by induction)

Basis: Check it for n = 1 (it works out).

Induction: Assume the result is true for a given value of $n$. That is, assume $$ \sum_{k = 1}^n k^2 = \frac{n(n+1)(2n+1)}{6}. $$ Try to show that the result holds for $n+1$. $$ \begin{align*} \sum_{k = 1}^{n+1} k^2 &= (n+1)^2 + \sum_{k=1}^n k^2\\ &= (n+1)^2 + \frac{n(n+1)(2n+1)}{6}\\ &= \frac{6(n+1)^2 + n(n+1)(2n+1)}{6}\\ &= \frac{(n+1)(n+1+1)(2(n+1)+1)}{6}. \end{align*} $$