Calculate sum of squares of first $n$ odd numbers [closed]
Is there an analytical expression for the summation $$1^2+3^2+5^2+\cdots+(2n-1)^2,$$ and how do you derive it?
$$ 1^2+3^2+5^2+\cdots+(2n-1)^2 = \sum_{i=1}^{n}(2i-1)^2 = \sum_{i=1}^{n}(4i^2)- \sum_{i=1}^{n}(4i) + \sum_{1}^{n}1=\dots.$$
Now, you need the identities
$$ \sum_{i=1}^{n}1 = n, $$
$$ \sum_{i=1}^{n}i = \frac{n(n+1)}{2}, $$
$$\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}{6} = \frac{n^3}{3} + \frac{n^2}{2} + \frac{n}{6}.$$
The following is a very general technique. In particular, it's probably not the best way to solve this sort of problem in the beginning. But it is worth knowing this technique in the long run.
We use the result that:$$\sum_{k=0}^{n-1} \binom{k}{i} = \binom{n}{i+1}$$
Write: $$(2k+1)^2=8\binom{k}{2} +8\binom{k}{1}+ \binom{k}{0}$$ Then $$\begin{align}\sum_{k=0}^{n-1} (2k+1)^2 &=\sum_{k=0}^{n-1}\left( 8\binom{k}{2} + 8\binom{k}{1} + \binom{k}{0}\right)\\&=8\binom{n}{3}+8\binom{n}{2} + \binom{n}{1}\end{align}$$
This method can be used to solve $\sum_{k=0}^{n-1} p(k)$ for any polynomial $p$. The result is always a polynomial of one degree higher than the degree of $p$.
One can give a combinatorial version of the argument below. But it takes some time to tell the right story. So for now we settle for the magic math approach. We have $$\binom{2k+1}{3}-\binom{2k-1}{3}=\frac{(2k+1)(2k)(2k-1)-(2k-1)(2k-2)(2k-3)}{3!}.\tag{1}$$ Note that the above equation even holds when $k=1$, if we use the convention that $\binom{1}{3}=0$.
The right-hand side of (1) magically simplifies to $(2k-1)^2$. It follows that our sum $1^2+3^2+5^2+\cdots +(2n-1)^2$ is equal to $$ \binom{3}{3}-\binom{1}{3} + \binom{5}{3}-\binom{3}{3} + \binom{7}{3}-\binom{5}{3} + \cdots + \binom{2n+1}{3}-\binom{2n-1}{3} .$$ Note the wholesale cancellation. We get $$1^2+3^2+5^2+\cdots +(2n-1)^2=\binom{2n+1}{3}.$$