Skip to content

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.

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 γk\gamma_k 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 symbols used in the problems:

SymbolMeaningType / shape
u=2−pu = 2^{-p}unit roundoff, pp significand bits with the implicit 1float
γk=ku/(1−ku)\gamma_k = ku/(1 - ku)accumulated relative error of kk roundingsfloat
κf(x)=∣xf′(x)/f(x)∣\kappa_f(x) = \lvert x f'(x)/f(x)\rvertrelative condition number of ff at xxfloat
κ2(A)=σmax⁡/σmin⁡\kappa_2(A) = \sigma_{\max}/\sigma_{\min}2-norm condition numberfloat
gg, x∗x^*an iteration map xk+1=g(xk)x_{k+1} = g(x_k) and its fixed point g(x∗)=x∗g(x^*) = x^*function, float
eke_kthe error after kk stepsfloat
TnT_nthe Chebyshev polynomial of degree nn, Tn(cos⁡θ)=cos⁡nθT_n(\cos\theta) = \cos n\thetapolynomial
XXan MX block scale, a power of twofloat

A relative change ϵ\epsilon in the input changes the output of ff by about κf(x) ϵ\kappa_f(x)\,\epsilon (first-order Taylor). For Ax=bAx = b, ∥δx∥/∥x∥≤κ2(A) ∥δb∥/∥b∥\lVert\delta x\rVert/\lVert x\rVert \le \kappa_2(A)\, \lVert\delta b\rVert/\lVert b\rVert, with ∥A∥2=σmax⁡\lVert A\rVert_2 = \sigma_{\max} and ∥A−1∥2=1/σmin⁡\lVert A^{-1}\rVert_2 = 1/\sigma_{\min}. The singular values of AA are the square roots of the eigenvalues of A⊤AA^\top A, not the eigenvalues of AA (they coincide only for symmetric positive semidefinite AA).

Under fl(a∘b)=(a∘b)(1+δ)\mathrm{fl}(a \circ b) = (a \circ b)(1 + \delta), ∣δ∣≤u\lvert\delta\rvert \le u, a dot product of length kk in any order satisfies ∣fl(x⊤y)−x⊤y∣≤γk ∣x∣⊤∣y∣\lvert\mathrm{fl}(x^\top y) - x^\top y\rvert \le \gamma_k\, \lvert x\rvert^\top\lvert y\rvert. To first order γk≈ku\gamma_k \approx ku. A balanced (pairwise) tree puts each term through ⌈log⁡2k⌉\lceil\log_2 k\rceil additions instead of up to k−1k - 1. Rounding errors with independent random signs add like a random walk, so the typical error is about k u\sqrt{k}\,u; the worst case is kuku.

If gg is differentiable near a fixed point x∗x^*, then ek+1=g(xk)−g(x∗)≈g′(x∗) eke_{k+1} = g(x_k) - g(x^*) \approx g'(x^*)\, e_k: linear convergence with rate ∣g′(x∗)∣\lvert g'(x^*)\rvert when it is below 1. Newton’s iteration for a root of ff is g(x)=x−f(x)/f′(x)g(x) = x - f(x)/f'(x); at a simple root g′(x∗)=0g'(x^*) = 0 and ek+1≈g′′(x∗)2ek2e_{k+1} \approx \tfrac{g''(x^*)}{2} e_k^2, which is quadratic. At a double root f′(x∗)=0f'(x^*) = 0 too and the rate degrades to linear.

Taylor’s theorem with the Lagrange remainder gives er=∑j=0nrj/j!+Rne^r = \sum_{j=0}^{n} r^j/j! + R_n with ∣Rn∣≤e∣r∣∣r∣n+1/(n+1)!\lvert R_n\rvert \le e^{\lvert r\rvert}\lvert r\rvert^{n+1}/(n+1)!. Range reduction x=kln⁡2+rx = k\ln 2 + r, k=round(x/ln⁡2)k = \mathrm{round}(x/\ln 2), keeps ∣r∣≤ln⁡2/2\lvert r\rvert \le \ln 2/2, so a short polynomial suffices, and ex=2kere^x = 2^k e^r is an exponent adjustment. Horner’s rule a0+r(a1+r(a2+… ))a_0 + r(a_1 + r(a_2 + \dots)) uses nn multiplications for degree nn. Interpolating at n+1n + 1 nodes leaves an error proportional to ∏i(x−xi)\prod_i (x - x_i); the Chebyshev nodes (zeros of Tn+1T_{n+1}) make that product the monic Tn+1/2nT_{n+1}/2^n, whose maximum on [−1,1][-1, 1] is 2−n2^{-n}, the smallest possible.

A format with MM fraction bits and bias BB has quantum 2max⁡(⌊log⁡2v⌋,1−B)−M2^{\max(\lfloor\log_2 v\rfloor, 1 - B) - M} near vv; rounding is to the nearest multiple, ties to the even significand. The formats used here are E4M3 (M=3M = 3, B=7B = 7, max 448), E5M2 (M=2M = 2, B=15B = 15, max 57344, top exponent reserved), and FP4 E2M1 (values 0, 0.5, 1, 1.5, 2, 3, 4, 6). An MX block scale is X=2⌊log⁡2amax⁡⌋−emax⁡X = 2^{\lfloor\log_2 a_{\max}\rfloor - e_{\max}}, with emax⁡e_{\max} the exponent of the element format’s largest normal.

These are siblings of q1, q14, and q24, worked in full before you start.

The conditioning of x\sqrt{x}: f′(x)=1/(2x)f'(x) = 1/(2\sqrt{x}), so κ=∣x⋅12x/x∣=12\kappa = \lvert x \cdot \tfrac{1}{2\sqrt{x}} / \sqrt{x}\rvert = \tfrac12 for every x>0x > 0. Square roots halve relative errors.

One Newton step for 1/a1/\sqrt{a}, with a=2a = 2 and y0=0.7y_0 = 0.7: y1=0.7 (3−2⋅0.49)/2=0.7⋅2.02/2=0.707y_1 = 0.7\,(3 - 2 \cdot 0.49)/2 = 0.7 \cdot 2.02/2 = 0.707. The relative error drops from 1−2⋅0.7=0.010051 - \sqrt{2} \cdot 0.7 = 0.01005 to 1−2⋅0.707=0.0001511 - \sqrt{2}\cdot 0.707 = 0.000151, close to 32(0.01005)2=0.000152\tfrac32 (0.01005)^2 = 0.000152: quadratic.

Rounding 2.75 to E4M3: ⌊log⁡22.75⌋=1\lfloor\log_2 2.75\rfloor = 1, the quantum is 21−3=0.252^{1-3} = 0.25, and 2.75/0.25=112.75/0.25 = 11 exactly, so the value is 2.75 and the code is ((−2+3+7−1)≪3)+11=56+11=67((-2 + 3 + 7 - 1) \ll 3) + 11 = 56 + 11 = 67. To decode: ef=8e_f = 8, f=3f = 3, (8+3)⋅28−7−3=2.75(8 + 3)\cdot 2^{8 - 7 - 3} = 2.75.

The problems are grouped by topic. The tag after each question is its answer type.

q1. Give the relative condition number of f(x)=x−1f(x) = x - 1 at x=1.001x = 1.001. [number]

Answer

10011001. f′(x)=1f'(x) = 1, so κf=∣x⋅1/(x−1)∣=1.001/0.001=1001\kappa_f = \lvert x \cdot 1 / (x - 1)\rvert = 1.001 / 0.001 = 1001: a relative error of 10−610^{-6} in xx becomes about 10−310^{-3} in x−1x - 1. This is cancellation seen as conditioning. A common mistake is 11, the absolute condition ∣f′(x)∣\lvert f'(x)\rvert; 1/10011/1001 inverts the ratio.

q2. Give the relative condition number of f(x)=exf(x) = e^x at x=50x = 50. [number]

Answer

5050. xf′(x)/f(x)=xex/ex=xx f'(x)/f(x) = x e^x / e^x = x. A common mistake is e50e^{50}, the absolute condition ∣f′(x)∣\lvert f'(x)\rvert; relative errors are amplified by xx, not by exe^x.

q3. Give κ2\kappa_2 of diag(10,1/10)\mathrm{diag}(10, 1/10). [number]

Answer

100100. For a diagonal matrix the singular values are the absolute diagonal entries, 1010 and 1/101/10, so κ2=10/(1/10)=100\kappa_2 = 10/(1/10) = 100. A common mistake is 1010, taking the largest entry alone.

q4. Give κ2\kappa_2 of A=(3045)A = \begin{pmatrix} 3 & 0 \\ 4 & 5 \end{pmatrix}. [number]

Answer

33. A⊤A=(25202025)A^\top A = \begin{pmatrix} 25 & 20 \\ 20 & 25 \end{pmatrix} has eigenvalues 4545 and 55, so the singular values are 45\sqrt{45} and 5\sqrt 5 and κ2=45/5=3\kappa_2 = \sqrt{45/5} = 3. A common mistake is 5/35/3, the ratio of AA‘s eigenvalues (its diagonal, since it is triangular): AA is not symmetric, so eigenvalues are not singular values. 99 is the ratio of A⊤AA^\top A‘s eigenvalues, the square of the answer.

q5. κ2(A)=1000\kappa_2(A) = 1000 and bb moves by a relative amount ∥δb∥/∥b∥=10−6\lVert\delta b\rVert/\lVert b\rVert = 10^{-6}. Give the bound on the relative change ∥δx∥/∥x∥\lVert\delta x\rVert/\lVert x\rVert of the solution of Ax=bAx = b. [number]

Answer

10−310^{-3}. ∥δx∥/∥x∥≤κ2(A)⋅∥δb∥/∥b∥=1000⋅10−6\lVert\delta x\rVert/\lVert x\rVert \le \kappa_2(A) \cdot \lVert\delta b\rVert/\lVert b\rVert = 1000 \cdot 10^{-6}. A common mistake is 10−910^{-9}, dividing by the condition number instead of multiplying.

q6. Prove that if Ax=bAx = b and A(x+δx)=b+δbA(x + \delta x) = b + \delta b with AA invertible and b≠0b \ne 0, then ∥δx∥/∥x∥≤κ2(A) ∥δb∥/∥b∥\lVert\delta x\rVert/\lVert x\rVert \le \kappa_2(A)\, \lVert\delta b\rVert/\lVert b\rVert in the 2-norm. [proof]

Answer

Proof. Subtracting Ax=bAx = b from A(x+δx)=b+δbA(x + \delta x) = b + \delta b gives A δx=δbA\,\delta x = \delta b, so δx=A−1δb\delta x = A^{-1}\delta b. By the definition of the induced norm,

∥δx∥≤∥A−1∥ ∥δb∥.\lVert\delta x\rVert \le \lVert A^{-1}\rVert\,\lVert\delta b\rVert.

Also ∥b∥=∥Ax∥≤∥A∥ ∥x∥\lVert b\rVert = \lVert Ax\rVert \le \lVert A\rVert\,\lVert x\rVert. Since b≠0b \ne 0, x≠0x \ne 0, and dividing gives 1/∥x∥≤∥A∥/∥b∥1/\lVert x\rVert \le \lVert A\rVert/\lVert b\rVert. Multiplying the two non-negative bounds,

∥δx∥∥x∥≤∥A∥ ∥A−1∥ ∥δb∥∥b∥.\frac{\lVert\delta x\rVert}{\lVert x\rVert} \le \lVert A\rVert\,\lVert A^{-1}\rVert\,\frac{\lVert\delta b\rVert}{\lVert b\rVert}.

In the 2-norm, ∥A∥2=σmax⁡(A)\lVert A\rVert_2 = \sigma_{\max}(A), and the singular values of A−1A^{-1} are the reciprocals of those of AA, so ∥A−1∥2=1/σmin⁡(A)\lVert A^{-1}\rVert_2 = 1/\sigma_{\min}(A). The factor is therefore σmax⁡/σmin⁡=κ2(A)\sigma_{\max}/\sigma_{\min} = \kappa_2(A). ■\blacksquare

A complete proof has four steps: A δx=δbA\,\delta x = \delta b; the two norm bounds on ∥δx∥\lVert\delta x\rVert and 1/∥x∥1/\lVert x\rVert; their product; and the identification of ∥A∥2∥A−1∥2\lVert A\rVert_2\lVert A^{-1}\rVert_2 with σmax⁡/σmin⁡\sigma_{\max}/\sigma_{\min}.

q7. Give γ3\gamma_3 for float32 exactly. [number]

Answer

γ3=3u1−3u=3⋅2−241−3⋅2−24=3224−3\gamma_3 = \dfrac{3u}{1 - 3u} = \dfrac{3 \cdot 2^{-24}}{1 - 3 \cdot 2^{-24}} = \dfrac{3}{2^{24} - 3} (multiply numerator and denominator by 2242^{24}), with float32’s u=2−24u = 2^{-24}. A common mistake is 3⋅2−243 \cdot 2^{-24}, the first-order value without the denominator; 3/(223−3)3/(2^{23} - 3) uses machine epsilon 2−232^{-23} instead of uu.

q8. A float32 dot product of length k=4096k = 4096 has ∣x∣⋅∣y∣=1\lvert x\rvert \cdot \lvert y\rvert = 1. Give the first-order bound kuk u on its error. [number]

Answer

2−122^{-12}. ku⋅∣x∣⊤∣y∣=4096⋅2−24⋅1=212−24ku \cdot \lvert x\rvert^\top\lvert y\rvert = 4096 \cdot 2^{-24} \cdot 1 = 2^{12 - 24}. A common mistake is 2−112^{-11}, from using ϵ=2−23\epsilon = 2^{-23} for uu.

q9. The same dot product with the sum done pairwise: give the first-order bound (⌈log⁡2k⌉+1) u(\lceil \log_2 k\rceil + 1)\, u (one rounding per product, one per tree level). [number]

Answer

13⋅2−2413 \cdot 2^{-24}. ⌈log⁡24096⌉=12\lceil\log_2 4096\rceil = 12 tree levels, each one rounding, plus one rounding for each product: (12+1)u(12 + 1)u. A common mistake is 12⋅2−2412 \cdot 2^{-24}, which forgets that the products round too; 2−122^{-12} is the recursive (non-pairwise) bound of q8.

q10. In bf16, give the smallest kk for which ku≥1k u \ge 1, where the bound γk\gamma_k says nothing. [number]

Answer

256256. bf16 has 8 significant bits, so u=2−8u = 2^{-8} and ku≥1ku \ge 1 first at k=28k = 2^8. A common mistake is 128128, from ϵ=2−7\epsilon = 2^{-7}.

q11. The statistical rule of thumb replaces kuk u by k u\sqrt{k}\, u (errors with random signs add like a random walk). Give it for float32 and k=4096k = 4096. [number]

Answer

2−182^{-18}. 4096 u=64⋅2−24=26−24\sqrt{4096}\,u = 64 \cdot 2^{-24} = 2^{6 - 24}, sixty-four times smaller than the worst case 2−122^{-12} of q8. A common mistake is 2−122^{-12}, which is the worst case kuku, not the statistical rule.

q12. Prove that recursive summation of three numbers satisfies ∣fl(fl(x1+x2)+x3)−(x1+x2+x3)∣≤γ2(∣x1∣+∣x2∣+∣x3∣)\lvert \mathrm{fl}(\mathrm{fl}(x_1 + x_2) + x_3) - (x_1 + x_2 + x_3)\rvert \le \gamma_2 (\lvert x_1\rvert + \lvert x_2\rvert + \lvert x_3\rvert) under the model fl(a+b)=(a+b)(1+δ)\mathrm{fl}(a + b) = (a + b)(1 + \delta), ∣δ∣≤u\lvert\delta\rvert \le u. [proof]

Answer

Proof. Assume 2u<12u < 1 so γ2=2u/(1−2u)\gamma_2 = 2u/(1 - 2u) is defined. The first addition gives s1=fl(x1+x2)=(x1+x2)(1+δ1)s_1 = \mathrm{fl}(x_1 + x_2) = (x_1 + x_2)(1 + \delta_1) and the second s2=fl(s1+x3)=(s1+x3)(1+δ2)s_2 = \mathrm{fl}(s_1 + x_3) = (s_1 + x_3)(1 + \delta_2), with ∣δ1∣,∣δ2∣≤u\lvert\delta_1\rvert, \lvert\delta_2\rvert \le u. Expanding,

s2=(x1+x2)(1+δ1)(1+δ2)+x3(1+δ2),s_2 = (x_1 + x_2)(1 + \delta_1)(1 + \delta_2) + x_3(1 + \delta_2),

so the error is

s2−(x1+x2+x3)=(x1+x2)[(1+δ1)(1+δ2)−1]+x3 δ2.s_2 - (x_1 + x_2 + x_3) = (x_1 + x_2)\bigl[(1 + \delta_1)(1 + \delta_2) - 1\bigr] + x_3\,\delta_2.

Bound each factor. ∣(1+δ1)(1+δ2)−1∣=∣δ1+δ2+δ1δ2∣≤2u+u2\lvert(1 + \delta_1)(1 + \delta_2) - 1\rvert = \lvert\delta_1 + \delta_2 + \delta_1\delta_2\rvert \le 2u + u^2, and this is at most γ2\gamma_2 because γ2−(2u+u2)=2u−(2u+u2)(1−2u)1−2u=u2(3+2u)1−2u≥0\gamma_2 - (2u + u^2) = \frac{2u - (2u + u^2)(1 - 2u)}{1 - 2u} = \frac{u^2(3 + 2u)}{1 - 2u} \ge 0. Also ∣δ2∣≤u≤γ2\lvert\delta_2\rvert \le u \le \gamma_2. By the triangle inequality,

∣s2−(x1+x2+x3)∣≤γ2∣x1+x2∣+γ2∣x3∣≤γ2(∣x1∣+∣x2∣+∣x3∣).■\lvert s_2 - (x_1 + x_2 + x_3)\rvert \le \gamma_2\lvert x_1 + x_2\rvert + \gamma_2\lvert x_3\rvert \le \gamma_2(\lvert x_1\rvert + \lvert x_2\rvert + \lvert x_3\rvert). \quad\blacksquare

The key observation is that x1x_1 and x2x_2 pass through two roundings and x3x_3 through one, and both counts are covered by γ2\gamma_2.

q13. The iteration xk+1=cos⁡xkx_{k+1} = \cos x_k converges to the fixed point x∗≈0.739085x^* \approx 0.739085. Give its asymptotic linear rate ∣g′(x∗)∣=sin⁡x∗\lvert g'(x^*)\rvert = \sin x^* to at least 7 significant digits. [number, rtol 1e-6]

Answer

sin⁡x∗≈0.6736120\sin x^* \approx 0.6736120. g(x)=cos⁡xg(x) = \cos x, so g′(x)=−sin⁡xg'(x) = -\sin x and the rate is ∣g′(x∗)∣=sin⁡(0.7390851332)=0.6736120291832148\lvert g'(x^*)\rvert = \sin(0.7390851332) = 0.6736120291832148: each step multiplies the error by about 0.6740.674, so one decimal digit takes about ln⁡10/ln⁡(1/0.674)≈5.8\ln 10 / \ln(1/0.674) \approx 5.8 steps. A common mistake is to quote the fixed point 0.7390.739 instead of the rate; four digits (0.67360.6736) are not enough for the requested precision.

q14. Newton’s method for f(y)=1/y2−af(y) = 1/y^2 - a gives yk+1=yk(3−ayk2)/2y_{k+1} = y_k (3 - a y_k^2)/2, the update Fixed-point iteration and fast inverse square root in C uses for rsqrt. With a=4a = 4 and y0=0.4y_0 = 0.4, give y1y_1 exactly. [number]

Answer

y1=59/125y_1 = 59/125. ay02=4⋅4/25=16/25a y_0^2 = 4 \cdot 4/25 = 16/25, 3−16/25=59/253 - 16/25 = 59/25, and y1=25⋅5925⋅12=59125=0.472y_1 = \frac{2}{5} \cdot \frac{59}{25} \cdot \frac12 = \frac{59}{125} = 0.472, approaching 1/4=1/21/\sqrt{4} = 1/2. A common mistake is 1/21/2, the limit rather than one step (and the decimal 0.4720.472 is the same number, but the exact fraction is asked).

q15. Let ek=1−a yke_k = 1 - \sqrt{a}\, y_k be the relative error of that iteration. Using the identity of q17, give e1e_1 exactly when e0=2−4e_0 = 2^{-4}. [number]

Answer

e1=47/8192e_1 = 47/8192. With e0=1/16e_0 = 1/16: 3e02−e032=3/256−1/40962=48/4096−1/40962=478192≈2−7.45\frac{3 e_0^2 - e_0^3}{2} = \frac{3/256 - 1/4096}{2} = \frac{48/4096 - 1/4096}{2} = \frac{47}{8192} \approx 2^{-7.45}. A common mistake is 3/5123/512, keeping only the leading term 32e02\frac32 e_0^2 and dropping −12e03-\frac12 e_0^3.

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 ek+1/eke_{k+1}/e_k in the limit). [number]

Answer

(a) 22. At a simple root, g′(x∗)=0g'(x^*) = 0 and ek+1≈g′′(x∗)2ek2e_{k+1} \approx \frac{g''(x^*)}{2} e_k^2.

(b) 1/21/2. Near a double root, f(x)=(x−x∗)2h(x)f(x) = (x - x^*)^2 h(x) with h(x∗)≠0h(x^*) \ne 0. Then f/f′≈(x−x∗)/2f/f' \approx (x - x^*)/2, so xk+1−x∗≈(xk−x∗)−(xk−x∗)/2x_{k+1} - x^* \approx (x_k - x^*) - (x_k - x^*)/2: the error halves every step. A common mistake is 1 (no convergence) or 2 (still quadratic).

q17. Prove that the iteration of q14 satisfies ek+1=(3ek2−ek3)/2e_{k+1} = (3 e_k^2 - e_k^3)/2, and conclude that it converges quadratically. [proof]

Answer

Proof. From the definition, yk=(1−ek)/ay_k = (1 - e_k)/\sqrt{a}, so ayk2=(1−ek)2a y_k^2 = (1 - e_k)^2. Substituting into the update and multiplying by a\sqrt{a},

a yk+1=(1−ek)(3−(1−ek)2)2.\sqrt{a}\,y_{k+1} = \frac{(1 - e_k)\bigl(3 - (1 - e_k)^2\bigr)}{2}.

Expand: 3−(1−ek)2=2+2ek−ek23 - (1 - e_k)^2 = 2 + 2e_k - e_k^2, and

(1−ek)(2+2ek−ek2)=2+2ek−ek2−2ek−2ek2+ek3=2−3ek2+ek3.(1 - e_k)(2 + 2e_k - e_k^2) = 2 + 2e_k - e_k^2 - 2e_k - 2e_k^2 + e_k^3 = 2 - 3e_k^2 + e_k^3.

So a yk+1=1−(3ek2−ek3)/2\sqrt{a}\,y_{k+1} = 1 - (3e_k^2 - e_k^3)/2, and reading off ek+1=1−a yk+1e_{k+1} = 1 - \sqrt{a}\,y_{k+1},

ek+1=3ek2−ek32.e_{k+1} = \frac{3e_k^2 - e_k^3}{2}.

Quadratic convergence. If ∣e0∣≤1/2\lvert e_0\rvert \le 1/2, then ∣ek+1∣≤∣ek∣2(3+∣ek∣)/2≤74∣ek∣2≤78∣ek∣\lvert e_{k+1}\rvert \le \lvert e_k\rvert^2 (3 + \lvert e_k\rvert)/2 \le \tfrac{7}{4}\lvert e_k\rvert^2 \le \tfrac{7}{8}\lvert e_k\rvert, so ek→0e_k \to 0 and yk→1/ay_k \to 1/\sqrt{a}. Then ek+1/ek2=(3−ek)/2→3/2e_{k+1}/e_k^2 = (3 - e_k)/2 \to 3/2, a finite non-zero constant: the convergence is quadratic, and the number of correct bits roughly doubles each step (q15: e0=2−4e_0 = 2^{-4} gives e1≈2−7.4e_1 \approx 2^{-7.4}). ■\blacksquare

q18. expf reduces x=kln⁡2+rx = k \ln 2 + r with k=round(x/ln⁡2)k = \mathrm{round}(x / \ln 2), so ex=2kere^x = 2^k e^r. Give rr for x=10x = 10, exactly. [number]

Answer

r=10−14ln⁡2≈0.29594r = 10 - 14\ln 2 \approx 0.29594. 10/ln⁡2=14.42710/\ln 2 = 14.427, the nearest integer is k=14k = 14, and r=x−kln⁡2r = x - k\ln 2. A common mistake is 10−15ln⁡2≈−0.39710 - 15\ln 2 \approx -0.397, which rounds 14.42714.427 up and leaves rr outside [−ln⁡2/2,ln⁡2/2][-\ln 2/2, \ln 2/2].

q19. Give the half-width of the interval the reduced argument rr lies in. [number]

Answer

ln⁡2/2≈0.3466\ln 2 / 2 \approx 0.3466. Rounding x/ln⁡2x/\ln 2 to the nearest integer leaves a remainder of at most 1/21/2 in units of ln⁡2\ln 2. A common mistake is ln⁡2\ln 2, the bound for truncation (floor), not rounding.

q20. On ∣r∣≤ln⁡2/2\lvert r\rvert \le \ln 2 / 2, the Taylor polynomial of ere^r of degree nn has the Lagrange bound eln⁡2/2(ln⁡2/2)n+1/(n+1)!e^{\ln 2/2} (\ln 2/2)^{n+1}/(n+1)!. Give the smallest nn for which it is below 2−242^{-24}. [number]

Answer

n=7n = 7. With h=ln⁡2/2≈0.3466h = \ln 2/2 \approx 0.3466 and eh=2e^h = \sqrt 2: for n=6n = 6 the bound is 2⋅h7/7!≈1.69×10−7\sqrt2 \cdot h^7/7! \approx 1.69 \times 10^{-7}, above 2−24≈5.96×10−82^{-24} \approx 5.96 \times 10^{-8}; for n=7n = 7 it is 2⋅h8/8!≈7.3×10−9\sqrt2 \cdot h^8/8! \approx 7.3 \times 10^{-9}, 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

77. Horner’s form a0+r(a1+r(a2+⋯+r a7))a_0 + r(a_1 + r(a_2 + \dots + r\,a_7)) has one multiplication per degree. A common mistake is 28=1+2+⋯+728 = 1 + 2 + \dots + 7, computing every power rjr^j from scratch.

q22. Give the three Chebyshev nodes on [−1,1][-1, 1] (the zeros of T3(x)=4x3−3xT_3(x) = 4x^3 - 3x). [set]

Answer

{−3/2,0,3/2}\{-\sqrt3/2, 0, \sqrt3/2\}. 4x3−3x=x(4x2−3)=04x^3 - 3x = x(4x^2 - 3) = 0 gives x=0x = 0 or x=±3/2x = \pm\sqrt{3}/2; equivalently xj=cos⁡(2j+1)π6x_j = \cos\frac{(2j + 1)\pi}{6} for j=0,1,2j = 0, 1, 2. Common mistakes are the equispaced {−1,0,1}\{-1, 0, 1\} or {−1/2,0,1/2}\{-1/2, 0, 1/2\}.

q23. Give max⁡x∈[−1,1]∣(x−x0)(x−x1)(x−x2)∣\max_{x \in [-1, 1]} \lvert (x - x_0)(x - x_1)(x - x_2)\rvert for those three nodes. [number]

Answer

1/41/4. The node product is the monic polynomial with those roots, x3−34x=T3(x)/4x^3 - \tfrac34 x = T_3(x)/4, and ∣T3∣≤1\lvert T_3\rvert \le 1 on [−1,1][-1, 1] with equality at the endpoints, so the maximum is 1/4=2−21/4 = 2^{-2}, the 2−n2^{-n} of the Chebyshev bound above. A common mistake is 2/(33)≈0.3852/(3\sqrt3) \approx 0.385, the maximum of ∣x3−x∣\lvert x^3 - x\rvert for the equispaced nodes −1,0,1-1, 0, 1 (attained at x=1/3x = 1/\sqrt3).

q24. Round 5.35.3 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) 11/2=5.511/2 = 5.5. ⌊log⁡25.3⌋=2\lfloor\log_2 5.3\rfloor = 2, so the quantum is 22−3=0.52^{2 - 3} = 0.5; 5.3/0.5=10.65.3/0.5 = 10.6 rounds to n=11n = 11, and 11⋅0.5=5.511 \cdot 0.5 = 5.5.

(b) 7575. The code is ((qe+M+B−1)≪M)+n=((−1+3+7−1)≪3)+11=64+11=75((q_e + M + B - 1) \ll M) + n = ((-1 + 3 + 7 - 1) \ll 3) + 11 = 64 + 11 = 75, binary 0 1001 011: sign 0, exponent field 9, fraction 3, value (1+3/8)⋅29−7=5.5(1 + 3/8) \cdot 2^{9 - 7} = 5.5.

A common mistake in (a) is 21/4=5.2521/4 = 5.25, which uses a grid twice as fine as E4M3’s in [4,8)[4, 8), or 55, which truncates. In (b), 1111 is the significand count nn, not the code, and 8383 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) 57344=1.75⋅21557344 = 1.75 \cdot 2^{15}. The largest finite exponent field is 3030 (31 is reserved), 30−15=1530 - 15 = 15, and the largest significand with 2 fraction bits is 1.112=1.751.11_2 = 1.75. A common mistake is 61440=1.875⋅21561440 = 1.875 \cdot 2^{15}, which uses 3 fraction bits; 448448 is E4M3’s maximum.

(b) 2−92^{-9}. The smallest subnormal is one unit of the subnormal quantum 21−B−M=21−7−32^{1 - B - M} = 2^{1 - 7 - 3}. A common mistake is 2−62^{-6}, the smallest normal.

q26. Give the unit roundoff of e4m3. [number]

Answer

2−42^{-4}. E4M3 has 3+1=43 + 1 = 4 significant bits, so u=2−4u = 2^{-4}. A common mistake is 2−32^{-3}, the gap at 1 (machine epsilon), twice uu.

q27. An MX block in fp4 E2M1 (largest value 6, emax⁡=2e_{\max} = 2) has largest magnitude 13. (a) Give its shared scale X=2⌊log⁡213⌋−emax⁡X = 2^{\lfloor \log_2 13 \rfloor - e_{\max}}. (b) Give the dequantized value of the element 13. [number]

Answer

(a) X=2X = 2. ⌊log⁡213⌋=3\lfloor\log_2 13\rfloor = 3, so X=23−2=2X = 2^{3 - 2} = 2. (b) 1212. 13/2=6.513 / 2 = 6.5 is above FP4’s largest value 6, so it saturates to 6, and 6⋅2=126 \cdot 2 = 12. A common mistake in (a) is 13/613/6, a per-tensor floating scale; MX scales are powers of two. In (b), 1313 assumes no rounding and 14=7⋅214 = 7 \cdot 2 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 2−162^{-16} (smallest subnormal) to 5734457344, about 32 binades, against E4M3’s 2−92^{-9} to 448448, about 18. E4M3 spends the bit on precision instead, which is why weights and activations use E4M3 and gradients often use E5M2.

The wrong answers flagged in the problems are the same mistakes that break real tolerances and kernels. Each maps to a problem:

PitfallSymptomHow to avoid it
The absolute condition ∣f′(x)∣\lvert f'(x)\rvert for the relative onee50e^{50} instead of 50q1, q2: multiply by x/f(x)x/f(x)
Eigenvalues of AA for singular values5/35/3 instead of 3 for a non-symmetric matrixq4: take square roots of the eigenvalues of A⊤AA^\top A
ϵ=2u\epsilon = 2u for uuevery bound off by 2; bf16 void at 128q7, q8, q10: u=2−pu = 2^{-p} with pp counting the implicit bit
Forgetting that products round toothe pairwise bound one uu shortq9: one rounding per tree level plus one per product
Quoting the fixed point instead of the rate0.739 for 0.674q13: the rate is ∣g′(x∗)∣=sin⁡x∗\lvert g'(x^*)\rvert = \sin x^*
Keeping only the leading term of Newton’s error3/5123/512 instead of 47/819247/8192q15: use the exact identity of q17
Rounding x/ln⁡2x/\ln 2 up instead of to nearesta reduced argument outside [−ln⁡2/2,ln⁡2/2][-\ln 2/2, \ln 2/2]q18: kk is the nearest integer
Equispaced interpolation nodesa larger node product (0.385 vs 0.25)q22, q23: the zeros of Tn+1T_{n+1}
E5M2’s or the significand count’s grid for E4M3’s codewrong value or codeq24: quantum 2⌊log⁡2v⌋−32^{\lfloor\log_2 v\rfloor - 3}, code ((qe+M+B−1)≪M)+n((q_e + M + B - 1) \ll M) + n
A per-tensor float scale where MX wants a power of twoa scale of 13/6q27: X=2⌊log⁡2amax⁡⌋−emax⁡X = 2^{\lfloor\log_2 a_{\max}\rfloor - e_{\max}}

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.

  • 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.
  • Relative condition number: ∣xf′(x)/f(x)∣\lvert x f'(x)/f(x)\rvert, the factor by which ff amplifies relative input errors.
  • γk\gamma_k: ku/(1−ku)ku/(1 - ku), the bound on the relative error accumulated over kk roundings.
  • Linear convergence: the error shrinks by a constant factor ∣g′(x∗)∣<1\lvert g'(x^*)\rvert < 1 each step.
  • Quadratic convergence: the error is proportional to the square of the previous error, so correct digits double.
  • Chebyshev nodes: the zeros of Tn+1T_{n+1}, which minimize the maximum of the interpolation node product on [−1,1][-1, 1].
  • MX block scale: a shared power of two that places a block’s largest magnitude in the element format’s top binade.
  • The relative condition number κf(x)=∣xf′(x)/f(x)∣\kappa_f(x) = \lvert x f'(x) / f(x)\rvert and the matrix condition number κ2(A)=σmax⁡/σmin⁡\kappa_2(A) = \sigma_{\max}/\sigma_{\min} say how much the problem amplifies input errors, whatever the algorithm (q1 to q6).
  • Every rounding multiplies by (1+δ)(1 + \delta), ∣δ∣≤u\lvert\delta\rvert \le u, and kk of them stay within γk=ku/(1−ku)\gamma_k = ku/(1 - ku); pairwise summation cuts kk to log⁡2k\log_2 k, and random signs typically give k u\sqrt{k}\,u (q7 to q12).
  • Fixed-point iteration converges linearly at the rate ∣g′(x∗)∣\lvert g'(x^*)\rvert; Newton converges quadratically at a simple root, so the correct digits double each step (q13 to q17).
  • expf reduces xx to r∈[−ln⁡2/2,ln⁡2/2]r \in [-\ln 2/2, \ln 2/2] 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 2−42^{-4} 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).