4.8.1Numerical Methods

Sources of error — truncation error, round-off error

1,499 words7 min readdifficulty · medium

1. The two error sources


2. Derive truncation error from scratch (forward difference)

We want f(x)f'(x). Start from Taylor's theorem (the one exact tool):

f(x+h)=f(x)+hf(x)+h22f(x)+h36f(x)+f(x+h) = f(x) + h f'(x) + \frac{h^2}{2}f''(x) + \frac{h^3}{6}f'''(x)+\cdots

Why this step? Taylor expansion is exact (with remainder), so any error we find is honest, not assumed.

Solve for f(x)f'(x):

f(x)=f(x+h)f(x)hh2f(x)h26f(x)what we throw awayf'(x) = \frac{f(x+h)-f(x)}{h} - \underbrace{\frac{h}{2}f''(x) - \frac{h^2}{6}f'''(x)-\cdots}_{\text{what we throw away}}

Why this step? Rearranging isolates the finite-difference formula and shows precisely the discarded tail.

Why f(ξ)f''(\xi) and not f(x)f''(x)? Taylor's remainder form puts the leftover at some unknown point ξ(x,x+h)\xi\in(x,x+h) — exact, no infinite sum needed.


3. Quantify round-off error

When the machine stores f(x)f(x) it actually stores f~(x)=f(x)(1+δ)\tilde f(x)=f(x)(1+\delta) with δεmach|\delta|\le\varepsilon_{\text{mach}}.

For the forward difference, the numerator f(x+h)f(x)f(x+h)-f(x) carries an absolute error εmachf(x)\sim \varepsilon_{\text{mach}}\,|f(x)|. Dividing by hh:

ER    εmachf(x)hE_R \;\approx\; \frac{\varepsilon_{\text{mach}}\,|f(x)|}{h}

Why divide by hh? The error in the numerator is roughly fixed (order εmachf\varepsilon_{\text{mach}}|f|), but we divide by the tiny hh, so the relative damage grows as h0h\to0.

Figure — Sources of error — truncation error, round-off error

4. Worked numerical example


5. Common mistakes


6. Active recall flashcards

What is truncation error?
Error from replacing an exact operation by an approximate/finite one (e.g. cutting a Taylor series); exists even with infinite precision.
What is round-off error?
Error from storing numbers with finitely many digits (finite floating-point precision).
Order of forward-difference truncation error?
O(h)O(h), equal to h2f(ξ)-\frac h2 f''(\xi).
Order of central-difference truncation error?
O(h2)O(h^2), equal to h26f(ξ)-\frac{h^2}{6}f'''(\xi).
Why does central difference beat forward?
Symmetric subtraction cancels the ff'' term, leaving O(h2)O(h^2).
How does round-off error scale with hh in forward difference?
εmachf/h\approx \varepsilon_{\text{mach}}|f|/h, grows as h0h\to0.
Optimal hh for forward difference?
hopt=2εmachf/fεmach108h_{\text{opt}}=\sqrt{2\varepsilon_{\text{mach}}|f|/|f''|}\sim\sqrt{\varepsilon_{\text{mach}}}\approx10^{-8} for doubles.
What is machine epsilon for IEEE double?
2.22×1016\approx 2.22\times10^{-16}.
What is catastrophic cancellation?
Loss of significant digits when subtracting two nearly equal numbers.
Test to tell the two errors apart?
Would the error vanish on a perfect-precision calculator? Yes → truncation, No → round-off.

Recall Feynman: explain to a 12-year-old

Imagine measuring a curved hill's steepness. You walk a step forward and divide height gained by step length. If your step is huge, you miss the curve's wiggle — that's truncation error (your "math shortcut" was too rough). If you take a tiny step, the two heights are almost the same, and your ruler can only read so many digits — the tiny difference gets lost in rounding — that's round-off error. So a medium step gives the best answer: not too big, not too small.

Connections

Concept Map

corrupted by

corrupted by

derives

derives

has

smaller

bounds

shrinks as h to 0

amplifies

grows as h to 0

determines

Numerical computation

Truncation error

Round-off error

Taylor theorem

Forward difference O h

Central difference O h2

Machine epsilon

Subtract near-equal numbers

Error trade-off

Optimal step size h

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, jab bhi computer ya tum khud koi numerical method se answer nikalte ho, woh exact nahi hota. Do main wajah hoti hain. Pehli — truncation error: hum exact process ko beech mein hi kaat dete hain. Jaise derivative ki definition mein limit h0h\to0 hoti hai, lekin practically hum chhota sa finite hh le lete hain. Taylor series ka jo tail bachta hai, woh hi truncation error hai. Yeh error perfect calculator pe bhi rahega, kyunki yeh maths ka approximation hai.

Dusri wajah — round-off error: computer har number ko sirf kuch hi digits mein store karta hai (machine epsilon 1016\approx 10^{-16} doubles ke liye). Toh real numbers thoda sa round ho jaate hain. Yeh error tab khatarnaak banta hai jab tum do bahut paas-paas ke numbers ko subtract karte ho — important digits cancel ho jaate hain, sirf noise bachta hai. Isko catastrophic cancellation kehte hain.

Ab maza yahan hai: truncation error chhota hota hai jab hh chhota karo, lekin round-off error bada hota hai jab hh bahut chhota karo (kyunki 1/h1/h bada ho jaata hai). Toh dono opposite directions mein khinchte hain. Best answer ek medium hh pe milta hai — jise hoptεmach108h_{opt}\sim\sqrt{\varepsilon_{mach}}\approx10^{-8} kehte hain (forward difference ke liye). Isiliye "hh jitna chhota, utna accurate" — yeh galat soch hai!

Yaad rakhne ka tarika: Truncate = jaldi trim kiya (bada h mein zyada error), Round = digits khatam (chhota h mein zyada error). Graph banao toh total error ki shape smiley jaisi U hoti hai — bottom pe sweet spot. Exam mein agar forward difference ka order poochhe toh O(h)O(h), central difference ka O(h2)O(h^2) — kyunki symmetric subtraction se ff'' term cancel ho jaata hai.

Test yourself — Numerical Methods

Connections