The history of zero: an infographic

Following up on an earlier post about Zero in Greek mathematics, here is a timeline for the use of zero in Europe (click to zoom). I have used images of, or quotes from, primary sources where possible (reliably dated Indian primary sources are much harder to find than Greek ones, unfortunately).

Chinese uses of zero are probably also derived from the Greeks, but Mayan uses are clearly independent.

Fast Fibonacci numbers

There was some discussion on reddit recently of the Fibonacci numbers (1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1,597, 2,584, 4,181, 6,765, 10,946, 17,711, 28,657, 46,368, 75,025, 121,393, 196,418, 317,811, 514,229, 832,040, …) and efficient ways of calculating them.

One way of doing so is using numbers of the form a + b σ where  σ is the square root of 5. Multiplication of such numbers satisfies:

(a + b σ) × (c + d σ) = ac + 5bd + (ad + bc) σ.

We can define the golden ratio φ = (1 + σ) / 2 and also ψ = 1 − φ = (1 − σ) / 2, in which case the nth Fibonacci number Fn will be exactly (φn − ψn) / σ. This is known as Binet’s formula.

We can use this formula to calculate Fibonacci numbers using only integer arithmetic, without ever evaluating the σ. We will have:

(2 φ)n − (2 ψ)n = (1 + σ)n − (1 − σ)n = 0 + p σ

for some integer p, and division by a power of two will give Fn = p / 2n.

I am using the R language, with the gmp package, which provides support for large integer matrices, and this allows us to use the relationship:

If we call this matrix A and calculate An−1, the first number in the resultant matrix will be the nth Fibonacci number Fn. The following R code calculates F10 = 55 using a combination of multiplication and squaring:

n <- 10

A <- matrix.bigz(c(
	1, 1,
	1, 0), 2)

p <- function(n) {
	if (n == 1) A
	else if (n %% 2 == 1) A %*% p(n-1)
	else {
		b <- p(n/2)
		b %*% b


This same code will calculate, for example:

The time taken to calculate Fn is approximately proportional to n1.156, with the case of n = 1,000,000,000 (giving a number with 208,987,640 digits) taking about a minute.

Recreational mathematics

The wolf, the goat, and the cabbages

Dancing alongside the more serious practitioners of mainstream mathematics are the purveyors of mathematical puzzles and problems. These go back at least as far as Diophantus (c. 200–284), the Alexandrian “father of algebra.” Alcuin of York (c. 735–804) produced a collection of problems that included the the wolf, the goat, and the cabbages (above); the three men who need to cross a river with their sisters; and problems similar to the bird puzzle published by Fibonacci a few centuries later. In more modern times, Martin Gardner (1914–2010) has done more than anyone else to popularise this offshoot of mathematics. It is often called “recreational mathematics,” because people do it for fun (in part because they are not told that it is mathematics).

Particularly popular in recent times have been Sudoku (which is really a network colouring problem in disguise) and the Rubik’s Cube (which illustrates many concepts of group theory, although it was not invented with that in mind). Sudoku puzzles have been printed in more than 600 newspapers worldwide, and more than 20 million copies of Sudoku books have been sold. The Rubik’s Cube has been even more popular: more than 350 million have been sold.

A Soma cube, assembled

Recreational puzzles may be based on networks, as in Hashi (“Bridges”). They may be based on fitting two-dimensional or three-dimensional shapes together, as in pentominoes or the Soma cube. They may be based on transformations, as in the Rubik’s Cube. They may even be based on arithmetic, as in Fibonacci’s problem of the birds, or the various barrel problems, which go back at least as far as the Middle Ages.

In one barrel problem, two men acquire an 8-gallon barrel of wine, which they wish to divide exactly in half. They have an empty 5-gallon barrel and an empty 3-gallon barrel to assist with this. How can this be done? It is impossible to accurately gauge how much wine is inside a barrel, so that all that the men can do is pour wine from one barrel to another, stopping when one barrel is empty, or the other is full [highlight to show solution → (8, 0, 0) → (3, 5, 0) → (3, 2, 3) → (6, 2, 0) → (6, 0, 2) → (1, 5, 2) → (1, 4, 3) → (4, 4, 0)]. There is a similar problem where the barrel sizes are 10, 7, and 3.

The barrels

Apart from being fun, puzzles of this kind have an educational benefit, training people to think. For this reason, Alcuin called his collection of problems Propositiones ad Acuendos Juvenes (Problems to Sharpen the Young). Problems like these may also benefit the elderly – the Alzheimer’s Association in the United States suggests that they may slow the onset of dementia. This is plausible, in that thinking hard boosts blood flow to the brain, and research supports the idea (playing board games and playing musical instruments are even better).

Fibonacci and his birds (solution)

In the previous post, we described Fibonacci’s “problem of the birds” (“the problem of the man who buys thirty birds of three kinds for 30 denari”). In English:

“A man buys 30 birds of three kinds (partridges, doves, and sparrows) for 30 denari. He buys a partridge for 3 denari, a dove for 2 denari, and 2 sparrows for 1 denaro, that is, 1 sparrow for ½ denaro. How many birds of each kind does he buy?”

The man must buy at least one of each kind of bird, or he wouldn’t be buying “birds of three kinds.” Also, he must buy less than 10 partridges, because 10 partridges (at 3 denari each) would use up all his money. Similarly, he must buy less than 15 doves. We can thus make up a table of possible solutions:

Of those 126 possible solutions, only one works out correctly in terms of cost, and that’s the answer. But that’s an unbelievably tedious way of getting the answer, and you’d be rather foolish to try to solve the problem that way. The obvious approach is to use algebra. Write p for the number of partridges bought, d for the number of doves, and s for the number of sparrows. Because the man buys 30 birds, we have the equation:

p + d + s = 30

And because the costs add up to 30 denari, we have:

3 p + 2 d + ½ s = 30

Doubling that second equation gets rid of the annoying fraction:

6 p + 4 d + s = 60

If you’ve done any high school algebra, no doubt you want to subtract the first equation from this, which will eliminate the variable s:

5 p + 3 d = 30

But now what? That gives a relationship between the variables p and d, but there doesn’t seem to be enough information to get specific values for those variables.

Fibonacci solves the problem a different way. His solution is based on a key insight – the man buys 30 birds for 30 denari, so that the birds cost, on average, 1 denaro each. Fibonacci then makes up “packages” of birds averaging 1 denaro each. There are only two ways of doing this. Package A has 1 partridge and 4 sparrows (5 birds for 5 denari), and package B has 1 dove and 2 sparrows (3 birds for 3 denari). The solution will be a combination of those two packages.

Now the man can take 1, 2, 3, 4, or 5 copies of package A, leaving 25, 20, 15, 10, or 5 birds to be made up of package B. But the birds making up package B must be multiple of 3, so that the only possible answer is 3 copies of package A and 5 copies of package B. This means that the man buys 3 partridges, 5 doves, and 3×4 + 5×2 = 22 sparrows. That’s 30 birds and 3×3 + 2×5 + ½×22 = 30 denari.

Now it turns out that, had we kept on going with the algebraic approach, we would have gotten the same answer. We had:

5 p + 3 d = 30

Given that the numbers of partridges and doves (p and d) had to be positive whole numbers, that meant that p had to be a multiple of 3, and d a multiple of 5. That could only be achieved with p = 3 and d = 5.

We can also return to the diagrammatic approach. The equation:

5 p + 3 d = 30

describes the diagonal red line in the diagram below. That line only crosses one of the possible solutions, namely the dot corresponding to 3 partridges and 5 doves.

In mathematics, there’s more than one way to skin a cat. Or, in this case, a bird.

Fibonacci and his birds

The mathematician Leonardo of Pisa (better known as Fibonacci) is famous for his rabbits, but I was recently reminded of his “problem of the birds” or “the problem of the man who buys thirty birds of three kinds for 30 denari.” This problem appears in his influential book, the Liber Abaci.

The “problem of the birds” is expressed in terms of Italian currency of the time – 12 denari (singular: denaro) made up a soldo, and 20 soldi made up a lira. In the original Latin, the problem reads:

“Quidam emit aves 30 pro denariis 30. In quibus fuerunt perdices, columbe, et passeres: perdices vero emit denariis 3, columba denariis 2, et passeres 2 pro denario 1, scilicet passer 1 pro denariis ½. Queritur quot aves emit de unoquoque genere.”

In English, that translates to:

“A man buys 30 birds of three kinds (partridges, doves, and sparrows) for 30 denari. He buys a partridge for 3 denari, a dove for 2 denari, and 2 sparrows for 1 denaro, that is, 1 sparrow for ½ denaro. How many birds of each kind does he buy?”

How many birds of each kind does the man buy? It may help to cut out and play with the bird tokens below (click image to zoom). In a similar vein, what if the man buys birds as follows (still purchasing birds of all three kinds, and at the same price)?

  • 4 birds for 6 denari
  • between 6 and 10 birds for twice as many denari as birds
  • 8, 11, 13–14, 16–22, 24–25, or 27 birds for the same number of denari as birds
  • 8 birds for 12 denari
  • 12 birds for 18 denari
  • 16 birds for 12 denari
  • 28 birds for 21 denari
  • 6, 8–9, or 14 birds for 11 denari
  • 7–10, 12, 15, or 18 birds for 13 denari

Solution to the main problem here.