Formal notation of the sum of the first $n$ squares

You can write it as a double summation I believe, if I have understood you correctly:

$$ \sum_{i=1}^n i^2 = n+(n+(n-1)+\dots = \sum_{k=0}^n\sum_{i=0}^kn - i $$

I may have some of the indexing off by one but this is the general idea.

Here is a good intuition for why the double sum on the RHS equals the sum on the LHS. Let us make a grid of the double summation on the right, where the rows represent values of $k$ and columns represent values for $i$:

$$ \begin{array}{|c|ccc} \hline k \ \ / \ \ i& 0 & 1 & 2 & 3 & 4 & \ldots & n\\ \hline 0 & n & \\ 1 & n & n-1 \\ 2 & n & n-1 & n-2 \\ 3 & n & n-1 & n-2 & n-3 \\ 4 & n & n-1 & n-2 & n-3 & n-4 \\ \vdots & \vdots &\vdots &\vdots &\vdots &\vdots & \ddots \\ n & n & n-1 & n-2 & n-3 & n-4 & \ldots & 1\\ \end{array} $$

The double summation on the RHS given by:

$$ \sum_{k=0}^n\sum_{i=0}^kn - i $$

is equivalent to adding up the values in the grid row by row. That is, you start at the first row and read across till the column number equal to the current row you are on. So you read the $0$-th row across and get $n$, then you read across the first row and add $n + (n-1)$ and finally read across the second row and add $n + (n-1) + (n-2)$ and so on, giving a total of $(n) + (n + (n-1)) + (n + (n-1) + (n-2) + \cdots + (n + (n-1) + (n-2) + \cdots + 1)$.

But notice rather than adding across the rows, we can equivalently add down the columns. That is, we start at column $0$ and add all the values in this column which are $n$ copies of the value $n$ giving a total of $n^2$. We then move on to the next column and add the values down this column which consists of $n-1$ copies of $n-1$ giving a total of $(n-1)^2$. Continuing in this way, we get that the sum in the grid is equal to:

$$ n^2 + (n-1)^2 + (n-2)^2 + \cdots + 1 \\ = \sum_{i = 0}^n i^2 $$

thus the RHS is equal to the LHS.


You can probably write it as $\sum\limits_{i=1}^n i^2=\sum\limits_{i=1}^n \sum\limits_{j=1}^i (n+1-j)$


Putting aside all the neat manipulations one can do with summation identities, note that $$\begin{align} \text{RHS}=\quad &\color{red}3\\ +(&\color{red}3+\color{green}2)+\\ +(&\color{red}3+\color{green}2+\color{blue}1)\\\\\ =3(&\color{red}3)+2(\color{green}2)+1(\color{blue}1)\\\\ =\; \; \; &3^2+2^2+1^2\\\\ =\;\;\;&\sum_{i=1}^3 i^2 = \text{LHS} \end{align}$$

You can prove the general case using the same method.


The formal notation for $n$ numbers, as requested, and the proof that it is equal to the sum of squares is as follows:

$$\begin{align} \color{purple}{\sum_{i=1}^n}\sum_{j=1}^i \color{orange}{(n+1-j)} &=\color{purple}{\sum_{i=1}^n}\sum_{j=1}^i\color{orange}{\sum_{k=j}^n1}\\ &=\sum_{j=1}^n\color{purple}{\sum_{i=j}^n}\color{orange}{\sum_{k=j}^n1} && (1\le j\le i\le n)\\ &=\sum_{r=1}^n \;\;\color{purple}{\sum_{i=(n+1-r)}^n} \;\color{orange}{\sum_{k=(n+1-r)}^n 1} &&(r=n+1-j)\\ &=\sum_{r=1}^n \qquad \color{purple}r\;\;\cdot \quad \color{orange}r\\ &=\sum_{r=1}^n r^2 =\sum_{i=1}^n i^2 \end{align}$$