## Friday, 21 December 2012

### My Formula for Series of Squares of Arithmetic Sequence

Recently while reading Fibonacci's Liber Abaci about the sums of squares I mis-read that he had included a formula for finding the sum of the squares of integers in arithmetic sequence.  He didn't; well he did, but only for select sequences that obeyed his special rule.
Fibonacci's rule for the sum of the squares of the first n integers was to the last term times the next term that would be in the sequence (if it was continued), and multiply these by their sum divided by 6.  This produces the familiar 12+22+32+...+n2 = (n)(n+1)(2n+1)/6 which appears in all the textbooks.
Fibonacci went on to show that if you wanted to square the first n odd integers then the same rule would apply if we divide by an additional 2.  That is 12+32+52+...+n2 = n(n+2)(2n+2)/(12).

He goes on to state that the same rule would work if you had multiples of 3 or 4 and divided by both 6 and the increment between terms.  It was this part that I glibly misread to think that it applied to all arithmetic sequences.  When I tried it out  on a sequence, 12+42+72 I found that 7(10)(17) was not going to be divisible by 6x3. And when I tried other examples, they almost always failed, but on following up with the division it turned out that; although they were not exact, they were always very close.
The true value of the series of squares above turns out to be 66, and the result by my over extension of Fibonacci's rule leads to 66.11111.....
As long as the first term in the sequence was one, it seemed that the floor function of the result was the correct answer.  For example, 12+62+112+162 =414
Using 16(21)(37)/(6*5) = 414.4

If you started with a first term other than one,  the results were undervalued.  22+52+82 = 93  while the generalized rule would give 8(11)(19)/(6x3) = 92.8888...
32+72+112152 = 404, and the rule gives (15)(19)(34)/(6*4)= 403.75.

I thought I remembered that the early Hindu or Arabic or somebody scholars had a formula for that, but I wasn't sure if it was a simple rule or one developed too late for inclusion in the Liber Abaci, so I flipped open a pad and began to scribble out a little high school level algebra, and rather quickly (for an older guy) came up with what I thought was  a somewhat pretty little method.  I would later search out an answer not TOOOO different, but thought my notation was much superior for remembering, so here it is; Ballew's formula for the sum of the squares of integers in an arithmetic sequence.
Let F, L, d, and n represent the first term, last term, common difference, and number of terms of an arithmetic Sequence, then the sum of the Squares, S, is given by FLn + d2 (n-1)n(2n-1)/6  .  Note the part after the addition sign is simply the sum of the squares of the first n-1 integers times the square of the common difference.

For the  12+62+112+162 =414  we have n=4, d=5, F=1 and L=16.  This gives 4(1)(16)+ 52(3)(4)(7)/6 =

If we started somewhere higher,  252+312+372 +...+492= 7205.  Using n=5, d=6, F=25 and L=49  we get (5)(25)(49)+62 (4)(5)(9)/6  = Yep, you guessed it, 7205.

Checking on the history of squaring arithmetic sequences, I found that as early as 850, Mahavira's  Ganita Sara Sangraha contained a much more complicated formula :

The sum is given as 8065.  Using my n=10, d= 5, F= 2 and L= 47 gives (10)(2)(47) + 25(9)(10)(19)/6 which is also 8065.

I did find another version somewhat later that was more similar to mine, but still not as nice (don't you agree?) in the work of Narayana Pandita from the 14th Century (perhaps you remember his problem of Cows and calves, something to write on later).

His result looks like this:
Note he also has the square of the difference on the right multiplied by the sum of n-1 squares.

Before I close on the topic, while scrolling through these old scholar's work I did find a really simple formula for the sum of the cubes of an arithmetic sequence.
The formula uses S as the sum of the simple arithmetic sequence.  Today we might write S=n (F+L) /2 .  The sum of the cubes of that sequence is given by  S2 +  SF(F-d)

For the case of S= 2+5+ 8 + 11 = 26, and  23 + 5 3+83+113 = 1976 the method says to use 2623+26(2)(-1) = 1976.

Note that for the natural sequence with a = 1 and d=1, the last term disappears to give S2 which is the textbook formula.