# Sum of elements in the nth set of the sequence of sets of squares $\{1\}$, $\{4,9\}$, $\{16,25,36\}$, …

Let $S_n$ denote the sum of the elements in the $n^{th}$ set of the sequence of sets of squares: $\{1\}$, $\{4,9\}$, $\{16,25,36\}$, $\{49,64,81,100\}$,.... i.e. $S_1 = 1$, $S_2 = 13$, ... How do you find a formula for $S_n$?

Note: this is from Koshy, Elementary Number Theory 2nd Edition, problem set 1.3, ex 45.

• What have you got so far? – chubakueno Jan 21 '14 at 3:29

Yours are $$\{1^2\},\{2^2,3^2\},\{4^2,5^2,6^2\},\{7^2,8^2,9^2,{10}^2\},\cdots.$$

So, the first element of the $n$-th set will be $i^2$ such that $$i=1+\sum_{k=1}^{n-1}k=1+\frac{(n-1)n}{2}=\frac{n^2-n+2}{2}.$$

Hence, $$S_n=\sum_{k=(n^2-n+2)/2}^{((n^2-n+2)/2)+n-1}k^2=\sum_{k=1}^{((n^2-n+2)/2)+n-1}k^2-\sum_{k=1}^{((n^2-n+2)/2)-1}k^2.$$

Here, you can use $$\sum_{k=1}^{p}k^2=\frac{p(p+1)(2p+1)}{6}.$$

• I don't think that this is the problematic step...(but I may be wrong) – chubakueno Jan 21 '14 at 3:45
• @chubakueno: I added a bit. – mathlove Jan 21 '14 at 3:49
• The last formula is not true, that one is just for the naturals. – chubakueno Jan 21 '14 at 3:56
• @chubakueno: But they are natural numbers. – mathlove Jan 21 '14 at 3:58
• Someone flagged this answer, but l was adding some steps. – mathlove Jan 21 '14 at 4:01

Can you compute the sum of $n$ consecutive squares $\sum_{i=x}^y i^2$? Can you figure out a closed form for the first square in your groupings?

• Yes I know the sum of first n squares, but I can't seem to work out what squares are in my groupings (i.e. the squares in the nth sequence) – liedora Jan 21 '14 at 3:39
• I think it's easiest if you try to figure out the first term in each group. 1,2,4,7,11,... Try OEIS if you're really stumped – Frederick Jan 21 '14 at 3:42
• Thanks Frederick, got the solution out after figuring out what the first element of each set was! My solution from there is similar to what mathlove posted below. – liedora Jan 21 '14 at 5:02

The last number squared in the $k$th group is the $k$th triangular number $t(k)=k(k+1)/2$. So the sum of squares in the $k$th group is obtained by using the sum of the first $n$ squares formula $s(n)=n(n+1)(2n+1)/6$ and computing $s(p(k))-s(p(k-1).$ This gives $$\frac{k(3k^4+7k^2+2)}{12}.$$

If you compute S1 being the sum of squares from 1 to (m-1) and S2 being the sum of squares from 1 to n and substract S1 from S2, you have the sum of squares from m to n and the formula is then simply

(m (-1 + (3 - 2 m) m) + n (1 + n) (1 + 2 n)) / 6

Our task is to calculate $$S_n=\sum_{i=0}^{n-1}(x+i)^2$$ where $x=\frac{n(n-1)}{2}+1$ The general formula for calculating the sum of $k$ consecutive squares is well-known to be $$\mathcal{S}_k=\frac{k(k+1)(2k+1)}{6}$$ In terms of $\mathcal{S}_n$, $S_n$ is \begin{align*} S_n&=\mathcal{S}_{x+n-1}-\mathcal{S}_{x-1}\\ &=\frac{1}{6}[k(k+1)(2k+1)-r(r+1)(2r+1)] \end{align*} where $k=x+n-1=(n^2+n)/2$ and $r=x-1=(n^2-n)/2$