taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Volume C1 · Basic concepts · TAOCP Section 1.2

Mathematical preliminaries

Draft. This chapter is written and checked by the tools of the project, and a person has not reviewed it yet. Read it with care.

Read it next to Section 1.2 of the book.

Contents
  1. Mathematical preliminaries

Mathematical preliminaries

Overview

Section 1.2 of TAOCP is a one-page introduction to the mathematical sections 1.2.1 to 1.2.11.3. Mathematics serves the book in two ways: it states what an algorithm does, and it counts how long the algorithm runs. The first use needs only the notation of Section 1.1. The second use needs sums, recurrences, factorials, binomial coefficients, generating functions and asymptotic estimates, and these are the topics of the subsections. Most of the work uses algebra and a little calculus, and a more advanced tool is explained or cited where it appears.

The introduction suggests a first pass that skims the subsections for the meaning of the formulas and returns to the proofs later. Section 1.2.1 is the exception, since it is about programs, and Section 1.2.10 deserves care, since the analysis of algorithms starts there.

The section has no numbered item, so this chapter has no Node line. It uses nothing before it. It sets the order of the other chapters of C1 that follow Section 1.2.

The ideas

Two uses of mathematics. When an algorithm is only described, the notation of Section 1.1 is enough: assignment, the step numbers and a few tests. When an algorithm is analyzed, the question changes. The analysis asks how many times each step runs, as a function of the input size nn. The count is often a sum of terms such as ∑k=1n1/k\sum_{k=1}^{n} 1/k, or it is defined by a recurrence, or it is a number of arrangements. So the mathematics of Section 1.2 is the mathematics of counting steps. Section 1.3.2 shows the first complete case: the time of a program for the largest of nn numbers is a formula in nn and in the number AA of changes of the maximum, and Section 1.2.10 finds the average of AA.

The plan of the eleven sections. The sections form a toolbox in four groups.

  1. Basic tools. Section 1.2.1 is induction and the proof of an algorithm by assertions. Section 1.2.2 fixes the real numbers, powers and logarithms. Section 1.2.3 is the sigma notation and the rules for changing a sum. Section 1.2.4 is the floor, the ceiling, the remainder and congruences.
  2. Counting objects. Section 1.2.5 counts arrangements: permutations, n!n!, and the gamma function as an extension of n!n! to non-integers. Section 1.2.6 is the binomial coefficients, the longest section of the group. Section 1.2.7 is the harmonic numbers HnH_n. Section 1.2.8 is the Fibonacci numbers.
  3. One method for sequences. Section 1.2.9 is the generating function: put a sequence into a power series, work on the series, and read the answer back from the coefficients.
  4. Analysis and estimates. Section 1.2.10 analyzes one small algorithm in full, with mean and variance. Sections 1.2.11.1 to 1.2.11.3 are the OO-notation, Euler's summation formula with the Bernoulli numbers, and three sums that need both.

The table gives, for each section, its main tool and a use of the tool later in the book. The uses are examples. Each later chapter of C1 states its own links.

Section Main tool Where the tool comes back
1.2.1 induction, invariants each proof of an algorithm in the book
1.2.2 lg⁡\lg, ln⁡\ln, powers the cost of a divide and conquer method, and each use of a logarithm
1.2.3 ∑\sum, the bracket [ ⋅ ][\,\cdot\,] each running time that is a sum of step counts
1.2.4 ⌊x⌋\lfloor x \rfloor, ⌈x⌉\lceil x \rceil,  mod \bmod hashing, random numbers, the analysis of halving
1.2.5 n!n!, falling and rising powers the count of orderings in sorting
1.2.6 (rk)\binom{r}{k} and its identities counting of subsets, trees and paths
1.2.7 HnH_n the average of AA in 1.2.10, and many averages in sorting and searching
1.2.8 FnF_n, ϕ\phi Euclid's algorithm in Section 4.5.3, Fibonacci search
1.2.9 G(z)=∑anznG(z) = \sum a_n z^n counting of trees, recurrences, the analysis of sorting
1.2.10 mean, variance, G′(1)G'(1) each later average-case analysis
1.2.11 OO, Euler's formula, Stirling's series each approximate value of a sum or a product

How the sections depend on each other. Section 1.2.1 comes first for all of them. Sections 1.2.2 to 1.2.4 need only school algebra and Section 1.2.1. Section 1.2.5 needs the sums of 1.2.3 and the floor of 1.2.4, and it states Stirling's formula, which Section 1.2.11.2 proves. Section 1.2.6 needs 1.2.3 and 1.2.5. Section 1.2.7 needs 1.2.3 and 1.2.6. Section 1.2.8 needs 1.2.1, 1.2.4 and 1.2.6. Section 1.2.9 needs 1.2.6 to 1.2.8. Section 1.2.10 needs 1.2.3, 1.2.5, 1.2.7 and 1.2.9. Section 1.2.11.1 needs only the sums and the logarithms. Section 1.2.11.2 needs 1.2.7 and the integral calculus. Section 1.2.11.3 needs 1.2.11.1, 1.2.11.2 and the gamma function of 1.2.5. If a reader skips a section, the list shows which later sections still stand.

How to study the plan. A reader has a few choices, and the chapters of C1 are written so that each one works.

  • First reading, in a hurry. Read Section 1.2.1 in full: it is the only one that is about programs. Read the definitions of Sections 1.2.2 to 1.2.4, and learn the notation ∑\sum, ⌊x⌋\lfloor x \rfloor and  mod \bmod. Skim 1.2.5 to 1.2.9 for the statements of the main results: n!n!, (nk)\binom{n}{k}, HnH_n and FnF_n with their growth, and the idea of a generating function. Read Section 1.2.10 with care. Skip the sections 1.2.11.x for now, and learn only what O(n)O(n) means. Then go on to Section 1.3.
  • Strong background. A reader who knows induction, sums, binomial coefficients and generating functions from a course on discrete mathematics can read Section 1.2.1 for its treatment of algorithms, take the notation of 1.2.2 to 1.2.9 from the summary tables of the chapters, and spend the time on 1.2.10 and 1.2.11. These two are the ones that the analysis chapters of the book use most. The reader should still do a few exercises of each section, since the notation differs from other books: the bracket of Section 1.2.3, the rising and falling powers of Section 1.2.5 and the sign convention of the Stirling numbers are all the habits of this book.
  • Second reading, later. When Chapters 3 to 6 apply a formula, return to its section and read the proof. A formula that was only a rule on the first pass is then a tool with a reason.

Which parts are used all the time. Four items come back on almost every page of the later chapters: the sigma notation and the four rules of Section 1.2.3, the floor and the remainder of Section 1.2.4, the binomial coefficients of Section 1.2.6, and the harmonic numbers of Section 1.2.7. The OO-notation of Section 1.2.11.1 is used in every statement about a running time. Generating functions (Section 1.2.9) are a method more than a table, and the reader should be able to use them, not only read them.

A small check of the plan. The reader can test whether a section is needed by a question about the algorithm of Section 1.3.2 for the largest of nn numbers. The listing of TAOCP takes 5n+3A+55n + 3A + 5 units, and the chapter of C1 for Section 1.3.2 has its own listing, which takes 5n+4A+35n + 4A + 3 units. To state such a formula, a reader needs the sums of 1.2.3 and the induction of 1.2.1. To find the average of AA for random input, the reader needs the permutations of 1.2.5, the harmonic numbers of 1.2.7 and the generating function of 1.2.9, and Section 1.2.10 puts them together: the average is Hn−1H_n - 1. For n=5n = 5 the average is 137/60−1=77/60137/60 - 1 = 77/60, and the average time of the TAOCP listing is 25+3⋅77/60+5=33.8525 + 3 \cdot 77/60 + 5 = 33.85 units. Over all 120120 orders of five distinct numbers, AA takes the values 0,1,2,3,40, 1, 2, 3, 4 for 24,50,35,10,124, 50, 35, 10, 1 orders, so the total time is 120⋅30+3⋅154=4062120 \cdot 30 + 3 \cdot 154 = 4062 units, and the average is 4062/120=33.854062/120 = 33.85 units. The question uses five of the eleven sections, so the plan has a reason.

Definitions, results and proofs

Section 1.2 has no definition, theorem or numbered equation. The sections that follow state them, and the chapters of C1 for those sections have the blocks. The page of the book has one claim that a reader can check at once: that the calculations need only college algebra and a little calculus. The chapters of C1 test this claim in each section, and they say where a deeper tool is used. The parts that go beyond the claim are few: the later sections on the gamma function, on asymptotic series and on Euler's formula use real analysis beyond a first course, and each of them says so where it happens.

Algorithms and programs

Section 1.2 has no algorithm and no program. The later sections of the group have three algorithms. Section 1.2.1 has Algorithm 1.2.1I and Algorithm 1.2.1E. Section 1.2.10 has Algorithm 1.2.10M, which Program 1.3.2M of Section 1.3.2 turns into MIX code.

The exercises

The section has no exercise. The advice of the page is to try a few exercises of each later section on the first reading. The exercises of Section 1.2.1 are the best start, then those of 1.2.3, 1.2.4 and 1.2.10. The tables of the later chapters of C1 give the rating and the kind of each exercise, so that the reader can pick the easy ones first.

Lean

Section 1.2 has no statement, so there is nothing to state in Lean. Each later chapter of C1 has its own Lean part.

Notes and history

The page is written to calm a reader who fears that the book is a book of mathematics. It says the opposite of what a reader may expect: the mathematics is a means, and the reader may skim it. The same advice is good for a student of the handbook. The handbook proves each result in full, so that a reader who wants the proof has it, and a reader who does not can read only the statements and the worked examples.

For the same set of tools, with more worked examples and exercises, see Graham, Knuth and Patashnik, Concrete Mathematics, which grew from a course on this material.

Section 1.2 of TAOCP has no theorem of its own. It is a short page that tells the reader what the eleven sections after it are for, and how to read them. This chapter of C1 gives the plan of Sections 1.2.1 to 1.2.11.3, says which parts a reader with a strong background can skip, and says which parts the rest of the book uses all the time.

The source of this page. Something is wrong? Report it.