Three families in one table
Three kinds of function grow without limit: logarithms such as , powers such as , and exponentials such as . For small n it is hard to tell them apart, and the order can even change.
At n = 4, and , while . At n = 8 the three are 3, 64 and 256. At n = 16 they are 4, 256 and 65536. Doubling n adds 1 to , multiplies by 4, and squares .
Before n = 4 the two are not in this order everywhere. At n = 3, is larger than , and they are equal at n = 2, where both are 4. From n = 5 on, is ahead and stays ahead: 32 against 25, then 64 against 36.
The gold curve is and the plain curve is . They meet at x = 2 and at x = 4. Between them is higher, 9 against 8 at x = 3; beyond x = 4, pulls away, 64 against 36 at x = 6.
One order, in the long run
The three families rank in one order once n is large enough: every logarithm is below every power with k > 0, and every power is below every exponential with a > 1. No choice of constants changes that order. A constant in front, such as , only moves the point where the order takes over.
The words "large enough" carry the meaning. Compare , the power with , with . They are equal at n = 4, where both are 2, and at n = 16, where both are 4. Between those two the logarithm is ahead: at n = 8, and is about 2.83. From n = 17 on, is ahead for good.
A small power can take a very long time. The tenth root of x is below ln x from about x = 3.06 until x is about , and above it from there on.
A small base also only delays the crossing. grows by just a tenth each step, yet it passes for good at n = 96: is about 9412, and .
The gold curve is and the plain curve is . They cross at x = 4 and at x = 16; between the two crossings the logarithm is higher, and after x = 16 the square root stays above it.
A large power only delays the crossing
Raising the power pushes the crossing point further out. passes for good at n = 5, at n = 10, where and , and at n = 59.
Even is overtaken. At n = 996, is still the larger, by a hair; from n = 997 on, is ahead and never falls behind again. The crossing is late, but it comes.
The first n from which is larger than each power for every n after it. The power goes up fifty-fold from to , and the crossing moves from 5 to 997.
Why the exponential must win
Compare what one step does to each. Going from n to n + 1 multiplies by 2, always. It multiplies by , and that factor falls toward 1 as n grows, because falls toward 0.
For k = 100, the factor is below 1.5 from n = 247 on. From there, each step multiplies the ratio by less than 1.5 ÷ 2 = 0.75. A number cut by at least a quarter at every step falls toward 0, however large it starts, so the ratio drops below 1, and then is the larger.
The same argument works for any power k and any base a > 1. In the end falls below any number larger than 1, so it falls below a number c between 1 and a, and from then on each step multiplies the ratio by less than , which is less than 1.
Written as limits
The order can be written with limits: as for every k and every a > 1, and as well. A ratio that tends to 0 says the bottom outgrows the top.
The fall need not start at once. The ratio is 0.5 at n = 1, rises to 4 at n = 4, and only then falls: about 0.98 at n = 10 and about 0.0076 at n = 20.
The logarithm limit is the same fact in disguise. Put n = 2ᵐ. Then , so , which is a power over an exponential with k = 1, and it tends to 0.
The ratio . At the whole numbers its largest value is 4, at n = 4; after that it sinks toward 0, and by n = 20 it is below 0.01.
The usual mistakes
Reading the order as true for every n. is not larger than at n = 3, and is larger than at n = 8. The order says what happens from some point on.
Trusting a large power. is ahead of for a long stretch, from n = 2 up to n = 996, and is still overtaken.
Treating a faster computer as a fix for exponential work. A machine 64 times as fast lets a job of steps grow by only 6, because , while a job of steps grows 8 times, because .
Sorting, searching and forecasting
In the first application, and steps are compared at powers of 2, where the logarithm is a whole number, and they are equal at n = 256. The second sets computers that double in speed every 2 years against a model whose running time grows as a fourth power.
Worked example: Two Sorting Programs and a Search Through Every Group on a Sensor Chip: Where One Program Overtakes the Other, and the Largest Job Each Finishes in a Second
Question A sensor chip carries out one million basic steps per second. To sort a list of n readings, program A takes 32nlog2 n steps and program B takes n2 steps. A third task, choosing the best group of readings by checking every possible group, takes 2n steps for n readings. (a) For which list lengths n ≥ 2 does B take fewer steps than A, and for which n do the two take the same number? (b) What is the largest n that B can sort, and the largest n for which the group search finishes, in no more than one second? What are these two numbers on a chip 64 times as fast?
1.B takes fewer steps than A when n2 < 32nlog2 n. Divide both sides by n: n < 32log2 n, which compares n with a multiple of its logarithm.
Dividing by n, B takes fewer steps than A when n < 32log2 n. 2.Try powers of 2, where log2 n is a whole number. At n = 128: 32 × 7 = 224, more than 128. At n = 256: 32 × 8 = 256, equal. At n = 512: 32 × 9 = 288, less than 512.
At powers of 2 the logarithm is a whole number: 32log2 n is 224, 256 and 288 at n = 128, 256 and 512. 3.(a) The ratio nlog2 n is 2 at n = 2 and rises for every n ≥ 3, so it reaches 32 only once, at n = 256. B takes fewer steps for 2 ≤ n < 256, the two take the same number, 65536, at n = 256, and A takes fewer from then on.
(a) The curves meet once, at n = 256, with 65536 steps each. B takes fewer steps below 256 and A above it. 4.One second is 1000000 steps. For B, n2 ≤ 1000000 gives n ≤ 1000. For the group search, 2n ≤ 1000000 gives n ≤ log2 1000000 ≈ 19.9, so n ≤ 19: 219 = 524288 and 220 = 1048576.
In one second of a million steps B sorts up to 1000 readings, and the group search handles up to 19. 5.A chip 64 times as fast carries out 64000000 steps in a second. For B, n2 ≤ 64000000 gives n ≤ 8000. For the group search, 64 = 26 adds 6 to the logarithm: n ≤ 19.9 + 6 = 25.9, so n ≤ 25, since 225 = 33554432 and 226 = 67108864.
On a chip 64 times as fast, B sorts 8 times as many readings, but 64 = 26 adds only 6 to the group search. 6.(b) In one second B sorts up to 1000 readings and the group search handles up to 19. On the faster chip these become 8000 and 25: eight times as many readings for B, but only 6 more for the group search.
(b) In one second: 1000 and 19. On the faster chip: 8000 and 25.
Answer: (a) B takes fewer steps for 2 ≤ n < 256, the same number at n = 256, and more for n > 256; (b) B sorts up to 1000 readings and the group search handles up to 19; on the faster chip, 8000 and 25
Common mistakes
- Concluding from small lists that B is always faster: at n = 16, B takes 256 steps and A takes 32 × 16 × 4 = 2048. The logarithm grows more slowly than n, so 32log2 n falls behind n in the end.
- Multiplying the group search's 19 by 64, or by 8 as for B. Each extra reading doubles its steps, so a chip 64 = 26 times as fast buys only 6 more readings.
Worked example: A Weather Model on a Finer Grid and Computers That Double in Speed: How Long Until It Runs in Time
Question A weather service runs its forecast model on a grid of points 10 km apart, and one run takes 1 hour. Making the spacing k times finer multiplies the running time by k4: there are k times as many points in each of three directions, and k times as many time steps. The service's computers double in speed every 2 years. (a) After how many years does the model with a spacing of 5 km first run in 1 hour? (b) What is the finest spacing at which the model runs in 1 hour after 24 years? A rival model's running time grows as k6 instead. What is the finest spacing at which it runs in 1 hour after 24 years?
1.The speed doubles once every 2 years, so after y years the computers are 2y/2 times as fast. A model k times finer runs in 1 hour when 2y/2 ≥ k4.
The speed doubles once every 2 years, so after y years it has grown 2y/2 times. 2.A spacing of 5 km is k = 2 times finer, so the run takes 24 = 16 times as long. The computers must be 16 = 24 times as fast: 2y/2 ≥ 24, so y2 ≥ 4.
Halving the spacing multiplies the running time by 24 = 16. 3.(a) The 5 km model first runs in 1 hour after 8 years. Check: 8 years hold 4 doublings, and 24 = 16.
(a) Four doublings make 16 times the speed: 8 years. 4.After 24 years there are 12 doublings, so the computers are 212 = 4096 times as fast. The model needs k4 ≤ 4096, and 4096 = 212 = 84, so k ≤ 8. The finest spacing is 10 ÷ 8 = 1.25 km.
After 24 years the speed has grown 212 = 4096 = 84 times, so the grid can be 8 times finer. 5.The rival model needs k6 ≤ 4096, and 4096 = 212 = 46, so k ≤ 4. Its finest spacing is 10 ÷ 4 = 2.5 km.
For the rival, 4096 = 46, so its grid can be only 4 times finer. 6.(b) After 24 years the model runs at a spacing of 1.25 km and the rival at 2.5 km. Both keep improving: k4 = 2y/2 gives k = 2y/8, and k6 = 2y/2 gives k = 2y/12, so a higher power only slows the exponential growth in k and never stops it.
(b) After 24 years: 1.25 km for the model and 2.5 km for the rival.
Answer: (a) 8 years; (b) 1.25 km for the model, and 2.5 km for the rival
Common mistakes
- Taking the running time as twice as long when the spacing is halved. There are twice as many points in each of three directions and twice as many time steps, so the run takes 24 = 16 times as long.
- Taking the computers as 2 × 12 = 24 times as fast after 24 years. Twelve doublings multiply the speed by 212 = 4096, not by 24.