General formula for a sum of quadratic sequence I understand that the general formula for a sum of quadratic sequence is :$\displaystyle \sum_{i=1}^n {i^2} = \frac{n(n+1)(2n+1)}{6}$
However, my question is that does $i$ here has to be single term always? Can I still use the formula if I am calculating $\displaystyle \sum_{i=1}^n {(1+i)^2} $ ?
For example, I was trying to calculate $\displaystyle \sum_{i=1}^3 {(2+i)^2} $, and this is what I did


*

*$\displaystyle \frac{(2+n)((2+n)+1)(2(2+n)+1)}{6}$

*$\displaystyle \frac{(2+n)(3+n)(2n+5)}{6}$

*$\displaystyle \frac{(5)(6)(11)}{6} = 55$
However, the right answer is 50.
I would like to know what is happening here? And why I can't use this formula directly?
 A: $$\begin{align*}\sum_{i=1}^3(2+i)^2 &= \sum_{j=3}^5 j^2&&(j=2+i)\\
&= \sum_{j=1}^5 j^2 - \sum_{j=1}^2 j^2\\
&= \sum_{j=1}^5 j^2 - 5
\end{align*}$$
A: You cannot use the formula with $2+n$, because that means you are calculating $\sum_{j=1}^{2+n} j^2$. What you want to do is 
$$
\sum_{j=1}^m(2+j)^2=\sum_{j=3}^{m+2} j^2=\frac{(m+2)(m+3)(2(m+2)+1)}{6}-1^2-2^2.
$$
More generally, 
\begin{align}
\sum_{j=n}^m(k+j)^2&=\sum_{j=k+n}^{k+m}j^2=\sum_{j=1}^{k+m}j^2-\sum_{j=1}^{k+n-1}j^2
\\ \ \\
&=\frac{(k+m)(k+m+1)(2k+2m+1)}{6}-\frac{(k+n-1)(k+n)(2(k+n-1)+1)}{6}
\end{align}
A: Here are two approaches


*

*reindexing:
$$\sum_{i=1}^n (k+i)^2 = \sum_{j=k+1}^{n+k} j^2 = \sum_{j=1}^{n+k}j^2 - \sum_{j=1}^k j^2 = \frac{(n+k)(n+k+1)(2n+2k+1) - k(k+1)(2k+1)}{6}$$

*expanding:
$$\sum_{i=1}^n (k+i)^2 = \sum_{i=1}^n(k^2+2ki+ i^2) = nk^2 + 2k\sum_{i=1}^n i + \sum_{i=1}^n i^2 = nk^2 + kn(n+1) + \frac{n(n+1)(2n+1)}{6}$$
If you plug in $k=2$ and $n=3$ you get $50$ in both cases. In general the two expressions are equal.
A: $$\sum_{i=1}^3 {(2+i)^2}=\sum_{i=1}^3 {(4+4i+i^2)}=\sum_{i=1}^3 4+\sum_{i=1}^3 4i+\sum_{i=1}^3 i^2$$
$$=4\times3+4\dfrac{3(3+1)}2+\dfrac{3(3+1)(2\times3+1)}6=12+24+14=50.$$

Alternatively, $$\sum_{i=1}^3 {(2+i)^2}=\sum_{i=3}^5 {i^2}=\sum_{i=1}^5 i^2-\sum_{i=1}^2 i^2=\dfrac{5\times6\times(2\times5+1)}6-\dfrac{2\times3\times(2\times2+1)}6 $$
$$=55-5=50.$$
A: No, you can't use the original formula directly. If you change what is to be squared, then here is how the formula transforms:
$SUM((a + i)^2) = i(i+1)(2i+1)/6 + a(i^2 + i) + a^2(i)$
In other words:
$f_n = f_o + a(i^2 + i) + a^2(i)$
where $f_n$ is the new formula and $f_o$ is the old formula. The old formula being:
$f_o = i(i+1)(2i+1)/6$
