The Sum of the Sum of Some Numbers
Subtitle: Anarchic Meets Impromptu
# Carl Gauss’ Very Bad Day
Johann Carl Friedrich Gauss has been called the Princeps mathematicorum (Latin for “the foremost of mathematicians” and anagram of “Anarchic Meets Impromptu”). He made many contributions to mathematics and science, and the British mathematician Henry John Stephen Smith said of Gauss,
If we except the great name of Newton it is probable that no mathematicians of any age or country have ever surpassed Gauss in the combination of an abundant fertility of invention with an absolute rigorousness in demonstration, which the ancient Greeks themselves might have envied.
An apocryphal story of Gauss is that his teacher J.G. Büttner gave him detention for misbehaving in class, and told Gauss that he could go home when he’d added up all the numbers from to . Gauss immediately said , and went home. Much later, Gauss’ picture appeared on the German 10-Deutche Mark note.
# Johnny von Neumann’s Train Wreck
A similar story about mathematician John von Neumann is that he was at a party one time when someone asked him to solve a train problem.
One train leaves New York heading toward Chicago and a second train leaves at the same time from Chicago for New York. (Stop me if you’ve heard this one before.) The distance between Chicago and New York is miles and both trains travel at .
A very fast bee going takes off from the front of the NY to CHI train just as the train leaves the station (going ) and flies until it reaches the CHI to NY train. At that moment, it turns around and returns to the first train.
This continues until the trains meet in the middle, and due to a switching error, they’re both on the same track and the bee gets squished in the wreckage. The problem was to figure out the total distance the bee flew on its final, fateful journey. You need to account for the positions of each train when the bee arrives and turns around.
John von Neumann instantly answered “600 miles”.
“Oh, you must have known the trick” the other person said.
“What trick?” von Neumann asked, “I just summed up all of the individual distances.”
There are an infinite number of distances between the trains as they approach each other, each distance smaller than the previous one. Von Neumann had to add them all together, and it’s a bit like Zeno’s “Achilles and the Tortoise” paradox.
The trick is that since both trains are going and the distance is miles, then when they crash into each other, they’ll both have gone miles, taking hours. Since the bee flies at then its total distance would be miles.
I won’t try to explain how von Neumann added up an infinite number of distances in his head so quickly, but we can understand how Gauss solved his detention problem. Think of the numbers arranged in a line, and connect the with , with , with , and so on.
Then the sum of , , , and the final pair is . Since there are pairs of then you can multiply and add to get the total . You can check that the formula for the sum of the first numbers is .
# Doubling Down on Gauss
A somewhat more complicated version of Gauss’ detention problem is this. Suppose you have numbered tiles with numbers ranging from . Add up all possible pairs and you’ll get either the total sum or .
The question is, which is the correct total sum or , and what is the value of ? Daniel Hardisky proposed this problem for the Classical Mathematics Facebook group.
Let’s start with an easy case, . Then, we have to add the pairs together, . Notice that each number appears twice, so we could have doubled .
Maybe it’s just that easy. Let’s try . If we combine sequentially, we get , but we’ve left out and which increases the final sum to .
How many ways can we combine two numbered tiles in a pile of tiles? This is a combinatorics problem and the answer is
where . For the case of choosing different tiles at a time, this simplifies to
Scientific computer languages have built-in functions to calculate the number of combinations for different values of and , in Julia, it’s binomial(n,2)
, in R, use choose(n,k)
, and Python calls scipy.special.comb(n, k)
.
Octave also calculates the binomial expansion with nchoosek(n,k)
, but has a feature not found in other languages - you can replace with a vector to show all of the possible combinations of numbers taken at a time. The notation 1:5
is a vector containing the first integers, so we can have Octave return all of the combinations taken at a time,
>> nchoosek(1:5,2)
ans =
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
Even better, if we add the numbers in each row, we get every possible pair sum, and then adding those sums gives the total.
>> sum(sum(nchoosek(1:5,2)))
ans = 60
Maybe we can arrange the numbers to be similar to the way Gauss did his sum. If we add up all possible pairs for , we can arrange them in descending order like this:
Notice the first line has four s and the sum . So, the top line is . It’s an easy multiplication followed by a sum using Gauss’ trick. The next line is the same, but shorter, .
For numbers the sum becomes
If we collect all of the individual terms in the top two lines there are of them, and then what’s left is the sum of , which can be written as
The total sum for all of the terms is
Now we can sum up all of the individual terms,
Since , this can be expressed as
# Squared Pictures
This is a pretty compact formula for , the sum of all possible pairs of the numbers from to . But, can we find a better way to express ? The first five squares are , and the sums are .
Here’s a neat visual proof from the Math and Multimedia website. Make a stack of the first squares like this:
Next, make three copies of this stack,
and fit them together to make a cube, except the red stack will extend one layer above the green and yellow stacks.
If you slice the top layer of the red pyramid in half and flip it over, you can fill in the missing part:
which lets us calculate the total volume,
so we might expect the formula is
# The Proof
Pictures are helpful, but they aren’t considered mathematical proofs. There are many ways to construct a mathematical proof, but one that gets used frequently is called “Proof by Induction”.
Suppose you have a formula you think is correct, and you check it for the case . If that holds, then show it holds for any , and add the term to see if the formula still holds. Let’s make this a bit more formal.
Theorem: The sum of the first squares is
Proof: For ,
Assume the formula holds for the case ,
Then the sum of the first squares is
The inductive part of this proof is that we didn’t specify a value for , so it can be any integer.
We showed the formula holds for in the first part, so it must hold for by the second part. Since it holds for , then it must also be true for and so on.
# The Formula Simplified
And now, we have a complete formula for the sum of all possible pairs of the first numbers,
# Tartaglia’s Depression
Niccolò Fontana Tartaglia was a -century mathematician and engineer from Venice.
Tartaglia found a neat trick to convert a general cubic equation, into a simpler form where the term disappears. By substituting , he got the “depressed cubic” .
With a bit of rearrangement, we can get our sum into the depressed cubic form,
where and . In this form, the solution for is where
You can check this with a simple substitution. If we put from the first equation into the second, we get
Substituting gives the quadratic
with solutions
Then, and . Solving for gives , while gives , so the first sum is the correct solution.
The Octave function depressedCubic.m calculates the solution for any depressed cubic in the form .
# Abel and the Terrible, Horrible, No Good, Very Bad Day
Niels Henrik Abel was a Norwegian mathematician who made many contributions to mathematics, and said of Gauss “He is like the fox, who effaces his tracks in the sand with his tail.”
The Abel Prize, named in his honor is the mathematical equivalent of the Nobel Prize, and his picture appears on the Norwegian 500 kroner banknote.
One of Abel’s great contributions to mathematics was his proof that there is no closed-form solution to the quintic equation,
which had been an open problem for 250 years. All in all, it was a great day for Abel, but a lousy day for anyone hoping to solve the equation directly, and we now know that no formula exists for the solution to fifth-order and higher polynomials.
Luckily, our problem involves only the quadratic formula and the solution to the depressed cubic.
If you’re feeling adventurous, you could try finding a formula for the sum of all possible combinations of the first integers taken three at a time, four at a time, and so on. Of course, if you take them at a time, you’re back to the beginning and the sum is .