Q:

Formalize a proof without words of the identity $(1 + 2 + \cdots + n)^2 = 1^3 + 2^3 + \cdots + n^3$

This website gives the following proof without words for the identity  $(1 + 2 + \cdots + n)^2 = 1^3 + 2^3 + \cdots + n^3$.

I find it interesting but have trouble seeing the proof behind it.  Could anyone could give me a formal proof based on this animation?

A:

This gif is a nice visualization of the following algebraic manipulations (color to correspond to the colors in the gif):
\begin{align*}
(1 + 2 + 3 + \cdots + n)^2
&= \sum_{i=1}^n \sum_{j=1}^n ij \\
&= \color{green}{\sum_{1 \le i < j \le n} ij} + \color{red}{\sum_{1 \le j < i \le n} ji} + \color{blue}{\sum_{1 \le j \le n} j^2} \\
&= \color{green}{\sum_{1 \le i < j \le n} ij} + \color{red}{\sum_{1 \le i < j \le n} ji} + \color{blue}{\sum_{1 \le j \le n} j^2} \\
&= \sum_{j=1}^n j \left[ \color{green}{\sum_{i=1}^{j-1} i} + \color{red}{\sum_{i=1}^{j-1} i} + \color{blue}{j} \right] \\
&= \sum_{j=1}^n j \left[ \sum_{i=1}^{j-1} \big(\color{green}{(i)} + \color{red}{(j-i)}\big) + \color{blue}{j} \right] \\
&= \sum_{j=1}^n j \left[ \sum_{i=1}^j j\right] \\
&= \sum_{j=1}^n j^3.
\end{align*}

