15.9 Problem set B: condition numbers, error bounds, Newton, polynomial approximation, and low precision
Inference code is full of numbers that should agree but were computed differently: the sampler’s float64 sums against the Rust engine’s, a quantized matmul against float32, a float16 KV cache against a float32 one. The C kernels then compute rsqrt by Newton’s method and expf by range reduction and a polynomial, and must be proved accurate to a few ulps. Error analysis, condition numbers, and tolerance budgets and FP8 and microscaling formats turn the bounds and the formats into code. This set derives them by hand first, so that a failing tolerance or a kernel that is off by one ulp is something you can explain rather than tune.
Concepts from other sections (22)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- KV cache: the stored keys and values of earlier tokens, bytes per token. Read more: 11.1 Counting: parameters, FLOPs, KV bytes, and memory plans
- Newton’s method: the iteration , jumping to the zero of the tangent line. Read more: 7.2 Newton’s Method
- Range reduction: rewriting so that the polynomial only needs to be accurate on a small interval around 0. Read more: 15.6 Polynomial approximation and range reduction: expf in C
- Condition number: how much the exact answer of a problem moves relative to a change in its input. Read more: 15.3 Error analysis, condition numbers, and tolerance budgets
- Lagrange remainder: the exact error of a Taylor polynomial, for some unknown between and . Read more: 8.1 Taylor series, remainder bounds, and range reduction
- E4M3: an 8-bit float with 4 exponent bits (bias 7) and 3 fraction bits, no infinity, largest finite value 448. Read more: 15.4 FP8 and microscaling formats
- E5M2: an 8-bit float with 5 exponent bits (bias 15) and 2 fraction bits, IEEE-style infinities and NaNs, largest finite value 57344. Read more: 15.4 FP8 and microscaling formats
- E2M1 (FP4): a 4-bit float whose only magnitudes are . Read more: 15.4 FP8 and microscaling formats
- Unit roundoff: , the largest relative error of a single round-to-nearest. Read more: 15.1 IEEE 754 anatomy, ulps, and round to nearest even
- Fixed point: a value with . Read more: 15.5 Fixed-point iteration and fast inverse square root in C
- Eigenvector / eigenvalue: a non-zero and scalar with . Read more: 9.4 Eigenvalues, power iteration, and the spectral radius
- Dot product: ; it measures how much two vectors point the same way, and it is zero exactly when they are perpendicular. Read more: Chapter 10: Calculus 3
- rounding error: the error from floating-point rounding, about in a difference quotient. Read more: 7.1 Derivatives and Finite Differences
- simple root: a root where , so the graph crosses zero at an angle. Read more: 7.2 Newton’s Method
- Horner’s rule: evaluating a polynomial as nested multiply-adds from the innermost coefficient out. Read more: 15.6 Polynomial approximation and range reduction: expf in C
- machine epsilon: , the gap between 1 and the next float64. Read more: 7.1 Derivatives and Finite Differences
- BF16: a 16-bit float with float32’s sign and exponent and 7 mantissa bits; the top half of a rounded float32. Read more: 6.7 Safetensors for every dtype, atomic checkpoints, and the token stream in AI Engineering
- Taylor polynomial: the degree- polynomial whose value and first derivatives at a point match those of . Read more: 8.1 Taylor series, remainder bounds, and range reduction
- Round to nearest, ties to even: IEEE 754’s default rounding, which breaks exact ties toward the code whose last kept bit is 0. Read more: 15.1 IEEE 754 anatomy, ulps, and round to nearest even
- Subnormal: a value with exponent field 0, no implicit leading 1, and a fixed exponent , filling the gap between zero and the smallest normal. Read more: 15.1 IEEE 754 anatomy, ulps, and round to nearest even
- Error budget: the bad events an objective allows over its period, as a full outage. Read more: 1.1 Design review: the tracer and the serving platform in Systems Engineering
- Pairwise summation: recursive halving of a sum, with error growing like . Read more: 15.2 Stable numerics: logsumexp, softmax, and compensated sums
The set has five parts: condition numbers (q1 to q6), sum and dot error bounds (q7 to q12), fixed-point and Newton convergence (q13 to q17), polynomial approximation (q18 to q23), and low-precision arithmetic (q24 to q28). Three of the problems, q6, q12, and q17, are short proofs. q14 to q17 prepare Fixed-point iteration and fast inverse square root in C, and q18 to q20 prepare Polynomial approximation and range reduction: expf in C; reading the set beside those sections and the two above works well.
It assumes the representation and rounding of Problem set A and Newton’s method from Newton’s Method. No code is needed. Work each problem before opening its answer; each answer gives the final value, the derivation, and the common wrong answer with the reason it is wrong.
Learning objectives
- Compute relative and matrix condition numbers and use them to bound how much a problem amplifies input errors.
- Derive and apply bounds for recursive, pairwise, and statistically typical summation.
- Determine the convergence rate of a fixed-point iteration and of Newton’s method at simple and double roots.
- Choose a polynomial degree from the Lagrange remainder after range reduction, and explain why Chebyshev nodes minimize the interpolation node product.
- Round values into E4M3, E5M2, and FP4, and choose an MX block scale.
The results every problem uses
Section titled “The results every problem uses”The symbols used in the problems:
| Symbol | Meaning | Type / shape |
|---|---|---|
| unit roundoff, significand bits with the implicit 1 | float | |
| accumulated relative error of roundings | float | |
| relative condition number of at | float | |
| 2-norm condition number | float | |
| , | an iteration map and its fixed point | function, float |
| the error after steps | float | |
| the Chebyshev polynomial of degree , | polynomial | |
| an MX block scale, a power of two | float |
Conditioning
Section titled “Conditioning”A relative change in the input changes the output of by about (first-order Taylor). For , , with and . The singular values of are the square roots of the eigenvalues of , not the eigenvalues of (they coincide only for symmetric positive semidefinite ).
Error bounds
Section titled “Error bounds”Under , , a dot product of length in any order satisfies . To first order . A balanced (pairwise) tree puts each term through additions instead of up to . Rounding errors with independent random signs add like a random walk, so the typical error is about ; the worst case is .
Iterations
Section titled “Iterations”If is differentiable near a fixed point , then : linear convergence with rate when it is below 1. Newton’s iteration for a root of is ; at a simple root and , which is quadratic. At a double root too and the rate degrades to linear.
Polynomial approximation
Section titled “Polynomial approximation”Taylor’s theorem with the Lagrange remainder gives with . Range reduction , , keeps , so a short polynomial suffices, and is an exponent adjustment. Horner’s rule uses multiplications for degree . Interpolating at nodes leaves an error proportional to ; the Chebyshev nodes (zeros of ) make that product the monic , whose maximum on is , the smallest possible.
Low precision
Section titled “Low precision”A format with fraction bits and bias has quantum near ; rounding is to the nearest multiple, ties to the even significand. The formats used here are E4M3 (, , max 448), E5M2 (, , max 57344, top exponent reserved), and FP4 E2M1 (values 0, 0.5, 1, 1.5, 2, 3, 4, 6). An MX block scale is , with the exponent of the element format’s largest normal.
Three worked examples
Section titled “Three worked examples”These are siblings of q1, q14, and q24, worked in full before you start.
The conditioning of : , so for every . Square roots halve relative errors.
One Newton step for , with and : . The relative error drops from to , close to : quadratic.
Rounding 2.75 to E4M3: , the quantum is , and exactly, so the value is 2.75 and the code is . To decode: , , .
The problems
Section titled “The problems”The problems are grouped by topic. The tag after each question is its answer type.
Condition numbers
Section titled “Condition numbers”q1. Give the relative condition number of at . [number]
Answer
. , so : a relative error of in becomes about in . This is cancellation seen as conditioning. A common mistake is , the absolute condition ; inverts the ratio.
q2. Give the relative condition number of at . [number]
Answer
. . A common mistake is , the absolute condition ; relative errors are amplified by , not by .
q3. Give of . [number]
Answer
. For a diagonal matrix the singular values are the absolute diagonal entries, and , so . A common mistake is , taking the largest entry alone.
q4. Give of . [number]
Answer
. has eigenvalues and , so the singular values are and and . A common mistake is , the ratio of ‘s eigenvalues (its diagonal, since it is triangular): is not symmetric, so eigenvalues are not singular values. is the ratio of ‘s eigenvalues, the square of the answer.
q5. and moves by a relative amount . Give the bound on the relative change of the solution of . [number]
Answer
. . A common mistake is , dividing by the condition number instead of multiplying.
q6. Prove that if and with invertible and , then in the 2-norm. [proof]
Answer
Proof. Subtracting from gives , so . By the definition of the induced norm,
Also . Since , , and dividing gives . Multiplying the two non-negative bounds,
In the 2-norm, , and the singular values of are the reciprocals of those of , so . The factor is therefore .
A complete proof has four steps: ; the two norm bounds on and ; their product; and the identification of with .
Sum and dot error bounds
Section titled “Sum and dot error bounds”q7. Give for float32 exactly. [number]
Answer
(multiply numerator and denominator by ), with float32’s . A common mistake is , the first-order value without the denominator; uses machine epsilon instead of .
q8. A float32 dot product of length has . Give the first-order bound on its error. [number]
Answer
. . A common mistake is , from using for .
q9. The same dot product with the sum done pairwise: give the first-order bound (one rounding per product, one per tree level). [number]
Answer
. tree levels, each one rounding, plus one rounding for each product: . A common mistake is , which forgets that the products round too; is the recursive (non-pairwise) bound of q8.
q10. In bf16, give the smallest for which , where the bound says nothing. [number]
Answer
. bf16 has 8 significant bits, so and first at . A common mistake is , from .
q11. The statistical rule of thumb replaces by (errors with random signs add like a random walk). Give it for float32 and . [number]
Answer
. , sixty-four times smaller than the worst case of q8. A common mistake is , which is the worst case , not the statistical rule.
q12. Prove that recursive summation of three numbers satisfies under the model , . [proof]
Answer
Proof. Assume so is defined. The first addition gives and the second , with . Expanding,
so the error is
Bound each factor. , and this is at most because . Also . By the triangle inequality,
The key observation is that and pass through two roundings and through one, and both counts are covered by .
Fixed point and Newton convergence
Section titled “Fixed point and Newton convergence”q13. The iteration converges to the fixed point . Give its asymptotic linear rate to at least 7 significant digits. [number, rtol 1e-6]
Answer
. , so and the rate is : each step multiplies the error by about , so one decimal digit takes about steps. A common mistake is to quote the fixed point instead of the rate; four digits () are not enough for the requested precision.
q14. Newton’s method for gives , the update Fixed-point iteration and fast inverse square root in C uses for rsqrt. With and , give exactly. [number]
Answer
. , , and , approaching . A common mistake is , the limit rather than one step (and the decimal is the same number, but the exact fraction is asked).
q15. Let be the relative error of that iteration. Using the identity of q17, give exactly when . [number]
Answer
. With : . A common mistake is , keeping only the leading term and dropping .
q16. (a) Give the order of convergence of Newton’s method at a simple root. (b) At a double root Newton converges only linearly; give the rate (the ratio in the limit). [number]
Answer
(a) . At a simple root, and .
(b) . Near a double root, with . Then , so : the error halves every step. A common mistake is 1 (no convergence) or 2 (still quadratic).
q17. Prove that the iteration of q14 satisfies , and conclude that it converges quadratically. [proof]
Answer
Proof. From the definition, , so . Substituting into the update and multiplying by ,
Expand: , and
So , and reading off ,
Quadratic convergence. If , then , so and . Then , a finite non-zero constant: the convergence is quadratic, and the number of correct bits roughly doubles each step (q15: gives ).
Polynomial approximation
Section titled “Polynomial approximation”q18. expf reduces with , so . Give for , exactly. [number]
Answer
. , the nearest integer is , and . A common mistake is , which rounds up and leaves outside .
q19. Give the half-width of the interval the reduced argument lies in. [number]
Answer
. Rounding to the nearest integer leaves a remainder of at most in units of . A common mistake is , the bound for truncation (floor), not rounding.
q20. On , the Taylor polynomial of of degree has the Lagrange bound . Give the smallest for which it is below . [number]
Answer
. With and : for the bound is , above ; for it is , below. This is why Polynomial approximation and range reduction: expf in C uses degree 7. A common mistake is 6, which looks close but is about three times too large; 8 is more than needed.
q21. How many multiplications does Horner’s rule use for a polynomial of degree 7? [number]
Answer
. Horner’s form has one multiplication per degree. A common mistake is , computing every power from scratch.
q22. Give the three Chebyshev nodes on (the zeros of ). [set]
Answer
. gives or ; equivalently for . Common mistakes are the equispaced or .
q23. Give for those three nodes. [number]
Answer
. The node product is the monic polynomial with those roots, , and on with equality at the endpoints, so the maximum is , the of the Chebyshev bound above. A common mistake is , the maximum of for the equispaced nodes (attained at ).
Low-precision arithmetic
Section titled “Low-precision arithmetic”q24. Round to e4m3 (OCP E4M3: bias 7, 3 fraction bits) with round to nearest, ties to even. (a) Give the value. (b) Give the code as an unsigned integer (sign bit, then 4 exponent bits, then 3 fraction bits). [number]
Answer
(a) . , so the quantum is ; rounds to , and .
(b) . The code is , binary 0 1001 011: sign 0, exponent field 9, fraction 3, value .
A common mistake in (a) is , which uses a grid twice as fine as E4M3’s in , or , which truncates. In (b), is the significand count , not the code, and puts the exponent field one too high.
q25. (a) Give the largest finite e5m2 value (bias 15, 2 fraction bits, the top exponent field reserved for infinity and NaN). (b) Give the smallest positive e4m3 value. [number]
Answer
(a) . The largest finite exponent field is (31 is reserved), , and the largest significand with 2 fraction bits is . A common mistake is , which uses 3 fraction bits; is E4M3’s maximum.
(b) . The smallest subnormal is one unit of the subnormal quantum . A common mistake is , the smallest normal.
q26. Give the unit roundoff of e4m3. [number]
Answer
. E4M3 has significant bits, so . A common mistake is , the gap at 1 (machine epsilon), twice .
q27. An MX block in fp4 E2M1 (largest value 6, ) has largest magnitude 13. (a) Give its shared scale . (b) Give the dequantized value of the element 13. [number]
Answer
(a) . , so . (b) . is above FP4’s largest value 6, so it saturates to 6, and . A common mistake in (a) is , a per-tensor floating scale; MX scales are powers of two. In (b), assumes no rounding and assumes FP4 has a 7.
q28. Which fp8 format covers the wider range of magnitudes? (a) e4m3 (b) e5m2 [choice]
Answer
(b) E5M2. Its five exponent bits span magnitudes from (smallest subnormal) to , about 32 binades, against E4M3’s to , about 18. E4M3 spends the bit on precision instead, which is why weights and activations use E4M3 and gradients often use E5M2.
Common mistakes
Section titled “Common mistakes”The wrong answers flagged in the problems are the same mistakes that break real tolerances and kernels. Each maps to a problem:
| Pitfall | Symptom | How to avoid it |
|---|---|---|
| The absolute condition for the relative one | instead of 50 | q1, q2: multiply by |
| Eigenvalues of for singular values | instead of 3 for a non-symmetric matrix | q4: take square roots of the eigenvalues of |
| for | every bound off by 2; bf16 void at 128 | q7, q8, q10: with counting the implicit bit |
| Forgetting that products round too | the pairwise bound one short | q9: one rounding per tree level plus one per product |
| Quoting the fixed point instead of the rate | 0.739 for 0.674 | q13: the rate is |
| Keeping only the leading term of Newton’s error | instead of | q15: use the exact identity of q17 |
| Rounding up instead of to nearest | a reduced argument outside | q18: is the nearest integer |
| Equispaced interpolation nodes | a larger node product (0.385 vs 0.25) | q22, q23: the zeros of |
| E5M2’s or the significand count’s grid for E4M3’s code | wrong value or code | q24: quantum , code |
| A per-tensor float scale where MX wants a power of two | a scale of 13/6 | q27: |
Where this leads
Section titled “Where this leads”q1 to q12 become code in Error analysis, condition numbers, and tolerance budgets (relative_condition, cond, gamma, dot_error_bound), and q24 to q28 become the fp8, FP4, and MX conversions of FP8 and microscaling formats. Fixed-point iteration and fast inverse square root in C implements q14 to q17’s Newton update and relies on its quadratic convergence, and Polynomial approximation and range reduction: expf in C implements q18 to q21’s range reduction, degree, and Horner evaluation. In AI Engineering, the quantization error budgets of Quantization: int8, int4 groups, fp8, and the KV cache combine q8’s bound with q24’s rounding error.
Further reading
Section titled “Further reading”- Higham, Accuracy and Stability of Numerical Algorithms, chapters 2 to 4 and 7.
- Trefethen, Approximation Theory and Approximation Practice (SIAM, 2013), chapters 1 to 4.
- Muller, Elementary Functions: Algorithms and Implementation (3rd ed., 2016), chapters 3 and 11.
Key terms
Section titled “Key terms”- Relative condition number: , the factor by which amplifies relative input errors.
- : , the bound on the relative error accumulated over roundings.
- Linear convergence: the error shrinks by a constant factor each step.
- Quadratic convergence: the error is proportional to the square of the previous error, so correct digits double.
- Chebyshev nodes: the zeros of , which minimize the maximum of the interpolation node product on .
- MX block scale: a shared power of two that places a block’s largest magnitude in the element format’s top binade.
Summary
Section titled “Summary”- The relative condition number and the matrix condition number say how much the problem amplifies input errors, whatever the algorithm (q1 to q6).
- Every rounding multiplies by , , and of them stay within ; pairwise summation cuts to , and random signs typically give (q7 to q12).
- Fixed-point iteration converges linearly at the rate ; Newton converges quadratically at a simple root, so the correct digits double each step (q13 to q17).
expfreduces to and evaluates a short polynomial; the Lagrange remainder fixes the degree, and Chebyshev nodes minimize the interpolation error’s node product (q18 to q23).- fp8 and MX formats are the same rounding with few bits: E4M3 has precision and range to 448, E5M2 trades a bit of precision for range to 57344, and an MX block scale is the power of two that puts the block’s maximum in the top binade (q24 to q28).