$n^2$的前n项和公式推导
$$1^2 + 2 ^ 2 + 3 ^ 2 + 4 ^ 2 + \cdots + n ^ 2 = \frac {n(n+1)(2n+1)}{6}$$
$已知公式:a^3 - b^3 = (a - b)(a^2 + ab + b^2)$
$可以得到:$
$2^3 - 1^3 = (2 - 1)(2 ^ 2 + 2 \times 1 + 1 ^ 2)$
$3^3 - 2^3 = (3 - 2)(3 ^ 2 + 3 \times 2 + 2 ^ 2)$
$4^3 - 3^3 = (4 - 3)(4 ^ 2 + 4 \times 3 + 3 ^ 2)$
$\cdots\cdots$
$n^3 - (n-1)^3 = (n - (n-1))(n ^ 2 + n \times (n-1) + (n-1) ^ 2)$
$左边加左边,右边加右边得到:$
$n^3 - 1^3 = (2^2 + 3^2 + 4^2 + \cdots + n^2) + (1 \times 2 + 2 \times 3 + 3 \times 4 + \cdots + (n-1) \times n) + (1^2 + 2^2 + 3^2 + \cdots + (n-1)^2)$
$左右两边同时加上1^2 + n^2$
$记1^2 + 2 ^ 2 + 3 ^ 2 + 4 ^ 2 + \cdots + n ^ 2 = S_n得到:$
$n^3 + n^2 = 2S_n + (1 \times 2 + 2 \times 3 + 3 \times 4 + \cdots + (n-1) \times n)~~~~~~~①$
$对于1 \times 2 + 2 \times 3 + 3 \times 4 + \cdots + (n-1) \times n有:为下矩阵中红色部分的和$
\begin{pmatrix}
1 & \color{#F00}{2} & \color{#F00}{3} & \color{#F00}{4} & \color{#F00}{\cdots} & \color{#F00}{n}\\
1 & 2 & \color{#F00}{3} & \color{#F00}{4} & \color{#F00}{\cdots} & \color{#F00}{n}\\
1 & 2 & 3 & \color{#F00}{4} & \color{#F00}{\cdots} & \color{#F00}{n}\\
1 & 2 & 3 & 4 & \color{#F00}{\cdots} & \color{#F00}{n}\\
\vdots & \vdots & \vdots & \vdots & \ddots & \color{#F00}{\vdots} \\
1 & 2 & 3 & 4 & \cdots & n\\
\end{pmatrix}
$矩阵的上半部分 = 红色部分 + (1 + 2 + 3 + \cdots + n)$
$\because 矩阵的上半部分 = 1^2 + 2^2 + 3^2 + \cdots + n^2 = S_n$
$(1 + 2 + 3 + \cdots + n)可以通过前等差数列的前n项和求出为:\frac{n(1 + n)}{2}$
$\therefore红色部分 = S_n - \frac{n(1 + n)}{2}$
$\therefore1 \times 2 + 2 \times 3 + 3 \times 4 + \cdots + (n-1) \times n = S_n - \frac{n(1 + n)}{2}$
$带入①得:$
$n^3 + n^2 = 3S_n - \frac{n(1 + n)}{2}$
$化简得:$
$S_n = \frac{2n^3 + 3n^2 + n}{6}$
$因式分解最终得到:$
$\frac {n(n+1)(2n+1)}{6}$