Special Numbers

Some sequences of numbers arise so often in mathematics that we recognize them instantly and give them special names. For example, everybody who learns arithmetic knows the sequence of square numbers Image 1, 4, 9, 16, . . . Image . In Chapter 1 we encountered the triangular numbers Image 1, 3, 6, 10, . . . Image ; in Chapter 4 we studied the prime numbers Image 2, 3, 5, 7, . . . Image ; in Chapter 5 we looked briefly at the Catalan numbers Image 1, 2, 5, 14, . . . Image .

In the present chapter we’ll get to know a few other important sequences. First on our agenda will be the Stirling numbers Image and Image , and the Eulerian numbers Image ; these form triangular patterns of coefficients analogous to the binomial coefficients Image in Pascal’s triangle. Then we’ll take a good look at the harmonic numbers H n , and the Bernoulli numbers B n ; these differ from the other sequences we’ve been studying because they’re fractions, not integers. Finally, we’ll examine the fascinating Fibonacci numbers F n and some of their important generalizations.

6.1 Stirling Numbers

We begin with some close relatives of the binomial coefficients, the Stirling numbers, named after James Stirling (1692–1770). These numbers come in two flavors, traditionally called by the no-frills names “Stirling numbers of the first and second kind.” Although they have a venerable history and numerous applications, they still lack a standard notation. Following Jovan Karamata, we will write Image for Stirling numbers of the second kind and Image for Stirling numbers of the first kind; these symbols turn out to be more user-friendly than the many other notations that people have tried.

Tables 258 and 259 show what Image and Image look like when n and k are small. A problem that involves the numbers “ 1 , 7 , 6 , 1 ” is likely to be related to Image , and a problem that involves “ 6 , 11 , 6 , 1 ” is likely to be related to Image , just as we assume that a problem involving “ 1 , 4 , 6 , 4 , 1 ” is likely to be related to Image ; these are the trademark sequences that appear when n \= 4 .

“. . . par cette notation, les formules deviennent plus symétriques.”

—J. Karamata [ 199 ]

Table 258 Stirling’s triangle for set partitions.

n Image Image Image Image Image Image Image Image Image Image

| 0 | 1 | |

|

|

|

|

|

|

|

| | 1 | 0 | 1 |

|

|

|

|

|

|

|

| | 2 | 0 | 1 | 1 |

|

|

|

|

|

|

| | 3 | 0 | 1 | 3 | 1 |

|

|

|

|

|

| | 4 | 0 | 1 | 7 | 6 | 1 |

|

|

|

|

| | 5 | 0 | 1 | 15 | 25 | 10 | 1 |

|

|

|

| | 6 | 0 | 1 | 31 | 90 | 65 | 15 | 1 |

|

|

| | 7 | 0 | 1 | 63 | 301 | 350 | 140 | 21 | 1 |

|

| | 8 | 0 | 1 | 127 | 966 | 1701 | 1050 | 266 | 28 | 1 |

| | 9 | 0 | 1 | 255 | 3025 | 7770 | 6951 | 2646 | 462 | 36 | 1 |

Stirling numbers of the second kind show up more often than those of the other variety, so let’s consider last things first. The symbol Image stands for the number of ways to partition a set of n things into k nonempty subsets. For example, there are seven ways to split a four-element set into two parts:

(Stirling himself considered this kind first in his book [ 343 ].)

Image

thus Image . Notice that curly braces are used to denote sets as well as the numbers Image . This notational kinship helps us remember the meaning of Image , which can be read “ n subset k .”

Let’s look at small k . There’s just one way to put n elements into a single nonempty set; hence Image , for all n > 0 . On the other hand Image , because a 0 -element set is empty.

The case k \= 0 is a bit tricky. Things work out best if we agree that there’s just one way to partition an empty set into zero nonempty parts; hence Image . But a nonempty set needs at least one part, so Image for n > 0 .

What happens when k \= 2 ? Certainly Image . If a set of n > 0 objects is divided into two nonempty parts, one of those parts contains the last object and some subset of the first n − 1 objects. There are 2 n −1 ways to choose the latter subset, since each of the first n − 1 objects is either in it or out of it; but we mustn’t put all of those objects in it, because we want to end up with two nonempty parts. Therefore we subtract 1 :

Image

(This tallies with our enumeration of Image ways above.)

Table 259 Stirling’s triangle for cycles.

n Image Image Image Image Image Image Image Image Image Image

| 0 | 1 | |

|

|

|

|

|

|

|

| | 1 | 0 | 1 |

|

|

|

|

|

|

|

| | 2 | 0 | 1 | 1 |

|

|

|

|

|

|

| | 3 | 0 | 2 | 3 | 1 |

|

|

|

|

|

| | 4 | 0 | 6 | 11 | 6 | 1 |

|

|

|

|

| | 5 | 0 | 24 | 50 | 35 | 10 | 1 |

|

|

|

| | 6 | 0 | 120 | 274 | 225 | 85 | 15 | 1 |

|

|

| | 7 | 0 | 720 | 1764 | 1624 | 735 | 175 | 21 | 1 |

|

| | 8 | 0 | 5040 | 13068 | 13132 | 6769 | 1960 | 322 | 28 | 1 |

| | 9 | 0 | 40320 | 109584 | 118124 | 67284 | 22449 | 4536 | 546 | 36 | 1 |

A modification of this argument leads to a recurrence by which we can compute Image for all k : Given a set of n > 0 objects to be partitioned into k nonempty parts, we either put the last object into a class by itself (in Image ways), or we put it together with some nonempty subset of the first n − 1 objects. There are Image possibilities in the latter case, because each of the Image ways to distribute the first n − 1 objects into k nonempty parts gives subsets that the n th object can join. Hence

Image

This is the law that generates Table 258 ; without the factor of k it would reduce to the addition formula ( 5.8 ) that generates Pascal’s triangle.

And now, Stirling numbers of the first kind. These are somewhat like the others, but Image counts the number of ways to arrange n objects into k cycles instead of subsets. We verbalize ‘ Image ’ by saying “ n cycle k .”

Cycles are cyclic arrangements, like the necklaces we considered in Chapter 4 . The cycle

Image

can be written more compactly as ‘ [A, B, C, D] ’, with the understanding that

[A, B, C, D] \= [B, C, D, A] \= [C, D, A, B] \= [D, A, B, C] ;

a cycle “wraps around” because its end is joined to its beginning. On the other hand, the cycle [A, B, C, D] is not the same as [A, B, D, C] or [D, C, B, A] .

There are eleven different ways to make two cycles from four elements:

Image

“There are nine and sixty ways of constructing tribal lays, And—every—single—one—of—them—is—right.”

— Rudyard Kipling

hence Image .

A singleton cycle (that is, a cycle with only one element) is essentially the same as a singleton set (a set with only one element). Similarly, a 2 -cycle is like a 2 -set, because we have [A , B] = [B, A] just as { A , B } \= { B , A } . But there are two different 3 -cycles, [A , B , C] and [A , C , B] . Notice, for example, that the eleven cycle pairs in ( 6.4 ) can be obtained from the seven set pairs in ( 6.1 ) by making two cycles from each of the 3 -element sets.

In general, n ! /n \= ( n − 1 )! different n -cycles can be made from any n- element set, whenever n > 0 . (There are n ! permutations, and each n -cycle corresponds to n of them because any one of its elements can be listed first.) Therefore we have

Image

This is much larger than the value Image we had for Stirling partition numbers. In fact, it is easy to see that the cycle numbers must be at least as large as the partition numbers,

Image

because every partition into nonempty subsets leads to at least one arrangement of cycles.

Equality holds in ( 6.6 ) when all the cycles are necessarily singletons or doubletons, because cycles are equivalent to subsets in such cases. This happens when k \= n and when k \= n − 1 ; hence

Image

In fact, it is easy to see that

Image

(The number of ways to arrange n objects into n − 1 cycles or subsets is the number of ways to choose the two objects that will be in the same cycle or subset.) The triangular numbers Image \= 1 , 3 , 6 , 10 , . . . are conspicuously present in both Table 258 and Table 259 .

We can derive a recurrence for Image by modifying the argument we used for Image . Every arrangement of n objects in k cycles either puts the last object into a cycle by itself (in Image ways) or inserts that object into one of the Image cycle arrangements of the first n − 1 objects. In the latter case, there are n − 1 different ways to do the insertion. (This takes some thought, but it’s not hard to verify that there are j ways to put a new element into a j -cycle in order to make a (j + 1 ) -cycle. When j \= 3 , for example, the cycle [A , B , C] leads to

[ A , B , C , D ] ,       [ A , B , D , C ] ,      or      [ A , D , B , C ]

when we insert a new element D , and there are no other possibilities. Summing over all j gives a total of n − 1 ways to insert an n th object into a cycle decomposition of n − 1 objects.) The desired recurrence is therefore

Image

This is the addition-formula analog that generates Table 259 .

Comparison of ( 6.8 ) and ( 6.3 ) shows that the first term on the right side is multiplied by its upper index ( n –1) in the case of Stirling cycle numbers, but by its lower index k in the case of Stirling partition numbers. We can therefore perform “absorption” in terms like Image and Image , when we do proofs by mathematical induction.

Every permutation is equivalent to a set of cycles. For example, consider the permutation that takes 123456789 into 384729156 . We can conveniently represent it in two rows,

1 2 3 4 5 6 7 8 9
3 8 4 7 2 9 1 5 6,

showing that 1 becomes 3 and 2 becomes 8 , etc. The cycle structure comes about because 1 becomes 3 , which becomes 4 , which becomes 7 , which becomes the original element 1 ; that’s the cycle [1, 3, 4, 7] . Another cycle in this permutation is [2, 8, 5] ; still another is [6, 9] . Therefore the permutation 384729156 is equivalent to the cycle arrangement

[1, 3, 4, 7] [2, 8, 5] [6, 9] .

If we have any permutation π 1 π 2 . . . π n of { 1, 2, . . . , n } , every element is in a unique cycle. For if we start with m 0 \= m and look at m 1 \= π m 0 , m 2 \= π m 1 , etc., we must eventually come back to m k \= m 0 . (The numbers must repeat sooner or later, and the first number to reappear must be m 0 because we know the unique predecessors of the other numbers m 1 , m 2 , . . . , m k − 1 .) Therefore every permutation defines a cycle arrangement. Conversely, every cycle arrangement obviously defines a permutation if we reverse the construction, and this one-to-one correspondence shows that permutations and cycle arrangements are essentially the same thing.

Therefore Image is the number of permutations of n objects that contain exactly k cycles. If we sum Image over all k , we must get the total number of permutations:

Image

For example, 6 + 11 + 6 + 1 \= 24 \= 4 ! .

Stirling numbers are useful because the recurrence relations ( 6.3 ) and ( 6.8 ) arise in a variety of problems. For example, if we want to represent ordinary powers x n by falling powers x n , we find that the first few cases are

x 0 \= x 0 ;
x 1 \= x 1 ;
x 2 \= x 2 + x 1 ;
x 3 \= x 3 + 3x 2 + x 1 ;
x 4 \= x 4 + 6x 3 + 7x 2 + x 1 .

These coefficients look suspiciously like the numbers in Table 258 , reflected between left and right; therefore we can be pretty confident that the general formula is

Image

We’d better define Image when k < 0 and n ⩾ 0 .

And sure enough, a simple proof by induction clinches the argument: We have x · x k \= x k + 1 + kx k , because x k + 1 \= x k ( x − k ) ; hence x · x n −1 is

Image

In other words, Stirling subset numbers are the coefficients of factorial powers that yield ordinary powers.

We can go the other way too, because Stirling cycle numbers are the coefficients of ordinary powers that yield factorial powers:

Image

We have (x + n − 1 ) · x k \= x k +1 + (n − 1 )x k , so a proof like the one just given shows that

Image

This leads to a proof by induction of the general formula

Image

(Setting x \= 1 gives ( 6.9 ) again.)

But wait, you say. This equation involves rising factorial powers Image , while ( 6.10 ) involves falling factorials Image . What if we want to express Image in terms of ordinary powers, or if we want to express x n in terms of rising powers? Easy; we just throw in some minus signs and get

Image

Image

This works because, for example, the formula

x 4 \= x ( x − 1 )( x − 2 )( x − 3 ) \= x 4 − 6x 3 + 11x 2 − 6x

is just like the formula

Image \= x ( x + 1 )( x + 2 )( x + 3 ) \= x 4 + 6x 3 + 11x 2 + 6x

but with alternating signs. The general identity

Image

of exercise 2.17 converts ( 6.10 ) to ( 6.12 ) and ( 6.11 ) to ( 6.13 ) if we negate x .

Table 264 Basic Stirling number identities, for integer n ⩾ 0 .

Recurrences:

Image

Special values:

Image

Converting between powers:

Image

Inversion formulas:

Image

Table 265 Additional Stirling number identities, for integers l , m , n ⩾ 0 .

Image
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---
Image
---

Image

Also , Image , a generalization of ( 6.9 ).

We can remember when to stick the (–1) n −k factor into a formula like ( 6.12 ) because there’s a natural ordering of powers when x is large:

Image

The Stirling numbers Image and Image are nonnegative, so we have to use minus signs when expanding a “small” power in terms of “large” ones.

We can plug ( 6.11 ) into ( 6.12 ) and get a double sum:

Image

This holds for all x , so the coefficients of x 0 , x 1 , . . . , x n −1 , x n +1 , x n +2 , . . . on the right must all be zero and we must have the identity

Image

Stirling numbers, like binomial coefficients, satisfy many surprising identities. But these identities aren’t as versatile as the ones we had in Chapter 5 , so they aren’t applied nearly as often. Therefore it’s best for us just to list the simplest ones, for future reference when a tough Stirling nut needs to be cracked. Tables 264 and 265 contain the formulas that are most frequently useful; the principal identities we have already derived are repeated there.

When we studied binomial coefficients in Chapter 5 , we found that it was advantageous to define Image for negative n in such a way that the identity Image is valid without any restrictions. Using that identity to extend the Image ’s beyond those with combinatorial significance, we discovered (in Table 164 ) that Pascal’s triangle essentially reproduces itself in a rotated form when we extend it upward. Let’s try the same thing with Stirling’s triangles: What happens if we decide that the basic recurrences

Image

are valid for all integers n and k ? The solution becomes unique if we make the reasonable additional stipulations that

Image

Table 267 Stirling’s triangles in tandem.

n Image Image Image Image Image Image Image Image Image Image Image

| –5 | 1 | |

|

|

|

|

|

|

|

|

| | –4 | 10 | 1 |

|

|

|

|

|

|

|

|

| | –3 | 35 | 6 | 1 |

|

|

|

|

|

|

|

| | –2 | 50 | 11 | 3 | 1 |

|

|

|

|

|

|

| | –1 | 24 | 6 | 2 | 1 | 1 |

|

|

|

|

|

| | 0 | 0 | 0 | 0 | 0 | 0 | 1 |

|

|

|

|

| | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |

|

|

|

| | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |

|

|

| | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 3 | 1 |

|

| | 4 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 7 | 6 | 1 |

| | 5 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 15 | 25 | 10 | 1 |

In fact, a surprisingly pretty pattern emerges: Stirling’s triangle for cycles appears above Stirling’s triangle for subsets, and vice versa! The two kinds of Stirling numbers are related by an extremely simple law [ 220 , 221 ]:

Image

We have “ duality,” something like the relations between min and max, between Image x Image and Image x Image , between Image and Image , between gcd and lcm. It’s easy to check that both of the recurrences Image and Image amount to the same thing, under this correspondence.

6.2 Eulerian Numbers

Another triangle of values pops up now and again, this one due to Euler [ 104 , §13 ; 110 , page 485], and we denote its elements by Image . The angle brackets in this case suggest “less than” and “greater than” signs; Image is the number of permutations π 1 π 2 . . . π n of { 1, 2, . . . , n } that have k ascents , namely, k places where π j < π j + 1 . (Caution: This notation is less standard than our notations Image , Image for Stirling numbers. But we’ll see that it makes good sense.)

( Knuth [ 209 , first edition] used Image for Image .)

For example, eleven permutations of { 1, 2, 3, 4 } have two ascents:

1324,       1423,       2314,       2413,       3412 ;
1243,       1342,       2341 ;          2134,       3124,       4123.

(The first row lists the permutations with π 1 < π 2 > π 3 < π 4 ; the second row lists those with π 1 < π 2 < π 3 > π 4 and π 1 > π 2 < π 3 < π 4 .) Hence Image .

Table 268 Euler’s triangle.

n Image Image Image Image Image Image Image Image Image Image

| 0 | 1 | |

|

|

|

|

|

|

|

| | 1 | 1 | 0 |

|

|

|

|

|

|

|

| | 2 | 1 | 1 | 0 |

|

|

|

|

|

|

| | 3 | 1 | 4 | 1 | 0 |

|

|

|

|

|

| | 4 | 1 | 11 | 11 | 1 | 0 |

|

|

|

|

| | 5 | 1 | 26 | 66 | 26 | 1 | 0 |

|

|

|

| | 6 | 1 | 57 | 302 | 302 | 57 | 1 | 0 |

|

|

| | 7 | 1 | 120 | 1191 | 2416 | 1191 | 120 | 1 | 0 |

|

| | 8 | 1 | 247 | 4293 | 15619 | 15619 | 4293 | 247 | 1 | 0 |

| | 9 | 1 | 502 | 14608 | 88234 | 156190 | 88234 | 14608 | 502 | 1 | 0 |

Table 268 lists the smallest Eulerian numbers; notice that the trademark sequence is 1 , 11 , 11 , 1 this time. There can be at most n − 1 ascents, when n > 0 , so we have Image on the diagonal of the triangle.

Euler’s triangle, like Pascal’s, is symmetric between left and right. But in this case the symmetry law is slightly different:

Image

The permutation π 1 π 2 . . . π n has n –1–k ascents if and only if its “reflection” π n . . . π 2 π 1 has k ascents.

Let’s try to find a recurrence for Image . Each permutation ρ \= ρ 1 . . . ρ n − 1 of { 1, . . . , n − 1 } leads to n permutations of { 1, 2, . . . , n } if we insert the new element n in all possible ways. Suppose we put n in position j , obtaining the permutation π \= ρ 1 . . . ρ j − 1 n ρ j . . . ρ n − 1 . The number of ascents in π is the same as the number in ρ , if j \= 1 or if ρ j − 1 < ρ j ; it’s one greater than the number in ρ , if ρ j − 1 > ρ j or if j \= n . Therefore π has k ascents in a total of Image ways from permutations ρ that have k ascents, plus a total of Image ways from permutations ρ that have k − 1 ascents. The desired recurrence is

Image

Once again we start the recurrence off by setting

Image

and we will assume that Image when k < 0 .

Eu lerian numbers are useful primarily because they provide an unusual connection between ordinary powers and consecutive binomial coefficients:

Image

(This is called “Worpitzky’s identity” [ 378 ].) For example, we have

Image

Western scholars have recently learned of a significant Chinese book by Li ShanLan [ 249 ; 265 , pages 320–325], published in 1867, which contains the first known appearance of formula ( 6.37 ).

and so on. It’s easy to prove ( 6.37 ) by induction ( exercise 14 ).

Incidentally, ( 6.37 ) gives us yet another way to obtain the sum of the first n squares: We have Image , hence

Image

The Eulerian recurrence ( 6.35 ) is a bit more complicated than the Stirling recurrences ( 6.3 ) and ( 6.8 ), so we don’t expect the numbers Image to satisfy as many simple identities. Still, there are a few:

Image

Image

Image

If we multiply ( 6.39 ) by z n −m and sum on m , we get Image . Replacing z by z − 1 and equating coefficients of z k gives ( 6.40 ). Thus the last two of these identities are essentially equivalent. The first identity, ( 6.38 ), gives us special values when m is small:

Image

Table 270 Second-order Eulerian triangle.

n Image Image Image Image Image Image Image Image Image

| 0 | 1 | |

|

|

|

|

|

|

| | 1 | 1 | 0 |

|

|

|

|

|

|

| | 2 | 1 | 2 | 0 |

|

|

|

|

|

| | 3 | 1 | 8 | 6 | 0 |

|

|

|

|

| | 4 | 1 | 22 | 58 | 24 | 0 |

|

|

|

| | 5 | 1 | 52 | 328 | 444 | 120 | 0 |

|

|

| | 6 | 1 | 114 | 1452 | 4400 | 3708 | 720 | 0 |

|

| | 7 | 1 | 240 | 5610 | 32120 | 58140 | 33984 | 5040 | 0 |

| | 8 | 1 | 494 | 19950 | 195800 | 644020 | 785304 | 341136 | 40320 | 0 |

We needn’t dwell further on Eulerian numbers here; it’s usually sufficient simply to know that they exist, and to have a list of basic identities to fall back on when the need arises. However, before we leave this topic, we should take note of yet another triangular pattern of coefficients, shown in Table 270 . We call these “second-order Eulerian numbers” Image , because they satisfy a recurrence similar to ( 6.35 ) but with n replaced by 2n − 1 in one place:

Image

These numbers have a curious combinatorial interpretation, first noticed by Gessel and Stanley [ 147 ]: If we form permutations of the multiset { 1, 1, 2, 2, . . . , n, n } with the special property that all numbers between the two occurrences of m are greater than m , for 1 ⩽ m ⩽ n , then Image is the number of such permutations that have k ascents. For example, there are eight suitable single-ascent permutations of { 1, 1, 2, 2, 3, 3 } :

113322, 133221, 221331, 221133, 223311, 233211, 331122, 331221.

Thus Image . The multiset { 1, 1, 2, 2, . . . , n, n } has a total of

Image

suitable permutations, because the two appearances of n must be adjacent and there are 2n − 1 places to insert them within a permutation for n − 1 . For example, when n \= 3 the permutation 1221 has five insertion points, yielding 331221 , 133221 , 123321 , 122331 , and 122133 . Recurrence ( 6.41 ) can be proved by extending the argument we used for ordinary Eulerian numbers.

Second-order Eulerian numbers are important chiefly because of their connection with Stirling numbers [ 148 ]: We have, by induction on n ,

Image

Image

For example,

Image

(We already encountered the case n \= 1 in ( 6.7 ).) These identities hold whenever x is an integer and n is a nonnegative integer. Since the right-hand sides are polynomials in x , we can use ( 6.43 ) and ( 6.44 ) to define Stirling numbers Image and Image for arbitrary real (or complex) values of x .

If n > 0 , these polynomials Image and Image are zero when x \= 0 , x \= 1 , . . . , and x \= n ; therefore they are divisible by (x–0) , (x–1) , . . . , and (x–n) . It’s interesting to look at what’s left after those known factors are divided out. We define the Stirling polynomials σ n ( x ) by the rule

Image

(The degree of σ n ( x ) is n − 1 .) The first few cases are

σ 0 ( x )     \=     1/x ;
σ 1 ( x )     \=     1/2 ;
σ 2 ( x )     \=     ( 3x − 1 ) /24 ;
σ 3 ( x )     \=     ( x 2 − x ) /48 ;
σ 4 ( x )     \=     ( 15x 3 − 30x 2 + 5x + 2 ) /5760 .

So 1/x is a polynomial?

(Sorry about that.)

They can be computed via the second-order Eulerian numbers; for example,

σ 3 (x) \= ((x–4)(x–5) + 8 (x–4)(x+1) + 6 (x+2)(x+1)) /6 ! .

Table 272 Stirling convolution formulas.

Image

Image

Image

Image

It turns out that these polynomials satisfy two very pretty identities:

Image

Image

And in general, if S t ( z ) is the power series that satisfies

Image

then

Image

Therefore we can obtain general convolution formulas for Stirling numbers, as we did for binomial coefficients in Table 202 ; the results appear in Table 272 . When a sum of Stirling numbers doesn’t fit the identities of Table 264 or 265 , Table 272 may be just the ticket. (An example appears later in this chapter, following equation ( 6.100 ). Exercise 7.19 discusses the general principles of convolutions based on identities like ( 6.50 ) and ( 6.53 ).)

6.3 Harmonic Numbers

It’s time now to take a closer look at harmonic numbers, which we first met back in Chapter 2 :

Image

These numbers appear so often in the analysis of algorithms that computer scientists need a special notation for them. We use H n , the ‘ H ’ standing for “harmonic,” since a tone of wavelength 1/n is called the n th harmonic of a tone whose wavelength is 1 . The first few values look like this:

Image

Exercise 21 shows that H n is never an integer when n > 1 .

(See also J. G. Coffin [ 62′ ].)

Here’s a card trick, based on an idea by R. T. Sharp [ 325 ], that illustrates how the harmonic numbers arise naturally in simple situations. Given n cards and a table, we’d like to create the largest possible overhang by stacking the cards up over the table’s edge, subject to the laws of gravity:

Image

This must be Table 273 .

To define the problem a bit more, we assume that card k rests on card k + 1 , for 1 ⩽ k < n . We also require the right edge of each card to be parallel to the edge of the table; otherwise we could increase the overhang by rotating the cards so that their corners stick out a little farther. And to make the answer simpler, we assume that each card is 2 units long.

With one card, we get maximum overhang when its center of gravity is just above the edge of the table. The center of gravity is in the middle of the card, so we can create half a cardlength, or 1 unit, of overhang.

With two cards, it’s not hard to convince ourselves that we get maximum overhang when the center of gravity of the top card is just above the edge of the second card, and the center of gravity of both cards combined is just above the edge of the table. The joint center of gravity of two cards will be in the middle of their common part, so we are able to achieve an additional half unit of overhang.

This pattern suggests a general method, where we place cards so that the center of gravity of the top k cards lies just above the edge of the k + 1 st card (which supports those top k ). The table plays the role of the n + 1 st card. To express this condition algebraically, we can let d k be the distance from the extreme edge of the top card to the corresponding edge of the k th card from the top. Then d 1 \= 0 , and we want to make d k + 1 the center of gravity of the first k cards:

Image

(The center of gravity of k objects, having respective weights w 1 , . . . , w k and having respective centers of gravity at positi ons p 1 , . . . , p k , is at position (w 1 p 1 + · · · + w k p k )/(w 1 + · · · + w k ) .) We can rewrite this recurrence in two equivalent forms

kd k + 1

= k + d 1 + · · · + d k – 1 + d k ,            k ⩾ 0 ;

( k − 1 ) d k

= k − 1 + d 1 + · · · + d k – 1 ,               k ⩾ 1.

Subtracting these equations tells us that

kd k + 1 − ( k − 1 ) d k \= 1 + d k ,                 k ⩾ 1 ;

hence d k + 1 \= d k + 1/k . The second card will be offset half a unit past the third, which is a third of a unit past the fourth, and so on. The general formula

Image

follows by induction, and if we set k \= n we get d n + 1 \= H n as the total overhang when n cards are stacked as described.

Could we achieve greater overhang by holding back, not pushing each card to an extreme position but storing up “potential gravitational energy” for a later advance? No; any well-balanced card placement has

Image

Furthermore d 1 \= 0 . It follows by induction that d k + 1 ⩽ H k .

Notice that it doesn’t take too many cards for the top one to be completely past the edge of the table. We need an overhang of more than one cardlength, which is 2 units. The first harmonic number to exceed 2 is Image , so we need only four cards.

Anyone who actually tries to achieve this maximum overhang with 52 cards is probably not dealing with a full deck—or maybe he’s a real joker.

And with 52 cards we have an H 52 -unit overhang, which turns out to be H 52 /2 ≈ 2.27 cardlengths. (We will soon learn a formula that tells us how to compute an approximate value of H n for large n without adding up a whole bunch of fractions.)

An amusing problem called the “worm on the rubber band” shows harmonic numbers in another guise. A slow but persistent worm, W , starts at one end of a meter-long rubber band and crawls one centimeter per minute toward the other end. At the end of each minute, an equally persistent keeper of the band, K , whose sole purpose in life is to frustrate W , stretches it one meter. Thus after one minute of crawling, W is 1 centimeter from the start and 99 from the finish; then K stretches it one meter. During the stretching operation W maintains his relative position, 1 % from the start and 99 % from the finish; so W is now 2 cm from the starting point and 198 cm from the goal. After W crawls for another minute the score is 3 cm traveled and 197 to go; but K stretches, and the distances become 4.5 and 295.5 . And so on. Does the worm ever reach the finish? He keeps moving, but the goal seems to move away even faster. (We’re assuming an infinite longevity for K and W , an infinite elasticity of the band, and an infinitely tiny worm.)

Metric units make this problem more scientific.

Let’s write down some formulas. When K stretches the rubber band, the fraction of it that W has crawled stays the same. Thus he crawls 1/100 th of it the first minute, 1/200 th the second, 1/300 th the third, and so on. After n minutes the fraction of the band that he’s crawled is

Image

So he reaches the finish if H n ever surpasses 100 .

We’ll see how to estimate H n for large n soon; for now, let’s simply check our analysis by considering how “Superworm” would perform in the same situation. Superworm, unlike W , can crawl 50 cm per minute; so she will crawl H n /2 of the band length after n minutes, according to the argument we just gave. If our reasoning is correct, Superworm should finish before n reaches 4 , since H 4 > 2 . And yes, a simple calculation shows that Superworm has only Image cm left to travel after three minutes have elapsed. She finishes in 3 minutes and 40 seconds flat.

A flatworm, eh?

Harmonic numbers appear also in Stirling’s triangle. Let’s try to find a closed form for Image , the number of permutations of n objects that have exactly two cycles. Recurrence ( 6.8 ) tells us that

Image

and this recurrence is a natural candidate for the summation factor technique of Chapter 2 :

Image

Unfolding this recurrence tells us that Image ; hence

Image

We proved in Chapter 2 that the harmonic series ∑ k >0 1/k diverges, which means that H n gets arbitrarily large as n → ∞. But our proof was indirect; we found that a certain infinite sum ( 2.58 ) gave different answers when it was rearranged, hence ∑ k >0 1/k could not be bounded. The fact that H n → ∞ seems counter-intuitive, because it implies among other things that a large enough stack of cards will overhang a table by a mile or more, and that the worm W will eventually reach the end of his rope. Let us therefore take a closer look at the size of H n when n is large.

The simplest way to see that H n → ∞ is probably to group its terms according to powers of 2 . We put one term into group 1 , two terms into group 2 , four into group 3 , eight into group 4 , and so on:

Image

Both terms in group 2 are between Image and Image , so the sum of that group is between Image and Image . All four terms in group 3 are between Image and Image , so their sum is also between Image and 1 . In fact, each of the 2 k −1 terms in group k is between 2 − k and 2 1 −k ; hence the sum of each individual group is between Image and 1 .

This grouping procedure tells us that if 1/n is in group k , we must have H n > k/2 and H n ⩽ k (by induction on k ). Thus H n → ∞ , and in fact

Image

We now know H n within a factor of 2 . Although the harmonic numbers approach infinity, they approach it only logarithmically—that is, quite slowly.

We should call them the worm numbers, they’re so slow.

Better bounds can be found with just a little more work and a dose of calculus. We learned in Chapter 2 that H n is the discrete analog of the continuous function ln n . The natural logarithm is defined as the area under a curve, so a geometric comparison is suggested:

Image

The area under the curve between 1 and n , which is Image , is less than the area of the n rectangles, which is Image . Thus ln n < H n ; this is a sharper result than we had in ( 6.59 ). And by placing the rectangles a little differently, we get a similar upper bound:

Image

“I now see a way too how y e aggregate of y e termes of Musicall progressions may bee found (much after the same manner) by Logarithms, but y e calculations for finding out those rules would bee still more troublesom.”

— I. Newton [ 280 ]

This time the area of the n rectangles, H n , is less than the area of the first rectangle plus the area under the curve. We have proved that

Image

We now know the value of H n with an error of at most 1 .

“ Second order” harmonic numbers Image arise when we sum the squares of the reciprocals, instead of summing simply the reciprocals:

Image

Similarly, we define harmonic numbers of order r by summing (–r) th powers:

Image

If r > 1 , these numbers approach a limit as n → ∞ ; we noted in exercise 2.31 that this limit is conventionally called Riemann’s zeta function:

Image

Euler [ 103 ] discovered a neat way to use generalized harmonic numbers to approximate the ordinary ones, Image . Let’s consider the infinite series

Image

which converges when k > 1 . The left-hand side is ln k − ln (k − 1 ) ; therefore if we sum both sides for 2 ⩽ k ⩽ n the left-hand sum telescopes and we get

Image

Rearranging, we have an expressi on for the difference between H n and ln n :

Image

When n → ∞ , the right-hand side approaches the limiting value

Image

which is now known as Euler’s constant and conventionally denoted by the Greek letter γ . In fact, ζ ( r ) − 1 is approximately 1/2 r , so this infinite series converges rather rapidly and we can compute the decimal value

Image

“Huius igitur quantitatis constantis C valorem deteximus, quippe est C \= 0, 577218 .”

— L. Euler [ 103 ]

Euler’s argument establishes the limiting relation

Image

thus H n lies about 58% of the way between the two extremes in ( 6.60 ). We are gradually homing in on its value.

Further refinements are possible, as we will see in Chapter 9 . We will prove, for example, that

Image

This formula allows us to conclude that the millionth harmonic number is

H 1000000 ≈ 14.3927267228657236313811275 ,

without adding up a million fractions. Among other things, this implies that a stack of a million cards can overhang the edge of a table by more than seven cardlengths.

What does ( 6.66 ) tell us about the worm on the rubber band? Since H n is unbounded, the worm will definitely reach the end, when H n first exceeds 100 . Our approximation to H n says that this will happen when n is approximately

e 100 −γ ≈ e 99.423 .

In fact, exercise 9.49 proves that the critical value of n is either Image e 100 −γ Image or Image e 100 −γ Image . We can imagine W ’s triumph when he crosses the finish line at last, much to K ’s chagrin, some 287 decillion centuries after his long crawl began. (The rubber band will have stretched to more than 10 27 light years long; its molecules will be pretty far apart.)

Well, they can’t really go at it this long; the world will have ended much earlier, when the Tower of Brahma is fully transferred.

6.4 Harmonic Summation

Now let’s look at some sums involving harmonic numbers, starting with a review of a few ideas we learned in Chapter 2 . We proved in ( 2.36 ) and ( 2.57 ) that

Image

Image

Let’s be bold and take on a more general sum, which includes both of these as special cases: What is the value of

Image

when m is a nonnegative integer?

The approach that worked best for ( 6.67 ) and ( 6.68 ) in Chapter 2 was called summation by parts . We wrote the summand in the form u ( k ) Δv(k) , and we applied the general identity

Image

Remember? The sum that faces us now, Image , is a natural for this method because we can let

Image

(In other words, harmonic numbers have a simple Δ and binomial coefficients have a simple Δ − 1 , so we’re in business.) Plugging into ( 6.69 ) yields

Image

The remaining sum is easy, since we can absorb the (k + 1 ) − 1 using our old standby, equation ( 5.5 ):

Image

Thus we have the answer we seek:

Image

(This checks nicely with ( 6.67 ) and ( 6.68 ) when m \= 0 and m \= 1 .)

The next example sum uses division instead of multiplication: Let us try to evaluate

Image

If we expand H k by its definition, we obtain a double sum,

Image

Now another method from Chapter 2 comes to our aid; equation ( 2.33 ) tells us that

Image

It turns out that we could also have obtained this answer in another way if we had tried to sum by parts (see exercise 26 ).

Now let’s try our hands at a more difficult problem [ 354 ], which doesn’t submit to summation by parts:

Image

(This sum doesn’t explicitly mention harmonic numbers either; but who knows when they might turn up?)

(Not to give the answer away or anything.)

We will solve this problem in two ways, one by grinding out the answer and the other by being clever and/or lucky. First, the grinder’s approach. We expand ( n − k ) n by the binomial theorem, so that the troublesome k in the denominator will combine with the numerator:

Image

This isn’t quite the mess it seems, because the k j −1 in the inner sum is a polynomial in k , and identity ( 5.40 ) tells us that we are simply taking the n th difference of this polynomial. Almost; first we must clean up a few things. For one, k j −1 isn’t a polynomial if j \= 0 ; so we will need to split off that term and handle it separately. For another, we’re missing the term k \= 0 from the formula for n th difference; that term is nonzero when j \= 1 , so we had better restore it (and subtract it out again). The result is

Image

OK, now the top line (the only remaining double sum) is zero: It’s the sum of multiples of n th differences of polynomials of degree less than n , and such n th differences are zero. The second line is zero except when j \= 1 , when it equals –n n . So the third line is the only residual difficulty; we have reduced the original problem to a much simpler sum:

Image

For example, Image ; hence U 3 \= 27 (T 3 − 1 ) as claimed.

How can we evaluate T n ? One way is to replace Image by Image , obtaining a simple recurrence for T n in terms of T n − 1 . But there’s a more instructive way: We had a similar formula in ( 5.41 ), namely

Image

If we subtract out the term for k \= 0 and set x \= 0 , we get –T n . So let’s do it:

Image

(We have used the expansion ( 6.11 ) of Image ; we can divide x out of the numerator because Image .) But we know from ( 6.58 ) that Image ; hence T n \= H n , and we have the answer:

Image

That’s one approach. The other approach will be to try to evaluate a much more general sum,

Image

the value of the original U n will drop out as the special case U n ( n , –1) . (We are encouraged to try for more generality because the previous derivation “threw away” most of the details of the given problem; somehow those details must be irrelevant, because the n th difference wiped them away.)

We could replay the previous derivation with small changes and discover the value of U n ( x, y ) . Or we could replace (x + ky ) n by (x + ky ) n −1 (x + ky ) and then replace Image by Image , leading to the recurrence

Image

this can readily be solved with a summation factor ( exercise 5 ).

But it’s easiest to use another trick that worked to our advantage in Chapter 2 : differentiation. The derivative of U n ( x, y ) with respect to y brings out a k that cancels with the k in the denominator, and the resulting sum is trivial:

Image

(Once again, the n th difference of a polynomial of degree < n has vanished.)

We’ve proved that the derivative of U n ( x, y ) with respect to y is nx n −1 , independent of y . In general, if f ′ ( y ) \= c then f ( y ) \= f (0) + cy ; therefore we must have U n ( x, y ) \= U n ( x, 0 ) + nx n −1 y .

The remaining task is to determine U n ( x, 0 ) . But U n ( x, 0 ) is just x n times the sum T n \= H n we’ve already considered in ( 6.72 ); therefore the general sum in ( 6.74 ) has the closed form

Image

In particular, the solution to the original problem is U n ( n , –1) \= n n (H n –1) .

6.5 Bernoulli Numbers

The next important sequence of numbers on our agenda is named after Jakob Bernoulli (1654–1705), who discovered curious relationships while working out the formulas for sums of m th powers [ 26 ]. Let’s write

Image

(Thus we have Image in the notation of generalized harmonic numbers.) Bernoulli looked at the following sequence of formulas and spotted a pattern:

Image

Can you see it too? The coefficient of n m +1 in S m ( n ) is always 1/ (m + 1 ) . The coefficient of n m is always –1/2 . The coefficient of n m −1 is always . . . let’s see . . . m/12 . The coefficient of n m −2 is always zero. The coefficient of n m −3 is always . . . let’s see . . . hmmm . . . yes, it’s –m(m–1)(m–2)/720 . The coefficient of n m −4 is always zero. And it looks as if the pattern will continue, with the coefficient of n m −k always being some constant times m k .

That was Bernoulli’s empirical discovery. (He did not give a proof.) In modern notation we write the coefficients in the form

Image

Since S m (1) = 1, the numbers B k satisfy an implicit recurrence relation,

Image

For example, Image . The first few values turn out to be

Image

(All conjectures about a simple closed form for B n are wiped out by the appearance of the strange fraction –691/2730 .)

Warning: Different authors use different notations for Bernoulli’s coefficients. For example, many 20th-century reference books such as [ 2 ] say that B1 is −1/2, not +1/2. Indeed, the authors of the present book followed that lead, before 2021. But we’ve now adopted Bernoulli’s original choice, because it actually fits best with 21st-century practice.

We can prove Bernoulli’s formula ( 6.78 ) by induction on m , using the perturbation method (one of the ways we found S 2 ( n ) \= Image n in Chapter 2 ):

Image

Let Ŝ m ( n ) be the right-hand side of ( 6.78 ); we wish to show that S m ( n ) \= Ŝ m ( n ) , assuming that S j ( n ) \= Ŝ j ( n ) for 0 ⩽ j < m . We begin as we did for m \= 2 in Chapter 2 , subtracting S m + 1 ( n ) from both sides of ( 6.80 ). Then we expand each S j ( n ) using ( 6.78 ), and regroup so that the coefficients of powers of n on the right-hand side are brought together and simplified:

Image

(Here Δ = S m (n) − Image m (n). This derivation is a good review of the standard manipulations we learned in Chapter 5 .) Thus Δ \= 0 , QED.

In Chapter 7 we’ll use generating functions to obtain a much simpler proof of ( 6.78 ). The key idea will be to show that the Bernoulli numbers are the coefficients of the power series

Image

Here’s some more neat stuff that you’ll probably want to skim through the first time.

—Friendly TA

Image

Let’s simply assume for now that equation ( 6.81 ) holds, so that we can derive some of its amazing consequences. If we subtract Image z from both sides, thereby cancelling the term B 1 z 1 /1 ! \= Image z from the right, we get

Image

Here coth is the “ hyperbolic cotangent” function, otherwise known in calculus books as cosh z/ sinh z ; we have

Image

Changing z to –z gives Image coth Image coth Image ; hence every odd-numbered coefficient of Image coth Image must be zero, and we have

Image

Furthermore ( 6.82 ) leads to a closed form for the coefficients of coth:

Image

But there isn’t much of a market for hyperbolic functions; people are more interested in the “real” functions of trigonometry. We can express ordinary trigonometric functions in terms of their hyperbolic cousins by using the rules

Image

the corresponding power series are

Image

Hence cot z \= cos z/ sin z \= i cosh iz/ sinh iz \= i coth iz , and we have

Image

I see, we get “real” functions by using imaginary numbers.

Another remarkable formula for z cot z was found by Euler ( exercise 73 ):

Image

We can expand Euler’s formula in powers of z 2 , obtaining

Image

Equating coefficients of z 2n with those in our other formula, ( 6.87 ), gives us an almost miraculous closed form for infinitely many infinite sums:

Image

For example,

Image

Image

Formula ( 6.89 ) is not only a closed form for Image , it also tells us the approximate size of B 2n , since Image is very near 1 when n is large. And it tells us that (–1) n −1 B 2n > 0 for all n > 0 ; thus the Bernoulli numbers B2, B4, B6, B8, ... are alternately positive and negative.

And that’s not all. Bernoulli numbers also appear in the coefficients of the tangent function,

Image

Image

as well as other trigonometric functions ( exercise 72 ). Formula ( 6.92 ) leads to another important fact about the Bernoulli numbers, namely that

Image

We have, for example:

Image

(The T ’s are called tangent numbers .)

One way to prove ( 6.93 ), following an idea of B. F. Logan, is to consider the power series

Image

where T n ( x ) is a polynomial in x ; setting x \= 0 gives T n (0) \= T n , the n th tangent number. If we differentiate ( 6.94 ) with respect to x , we get

Image

When x \= tan w , this is tan (z + w ) . Hence, by Taylor’s theorem, the n th derivative of tan w is T n ( tan w ) .

but if we differentiate with respect to z , we get

Image

(Try it—the cancellation is very pretty.) Therefore we have

Image

a simple recurrence from which it follows that the coefficients of T n ( x ) are nonnegative integers. Moreover, we can easily prove that T n ( x ) has degree n + 1 , and that its coefficients are alternately zero and positive. Therefore T 2n + 1 (0) \= T 2n + 1 is a positive integer, as claimed in ( 6.93 ).

Recurrence ( 6.95 ) gives us a simple way to calculate Bernoulli numbers, via tangent numbers, using only simple operations on integers; by contrast, the defining recurrence ( 6.79 ) involves difficult arithmetic with fractions.

If we want to compute the sum of m th powers from a + 1 to b instead of from 1 to n , the theory of Chapter 2 tells us that

Image

This identity has interesting consequences when we consider negative values of k : We have

Image

hence

S m (0) − S m (–n ) \= (–1) m S m ( n − 1 ) .

But S m (0) \= 0 , so we have the identity

Image

Therefore S m (−1) \= 0 . The polynomial S m ( n ) will always have the factors n and ( n + 1) , because it has the roots 0 and 1 .

In general, S m ( n ) is a polynomial of degree m + 1 whose leading term Image . Moreover, we can set Image in ( 6.97 ) to deduce that Image ; if m is even, this makes Image , so Image will be an additional factor. These observations explain why we found

Image

(Johann Faulhaber implicitly used ( 6.97 ) in 1631 [ 119 ] to find simple formulas for S m ( n ) as polynomials in n ( n + 1 )/2 when m ⩽ 17 ; see [ 222 ].)

in Chapter 2 ; we could have used such reasoning to deduce the value of S 2 ( n ) without calculating it! Furthermore, ( 6.97 ) implies that the polynomial with the remaining factors, Ŝ m ( n ) \= S m ( n ) / Image , always satisfies

Ŝ m ( − n ) \= Ŝ m ( n − 1 ) ,           m even,      m > 0.

It follows that S m (n) can always be written in the factored form

Image

Here Image , and α 2 , . . . , α Image m/2 Image are appropriate complex numbers whose values depend on m . For example,

Image

Image

If m is odd and greater than 1 , we have B m \= 0 ; hence S m ( n ) is divisible by n 2 (and by ( n + 1 ) 2 ). Otherwise the roots of S m ( n ) don’t seem to obey a simple law.

Let’s conclude our study of Bernoulli numbers by looking at how they relate to Stirling numbers. One way to compute S m ( n ) is to change ordinary powers to falling powers, since the falling powers have easy sums. After doing those easy sums we can convert back to ordinary powers:

Image

Therefore, equating coefficients with those in ( 6.78 ), we must have the identity

Image

It would be nice to prove this relation directly, thereby discovering Bernoulli numbers in a new way. Do the identities in Tables 264 or 265 offer any help?

Yes, the first one is worth a try: We can replace Image by Image . The (j + 1) nicely cancels with the awkward denominator, and the left-hand side becomes

Image

The second sum is zero by ( 6.31 ), since k < m. That leaves us with the first sum, which cries out for a change in notation; let’s rename all variables so that the index of summation is k, and so that the other parameters are m and n. Then identity ( 6.99 ), with (m, k, j) replaced by (n−1, m, k−1), is equivalent to

Image

because this formula holds when n = m + 1, when n = m, and when n < m. Good, we have something that looks more pleasant—although Tables 264 and 265 donÙt suggest any obvious next step.

The convolution formulas in Table 272 now come to the rescue. We can use ( 6.49 ) and ( 6.48 ) to rewrite the summand in terms of Stirling polynomials:

Image

Things are looking up; the convolution in ( 6.46 ), with t \= 1 , yields

Image

Furthermore exercise 18, with x = 0, tells us that σ n (1) = −nσ n (0) + [n = 1]. Thus the sum on the left of (6.100), when n > m + 1, is equal to

Image

And finally we have σ n−m (1) = B n−m /(n − m)!, by ( 6.50 ). Thus formula ( 6.100 ) is indeed verified, because (−1) n−m B n−m = B n−m when n > m + 1. (Whew.) We’ve also proved, incidentally, that Bernoulli numbers are related to the constant terms in the Stirling polynomials:

Image

Image

6.6 Fibonacci Numbers

Now we come to a special sequence of numbers that is perhaps the most pleasant of all, the Fibonacci sequence Image F n Image :

Image

Unlike the harmonic numbers and the Bernoulli numbers, the Fibonacci numbers are nice simple integers. They are defined by the recurrence

Image

The simplicity of this rule—the simplest possible recurrence in which each number depends on the previous two—accounts for the fact that Fibonacci numbers occur in a wide variety of situations.

“ Bee trees” provide a good example of how Fibonacci numbers can arise naturally. Let’s consider the pedigree of a male bee. Each male (also known as a drone) is produced asexually from a female (also known as a queen); each female, however, has two parents, a male and a female. Here are the first few levels of the tree:

Image

The back-to-nature nature of this example is shocking. This book should be banned.

The drone has one grandfather and one grandmother; he has one greatgrandfather and two great-grandmothers; he has two great-great-grandfathers and three great-great-grandmothers. In general, it is easy to see by induction that he has exactly F n +1 great n -grandpas and F n +2 great n -grandmas.

Fibonacci numbers are often found in nature, perhaps for reasons similar to the bee-tree law. For example, a typical sunflower has a large head that contains spirals of tightly packed florets, usually with 34 winding in one direction and 55 in another. Smaller heads will have 21 and 34, or 13 and 21; a gigantic sunflower with 89 and 144 spirals was once exhibited in England. Similar patterns are found in some species of pine cones.

Phyllotaxis, _n . The love of taxis._

And here’s an example of a different nature [ 277 ]: Suppose we put two panes of glass back-to-back. How many ways a n are there for light rays to pass through or be reflected after changing direction n times? The first few cases are:

Image

When n is even, we have an even number of bounces and the ray passes through; when n is odd, the ray is reflected and it re-emerges on the same side it entered. The a n ’s seem to be Fibonacci numbers, and a little staring at the figure tells us why: For n ⩾ 2 , the n -bounce rays either take their first bounce off the opposite surface and continue in a n − 1 ways, or they begin by bouncing off the middle surface and then bouncing back again to finish in a n − 2 ways. Thus we have the Fibonacci recurrence a n \= a n − 1 + a n − 2 . The initial conditions are different, but not very different, because we have a 0 \= 1 \= F 2 and a 1 \= 2 \= F 3 ; therefore everything is simply shifted two places, and a n \= F n + 2 .

Leonardo Fibonacci introduced these numbers in 1202, and mathematicians gradually began to discover more and more interesting things about them. Edouard Lucas, the perpetrator of the Tower of Hanoi puzzle discussed in Chapter 1 , worked with them extensively in the last half of the nineteenth century (in fact it was Lucas who popularized the name “ Fibonacci numbers ”). One of his amazing results was to use properties of Fibonacci numbers to prove that the 39-digit Mersenne number 2 127 − 1 is prime.

“La suite de Fibonacci possède des propriétés nombreuses fort intéressantes.”

— E. Lucas [ 259 ]

One of the oldest theorems about Fibonacci numbers, first published by the Italian astronomer Gian Domenico Cassini in 1680 [ 51 ], is the identity

Image

When n \= 6 , for example, Cassini’s identity correctly claims that 13 · 5 − 8 2 equals 1 . (Johannes Kepler knew this law already in 1608 [ 202 ].)

A polynomial formula that involves Fibonacci numbers of the form F n ± k for small values of k can be transformed into a formula that involves only F n and F n + 1 , because we can use the rule

Image

to express F m in terms of higher Fibonacci numbers when m < n , and we can use

Image

to replace F m by lower Fibonacci numbers when m > n +1 . Thus, for example, we can replace F n − 1 by F n + 1 − F n in ( 6.103 ) to get Cassini’s identity in the form

Image

Moreover, Cassini’s identity reads

F n + 2 F n − Image \= (– 1 ) n + 1

when n is replaced by n + 1 ; this is the same as ( F n + 1 + F n ) F n − Image \= (– 1 ) n + 1 , which is the same as ( 6.106 ). Thus Cassini ( n ) is true if and only if Cassini (n+1) is true; equation ( 6.103 ) holds for all n by induction.

Cassini’s identity is the basis of a geometrical paradox that was one of Lewis Carroll’s favorite puzzles [ 63 ], [ 319 ], [ 364 ]. The idea is to take a chessboard and cut it into four pieces as shown here, then to reassemble the pieces into a rectangle:

Image

Presto: The original area of 8 × 8 \= 64 squares has been rearranged to yield 5 × 13 \= 65 squares! A similar construction dissects any F n × F n square into four pieces, using F n + 1 , F n , F n − 1 , and F n − 2 as dimensions wherever the illustration has 13 , 8 , 5 , and 3 respectively. The result is an F n − 1 × F n + 1 rectangle; by ( 6.103 ), one square has therefore been gained or lost, depending on whether n is even or odd.

The paradox is explained because . . . well, magic tricks aren’t supposed to be explained.

Strictly speaking, we can’t apply the reduction ( 6.105 ) unless m ⩾ 2 , because we haven’t defined F n for negative n . A lot of maneuvering becomes easier if we eliminate this boundary condition and use ( 6.104 ) and ( 6.105 ) to define Fibonacci numbers with negative indices. For example, F − 1 turns out to be F 1 − F 0 \= 1 ; then F − 2 is F 0 − F − 1 \= –1 . In this way we deduce the values

Image

and it quickly becomes clear (by induction) that

Image

Cassini’s identity ( 6.103 ) is true for all integers n , not just for n > 0 , when we extend the Fibonacci sequence in this way.

The process of reducing F n ± k to a combination of F n and F n + 1 by using ( 6.105 ) and ( 6.104 ) leads to the sequence of formulas

F n + 2     =        F n + 1 +     F n

             

F n – 1     =       F n + 1     −       F n

F n + 3     =     2F n + 1 +     F n

 

F n – 2     =     − F n + 1     +    2F n

F n + 4     =     3F n + 1 + 2F n

 

F n – 3     =       2F n + 1    −    3F n

F n + 5     =     5F n + 1 + 3F n

 

F n – 4     =     − 3F n + 1    +    5F n

in which another pattern becomes obvious:

Image

This identity, easily proved by induction, holds for all integers k and n (positive, negative, or zero).

If we set k \= n in ( 6.108 ), we find that

Image

hence F 2n is a multiple of F n . Similarly,

F 3n \= F 2n F n + 1 + F 2n − 1 F n ,

and we may conclude that F 3n is also a multiple of F n . By induction,

Image

for all integers k and n . This explains, for example, why F 15 (which equals 610 ) is a multiple of both F 3 and F 5 (which are equal to 2 and 5 ). Even more is true, in fact; exercise 27 proves that

Image

For example, gcd (F 12 , F 18 ) \= gcd ( 144, 2584 ) \= 8 \= F 6 .

We can now prove a converse of ( 6.110 ): If n > 2 and if F m is a multiple of F n , then m is a multiple of n . For if F n \ F m then F n \ gcd (F m , F n ) \= F gcd ( m,n ) ⩽ F n . This is possible only if F gcd ( m,n ) \= F n ; and our assumption that n > 2 makes it mandatory that gcd ( m, n ) \= n . Hence n \ m .

An extension of these divisibility ideas was used by Yuri Matijasevich in his famous proof [ 266 ] that there is no algorithm to decide if a given multivariate polynomial equation with integer coefficients has a solution in integers. Matijasevich’s lemma states that, if n > 2 , the Fibonacci number F m is a multiple of Image if and only if m is a multiple of nF n .

Let’s prove this by looking at the sequence Image F kn mod Image Image for k \= 1 , 2 , 3 , . . . , and seeing when F kn mod Image = 0 . (We know that m must have the form kn if F m mod F n \= 0 .) First we have F n mod Image = F n ; that’s not zero. Next we have

F 2n \= F n F n + 1 + F n – 1 F n ≡ 2F n F n + 1           (mod Image ) ,

by ( 6.108 ), since F n + 1 ≡ F n − 1 (mod F n ). Similarly

Image

This congruence allows us to compute

F 3n

= F 2n + 1 F n + F 2n F n – 1

 

≡ Image F n + ( 2F n F n + 1 ) F n + 1 = 3 Image F n           (mod Image );

F 3n+1

= F 2n + 1 F n+1 + F 2n F n

 

≡ Image + ( 2F n F n + 1 ) F n ≡ Image                           (mod Image ) .

In general, we find by induction on k that

Image

Now F n + 1 is relatively prime to F n , so

F kn ≡ 0 (mod Image )

Image

      kF n ≡ 0 (mod Image )

 

Image

      k ≡ 0 (mod F n ) .

We have proved Matijasevich’s lemma.

One of the most important properties of the Fibonacci numbers is the special way in which they can be used to represent integers. Let’s write

Image

Then every positive integer has a unique representation of the form

Image

[The anonymous author of a classic Sanskrit work, Pr ā k ṛ ta Pai ṅ gala (c. 1320), actually knew this representation many centuries ago.]

(This is “Zeckendorf’s theorem” [ 246 ], [ 381 ].) For example, the representation of one million turns out to be

1000000

= 832040 + 121393 + 46368 + 144 + 55

 

=      F 30       +      F 26       +      F 24     +    F 12 + F 10 .

We can always find such a representation by using a “ greedy” approach, choosing F k 1 to be the largest Fibonacci number ⩽ n , then choosing F k 2 to be the largest that is ⩽ n − F k 1 , and so on. (More precisely, suppose that F k ⩽ n < F k + 1 ; then we have 0 ⩽ n − F k < F k + 1 − F k \= F k − 1 . If n is a Fibonacci number, ( 6.113 ) holds with r \= 1 and k 1 \= k . Otherwise n − F k has a Fibonacci representation F k 2 + · · · + F k r , by induction on n ; and ( 6.113 ) holds if we set k 1 \= k , because the inequalities F k 2 ⩽ n − F k < F k − 1 imply that k ≫ k 2 .) Conversely, any representation of the form ( 6.113 ) implies that

F k 1 ⩽ n < F k 1 + 1 ,

because the largest possible value of F k 2 + · · · + F k r when k ≫ k 2 ≫ · · · ≫ k r ≫ 0 is

Image

(This formula is easy to prove by induction on k ; the left-hand side is zero when k is 2 or 3 .) Therefore k 1 is the greedily chosen value described earlier, and the representation must be unique.

Any system of unique representation is a number system; therefore Zeckendorf’s theorem leads to the Fibonacci number system . We can represent any nonnegative integer n as a sequence of 0 ’s and 1 ’s, writing

Image

This number system is something like binary (radix 2 ) notation, except that there never are two adjacent 1 ’s. For example, here are the numbers from 1 to 20 , expressed Fibonacci-wise:

1 = ( 000001 ) F

       6 = ( 001001 ) F

       11 = ( 010100 ) F

       16 = ( 100100 ) F

2 = ( 000010 ) F

7 = ( 001010 ) F

12 = ( 010101 ) F

17 = ( 100101 ) F

3 = ( 000100 ) F

8 = ( 010000 ) F

13 = ( 100000 ) F

18 = ( 101000 ) F

4 = ( 000101 ) F

9 = ( 010001 ) F

14 = ( 100001 ) F

19 = ( 101001 ) F

5 = ( 001000 ) F

10 = ( 010010 ) F

15 = ( 100010 ) F

20 = ( 101010 ) F

The Fibonacci representation of a million, shown a minute ago, can be contrasted with its binary representation 2 19 + 2 18 + 2 17 + 2 16 + 2 14 + 2 9 + 2 6 :

( 1000000 ) 10 \= ( 10001010000000000010100000000 ) F

        \= ( 11110100001001000000 ) 2 .

The Fibonacci representation needs a few more bits because adjacent 1 ’s are not permitted; but the two representations are analogous.

To add 1 in the Fibonacci number system, there are two cases: If the “units digit” is 0 , we change it to 1 ; that adds F 2 \= 1 , since the units digit refers to F 2 . Otherwise the two least significant digits will be 01 , and we change them to 10 (thereby adding F 3 − F 2 \= 1 ). Finally, we must “carry” as much as necessary by changing the digit pattern ‘ 011 ’ to ‘ 100 ’ until there are no two 1 ’s in a row. (This carry rule is equivalent to replacing F m + 1 + F m by F m + 2 .) For example, to go from 5 \= (1000) F to 6 \= (1001) F or from 6 \= (1001) F to 7 \= (1010) F requires no carrying; but to go from 7 \= (1010) F to 8 \= (10000) F we must carry twice.

So far we’ve been discussing lots of properties of the Fibonacci numbers, but we haven’t come up with a closed formula for them. We haven’t found closed forms for Stirling numbers, Eulerian numbers, or Bernoulli numbers either; but we were able to discover the closed form Image for harmonic numbers. Is there a relation between F n and other quantities we know? Can we “solve” the recurrence that defines F n ?

The answer is yes. In fact, there’s a simple way to solve the recurrence by using the idea of generating function that we looked at briefly in Chapter 5 . Let’s consider the infinite series

Image

If we can find a simple formula for F ( z ) , chances are reasonably good that we can find a simple formula for its coefficients F n .

“Sit 1 + x + 2xx + 3x 3 + 5x 4 + 8x 5 + 13x 6 + 21x 7 + 34x 8 &c. Series nata ex divisione Unitatis per Trinomium 1 − x − xx .”

— A. de Moivre [ 76 ]

“The quantities r , s , t , which show the relation of the terms, are the same as those in the denominator of the fraction. This property, howsoever obvious it may be, M. DeMoivre was the first that applied it to use, in the solution of problems about infinite series, which otherwise would have been very intricate.”

—J. Stirling [ 343 ]

In Chapter 7 we will focus on generating functions in detail, but it will be helpful to have this example under our belts by the time we get there. The power series F ( z ) has a nice property if we look at what happens when we multiply it by z and by z 2 :

    F ( z ) =

F 0 + F 1 z + F 2 z 2 + F 3 z 3 + F 4 z 4 + F 5 z 5 + · · · ,

   zF ( z ) =

F 0 z + F 1 z 2 + F 2 z 3 + F 3 z 4 + F 4 z 5 + · · · ,

z 2 F ( z ) =

        F 0 z 2 + F 1 z 3 + F 2 z 4 + F 3 z 5 + · · · .

If we now subtract the last two equations from the first, the terms that involve z 2 , z 3 , and higher powers of z will all disappear, because of the Fibonacci recurrence. Furthermore the constant term F 0 never actually appeared in the first place, because F 0 \= 0 . Therefore all that’s left after the subtraction is (F 1 − F 0 )z , which is just z . In other words,

F ( z ) − zF ( z ) − z 2 F ( z ) \= z ,

and solving for F ( z ) gives us the compact formula

Image

We have now boiled down all the information in the Fibonacci sequence to a simple (although unrecognizable) expression z/ (1 − z − z 2 ) . This, believe it or not, is progress, because we can factor the denominator and then use partial fractions to achieve a formula that we can easily expand in power series. The coefficients in this power series will be a closed form for the Fibonacci numbers.

The plan of attack just sketched can perhaps be understood better if we approach it backwards. If we have a simpler generating function, say 1/ (1 − αz ) where α is a constant, we know the coefficients of all powers of z , because

Image \= 1 + αz + α 2 z 2 + α 3 z 3 + · · · .

Similarly, if we have a generating function of the form A/ (1–αz)+B/(1–βz) , the coefficients are easily determined, because

Image

Therefore all we have to do is find constants A , B , α , and β such that

Image

and we will have found a closed form Aα n + Bβ n for the coefficient F n of z n in F ( z ) . The left-hand side can be rewritten

Image

so the four constants we seek are the solutions to two polynomial equations:

Image

Image

We want to factor the denominator of F ( z ) into the form (1 − αz )(1 − βz ) ; then we will be able to express F ( z ) as the sum of two fractions in which the factors (1 − αz ) and (1 − βz ) are conveniently separated from each other.

Notice that the denominator factors in ( 6.119 ) have been written in the form (1 − αz )(1 − βz ) , instead of the more usual form c (z − ρ 1 )(z − ρ 2 ) where ρ 1 and ρ 2 are the roots. The reason is that (1 − αz )(1 − βz ) leads to nicer expansions in power series.

We can find α and β in several ways, one of which uses a slick trick: Let us introduce a new variable w and try to find the factorization

w 2 − wz − z 2 \= (w − αz )(w − βz ) .

As usual, the authors can’t resist a trick.

Then we can simply set w \= 1 and we’ll have the factors of 1 − z − z 2 . The roots of w 2 − wz − z 2 \= 0 can be found by the quadratic formula; they are

Image

Therefore

Image

and we have the constants α and β we were looking for.

The number Image is important in many parts of mathematics as well as in the art world, where it has been considered since ancient times to be the most pleasing ratio for many kinds of design. Therefore it has a special name, the golden ratio . We denote it by the Greek letter ϕ , in honor of Phidias who is said to have used it consciously in his sculpture. The other root Image shares many properties of ϕ , so it has the special name Image , “phi hat.” These numbers are roots of the equation w 2 − w − 1 \= 0 , so we have

Image

The ratio of one’s height to the height of one’s navel is approximately 1.618 , according to extensive empirical observations by European scholars [ 136 ].

(More about ϕ and Image later.)

We have found the constants α \= ϕ and Image needed in ( 6.119 ); now we merely need to find A and B in ( 6.120 ). Setting z \= 0 in that equation tells us that B \= –A , so ( 6.120 ) boils down to

Image

The solution is Image ; the partial fraction expansion of ( 6.117 ) is therefore

Image

Good, we’ve got F ( z ) right where we want it. Expanding the fractions into power series as in ( 6.118 ) gives a closed form for the coefficient of z n :

Image

(This formula was first published by Daniel Bernoulli in 1728, but people forgot about it until it was rediscovered by Jacques Binet [ 31 ] in 1843.)

Before we stop to marvel at our derivation, we should check its accuracy. For n \= 0 the formula correctly gives F 0 \= 0 ; for n \= 1 , it gives Image , which is indeed 1 . For higher powers, equations ( 6.121 ) show that the numbers defined by ( 6.123 ) satisfy the Fibonacci recurrence, so they must be the Fibonacci numbers by induction. (We could also expand ϕ n and Image by the binomial theorem and chase down the various powers of Image ; but that gets pretty messy. The point of a closed form is not necessarily to provide us with a fast method of calculation, but rather to tell us how F n relates to other quantities in mathematics.)

With a little clairvoyance we could simply have guessed formula ( 6.123 ) and proved it by induction. But the method of generating functions is a powerful way to discover it; in Chapter 7 we’ll see that the same method leads us to the solution of recurrences that are considerably more difficult. Incidentally, we never worried about whether the infinite sums in our derivation of ( 6.123 ) were convergent; it turns out that most operations on the coefficients of power series can be justified rigorously whether or not the sums actually converge [ 182 ]. Still, skeptical readers who suspect fallacious reasoning with infinite sums can take comfort in the fact that equation ( 6.123 ), once found by using infinite series, can be verified by a solid induction proof.

One of the interesting consequences of ( 6.123 ) is that the integer F n is extremely close to the irrational number Image when n is large. (Since Image is less than 1 in absolute value, Image becomes exponentially small and its effect is almost negligible.) For example, F 10 \= 55 and F 11 \= 89 are very near

Image

We can use this observation to derive another closed form,

Image

because Image for all n ⩾ 0 . When n is even, F n is a little bit less than Image ; otherwise it is a little greater.

Cassini’s identity ( 6.103 ) can be rewritten

Image

When n is large, 1/F n − 1 F n is very small, so F n + 1 /F n must be very nearly the same as F n /F n − 1 ; and ( 6.124 ) tells us that this ratio approaches ϕ . In fact, we have

Image

(This identity is true by inspection when n \= 0 or n \= 1 , and by induction when n > 1 ; we can also prove it directly by plugging in ( 6.123 ).) The ratio F n + 1 /F n is very close to ϕ , which it alternately overshoots and undershoots.

By coincidence, ϕ is also very nearly the number of kilometers in a mile. (The exact number is 1.609344 , since 1 inch is exactly 2.54 centimeters.) This gives us a handy way to convert mentally between kilometers and miles, because a distance of F n + 1 kilometers is (very nearly) a distance of F n miles.

Suppose we want to convert a non- Fibonacci number from kilometers to miles; what is 30 km, American style? Easy: We just use the Fibonacci number system and mentally convert 30 to its Fibonacci representation 21 + 8 + 1 by the greedy approach explained earlier. Now we can shift each number down one notch, getting 13 + 5 + 1 . (The former ‘ 1 ’ was F 2 , since k r ≫ 0 in ( 6.113 ); the new ‘ 1 ’ is F 1 .) Shifting down divides by ϕ , more or less. Hence 19 miles is our estimate. (That’s pretty close; the correct answer is about 18.64 miles.) Similarly, to go from miles to kilometers we can shift up a notch; 30 miles is approximately 34 + 13 + 2 \= 49 kilometers. (That’s not quite as close; the correct number is about 48.28 .)

If the USA ever goes metric, our speed limit signs will go from 55 mi/hr to 89 km/hr. Or maybe the highway people will be generous and let us go 90.

It turns out that this shift-down rule gives the correctly rounded number of miles per n kilometers for all n ⩽ 100 , except in the cases n \= 4 , 12 , 54 , 62 , 75 , 83 , 91 , 96 , and 99 , when it is off by less than 2/3 mile. And the shift-up rule gives either the correctly rounded number of kilometers for n miles, or 1 km too many, for all n ⩽ 113 . (The only really embarrassing case is n \= 4 , where the individual rounding errors for n \= 3 + 1 both go the same direction instead of cancelling each other out.)

The “shift down” rule changes n to f ( n /ϕ) and the “shift up” rule changes n to f ( n ϕ) , where f ( x ) \= Image x + ϕ − 1 Image .

6.7 Continuants

Fibonacci numbers have important connections to the Stern–Brocot tree that we studied in Chapter 4 , and they have important generalizations to a sequence of polynomials that Euler studied extensively. These polynomials are called continuants , because they are the key to the study of continued fractions like

Image

The continuant polynomial K n (x 1 , x 2 , . . . , x n ) has n parameters, and it is defined by the following recurrence:

Image

For example, the next three cases after K 1 (x 1 ) are

K 2 ( x 1 , x 2 )

=

x 1 x 2 + 1 ;

K 3 ( x 1 , x 2 , x 3 )

=

x 1 x 2 x 3 + x 1 + x 3 ;

K 4 ( x 1 , x 2 , x 3 , x 4 )

=

x 1 x 2 x 3 x 4 + x 1 x 2 + x 1 x 4 + x 3 x 4 + 1 .

It’s easy to see, inductively, that the number of terms is a Fibonacci number:

Image

When the number of parameters is implied by the context, we can write simply ‘ K ’ instead of ‘ K n ’, just as we can omit the number of parameters when we use the hypergeometric functions F of Chapter 5 . For example, K (x 1 , x 2 ) \= K 2 (x 1 , x 2 ) \= x 1 x 2 + 1 . The subscript n is of course necessary in formulas like ( 6.128 ).

Euler [ 112 ] observed that K (x 1 , x 2 , . . . , x n ) can be obtained by starting with the product x 1 x 2 . . . x n and then striking out adjacent pairs x k x k + 1 in all possible ways. We can represent Euler’s rule graphically by constructing all “ Morse code” sequences of dots and dashes having length n , where each dot contributes 1 to the length and each dash contributes 2 ; here are the Morse code sequences of length 4 :

Image

These dot-dash patterns correspond to the terms of K (x 1 , x 2 , x 3 , x 4 ) ; a dot signifies a variable that’s included and a dash signifies a pair of variables that’s excluded. For example, Image corresponds to x 1 x 4 .

A Morse code sequence of length n that has k dashes has n − 2k dots and n − k symbols altogether. These dots and dashes can be arranged in Image ways; therefore if we replace each dot by z and each dash by 1 we get

Image

We also know that the total number of terms in a continuant is a Fibonacci number; hence we have the identity

Image

(A closed form for ( 6.129 ), generalizing the Euler– Binet formula ( 6.123 ) for Fibonacci numbers, appears in ( 5.74 ).)

The relation between continuant polynomials and Morse code sequences shows that continuants have a mirror symmetry:

Image

Therefore they obey a recurrence that adjusts parameters at the left, in addition to the right-adjusting recurrence in definition ( 6.127 ):

Image

Both of these recurrences are special cases of a more general law:

Image

This law is easily understood from the Morse code analogy: The first product K m K n yields the terms of K m + n in which there is no dash in the [m, m + 1 ] position, while the second product yields the terms in which there is a dash there. If we set all the x ’s equal to 1 , this identity tells us that F m + n + 1 \= F m + 1 F n + 1 + F m F n ; thus, ( 6.108 ) is a special case of ( 6.133 ).

Euler [ 112 ] discovered that continuants obey an even more remarkable law, which generalizes Cassini’s identity:

Image

This law (proved in exercise 29 ) holds whenever the subscripts on the K ’s are all nonnegative. For example, when k \= 2 , m \= 1 , and n \= 3 , we have

K (x 1 , x 2 , x 3 , x 4 ) K (x 2 , x 3 ) \= K (x 1 , x 2 , x 3 ) K (x 2 , x 3 , x 4 ) + 1 .

Continuant polynomials are intimately connected with Euclid’s algorithm. Suppose, for example, that the computation of gcd ( m, n ) finishes in four steps:

gcd ( m , n ) = gcd ( n 0 , n 1 )

     n 0 = m ,           n 1 = n ;

 

                = gcd ( n 1 , n 2 )

     n 2 = n 0 mod n 1 = n 0 − q 1 n 1 ;

 

                = gcd ( n 2 , n 3 )

n 3 = n 1 mod n 2 = n 1 − q 2 n 2 ;

 

                = gcd ( n 3 , n 4 )

n 4 = n 2 mod n 3 = n 2 − q 3 n 3 ;

 

                = gcd ( n 4 , 0 ) = n 4 .

0 = n 3 mod n 4 = n 3 − q 4 n 4 .

Then we have

n 4    =    n 4

   =    K () n 4 ;

n 3    =    q 4 n 4

   =    K ( q 4 ) n 4 ;

n 2    =    q 3 n 3 + n 4

   =    K ( q 3 , q 4 ) n 4 ;

n 1    =    q 2 n 2 + n 3

   =    K ( q 2 , q 3 , q 4 ) n 4 ;

n 0    =    q 1 n 1 + n 2

   =    K ( q 1 , q 2 , q 3 , q 4 ) n 4 .

In general, if Euclid’s algorithm finds the greatest common divisor d in k steps, after computing the sequence of quotients q 1 , . . . , q k , then the starting numbers were K (q 1 , q 2 , . . . , q k )d and K (q 2 , . . . , q k )d . (This fact was noticed early in the eighteenth century by Thomas Fantet de Lagny [ 232 ], who seems to have been the first person to consider continuants explicitly. Lagny pointed out that consecutive Fibonacci numbers, which occur as continuants when the q ’s take their minimum values, are therefore the smallest inputs that cause Euclid’s algorithm to take a given number of steps.)

Continuants are also intimately connected with continued fractions, from which they get their name. We have, for example,

Image

The same pattern holds for continued fractions of any depth. It is easily proved by induction; we have, for example,

Image

because of the identity

Image

(This identity is proved and generalized in exercise 30 .)

Moreover, continuants are closely connected with the Stern–Brocot tree discussed in Chapter 4 . Each node in that tree can be represented as a sequence of L ’s and R ’s, say

Image

where a 0 ⩾ 0 , a 1 ⩾ 1 , a 2 ⩾ 1 , a 3 ⩾ 1 , . . . , a n − 2 ⩾ 1 , a n − 1 ⩾ 0 , and n is even. Using the 2 × 2 matrices L and R of ( 4.33 ), it is not hard to prove by induction that the matrix equivalent of ( 6.137 ) is

Image

(The proof is part of exercise 87 .) For example,

Image

Finally, therefore, we can use ( 4.34 ) to write a closed form for the fraction in the Stern–Brocot tree whose L -and- R representation is ( 6.137 ):

Image

(This is “ Halphen’s theorem” [ 174 ].) For example, to find the fraction for LRRL we have a 0 \= 0 , a 1 \= 1 , a 2 \= 2 , a 3 \= 1 , and n \= 4 ; equation ( 6.139 ) gives

Image

(We have used the rule K n (x 1 , . . . , x n − 1 , x n + 1 ) \= K n + 1 (x 1 , . . . , x n − 1 , x n , 1 ) to absorb leading and trailing 1 ’s in the parameter lists; this rule is obtained by setting y \= 1 in ( 6.136 ).)

A comparison of ( 6.135 ) and ( 6.139 ) shows that the fraction corresponding to a general node ( 6.137 ) in the Stern–Brocot tree has the continued fraction representation

Image

Thus—as implicitly observed by Halphen [ 174 ] —we can convert at sight between continued fractions and the corresponding nodes in the Stern–Brocot tree. For example,

Image

We observed in Chapter 4 that irrational numbers define infinite paths in the Stern–Brocot tree, and that they can be represented as an infinite string of L ’s and R ’s. If the infinite string for α is R a 0 L a 1 R a 2 L a 3 . . . , there is a corresponding infinite continued fraction

Image

This infinite continued fraction can also be obtained directly: Let α 0 \= α and for k ⩾ 0 let

Image

The a ’s are called the “ partial quotients” of α . If α is rational, say m/n , this process runs through the quotients found by Euclid’s algorithm and then stops (with α k + 1 \= ∞ ).

Is Euler’s constant γ rational or irrational? Nobody knows. We can get partial information about this famous unsolved problem by looking for γ in the Stern–Brocot tree; if it’s rational we will find it, and if it’s irrational we will find all the closest rational approximations to it. The continued fraction for γ begins with the following partial quotients:

Image

Or if they do, they’re not talking.

Therefore its Stern–Brocot representation begins LRLLRLLRLLLLRRRL . . . ; no pattern is evident. Calculations by Richard Brent [ 38 ] have shown that, if γ is rational, its denominator must be more than 10,000 decimal digits long. Therefore nobody believes that γ is rational; but nobody so far has been able to prove that it isn’t.

Well , γ must be irrational, because of a little-known Einsteinian assertion: “ God does not throw huge denominators at the universe.”

Let’s conclude this chapter by proving a remarkable identity that ties a lot of these ideas together. We introduced the notion of spectrum in Chapter 3 ; the spectrum of α is the multiset of numbers Image nα Image , where α is a given constant. The infinite series

Image

can therefore be said to be the generating function for the spectrum of ϕ , where Image is the golden ratio. The identity we will prove, discovered in 1976 by J. L. Davison [ 73 ], uses an infinite continued fraction to connect this generating function with the Fibonacci sequence:

Image

Both sides of ( 6.143 ) are interesting; let’s look first at the numbers Image nϕ Image . If the Fibonacci representation ( 6.113 ) of n is F k 1 + · · · + F k r , we expect nϕ to be approximately F k 1 + 1 + · · · + F k r + 1 , the number we get from shifting the Fibonacci representation left (as when converting from miles to kilometers). In fact, we know from ( 6.125 ) that

nϕ \= F k 1 + 1 + · · · + F k r + 1 − ( Image k 1 + · · · + Image k r ) .

Now Image \= − 1/ϕ and k 1 ≫ · · · ≫ k r ≫ 0 , so we have

Image

and Image k 1 + · · · + Image k r has the same sign as (–1) k r , by a similar argument. Hence

Image

Let us say that a number n is Fibonacci odd (or F -odd for short) if its least significant Fibonacci bit is 1 ; this is the same as saying that k r ( n ) \= 2 . Otherwise n is Fibonacci even ( F -even). For example, the smallest F -odd numbers are 1 , 4 , 6 , 9 , 12 , 14 , 17 , and 19 . If k r ( n ) is even, then n − 1 is F -even, by ( 6.114 ); similarly, if k r ( n ) is odd, then n − 1 is F -odd. Therefore

k r ( n ) is even           Image            n − 1 is F -even .

Furthermore, if k r ( n ) is even, ( 6.144 ) implies that k r ( Image nϕ Image ) \= 2 ; if k r ( n ) is odd, ( 6.144 ) says that k r ( Image nϕ Image ) \= k r ( n ) + 1 . Therefore k r ( Image nϕ Image ) is always even, and we have proved that

Image nϕ Image − 1 is always F -even.

Conversely, if m is any F -even number, we can reverse this computation and find an n such that m + 1 \= Image nϕ Image . (First add 1 in F -notation as explained earlier. If no carries occur, n is (m + 2 ) shifted right; otherwise n is (m + 1 ) shifted right.) The right-hand sum of ( 6.143 ) can therefore be written

Image

How about the fraction on the left? Let’s rewrite ( 6.143 ) so that the continued fraction looks like ( 6.141 ), with all numerators 1 :

Image

(This transformation is a bit tricky! The numerator and denominator of the original fraction having z F n as numerator should be divided by z F n − 1 .) If we stop this new continued fraction at 1/z − F n , its value will be a ratio of continuants,

Image

as in ( 6.135 ). Let’s look at the denominator first, in hopes that it will be tractable. Setting Q n \= K n + 1 (z − F 0 , . . . , z − F n ) , we find Q 0 \= 1 , Q 1 \= 1 +z − 1 , Q 2 \= 1 +z − 1 +z − 2 , Q 3 \= 1 +z − 1 +z − 2 +z − 3 +z − 4 , and in general everything fits beautifully and gives a geometric series

Q n \= 1 + z − 1 + z − 2 + · · · + z −( F n + 2 −1 ) .

The corresponding numerator is P n \= K n (z − F 1 , . . . , z − F n ) ; this turns out to be like Q n but with fewer terms. For example, we have

P 5 \= z − 1 + z − 2 + z − 4 + z − 5 + z − 7 + z − 9 + z − 10 + z − 12 ,

compared with Q 5 \= 1 + z − 1 + · · · + z − 12 . A closer look reveals the pattern governing which terms are present: We have

Image

and in general we can prove by induction that

Image

Therefore

Image

Taking the limit as n → ∞ now gives ( 6.146 ), because of ( 6.145 ).

Exercises

Warmups

1 What are the Image permutations of { 1, 2, 3, 4 } that have exactly two cycles? (The cyclic forms appear in ( 6.4 ); non-cyclic forms like 2314 are desired instead.)

2 There are m n functions from a set of n elements into a set of m elements. How many of them range over exactly k different function values?

3 Card stackers in the real world know that it’s wise to allow a bit of slack so that the cards will not topple over when a breath of wind comes along. Suppose the center of gravity of the top k cards is required to be at least Image units from the edge of the k + 1 st card. (Thus, for example, the first card can overhang the second by at most 1 − Image units.) Can we still achieve arbitrarily large overhang, if we have enough cards?

4 Express 1/1 + 1/3 + · · · + 1/ (2n+1) in terms of harmonic numbers.

5 Explain how to get the recurrence ( 6.75 ) from the definition of U n ( x, y ) in ( 6.74 ), and solve the recurrence.

6 An explorer has left a pair of baby rabbits on an island. If baby rabbits become adults after one month, and if each pair of adult rabbits produces one pair of baby rabbits every month, how many pairs of rabbits are present after n months? (After two months there are two pairs, one of which is newborn.) Find a connection between this problem and the “bee tree” in the text.

If the harmonic numbers are worm numbers, the Fibonacci numbers are rabbit numbers.

7 Show that Cassini’s identity ( 6.103 ) is a special case of ( 6.108 ), and a special case of ( 6.134 ).

8 Use the Fibonacci number system to convert 65 mi/hr into an approximate number of km/hr.

9 About how many square kilometers are in 8 square miles?

10 What is the continued fraction representation of ϕ ?

Basics

11 What is Image , the row sum of Stirling’s cycle-number triangle with alternating signs, when n is a nonnegative integer?

12 Prove that Stirling numbers have an inversion law analogous to ( 5.48 ):

Image

13 The differential operators Image and ϑ \= zD are mentioned in Chapters 2 and 5 . We have

ϑ 2 \= z 2 D 2 + zD ,

because ϑ 2 f ( z ) \= ϑzf ′ ( z ) \= z Image zf ′ ( z ) \= z 2 f ″ ( z ) + zf ′ ( z ) , which is (z 2 D 2 +zD)f(z) . Similarly it can be shown that ϑ 3 \= z 3 D 3 +3 z 2 D 2 +zD . Prove the general formulas

Image

for all n ⩾ 0 . (These can be used to convert between differential expressions of the forms ∑ k α k z k f ( k ) ( z ) and ∑ k β k ϑ k f ( z ) , as in ( 5.109 ).)

14 Prove the power identity ( 6.37 ) for Eulerian numbers.

15 Prove the Eulerian identity ( 6.39 ) by taking the m th difference of ( 6.37 ).

16 What is the general solution of the double recurrence

A n,0 \= a n [ n ⩾ 0 ] ;           A 0,k \= 0 ,           if k > 0 ;
A n,k \= kA n – 1,k + A n – 1,k – 1 ,           integers k , n,

when k and n range over the set of all integers?

17 Solve the following recurrences, assuming that Image is zero when n < 0 or k < 0 :

  1. Image

  2. Image

  3. Image

18 Prove that the Stirling polynomials satisfy

(x + 1 ) σ n (x + 1 ) \= ( x − n ) σ n ( x ) + xσ n − 1 ( x ) .

19 Prove that the generalized Stirling numbers satisfy

Image

20 Find a closed form for Image .

21 Show that if H n \= a n /b n where a n and b n are integers, the denominator b n is a multiple of 2 Image lg n Image . Hint: Consider the number 2 _ Image _lg n Image − 1 H n − Image .

22 Prove that the infinite sum

Image

converges for all complex numbers z , except when z is a negative integer; and show that it equals H z when z is a nonnegative integer. (Therefore we can use this formula to define harmonic numbers H z when z is complex.)

23 Equation ( 6.81 ) gives the coefficients of z/(1 − e −z ),, when expanded in powers of z . What are the coefficients of z/(1 + e −z )? Hint: Consider the identity (1 + e −z )(1 − e −z ) = 1 − e −2z .

24 Prove that the tangent number T 2n + 1 is a multiple of 2 n . Hint: Prove that all coefficients of T 2n ( x ) and T 2n + 1 ( x ) are multiples of 2 n .

25 Equation ( 6.57 ) proves that the worm will eventually reach the end of the rubber band at some time N . Therefore there must come a first time n when he’s closer to the end after n minutes than he was after n − 1 minutes. Show that Image .

26 Use summation by parts to evaluate Image . Hint: Consider also the related sum Image .

27 Prove the gcd law ( 6.111 ) for Fibonacci numbers.

28 The Lucas number L n is defined to be F n + 1 + F n − 1 . Thus, according to ( 6.109 ), we have F 2n \= F n L n . Here is a table of the first few values:

Image

  1. Use the repertoire method to show that the solution Q n to the general recurrence

    Q 0 \= α ;       Q 1 \= β ;       Q n \=    Q n – 1 + Q n – 2 ,        n > 1

    can be expressed in terms of F n and L n .

  2. Find a closed form for L n in terms of ϕ and Image .

29 Prove Euler’s identity for continuants, equation ( 6.134 ).

30 Generalize ( 6.136 ) to find an expression for the incremented continuant K (x 1 , . . . , x m − 1 , x m + y , x m + 1 , . . . , x n ) , when 1 ⩽ m ⩽ n .

Homework exercises

31 Find a closed form for the coefficients Image in the representation of rising powers by falling powers:

Image

(For example, Image , hence Image .)

32 In Chapter 5 we obtained the formulas

Image

by unfolding the recurrence Image in two ways. What identities appear when the analogous recurrence Image is unwound?

33 Table 264 gives the values of Image and Image . What are closed forms (not involving Stirling numbers) for the next cases, Image and Image ?

34 What are Image and Image , if the basic recursion relation ( 6.35 ) is assumed to hold for all integers k and n , and if Image for all k < 0 ?

35 Prove that, for every Image > 0 , there exists an integer n > 1 (depending on Image ) such that H n mod 1 < Image .

36 Is it possible to stack n bricks in such a way that the topmost brick is not above any point of the bottommost brick, yet a person who weighs the same as 100 bricks can balance on the middle of the top brick without toppling the pile?

37 Express Image in terms of harmonic numbers, assuming that m and n are positive integers. What is the limiting value as n → ∞ ?

38 Find the indefinite sum Image .

39 Express Image in terms of n and H n .

40 Prove that 1979 divides the numerator of Image , and give a similar result for 1987 . Hint: Use Gauss’s trick to obtain a sum of fractions whose numerators are 1979 . See also exercise 4 .

Ah! Those were prime years.

41 Evaluate the sum

Image

in closed form, when n is an integer (possibly negative).

42 If S is a set of integers, let S + 1 be the “shifted” set { x + 1 | x ∈ S } . How many subsets of { 1, 2, . . . , n } have the property that S ∪ (S + 1 ) \= { 1, 2, . . . , n + 1 } ?

43 Prove that the infinite sum

    .1

  • .01
  • .002
  • .0003
  • .00005
  • .000008
  • .0000013
           .
           .
           .

converges to a rational number.

44 Prove the converse of Cassini’s identity ( 6.106 ): If k and m are integers such that | m 2 –km–k 2 | \= 1 , then there is an integer n such that k \= ± F n and m \= ± F n + 1 .

45 Use the repertoire method to solve the general recurrence

X 0 \= α ;     X 1 \= β ;       X n \= X n – 1 + X n – 2 + γn + δ .

46 What are cos 36 ° and cos 72 °?

47 Show that

Image

and use this identity to deduce the values of F p mod p and F p + 1 mod p when p is prime.

48 Prove that zero-valued parameters can be removed from continuant polynomials by collapsing their neighbors together:

K n ( x 1 , . . . , x m – 1 , 0, x m + 1 , . . . , x n )

    \= K n – 2 ( x 1 , . . . , x m – 2 , x m – 1 + x m + 1 , x m + 2 , . . . , x n ) , 1 < m < n.

49 Find the continued fraction representation of the number ∑ n ⩾ 1 2 − Image nϕ Image .

50 Define f ( n ) for all positive integers n by the recurrence

          f ( 1 ) \= 1 ;

       f ( 2n ) \= f ( n ) ;

f ( 2n + 1 ) \= f ( n ) + f ( n + 1 ) .

  1. For which n is f ( n ) even?

  2. Show that f ( n ) can be expressed in terms of continuants.

Exam problems

51 Let p be a prime number.

  1. Prove that Image (mod p ), for 1 < k < p .

  2. Prove that Image , for 1 ⩽ k < p .

  3. Prove that Image , if p > 2 .

  4. Prove that if p > 3 we have Image . Hint: Consider Image .

52 Let H n be written in lowest terms as a n /b n .

  1. Prove that Image , if p is prime.

  2. Find all n > 0 such that a n is divisible by 5 .

53 Find a closed form for Image , when 0 ⩽ m ⩽ n . Hint: Exercise 5.42 has the sum without the H k factor.

54 Let n > 0 . The purpose of this exercise is to show that the denominator of B 2n is the product of all primes p such that (p–1) \ (2n) .

  1. Show that S m ( p ) + [ (p–1) \ m ] is a multiple of p , when p is prime and m > 0 .

  2. Use the result of part (a) to show that

    Image

    Hint: It suffices to prove that, if p is any prime, the denominator of the fraction B 2n + [ (p–1) \ (2n) ] /p is not divisible by p .

  3. Prove that the denominator of B 2n is always an odd multiple of 6 , and it is equal to 6 for infinitely many n .

55 Prove ( 6.70 ) as a corollary of a more general identity, by summing

Image

and differentiating with respect to x .

56 Evaluate Image in closed form as a function of the integers m and n . (The sum is over all integers k except for the value k \= m .)

57 The “ wraparound binomial coefficients of order 5 ” are defined by

Image

and Image . Let Q n be the difference between the largest and smallest of these numbers in row n :

Image

Find and prove a relation between Q n and the Fibonacci numbers.

58 Find closed forms for Image and Image . What do you deduce about the quantity Image ?

59 Prove that if m and n are positive integers, there exists an integer x such that F x ≡ m (mod 3 n ).

60 Find all positive integers n such that either F n + 1 or F n − 1 is a prime number.

61 Prove the identity

Image

What is Image ?

62 Let A n \= ϕ n + ϕ − n and B n \= ϕ n − ϕ − n .

  1. Find constants α and β such that A n \= αA n − 1 + βA n − 2 and B n \= αB n − 1 + βB n − 2 for all n ⩾ 0 .

  2. Express A n and B n in terms of F n and L n (see exercise 28 ).

  3. Prove that Image .

  4. Find a closed form for Image .

Bogus problems

Bonus problems

63 How many permutations π 1 π 2 . . . π n of { 1, 2, . . . , n } have exactly k indices j such that

  1. π i < π j for all i < j ? (Such j are called “ left-to-right maxima.”)

  2. π j > j ? (Such j are called “ excedances.”)

64 What is the denominator of Image , when this fraction is reduced to lowest terms?

65 Prove the identity

Image

66 What is Image , the n th alternating row sum of Euler’s triangle?

67 Prove that

Image

68 Show that Image , and find a closed form for Image .

69 Find a closed form for Image .

70 Show that the complex harmonic numbers of exercise 22 have the power series expansion Image .

71 Prove that the generalized factorial of equation ( 5.83 ) can be written

Image

by considering the limit as n → ∞ of the first n factors of this infinite product. Show that Image is related to the general harmonic numbers of exercise 22 .

72 Prove that the tangent function has the power series ( 6.92 ), and find the corresponding series for z/ sin z and ln (( tan z )/z ).

73 Prove that z cot z is equal to

Image

for all integers n ⩾ 1 , and show that the limit of the k th summand is 2z 2 / (z 2 − k 2 π 2 ) for fixed k as n → ∞ .

74 Find a relation between the numbers T n (1) and the coefficients of 1/ cos z .

75 Prove that the tangent numbers and the coefficients of 1/ cos z appear at the edges of the infinite triangle that begins as follows:

1
0         1
1        1        0
0        1        2        2
5        5        4        2        0
0       5       10       14       16       16
61       61       56       46       32       16       0

Each row contains partial sums of the previous row, going alternately leftto-right and right-to-left. Hint: Consider the coefficients of the power series ( sin z + cos z )/ cos (w + z ) .

76 Find a closed form for the sum

Image

and show that it is zero when n > 0 is even.

77 When m and n are integers, n ⩾ 0 , the value of σ n ( m ) is given by ( 6.48 ) if m < 0 , by ( 6.49 ) if m > n , and by ( 6.101 ) if m \= 0 . Show that in the remaining cases we have

Image

78 Prove the following relation that connects Stirling numbers, Bernoulli numbers, and Catalan numbers:

Image

79 Show that the four chessboard pieces of the 64 \= 65 paradox can also be reassembled to prove that 64 \= 63 .

80 A sequence defined by the recurrence A 1 \= x , A 2 \= y , and A n \= A n − 1 + A n − 2 has A m \= 1000000 for some m . What positive integers x and y make m as large as possible?

81 The text describes a way to change a formula involving F n ± k to a formula that involves F n and F n + 1 only. Therefore it’s natural to wonder if two such “reduced” formulas can be equal when they aren’t identical in form. Let P ( x, y ) be a polynomial in x and y with integer coefficients. Find a necessary and sufficient condition that P (F n + 1 , F n ) \= 0 for all n ⩾ 0 .

82 Explain how to add positive integers, working entirely in the Fibonacci number system.

83 Is it possible that a sequence Image A n Image satisfying the Fibonacci recurrence A n \= A n − 1 + A n − 2 can contain no prime numbers, if A 0 and A 1 are relatively prime?

84 Let m and n be odd, positive integers. Find closed forms for

Image

Hint: The sums in exercise 62 are Image and Image .

85 Characterize all N such that the Fibonacci residues F n mod N for n ⩾ 0 form the complete set { 0, 1, . . . , N − 1 } . (See exercise 59 .)

86 Let C 1 , C 2 , . . . be a sequence of nonzero integers such that

gcd (C m , C n ) \= C gcd ( m,n )

for all positive integers m and n . Prove that the generalized binomial coefficients

Image

are all integers. (In particular, the “ Fibonomial coefficients” formed in this way from Fibonacci numbers are integers, by ( 6.111 ).)

87 Show that continuant polynomials appear in the matrix product

Image

and in the determinant

Image

88 Generalizing ( 6.146 ), find a continued fraction related to the generating function ∑ n ⩾ 1 z Image nα Image , when α is any positive irrational number.

89 Let α be an irrational number in (0 . . 1) and let a 1 , a 2 , a 3 , . . . be the partial quotients in its continued fraction representation. Show that | D (α, n) | < 2 when n \= K (a 1 , . . . , a m ) , where D is the discrepancy defined in Chapter 3 .

90 Let Q n be the largest denominator on level n of the Stern–Brocot tree. (Thus Image Q 0 , Q 1 , Q 2 , Q 3 , Q 4 , . . . Image \= Image 1, 2, 3, 5, 8, . . . Image according to the diagram in Chapter 4 .) Prove that Q n \= F n + 2 .

Research problems

91 What is the best way to extend the definition of Image to arbitrary real values of n and k ?

92 Let H n be written in lowest terms as a n /b n , as in exercise 52 .

  1. Are there infinitely many n with p \ a n , for some fixed prime p ?

  2. Are there infinitely many n with b n \= lcm (1, 2, . . . , n) ? (Two such values are n \= 250 and n \= 1000 .)

93 Prove that γ and e γ are irrational.

94 Develop a general theory of the solutions to the two-parameter recurrence

Image

assuming that Image when n < 0 or k < 0 . (Binomial coefficients, Stirling numbers, Eulerian numbers, and the sequences of exercises 17 and 31 are special cases.) What special values (α, β, γ, α ′ , β ′ , γ ′ ) yield “fundamental solutions” in terms of which the general solution can be expressed?

95 Find an efficient way to extend the Gosper–Zeilberger algorithm from hypergeometric terms to terms that may involve Stirling numbers.