Chapter 01
Medium

Floating-Point Arithmetic and Rounding Error

00 · Symbol Glossary

$\beta$beta — base

The integer base of the digit expansion, with β≥2\beta\geq 2. Decimal examples in this chapter use β=10\beta=10. The binary model uses β=2\beta=2. Read "β\beta" as "base beta."

$p$p — precision

The number of significant digits kept in a normal floating-point number. Precision is a count of digits, not a statement about a particular device. With β=10\beta=10 and p=4p=4, every normal number has the shape ±d0.d1d2d3×10e\pm d_0.d_1 d_2 d_3\times 10^{e}.

$F$F — floating-point set

The finite set of normal floating-point numbers determined by β\beta, pp, and the exponent bounds. Rounding is a map from a real number in range into FF. Read "x∈Fx\in F" as "x is a floating-point number."

$\varepsilon_{\mathrm{mach}}$epsilon mach — machine epsilon

The gap β1−p\beta^{1-p} between 11 and the next larger number in FF. It is a property of the set FF, not of an algorithm. Linear Algebra 20 uses this same gap.

$u$u — unit roundoff

Half a machine epsilon under round-to-nearest: u=12β1−pu=\tfrac12\beta^{1-p}. A single rounding of a real in the normal range changes it by a relative amount of at most uu.

$\mathrm{fl}(x)$fl of x — rounded value

The floating-point number obtained by rounding the real xx into FF. Read "fl of x." For an operation ⋆\star, fl(x⋆y)\mathrm{fl}(x\star y) means the exact real result is formed and then rounded.

$\delta$delta — relative rounding factor

The real number, depending on the operands, for which the rounded result equals the exact result times 1+δ1+\delta, with ∣δ∣≤u|\delta|\leq u. It is not a constant defect: each operation has its own δ\delta.

$E_{\mathrm{abs}},\ E_{\mathrm{rel}}$absolute and relative error

Eabs=∣x^−x∣E_{\mathrm{abs}}=|\hat x-x| and, when x≠0x\neq 0, Erel=∣x^−x∣/∣x∣E_{\mathrm{rel}}=|\hat x-x|/|x|. Unit roundoff controls the second of these for one rounding. Cancellation inflates the second while leaving the first small.

$\kappa_{\mathrm{sub}}$kappa sub — condition of subtraction

The amplification (∣x∣+∣y∣)/∣x−y∣(|x|+|y|)/|x-y| of relative perturbations through the map (x,y)↦x−y(x,y)\mapsto x-y. A large value means the subtraction is sensitive. The matrix condition number in Linear Algebra 20 is the same idea for a linear map.


01 · A Finite Subset of the Reals

Exact real arithmetic has infinite precision. A calculation that keeps a fixed number of digits cannot. The object of this chapter is that restriction, written as a set of real numbers and a rounding map, together with the error bounds the map satisfies. Nothing below depends on a programming language. A four-digit decimal calculation done by hand is the same mathematical model as a binary system with a larger pp.

The practical distinction the bounds explain is this. Rounding 123.448123.448 to four significant digits moves it by a few hundredths, a small relative change. Subtracting two such rounded prices can move the difference by a large relative amount, because the digits that survived rounding are precisely the digits the two prices share. Later sections turn that observation into a theorem.

Definition — Normal floating-point numbers

Fix integers β≥2\beta\geq 2, p≥1p\geq 1, and exponent bounds emin⁡≤emax⁡e_{\min}\leq e_{\max}. A normal floating-point number is a real number

x=± m×β e−p,m∈Z,βp−1≤m≤βp−1,emin⁡≤e≤emax⁡.x=\pm\, m\times \beta^{\,e-p},\qquad m\in\mathbb{Z},\quad \beta^{p-1}\leq m\leq \beta^{p}-1,\quad e_{\min}\leq e\leq e_{\max}.

The integer mm is the integer significand. Equivalently, in scientific form,

x=± (d0.d1…dp−1)β×β e−1,d0∈{1,…,β−1},x=\pm\,(d_0.d_1\ldots d_{p-1})_{\beta}\times \beta^{\,e-1},\qquad d_0\in\{1,\ldots,\beta-1\},

so the leading digit is nonzero. The factor (d0.d1…dp−1)β(d_0.d_1\ldots d_{p-1})_{\beta} is the significand (or mantissa), and e−1e-1 in this second writing is the exponent of the scientific form. The set of all such xx, together with 00, is denoted FF.

Plain language: keep a fixed number of digits, require the first digit to be nonzero, and attach a power of the base. Those rules name a finite list of real numbers, written FF, together with zero. A real that is not on the list is not a floating-point number, however close it sits to one that is.

The two displays are the same set. For β=10\beta=10 and p=4p=4, the integer form 1234×10−21234\times 10^{-2} is the scientific form 1.234×1011.234\times 10^{1}. Normalization — the demand that d0≠0d_0\neq 0, or equivalently βp−1≤m\beta^{p-1}\leq m — prevents the same real from being written with two different exponents inside FF. Without it, 1.234×1011.234\times 10^{1} and 0.1234×1020.1234\times 10^{2} would be two names for one number, and "the" gap between adjacent elements would be undefined.

In the binade βe−1≤∣x∣<βe\beta^{e-1}\leq |x|<\beta^{e} the admissible mm step by 11, so adjacent elements of FF are spaced βe−p\beta^{e-p} apart. The spacing is proportional to the magnitude. That is the structural fact behind every relative-error bound in this chapter.

Example — Four decimal digits, two binades

Take β=10\beta=10, p=4p=4, and exponents wide enough that every number below is normal.

  • At 1=1.000×1001=1.000\times 10^{0} the successor in FF is 1.0011.001, so the forward gap is 0.001=β1−p0.001=\beta^{1-p}. The predecessor is 0.99990.9999, one binade lower, where the gap is 0.00010.0001.
  • At 1000=1.000×1031000=1.000\times 10^{3} the successor is 10011001 and the forward gap is 11. The predecessor is 999.9999.9. Throughout [1000,9999][1000,9999] the gap stays 11.
  • The real 1000.41000.4 lies strictly between 10001000 and 10011001, so it is not an element of FF.

A price quoted near 10001000 and a rate quoted near 11 are not being recorded to the same absolute tolerance, even though both keep four digits.

Binary parameters, including the IEEE set

For β=2\beta=2 the leading digit of a normal number is necessarily 11. Describing mm then requires only the remaining p−1p-1 bits; the set FF is unchanged. The binary64 normal numbers are exactly this model with β=2\beta=2, p=53p=53, emin⁡=−1022e_{\min}=-1022, and emax⁡=1023e_{\max}=1023. Then εmach=2−52\varepsilon_{\mathrm{mach}}=2^{-52}. The specification also fixes a tie-breaking rule, recorded in the next section. Subnormal numbers, which fill the gap below the smallest normal with constant absolute spacing, are not needed for the identities below; the bounds assume a normal result.

❌ What Breaks — Treating spacing as an absolute constant

Suppose four decimal digits are in use, and a spread of 0.40.4 is treated as "safely larger than the last digit" because the last digit near 11 is 0.0010.001.

Why it breaks: the gap at magnitude 10310^{3} is 11, not 0.0010.001. The real 1000.41000.4 is not in FF, and both 10001000 and 10011001 are admissible roundings of nearby reals. A tolerance copied from the binade of 11 does not apply in the binade of 10001000.

Consequence: an absolute error budget with no factor of ∣x∣|x| is not a floating-point error budget. The quantity that is uniform across binades is the relative gap, computed next.


02 · Rounding and the Standard Model

FF is discrete. A real xx in the normal range is replaced by a nearby element of FF.

Definition — Rounding, machine epsilon, unit roundoff

Let x≠0x\neq 0 lie between the least and greatest positive elements of FF, and let x−<x+x_{-}<x_{+} be the adjacent elements of FF with x−≤x≤x+x_{-}\leq x\leq x_{+}. Round-to-nearest sets fl(x)\mathrm{fl}(x) equal to whichever of x−x_{-}, x+x_{+} is closer to xx. On an exact tie either neighbor may be chosen; the binary64 rule chooses the neighbor whose integer significand is even. Chopping always chooses the neighbor toward 00.

The machine epsilon is the gap just above 11,

εmach=β1−p.\varepsilon_{\mathrm{mach}}=\beta^{1-p}.

For round-to-nearest the unit roundoff is half that gap,

u=12 εmach=12 β1−p.u=\tfrac12\,\varepsilon_{\mathrm{mach}}=\tfrac12\,\beta^{1-p}.

For the running decimal system, εmach=10−3\varepsilon_{\mathrm{mach}}=10^{-3} and u=5×10−4u=5\times 10^{-4}. For binary64, εmach=2−52\varepsilon_{\mathrm{mach}}=2^{-52} and u=2−53u=2^{-53}.

Plain language: rounding sends a real to a neighboring entry of FF. Machine epsilon is the distance from 11 to the next larger entry. Unit roundoff is half that distance, and it is the largest relative change one round-to-nearest step is allowed to make.

Linear Algebra 20 quotes εmach≈2.2×10−16\varepsilon_{\mathrm{mach}}\approx 2.2\times 10^{-16} for binary64. That number is 2−522^{-52}, the gap. The rounding inequality in this chapter is stated with uu, which is half the gap when ties are broken by nearness. For chopping, the sharp constant is εmach\varepsilon_{\mathrm{mach}} rather than uu; every theorem below is the round-to-nearest case.

Theorem — Relative form of a single rounding

If xx lies in the open normal range, then there exists a real δ\delta with

fl(x)=x(1+δ),∣δ∣≤u.\mathrm{fl}(x)=x(1+\delta),\qquad |\delta|\leq u.

Equivalently, ∣fl(x)−x∣≤u ∣x∣|\mathrm{fl}(x)-x|\leq u\,|x|.

Plain language: a single rounding multiplies the true value by 1+δ1+\delta, and ∣δ∣|\delta| is at most the unit roundoff. The absolute error may grow with ∣x∣|x|; the relative error stays within uu.

Step-by-step — Why the relative error is at most u
1

Place xx in its binade. For some exponent ee, βe−1≤∣x∣<βe\beta^{e-1}\leq |x|<\beta^{e}. The proof for x<0x<0 is the same after changing sign, so take x>0x>0.

2

Read the gap. Adjacent elements of FF in this binade differ by βe−p\beta^{e-p}. Round-to-nearest moves xx by at most half a gap, including on a tie: ∣fl(x)−x∣≤12βe−p|\mathrm{fl}(x)-x|\leq \tfrac12\beta^{e-p}.

3

Divide by the smallest magnitude in the binade. The largest relative error occurs at the left endpoint, where ∣x∣|x| may be as small as βe−1\beta^{e-1}. Therefore

∣fl(x)−x∣∣x∣≤12βe−pβe−1=12β1−p=u.\frac{|\mathrm{fl}(x)-x|}{|x|}\leq \frac{\tfrac12\beta^{e-p}}{\beta^{e-1}}=\tfrac12\beta^{1-p}=u.
Higher in the same binade the denominator is larger and the relative error is strictly smaller.

4

Rewrite as a factor. Set δ=(fl(x)−x)/x\delta=(\mathrm{fl}(x)-x)/x. The previous step is ∣δ∣≤u|\delta|\leq u, and fl(x)=x(1+δ)\mathrm{fl}(x)=x(1+\delta).

Compare

Unit roundoff is the smallest relative nudge near 11: half the step from 11 to the next number in FF. The absolute step grows with the magnitude, and that relative nudge stays the size of uu.

Rounding each input, then operating, then rounding the result, is the whole of floating-point arithmetic. For inputs already in FF the first rounding is idle.

Theorem — Standard model of arithmetic

Let ⋆\star be one of ++, −-, ×\times, ÷\div. Let x,y∈Fx,y\in F, with y≠0y\neq 0 in the division case, and assume x⋆yx\star y lies in the normal range (no overflow and no underflow). Then there exists δ\delta, depending on xx, yy, and ⋆\star, such that

fl(x⋆y)=(x⋆y) (1+δ),∣δ∣≤u.\mathrm{fl}(x\star y)=(x\star y)\,(1+\delta),\qquad |\delta|\leq u.

In words: the computed result is the exact result, multiplied by a relative factor within one unit roundoff.

Plain language: the computed result of one addition, subtraction, multiplication, or division is the exact real result, then one rounding. That rounding is a relative factor within one unit roundoff, as long as the exact result stays inside the normal range.

The identity is not an approximation slogan. It is the previous theorem applied to the real number x⋆yx\star y. Overflow (an exponent above emax⁡e_{\max}) and underflow (a result below the smallest normal) are excluded from the hypothesis because the rounded result then leaves the model: there is no δ\delta of size at most uu for which the identity holds.

Example — A product in four decimal digits

Compute 1.248×3.1621.248\times 3.162 with β=10\beta=10, p=4p=4, round-to-nearest.

The exact product splits as 1.248×3=3.7441.248\times 3=3.744, 1.248×0.16=0.199681.248\times 0.16=0.19968, and 1.248×0.002=0.0024961.248\times 0.002=0.002496. Adding these gives 3.744+0.19968=3.943683.744+0.19968=3.94368, then 3.94368+0.002496=3.9461763.94368+0.002496=3.946176.

The fifth significant digit of 3.9461763.946176 is 11, so fl(3.946176)=3.946\mathrm{fl}(3.946176)=3.946. The absolute discrepancy is 3.946176−3.946=0.0001763.946176-3.946=0.000176. Hence

δ=3.946−3.9461763.946176,∣δ∣=1.76×10−43.946176.\delta=\frac{3.946-3.946176}{3.946176},\qquad |\delta|=\frac{1.76\times 10^{-4}}{3.946176}.

Since 3.946176×5×10−5=1.973×10−4>1.76×10−43.946176\times 5\times 10^{-5}=1.973\times 10^{-4}>1.76\times 10^{-4}, one has ∣δ∣<5×10−5|\delta|<5\times 10^{-5}, which is well below u=5×10−4u=5\times 10^{-4}. The standard model guarantees only the coarser bound; this particular product lands closer.

The model does not say that a formula of several operations has relative error uu. Each operation contributes its own factor 1+δi1+\delta_i. Nor does it say that the operations remain associative.

❌ What Breaks — Associativity of addition

Work in β=10\beta=10, p=3p=3, so the gap at 10310^{3} is 1010 and u=5×10−3u=5\times 10^{-3}. Let a=1.00×103a=1.00\times 10^{3}, b=−1.00×103b=-1.00\times 10^{3}, and c=1.00×100c=1.00\times 10^{0}, all three already in FF.

The two groupings. First, fl(a+b)=0\mathrm{fl}(a+b)=0 and fl(0+c)=1\mathrm{fl}(0+c)=1. Second, the exact sum b+c=−999b+c=-999 lies at distance 11 from −1000-1000 and at distance 99 from −990-990, so fl(b+c)=−1.00×103\mathrm{fl}(b+c)=-1.00\times 10^{3}. Then fl(a+fl(b+c))=0\mathrm{fl}(a+\mathrm{fl}(b+c))=0.

Why it breaks: each individual addition satisfies the standard model. The two expressions insert the rounding at different places. After fl(b+c)\mathrm{fl}(b+c) has discarded the unit, no later addition can recover it.

Consequence: a+(b+c)a+(b+c) and (a+b)+c(a+b)+c are not interchangeable once results are required to lie in FF. A rearrangement is a different algorithm and needs its own error bound.


03 · Absolute and Relative Error

Definition — Absolute and relative error

If x^\hat x is an approximation to a real xx, the absolute error is Eabs=∣x^−x∣E_{\mathrm{abs}}=|\hat x-x|. When x≠0x\neq 0, the relative error is Erel=∣x^−x∣/∣x∣E_{\mathrm{rel}}=|\hat x-x|/|x|. Relative error is unchanged if xx and x^\hat x are scaled by the same nonzero constant. Absolute error is not.

Plain language: absolute error is the distance between the approximation and the true value. Relative error is that distance divided by the size of the true value, so scaling both numbers by the same nonzero constant leaves it unchanged.

The theorem of the previous section is a relative-error statement: one rounding produces Erel≤uE_{\mathrm{rel}}\leq u, and therefore Eabs≤u ∣x∣E_{\mathrm{abs}}\leq u\,|x|. An absolute tolerance copied from one magnitude to another has no justification in FF.

Example — One absolute error, two relative errors

Suppose a computed value is 0.0100.010 above the true value.

  • On a price x=250x=250, one has Erel=0.010/250=4×10−5E_{\mathrm{rel}}=0.010/250=4\times 10^{-5}. In the four-digit decimal system this is below u=5×10−4u=5\times 10^{-4}: the price has survived to better than a unit roundoff.
  • On a one-day rate difference x=0.0004x=0.0004, the same absolute error gives Erel=0.010/0.0004=25E_{\mathrm{rel}}=0.010/0.0004=25. The computed difference has no correct digit. The absolute defect did not change; the denominator did.

Reporting "0.0100.010 of error" without ∣x∣|x| does not say whether the result is usable.

❌ What Breaks — Reading u as an absolute tolerance

In binary64, u=2−53≈1.11×10−16u=2^{-53}\approx 1.11\times 10^{-16}. A notional of size 10910^{9} is rounded.

Why it breaks: the absolute bound from the rounding theorem is u ∣x∣≈1.11×10−7u\,|x|\approx 1.11\times 10^{-7}, not 10−1610^{-16}. The number uu is dimensionless. Multiplying a cash amount by uu changes the unit from "relative" back to "currency."

Consequence: a control that treats 10−1610^{-16} as a currency tolerance accepts absolute errors a billion times larger than that control was meant to catch, as soon as the notional is 10910^{9}.


04 · Catastrophic Cancellation

Subtraction of nearly equal floating-point numbers is often exact. The damage is older than the subtraction.

Lemma — Exact difference at a common exponent

Let x,y∈Fx,y\in F be nonzero and have the same scientific exponent, and assume x−yx-y does not underflow. Then x−y∈Fx-y\in F, so fl(x−y)=x−y\mathrm{fl}(x-y)=x-y.

Plain language: if two floating-point numbers share an exponent, their difference is already an element of FF, provided it does not underflow. The subtraction returns the exact difference, and the rounding factor on that operation is 11.

Step-by-step — Why a same-exponent difference needs no extra digits
1

Write both numbers on the integer lattice of that binade. For a common exponent parameter ee, x=mx βe−px=m_x\,\beta^{e-p} and y=my βe−py=m_y\,\beta^{e-p} with integers mx,mym_x,m_y between βp−1\beta^{p-1} and βp−1\beta^{p}-1.

2

Subtract the integers. x−y=(mx−my) βe−px-y=(m_x-m_y)\,\beta^{e-p}. The coefficient mx−mym_x-m_y is an integer of absolute value at most βp−βp−1−1<βp\beta^{p}-\beta^{p-1}-1<\beta^{p}, so it does not need a (p+1)(p+1)st digit.

3

Normalize if the leading digit vanished. If ∣mx−my∣≥βp−1|m_x-m_y|\geq \beta^{p-1}, the difference is already normal at this exponent. If the coefficient is smaller, lower the exponent until the leading digit is nonzero. Lowering the exponent shifts a shorter integer; it does not invent digits. The hypothesis that the result is still above the underflow threshold keeps the new exponent inside the range.

4

Conclude. x−yx-y equals an element of FF, so rounding changes nothing and the δ\delta in the standard model is 00.

The binary statement extends past a single binade. If x,yx,y are binary floating-point numbers, y/2≤x≤2yy/2\leq x\leq 2y, and x−yx-y does not underflow, then again x−y∈Fx-y\in F. The extra room of a factor two is special to β=2\beta=2: the unit in the last place at most doubles when the exponent increases by one, and x≤2yx\leq 2y keeps xx on the same lattice as yy. This is Sterbenz's lemma. The decimal examples below need only the same-exponent form already proved.

Definition — Catastrophic cancellation

Let x,yx,y be reals and x^=fl(x)\hat x=\mathrm{fl}(x), y^=fl(y)\hat y=\mathrm{fl}(y). Catastrophic cancellation is the situation in which ∣x^−y^∣|\hat x-\hat y| is comparable to the absolute errors ∣x^−x∣|\hat x-x| and ∣y^−y∣|\hat y-y|, so that the relative error of x^−y^\hat x-\hat y as an approximation to x−yx-y is large, even though fl(x^−y^)=x^−y^\mathrm{fl}(\hat x-\hat y)=\hat x-\hat y exactly.

Plain language: the stored difference can equal x^−y^\hat x-\hat y exactly and still be a poor stand-in for x−yx-y. The digits that separated the true values were dropped when each value was rounded, so the difference is assembled from what rounding discarded.

The condition number of the map makes the inflation quantitative. Perturb xx by a relative amount δx\delta_x and yy by δy\delta_y. The relative change in the difference satisfies

∣(x(1+δx)−y(1+δy))−(x−y)∣∣x−y∣≤∣x∣ ∣δx∣+∣y∣ ∣δy∣∣x−y∣.\frac{|(x(1+\delta_x)-y(1+\delta_y))-(x-y)|}{|x-y|}\leq \frac{|x|\,|\delta_x|+|y|\,|\delta_y|}{|x-y|}.

If ∣δx∣,∣δy∣≤u|\delta_x|,|\delta_y|\leq u, the right-hand side is at most κsub u\kappa_{\mathrm{sub}}\,u with

κsub(x,y)=∣x∣+∣y∣∣x−y∣.\kappa_{\mathrm{sub}}(x,y)=\frac{|x|+|y|}{|x-y|}.

When x≈yx\approx y the denominator is small and κsub\kappa_{\mathrm{sub}} is large. The subtraction did not become an inaccurate operation. The function (x,y)↦x−y(x,y)\mapsto x-y became a sensitive function.

Compare

Cancellation here is shared leading digits wiping the difference. The stored values agree on the digits that were kept, so x^−y^\hat x-\hat y is built from the digits the two roundings already threw away.

Example — Leading digits that were never stored

Take β=10\beta=10, p=4p=4, u=5×10−4u=5\times 10^{-4}. Let the true values be x=1.23448x=1.23448 and y=1.23052y=1.23052, so x−y=0.00396x-y=0.00396.

The fifth digit of 1.234481.23448 is 44, so x^=1.234\hat x=1.234. The fifth digit of 1.230521.23052 is 55 followed by a nonzero remainder, so y^=1.231\hat y=1.231 under round-half-away-from-zero. Both inputs have absolute error 0.000480.00048, and both relative errors are about 3.9×10−4≤u3.9\times 10^{-4}\leq u.

The stored numbers share an exponent. By the lemma, fl(x^−y^)=1.234−1.231=0.003\mathrm{fl}(\hat x-\hat y)=1.234-1.231=0.003 exactly. Against the true difference,

Eabs=∣0.003−0.00396∣=0.00096,Erel=0.000960.00396=833≈0.242.E_{\mathrm{abs}}=|0.003-0.00396|=0.00096,\qquad E_{\mathrm{rel}}=\frac{0.00096}{0.00396}=\frac{8}{33}\approx 0.242.

The relative error is several hundred times uu. The condition number explains the size: (∣x∣+∣y∣)/∣x−y∣≈2.465/0.00396≈622(|x|+|y|)/|x-y|\approx 2.465/0.00396\approx 622, and 622×3.9×10−4≈0.24622\times 3.9\times 10^{-4}\approx 0.24.

The same arithmetic is a spread of two quoted levels. The stored level keeps four digits; the spread lives in the digits the rounding already discarded. Measuring the spread's relative error against uu alone, with no factor κsub\kappa_{\mathrm{sub}}, will call a bad spread acceptable.

A standard cure is to rewrite the expression so that the small result is not a difference of two rounded quantities. The quadratic formula is the classical case, and every step below is four-digit decimal arithmetic.

Step-by-step — The smaller root of x squared minus 1000 x plus 1
1

Record the exact roots. For x2−1000x+1=0x^{2}-1000x+1=0, the discriminant is 106−4=99999610^{6}-4=999996 and its square root is just under 10001000. The smaller root is (1000−999996)/2=0.001000001000…(1000-\sqrt{999996})/2=0.001000001000\ldots, and the product of the roots is 11.

2

Round the discriminant in four digits. 999996=9.99996×105999996=9.99996\times 10^{5}. The fifth significant digit is 66, so fl(999996)=1.000×106\mathrm{fl}(999996)=1.000\times 10^{6}. The subtraction 106−410^{6}-4 has been lost: the gap at 10610^{6} is 100100, and 44 is far below half a gap.

3

Evaluate the cancelling formula. fl(1.000×106)=1.000×103\mathrm{fl}(\sqrt{1.000\times 10^{6}})=1.000\times 10^{3}. Then fl(1000−1000)=0\mathrm{fl}(1000-1000)=0, so the computed smaller root is 00. The relative error against 0.0010.001 is 11.

4

Use the conjugate identity instead. For x2−Bx+C=0x^{2}-Bx+C=0 with B>0B>0, the smaller root equals 2C/(B+B2−4C)2C/(B+\sqrt{B^{2}-4C}). In four digits, B+⋅B+\sqrt{\cdot} is computed as 1000+1000=20001000+1000=2000 and 2/2000=0.001=1.000×10−32/2000=0.001=1.000\times 10^{-3}, which lies in FF. The absolute error is about 10−910^{-9}, and the relative error is about 10−610^{-6}, far below uu.

The algebra of the rewrite is worth one line, because it is the reason the second algorithm never subtracts. If s=B2−4Cs=\sqrt{B^{2}-4C}, then

B−s2=(B−s)(B+s)2(B+s)=B2−s22(B+s)=2CB+s.\frac{B-s}{2}=\frac{(B-s)(B+s)}{2(B+s)}=\frac{B^{2}-s^{2}}{2(B+s)}=\frac{2C}{B+s}.

The left side subtracts two quantities that agree to six figures. The right side divides two quantities of moderate size. They are equal in real arithmetic and unequal in FF.

❌ What Breaks — Blaming the subtraction operation

In the quadratic calculation, 1000−10001000-1000 was exact, and in the two-level example 1.234−1.2311.234-1.231 was exact.

Why it breaks: the standard model applied to those subtractions gives δ=0\delta=0. The zeros that appeared in the leading digits were already zeros in FF before the subtraction was performed. Sterbenz's setting, and the same-exponent lemma, describe an operation that returns its exact mathematical value.

Consequence: "carrying more guard digits through the subtraction" does not repair a difference whose error was committed when the operands were rounded. The repair is an algebraically equivalent expression whose condition number is moderate, as with 2C/(B+s)2C/(B+s).


05 · Truncation Error and Roundoff

Rounding is not the only discrepancy between a mathematical expression and the number that replaces it. Stopping a limit, a series, or a difference quotient introduces a second discrepancy that would be present even if every arithmetic operation were exact in R\mathbb{R}.

Definition — Truncation error and roundoff error

Suppose a target value LL is replaced by a mathematical approximation T(h)T(h), and T(h)T(h) is then evaluated in FF to produce T^(h)\hat T(h). The truncation error is ∣T(h)−L∣|T(h)-L|. The roundoff error is ∣T^(h)−T(h)∣|\hat T(h)-T(h)|. The error that is actually observed splits as

∣T^(h)−L∣≤∣T(h)−L∣+∣T^(h)−T(h)∣.|\hat T(h)-L|\leq |T(h)-L|+|\hat T(h)-T(h)|.

The first summand is a statement about analysis in R\mathbb{R}. The second is a statement about fl\mathrm{fl} and is bounded using uu.

Plain language: truncation error is the distance between the mathematical shortcut T(h)T(h) and the target LL. It would remain if every arithmetic step were exact. Roundoff error is the further distance between the digit-limited value T^(h)\hat T(h) and that same shortcut.

Compare

Truncation is the formula cut short of the limit, series, or quotient that defines LL. Roundoff is the effect of a finite digit budget on the formula that was actually evaluated. The observed error adds the two.

The two summands typically move in opposite directions as a step hh shrinks. A first-order difference quotient has truncation of order hh and a roundoff contribution of order u/hu/h, because a difference of size hh is divided by hh after absolute noise of size about uu has entered the function values. Shrinking hh improves the first and degrades the second.

Step-by-step — (e to the h, minus 1), divided by h, in four digits
1

Name the target and the remainder. The target is e0=1e^{0}=1, estimated by T(h)=(eh−1)/hT(h)=(e^{h}-1)/h. Taylor's theorem with remainder gives eh=1+h+12h2eξe^{h}=1+h+\tfrac12 h^{2}e^{\xi} for some ξ\xi between 00 and hh, so

∣T(h)−1∣=12h eξ≤12h e∣h∣.\big|T(h)-1\big|=\tfrac12 h\,e^{\xi}\leq \tfrac12 h\,e^{|h|}.
The right-hand side is pure truncation: no rounding has been used.

2

Take h=10−1h=10^{-1}, where truncation dominates. The series 1+0.1+0.005+0.0001667+0.0000041671+0.1+0.005+0.0001667+0.000004167 sums to 1.1051708…1.1051708\ldots, and the unused remainder is smaller than 10−710^{-7}. Four-digit rounding gives fl(e0.1)=1.105\mathrm{fl}(e^{0.1})=1.105. Then (1.105−1)/0.1=1.05(1.105-1)/0.1=1.05. The observed absolute error is ∣1.05−1∣=0.05|1.05-1|=0.05, matching 12h=0.05\tfrac12 h=0.05 from the truncation bound. Replacing 1.10517081.1051708 by 1.1051.105 changed the quotient by only 0.00170.0017.

3

Take h=10−4h=10^{-4}, where roundoff dominates. Here eh=1.000100005…e^{h}=1.000100005\ldots. The successor of 1.0001.000 is 1.0011.001. Distance 0.00010.0001 against distance 0.00090.0009 puts 1.00011.0001 closer to 1.0001.000, so fl(eh)=1.000\mathrm{fl}(e^{h})=1.000. The computed quotient is (1.000−1)/10−4=0(1.000-1)/10^{-4}=0. Truncation is at most 12h eh<6×10−5\tfrac12 h\,e^{h}<6\times 10^{-5}. The observed absolute error is 11, from rounding the numerator to zero in FF.

4

Check the roundoff budget. An absolute perturbation of size at most u e∣h∣u\,e^{|h|} in the numerator, followed by division by hh, moves T(h)T(h) by at most about u/∣h∣u/|h|. For h=10−4h=10^{-4} and u=5×10−4u=5\times 10^{-4} this ceiling is 55, which is large enough to permit the computed value 00. For h=10−1h=10^{-1} the same ceiling is 5×10−35\times 10^{-3}, smaller than the truncation 5×10−25\times 10^{-2}. The bound tells which term is in charge before the quotient is formed.

What later chapters inherit

Differentiation, quadrature, and one-step methods for differential equations each produce a T(h)T(h) whose truncation tends to 00 with hh, and a computed T^(h)\hat T(h) whose roundoff does not. Those chapters bound truncation by a Taylor expansion in R\mathbb{R} and roundoff by the standard model above. The useful step balances the two terms in the split.

❌ What Breaks — Taking a smaller step to buy accuracy

The four-digit quotient at h=10−1h=10^{-1} has absolute error 0.050.05. Replacing the step by h=10−4h=10^{-4} is proposed in order to "make the Taylor remainder negligible."

Why it breaks: the truncation bound does fall, from 5×10−25\times 10^{-2} to under 6×10−56\times 10^{-5}. The computed numerator eh−1e^{h}-1 falls below half a unit in the last place of 11 and rounds to 00. The observed error rises from 0.050.05 to 11.

Consequence: once ∣T^(h)−T(h)∣|\hat T(h)-T(h)| exceeds ∣T(h)−L∣|T(h)-L|, further reduction of hh is not a refinement of the approximation. The limiting value in exact arithmetic and the limiting value in FF are different objects.


06 · The Scalar Model Beside a Linear System

Every bound above concerns a scalar map. A linear system Ax=bA\mathbf{x}=\mathbf{b} is a map on matrices and vectors. If κ(A)=∥A∥ ∥A−1∥\kappa(A)=\|A\|\,\|A^{-1}\| and the data move by small relative amounts, the relative change in x\mathbf{x} is controlled by κ(A)\kappa(A) times those amounts. Linear Algebra 20 states that theorem; the argument is not repeated here.

The scalar standard model supplies only the size of the perturbation. One rounding multiplies by 1+δ1+\delta with ∣δ∣≤u|\delta|\leq u. A backward-stable elimination returns the exact solution of a nearby system whose relative perturbation is a modest multiple of uu, and passing to the forward error multiplies by κ(A)\kappa(A):

relative forward error ≲ κ(A)⋅u,\text{relative forward error}\ \lesssim\ \kappa(A)\cdot u,

up to the dimensional factors kept explicit in Linear Algebra 20. Moderate κ(A)\kappa(A) with small uu leaves digits intact. A condition number as large as 1/u1/u can remove every digit while each arithmetic step still satisfies ∣δ∣≤u|\delta|\leq u.

Section 04 is the same pattern with κsub\kappa_{\mathrm{sub}} in place of κ(A)\kappa(A). An exact subtraction and a large κsub\kappa_{\mathrm{sub}} match a backward-stable factorization and a large κ(A)\kappa(A): the operation met the model, and the function amplified it. The conjugate form of the quadratic changes the condition number. It leaves uu as it is.


07 · Exercises

EXERCISE 1.1

Write 2/32/3 as 6.666…×10−16.666\ldots\times 10^{-1} and look at the fifth significant digit. The absolute error is a difference of two fractions with denominator 3000030000.

The expansion is 2/3=0.6666…=6.666…×10−12/3=0.6666\ldots=6.666\ldots\times 10^{-1}. Five leading digits begin 6666666666, so the fifth digit is 66 and fl(2/3)=6.667×10−1=0.6667\mathrm{fl}(2/3)=6.667\times 10^{-1}=0.6667. Then 0.6667−2/3=6667/10000−2/3=(20001−20000)/30000=1/300000.6667-2/3=6667/10000-2/3=(20001-20000)/30000=1/30000, so Eabs=1/30000E_{\mathrm{abs}}=1/30000. The relative error is (1/30000)/(2/3)=1/20000=5×10−5(1/30000)/(2/3)=1/20000=5\times 10^{-5}. Since u=5×10−4u=5\times 10^{-4}, this δ\delta satisfies ∣δ∣≤u|\delta|\leq u. For this system εmach=101−4=10−3\varepsilon_{\mathrm{mach}}=10^{1-4}=10^{-3}, and u=εmach/2u=\varepsilon_{\mathrm{mach}}/2. The predecessor of 11 in FF is 0.99990.9999 and the successor is 1.0011.001.

In the system β=10\beta=10, p=4p=4, with round-to-nearest (half away from zero when the discarded part is at least half a unit), compute fl(2/3)\mathrm{fl}(2/3). Give the absolute error and the relative error as exact fractions, and check them against uu. State εmach\varepsilon_{\mathrm{mach}} and the two neighbors of 11 in FF.

EXERCISE 1.2

Expand 2.375×82.375\times 8 and 2.375×0.1242.375\times 0.124 separately, add, then keep four significant digits. Compare the absolute discrepancy with uu times the exact product.

2.375×8=192.375\times 8=19 and 2.375×0.124=2.375×0.1+2.375×0.02+2.375×0.004=0.2375+0.0475+0.0095=0.29452.375\times 0.124=2.375\times 0.1+2.375\times 0.02+2.375\times 0.004=0.2375+0.0475+0.0095=0.2945. The exact product is 19.294519.2945. The fifth significant digit is 44, so fl(19.2945)=19.29\mathrm{fl}(19.2945)=19.29. The absolute discrepancy is 0.00450.0045. Then ∣δ∣=0.0045/19.2945|\delta|=0.0045/19.2945. Because 19.2945×3×10−4=0.005788>0.004519.2945\times 3\times 10^{-4}=0.005788>0.0045, one has ∣δ∣<3×10−4≤u=5×10−4|\delta|<3\times 10^{-4}\leq u=5\times 10^{-4}, in agreement with the standard model. The model asserts existence of some such δ\delta; this product exhibits one.

In four-digit decimal round-to-nearest arithmetic, compute fl(2.375×8.124)\mathrm{fl}(2.375\times 8.124) from the exact product. Exhibit a δ\delta satisfying the standard model and show ∣δ∣≤u|\delta|\leq u by a direct comparison, without appealing to the general proof.

EXERCISE 1.3

With B=400B=400 and C=1C=1, form B2−4C=159996B^{2}-4C=159996 and round to four significant digits before taking the square root. For the stable value use 2C/(B+s)2C/(B+s) with that same rounded square root.

B2−4C=160000−4=159996=1.59996×105B^{2}-4C=160000-4=159996=1.59996\times 10^{5}, which rounds to 1.600×1051.600\times 10^{5} because the fifth digit is 99. The square root in four digits is 400.0400.0. The cancelling formula returns (400−400)/2=0(400-400)/2=0. The true smaller root is (400−159996)/2≈0.0025000156(400-\sqrt{159996})/2\approx 0.0025000156, so the computed root 00 has relative error 11. The conjugate form uses the same rounded square root: 2/(400+400)=2/800=0.00252/(400+400)=2/800=0.0025, which equals 2.500×10−32.500\times 10^{-3} and lies in FF. Its absolute error is about 1.6×10−81.6\times 10^{-8} and its relative error is about 6×10−66\times 10^{-6}, below u=5×10−4u=5\times 10^{-4}. The subtraction 400−400400-400 was exact; the information was lost when 159996159996 was replaced by 160000160000.

For x2−400x+1=0x^{2}-400x+1=0, compute the smaller root in four-digit decimal arithmetic by the cancelling quadratic formula, and again by the conjugate form 2C/(B+B2−4C)2C/(B+\sqrt{B^{2}-4C}). Compare both with the true smaller root, and state whether the subtraction of the two four-digit terms was itself inexact.

EXERCISE 1.4

Bound the truncation by 12∣h∣ e∣h∣\tfrac12 |h|\,e^{|h|}. Build ehe^{h} from its Taylor polynomial far enough to round to four digits, then form (fl(eh)−1)/h( \mathrm{fl}(e^{h})-1)/h. At h=10−4h=10^{-4} the series 1+h+h2/21+h+h^{2}/2 already shows where ehe^{h} sits between 1.0001.000 and 1.0011.001.

At h=0.2h=0.2 the truncation bound is 0.1 e0.20.1\,e^{0.2}. The partial sum 1+0.2+0.02+0.00133333+0.000066667=1.2214001+0.2+0.02+0.00133333+0.000066667=1.221400. The tail is smaller than 0.25/1200.2^{5}/120 divided by 1−0.2/61-0.2/6, which is under 3×10−63\times 10^{-6}, so e0.2<1.221403e^{0.2}<1.221403 and the truncation is under 0.12220.1222. Four-digit rounding gives 1.2211.221 because the fifth digit is 44. The quotient is (1.221−1)/0.2=1.105(1.221-1)/0.2=1.105, absolute error 0.1050.105 against the derivative 11. Rounding the exponential moved the quotient by about 0.00040/0.2=0.0020.00040/0.2=0.002, so truncation dominates. At h=10−4h=10^{-4} the truncation is at most 12⋅10−4⋅e0.0001<5.1×10−5\tfrac12\cdot 10^{-4}\cdot e^{0.0001}<5.1\times 10^{-5}. The series gives eh=1.000100005…e^{h}=1.000100005\ldots. The successor of 1.0001.000 is 1.0011.001, and 1.00011.0001 is closer to 1.0001.000, so fl(eh)=1.000\mathrm{fl}(e^{h})=1.000 and the quotient is 00. The absolute error against the derivative is 11. Roundoff dominates.

Let T(h)=(eh−1)/hT(h)=(e^{h}-1)/h estimate the derivative of ete^{t} at t=0t=0. In the four-digit decimal system, bound the truncation for h=0.2h=0.2 and for h=10−4h=10^{-4}, compute both rounded quotients, and say which of truncation or roundoff dominates at each step. Use the Taylor expansion with remainder, evaluated by hand.


08 · Summary

ObjectStatement
Normal set FF±m βe−p\pm m\,\beta^{e-p} with βp−1≤m≤βp−1\beta^{p-1}\leq m\leq \beta^{p}-1
Machine epsilongap εmach=β1−p\varepsilon_{\mathrm{mach}}=\beta^{1-p} just above 11
Unit roundoffu=12β1−pu=\tfrac12\beta^{1-p} for round-to-nearest
One roundingfl(x)=x(1+δ)\mathrm{fl}(x)=x(1+\delta) with δ\delta at most uu in magnitude
Standard modelfl(x⋆y)=(x⋆y)(1+δ)\mathrm{fl}(x\star y)=(x\star y)(1+\delta) under the same bound, no over/underflow
Absolute vs relativeuu bounds relative error; absolute error scales with the magnitude
Exact cancellationsame-exponent differences in FF are exact if they do not underflow
Catastrophic cancellationrelative error inflated by κsub\kappa_{\mathrm{sub}}, magnitudes over the difference
Truncation vs roundoffT(h)−LT(h)-L and T^(h)−T(h)\hat T(h)-T(h) scale oppositely in hh
Link to linear systemsforward error carries a factor κ(A)⋅u\kappa(A)\cdot u; κ(A)\kappa(A) is proved in Linear Algebra 20

Next: Chapter 02 — Root-Finding Algorithms, which uses this model when a bracketed root is refined by bisection, Newton, and secant updates: each update is exact arithmetic plus a rounding factor 1+δ1+\delta, and the truncation of the iteration is a separate term.