Differential Equations & Numerical Methods · BE5B01DEN · Topic 2 of 13
Errors in computing
Week 2. Know absolute and relative error, the floating point bound, and why subtracting nearly equal numbers is dangerous.
Key ideas
Name the error you measure
For an exact x and an estimate x̂, the absolute error is E=x−x̂ and the relative error is ε=|E|/|x|. An error estimate is any number e with |E|≤e.
Floating point: the relative bound
Rounding x to p significant digits in base β gives fl(x)=d₁.d₂…d_p×β^e, and the relative error stays below half a unit in the last place relative to the leading digit.
Watch the subtraction
Sums of positive numbers, products and quotients keep the relative error under control, but a difference can magnify it by (|x|+|y|)/|x−y|. This is why close numbers should not be subtracted if you can rearrange the formula.
In one line: Relative error is what counts, and subtraction of near-equal numbers is where it explodes.
Formulas
- Name the error you measure
- Floating point: the relative bound
- Watch the subtraction
Practice with worked solutions
Question 1
A decimal floating point system keeps p = 4 significant digits (β = 10). Use the bound to find the largest relative rounding error.
Worked solution
Answer: 0.0005
Insert β=10 and p=4 into ½β¹⁻ᵖ.
Question 2
Estimates of x = 10.01 and y = 10.00 have relative errors at most 0.000001 each. Bound the relative error of x − y.
Worked solution
Answer: 0.002001
The factor (|x|+|y|)/|x−y| = 2001 magnifies the input error.
Question 3
Which operation can destroy the relative accuracy of the result?
- Adding two positive estimates
- Multiplying two estimates
- Subtracting two nearly equal estimates (correct)
- Taking the reciprocal of an estimate
Worked solution
Subtraction of close numbers is the one operation with a large amplification factor.
More Differential Equations & Numerical Methods practice in Ucenly
Sources
Written by Ucenly. Based on the BE5B01DEN course materials:
- Course card BE5B01DEN (Bílá kniha), p. 1
- Lecture slides: Errors in calculations (edens_n1error.pdf), p. 1, 2
- Habala: Ordinary Differential Equations and Numerical Analysis (dnbook.pdf), p. 13
- Homework 3 (edenhw03.pdf), p. 1