Preliminaries
Most entries assume four small bodies of background: how computers store real numbers, how to measure the size of a vector or matrix, a little probability, and complex numbers. Each is summarised here in enough detail to read the book, with a pointer to where it is used. A reader who has met them can skip the page and return when a later entry leans on one of them.
Floating-point arithmetic and the three kinds of error
A computer stores a real number as a floating-point number: a sign, a fixed number of significant binary digits (the
significand) and an exponent, so that the value is . IEEE double precision, the type behind Rust’s
f64, has a 53-bit significand. Two consequences shape almost every entry:
- Only some numbers exist. Between and the representable numbers are spaced apart. This spacing is the machine epsilon, written throughout the book. Near a number the spacing is about , so a double carries about 16 significant decimal digits, whatever the magnitude. The decimal is not representable, which is why evaluates to and not .
- Every operation rounds. The computed result of , for one of , is the exact result moved to the nearest representable number. That is the rounding model: The book’s tolerances and “accuracy” rows are usually stated in multiples of ; the factor of two between and rarely matters.
Individual roundings are tiny. Trouble arises from what the algorithm does with them, and it helps to keep three sources of error apart.
- Truncation (discretisation) error is made by the method, even in exact arithmetic: replacing a derivative by a difference quotient, an integral by a sum, an infinite series by its first terms. It shrinks as the step shrinks or the work grows. Most “order of convergence” statements are about this error.
- Rounding error is made by the arithmetic. It does not shrink as the work grows; if anything it accumulates.
- Conditioning is a property of the problem, not the method: how strongly the exact answer reacts to small changes in the data. A problem with large condition number turns the unavoidable rounding of the input into a large error in the answer, whatever algorithm is used.
Cancellation is the most important way in which rounding becomes visible. Subtracting two nearly equal numbers cancels their leading digits and leaves the digits that were already wrong. For example, in double precision is stored with an error of up to , which is a relative error of about in the small number that we are trying to recover. Computing gives instead of : eight of the sixteen digits are gone in one subtraction. The optimal step in finite-difference derivatives is exactly the balance between truncation error (which wants a small ) and the cancellation in (which wants a large one).
Errors in an algorithm’s output are described in two complementary ways. The forward error is the distance between the computed answer and the true answer . The backward error asks instead: for which slightly perturbed input would be the exact answer? An algorithm is backward stable if that perturbation is of the size of rounding error. The two are linked by conditioning:
So a backward stable algorithm applied to a well-conditioned problem is accurate, while on an ill-conditioned problem nothing can be done by choosing a better algorithm. Linear systems develop this in detail.
Norms: measuring the size of vectors and matrices
Error statements need a single number for the size of a vector or matrix. For the common choices are
The 2-norm is the Euclidean length and is the default when no subscript is written. A matrix norm measures the largest amount by which the matrix can stretch a vector. The induced norm is , which gives
- = the largest absolute column sum,
- = the largest absolute row sum,
- = the largest singular value (the 2-norm, costly to compute exactly but the natural one in theory),
and the Frobenius norm , which treats the matrix as one long vector and is cheap. For these are , , and : the norms differ by a modest factor, which is why the choice usually does not change a conclusion, only a constant. Induced norms satisfy and .
The condition number of a nonsingular matrix is . For the matrix above . It is the factor in the rule of thumb of the previous section for solving : a relative perturbation of size in or can change the solution by a relative , so with one loses about of the 16 digits.
Probability in brief
The random numbers, statistics, machine learning and information theory chapters use the following ideas without redeveloping them.
- A random variable is a quantity whose value is determined by chance. It has a distribution: for a discrete the probabilities , for a continuous a density with .
- The expectation (mean) is the probability-weighted average, or . It is linear: always.
- The variance measures spread, and the standard deviation has the units of .
- and are independent if knowing one tells nothing about the other. Then and variances add, . Without independence the second statement fails.
- An estimator computed from data is itself random. It is unbiased if .
Two results explain why averaging works, and they are the foundation of Monte Carlo methods, bootstrap resampling and most of the error estimates in the book. Let be independent with the same mean and variance , and their average.
- Law of large numbers. as .
- Central limit theorem. is close to normally distributed with mean and standard deviation , and the approximation improves with . Averaging values therefore divides the typical error by , and each extra digit of accuracy costs a hundred times as many samples.
For example, the mean of independent draws with is within of about 68% of the time and within about 95% of the time, whatever the shape of the distribution being sampled.
Complex numbers
A complex number is with , or in polar form with and ; Euler’s formula links the two. Multiplying complex numbers multiplies their magnitudes and adds their angles, which is why is the natural way to describe a rotation or a phase. The roots of unity , , are the equally spaced points on the unit circle that satisfy ; they underlie the fast Fourier transform. A function of a complex variable is analytic in a region if it is complex-differentiable there. That is a much stronger condition than real differentiability: an analytic function is infinitely differentiable, equals its Taylor series near each point, and its behaviour on a real interval is controlled by where its nearest singularities lie in the complex plane. That is the source of the geometric convergence rates in polynomial interpolation, tanh-sinh quadrature and contour integration. Signal processing and electromagnetics write for the imaginary unit.