Derive the formula for the sum of the first $n$ squares using derivatives and integrals I wanted to prove the formula for sum of squares without using induction and thought using derivatives would be the easiest approach
$$f(n)=\sum_{k=1}^nk^2=\sum_{k=0}^{n-1}(n-k)^2\\f'(n)=2\sum_{k=0}^{n-1}(n-k)=2\sum_{k=1}^n k=n^2+n\\\int f'(n)dn=\frac{n^3}{3}+\frac{n^2}{2}+C$$
Now there is a term $\frac{n}{6}$ which is missing,why is this approach wrong?
 A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
\begin{align}
\sum_{k = 1}^{n}k^{2}&=\lim_{t\ \to\ 0}\partiald[2]{}{t}\sum_{k = 0}^{n}\expo{tk}
=\lim_{t\ \to\ 0}\partiald[2]{}{t}
\bracks{\color{#00f}{\expo{\pars{n + 1}t} - 1 \over \expo{t} - 1}}
\end{align}
$\ds{{\tt\mbox{We just need an expansion of the}}\ \color{#00f}{blue}\
\mbox{expression up to}\ t^{2}\ !!!}$.

Another approach. With $\ds{\verts{z} < 1}$:
  \begin{align}
\sum_{n = 0}^{\infty}z^{n}\sum_{k = 1}^{n}k^{2}&
=\sum_{k = 0}^{\infty}k^{2}\sum_{n = k}^{\infty}z^{n}
=\sum_{k = 0}^{\infty}k^{2}{z^{k} \over 1 - z}
={1 \over 1 - z}\sum_{k = 0}^{\infty}k^{2}z^{k}
={1 \over 1 - z}\,{z\pars{1 + z} \over \pars{1 - z}^{3}}
={z\pars{1 + z} \over \pars{1 - z}^{4}}
\\[3mm]&=z\pars{1 + z}\sum_{n = 0}^{\infty}{\mbox{}-4 \choose n}\pars{-1}^{n}z^{n}
\\[3mm]&=\sum_{n = 0}^{\infty}{\mbox{}-4 \choose n}\pars{-1}^{n}z^{n + 1}
+\sum_{n = 0}^{\infty}{\mbox{}-4 \choose n}\pars{-1}^{n}z^{n + 2}
\\[3mm]&=\sum_{n = 1}^{\infty}{\mbox{}-4 \choose n - 1}\pars{-1}^{n - 1}z^{n}
+\sum_{n = 2}^{\infty}{\mbox{}-4 \choose n - 2}\pars{-1}^{n - 2}z^{n}
\\[3mm]&=1 + \sum_{n = 1}^{\infty}\bracks{%
{\mbox{}-4 \choose n - 1}\pars{-1}^{n - 1}
+
{\mbox{}-4 \choose n - 2}\pars{-1}^{n}}z^{n}
\end{align}

\begin{align}
\sum_{k = 1}^{n}k^{2}&
={\mbox{}-4 \choose n - 1}\pars{-1}^{n - 1}
+{\mbox{}-4 \choose n - 2}\pars{-1}^{n}
\\[3mm]&=\pars{-1}^{n - 1}{4 + n - 1 - 1 \choose n - 1}\pars{-1}^{n - 1}
+\pars{-1}^{n - 2}{4 + n - 2 - 1 \choose n - 2}\pars{-1}^{n}
\\[3mm]&={n + 2 \choose  n - 1} + {n + 1 \choose n - 2}
={n + 2 \choose  3} + {n + 1 \choose 3}
\\[3mm]&={\pars{n + 2}\pars{n + 1}n \over 6} + {\pars{n + 1}n\pars{n - 1} \over 6}
={\pars{n + 1}n \over 6}\,\bracks{\pars{n + 2} + \pars{n - 1}}
\\[3mm]&={n\pars{n + 1}\pars{2n + 1} \over 6}
\end{align}
