It is well known that the sum of the first N integers, squared, is equal to
the sum of the first N cubes, and there are many proofs
of this already. The geometric proof is both famous and beautiful. I,
however, am a programmer, and as such, my first instinct is to prove by
induction. Iām sure Iām not the first to do this, but I had fun working it
out for myself.
So, formally, I want to show that
i=1ānāi3=(i=1ānāi)2
First, demonstrate that this is true for n=1
i=1ā1āi3=(i=1ā1āi)2
13=12
Then the inductive step: assuming that it is true for some N, prove that it is
true for N+1:
Given
i=1ānāi3=(i=1ānāi)2
prove
i=1ān+1āi3=(i=1ān+1āi)2
Rewriting the sum back to the original range yields
(i=1ānāi3)+(n+1)3=((i=1ānāi)+n+1)2
expand out the square to get
(i=1ānāi3)+(n+1)3=((i=1ānāi)+n+1)((i=1ānāi)+n+1)
and multiply to get
(i=1ānāi3)+(n+1)3=(i=1ānāi)2+(2n+2)(i=1ānāi)+n2+2n+1
Next, use the triangular number identity to replace the sum in the second term
i=1ānā=2n(n+1)ā
And factor to get
n2+2n+1=(n+1)2
Rewriting again to get
(i=1ānāi3)+(n+1)3=(i=1ānāi)2+(2n+2)(2n(n+1)ā)+(n+1)2
and simplify
(i=1ānāi3)+(n+1)3=(i=1ānāi)2+(n+1)(n(n+1))+(n+1)2
(i=1ānāi3)+(n+1)3=(i=1ānāi)2+n(n+1)2+(n+1)2
(i=1ānāi3)+(n+1)3=(i=1ānāi)2+(n+1)3
From our initial inductive assumption, we have
i=1ānāi3=(i=1ānāi)2
and clearly
(n+1)3=(n+1)3
so that concludes the proof. This shows that if the initial hypothesis is
true for some N, it is also true for N+1, and demonstrates that it is true for
N=1. Thus, by induction, it is true for all N > 1.