Shelves / Arithmetic and Numbers
AN·11
Estimation, Rounding, Error and Units
Making numbers honest: estimating before calculating and Fermi problems, rounding to decimal places and significant figures, the different rounding rules and which bias they bring, double rounding, absolute and relative error and how errors grow through sums and products, why subtracting close measurements is dangerous, and units: converting by multiplying by one, units inside rates, areas and volumes, mixed units like hours and minutes, and the disasters that came from mixing them up.
Start here
What this chapter answers
What's a sensible quick answer for , and how many litres of water does a city drink in a day? What's the difference between "to 2 decimal places" and "to 2 significant figures"? Why does Python round 2.5 to 2? How accurate is an area worked out from two measurements, and why is the difference of two close measurements so unreliable? How do you turn km/h into m/s without memorising a factor? How do you add 2 h 45 min and 1 h 30 min? And how did a unit mix-up lose a spacecraft?
Honest numbers in one picture
A tailor's tape says a waist is 81 cm. The tape is marked in centimetres, so the truth is somewhere between 80.5 and 81.5 cm: the number is a range written as one value. Everything in this chapter follows from that picture: estimates are deliberately rough values, rounding chooses which single value to write for a range, error measures how wide the range is, and units say what the number counts.
Estimation
Estimate first
Before calculating, estimate: round each number to one or two significant figures and do the easy version. ; the exact answer is 14,976. An estimate catches the errors that matter most, a misplaced decimal point or a missing zero, because those make the answer ten times wrong, not 3 % wrong. Chapter 4's digit count (a 2-digit number times a 3-digit number has 4 or 5 digits) is a cruder check of the same kind.
Useful tricks: round to compatible numbers that are easy together ( ); use front-end estimation for sums (add the leading digits, then adjust); and estimate both ways when you need bounds, rounding everything down for a low estimate and up for a high one.
Fermi estimates
Some questions have no data to hand: how much water does Hyderabad use in a day? Break the question into factors you can guess: about people (order of magnitude, chapter 10), each using about 100 to 150 litres a day for drinking, cooking, washing and bathing, so about litres, a billion litres a day. Each factor may be off by a factor of 2, but errors in different directions partly cancel, and the answer is usually right to within a factor of a few, which is enough to decide whether a plan is plausible. The method's power is that it shows which factor matters most and what to measure next.
Estimates as checks in code
Estimation works in software too: a monthly bill that's ten times last month's, a speed above the speed of light, a population larger than the planet's. Sanity checks compare a computed result with an estimated range and flag anything outside it, catching unit mistakes and misplaced points before they reach a user.
Rounding
Decimal places and significant figures
Decimal places count digits after the point: 3.14159 to 2 decimal places is 3.14. Significant figures count digits from the first non-zero one: 0.004 076 to 2 significant figures is 0.0041, and 7,651 to 2 significant figures is 7,700. Decimal places suit money (always to the paisa); significant figures suit measurements and scientific notation, where the size varies but the precision is relative: has 3 significant figures.
Zeros are ambiguous in whole numbers: is 7,700 given to 2 significant figures or 4? Scientific notation removes the doubt: against . Trailing zeros after a point are information: 2.50 m claims precision to the centimetre; 2.5 m only to the 10 cm.
Rules for the halfway case
Rounding is only a choice when a number is exactly halfway, as with 2.5 to a whole number. Several rules are in use:
| Aspect | Half up | Half even ("banker's") | Down (truncate) | Up | Floor | Ceiling |
|---|---|---|---|---|---|---|
| 2.5 | 3 | 2 | 2 | 3 | 2 | 3 |
| 3.5 | 4 | 4 | 3 | 4 | 3 | 4 |
| −2.5 | −3 | −2 | −2 | −3 | −3 | −2 |
| 2.51 | 3 | 3 | 2 | 3 | 2 | 3 |
| Used for | Money, school arithmetic | Statistics, IEEE floats, Python's round |
Cutting off digits | Charging for any part | Whole units that fit | Whole units needed |
(Here "half up" means away from zero for halves, as most money rules do.) Half up pushes every half the same way, so over many values it adds a bias: the lab rounds 10,000 numbers ending in .5 and finds half up adds 5,000 in total, while half even rounds half of them up and half down and adds nothing. That's why statistical software and floating-point hardware use half even. Floor and ceiling answer chapter 4's grouping questions: how many full boxes (floor), how many boxes to hold everything (ceiling).
Round once, at the end
Rounding throws information away, so do it once, as late as possible. Double rounding can give a different answer from rounding once: 1.445 rounded to 2 places is 1.45, which rounds to 1 place as 1.5; but 1.445 rounded straight to 1 place is 1.4. Rounding each line of a bill and then adding can differ from adding and then rounding (chapter 7's exercises, S2). When a rule says to round at a particular step (each invoice line, each month's interest), follow it exactly; otherwise keep full precision until the final display.
Error
Absolute and relative error
If the true value is and the measured or approximate value is , the absolute error is and the relative error is , often given as a percentage. A ruler reading of 81 cm for a true 81.3 cm has an absolute error of 0.3 cm and a relative error of 0.37 %. Relative error is what lets you compare: being 1 km off is excellent for the distance to the Moon and terrible for the length of a room.
A measurement's precision is usually stated as a range: 81 cm "to the nearest centimetre" means cm. Significant figures are a rough way of saying the same: a value given to 3 significant figures has a relative error of up to about 0.5 % to 5 %, depending on its leading digit.
How errors grow
When measured values are combined, their errors combine too.
So absolute errors add for sums and differences; relative errors add for products and quotients. A room measured as 412 cm by 365.5 cm, each to ±0.25 cm, has an area of about 15.06 m² with a relative error of about 0.13 %, the sum of the two lengths' relative errors (the lab checks it). These are worst cases; independent errors usually partly cancel, which statistics (beyond this book) quantifies.
Subtracting close numbers
The rule for differences hides a danger. Two readings of 1000.0 and 998.0, each , are each accurate to 0.05 %. Their difference, 2.0, has an absolute error of up to 1.0: a relative error of 50 %. Subtracting nearly equal values keeps the absolute error but removes most of the value, so the relative error explodes. This cancellation is behind the variance bug in chapter 10's companion and many numerical failures; the cure is to rearrange calculations so they don't subtract close quantities, or to measure the difference directly.
Units
A quantity is a number and a unit
"5" isn't a length; "5 m" is. A unit is part of the quantity, and arithmetic treats it like a factor: , , and you can only add quantities with the same unit, as you could only add fractions with the same denominator (chapter 6). The SI has seven base units (metre, kilogram, second, ampere, kelvin, mole, candela) and builds the rest from them, with the powers-of-ten prefixes of chapter 10.
Converting: multiply by one
A conversion factor is a fraction equal to 1, such as or . Multiplying by it changes the units without changing the quantity, and the units cancel like factors:
There's nothing to memorise: write the factors so the unwanted units cancel. If they don't cancel, the factor is upside down, which is the whole check. This is dimensional analysis, and it also checks formulas: speed × time must give a length, so a formula that gives km·h for a distance is wrong.
Areas and volumes
Units that are squared or cubed convert with squared or cubed factors (chapter 10's scaling): , so and litres. A hectare is , and a square kilometre is 100 hectares. Land in India is still often measured in local units (acres, guntas, cents, bighas, whose size varies by state), so conversion factors must come from the right local table.
Mixed units and carrying
Some quantities are written in several units at once: 2 h 45 min, 5 ft 8 in, 3 kg 250 g. Adding them is chapter 3's column addition with a different carry: 60 minutes make an hour, 12 inches a foot, 1000 grams a kilogram.
Subtraction borrows the same way (borrow 1 h as 60 min). The safest method, in code especially, is to convert everything to the smallest unit (minutes, inches, grams), calculate with whole numbers, and convert back with the division algorithm (chapter 4): 255 minutes is , 4 h 15 min. Indian number names (lakh, crore) are a naming convention for powers of ten, not a different unit: ₹2.5 lakh is ₹2,50,000 whichever way it's written.
Lab: rounding, error and units in code
Experiment 1: rounding rules, double rounding and bias
from decimal import Decimal as D, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_HALF_DOWN, ROUND_DOWN, ROUND_UP, ROUND_CEILING, ROUND_FLOOR
modes = [("half up", ROUND_HALF_UP), ("half even", ROUND_HALF_EVEN), ("down", ROUND_DOWN), ("up", ROUND_UP), ("floor", ROUND_FLOOR), ("ceiling", ROUND_CEILING)]
print("value " + "".join(f"{n:>10}" for n, _ in modes))
for v in ("2.5", "3.5", "-2.5", "2.51", "-2.49"):
print(f"{v:<6} " + "".join(f"{str(D(v).quantize(D('1'), rounding=m)):>10}" for _, m in modes))
# Double rounding: round to 2 places, then to 1, against rounding once
x = D("1.445")
twice = x.quantize(D("0.01"), ROUND_HALF_UP).quantize(D("0.1"), ROUND_HALF_UP)
print("1.445 rounded twice:", twice, "| once:", x.quantize(D("0.1"), ROUND_HALF_UP))
# Rounding bias: 10,000 values ending in exactly .5
vals = [D(n) + D("0.5") for n in range(10_000)]
exact = sum(vals)
for name, m in (("half up", ROUND_HALF_UP), ("half even", ROUND_HALF_EVEN)):
print(f"sum of {name} roundings - exact sum = {sum(v.quantize(D('1'), rounding=m) for v in vals) - exact}")
value half up half even down up floor ceiling
2.5 3 2 2 3 2 3
3.5 4 4 3 4 3 4
-2.5 -3 -2 -2 -3 -3 -2
2.51 3 3 2 3 2 3
-2.49 -2 -2 -2 -3 -3 -2
1.445 rounded twice: 1.5 | once: 1.4
sum of half up roundings - exact sum = 5000.0
sum of half even roundings - exact sum = 0.0
The six rules agree away from halves and disagree exactly on them: 2.5 goes to 2 or 3, and splits floor from "down" (towards zero). Rounding 1.445 twice gives 1.5, once gives 1.4. And over 10,000 exact halves, half up adds 5,000 to the total (every half goes up), while half even adds exactly nothing: the reason banks' "banker's rounding" is used where many rounded values are summed. Python's decimal names each rule, so code can say which one it uses.
Experiment 2: how measurement errors grow
from fractions import Fraction as F
# A room measured to the nearest 0.5 cm: 412.0 cm by 365.5 cm, each ±0.25 cm
L, W, e = F("412.0"), F("365.5"), F("0.25")
area = L * W
low, high = (L - e) * (W - e), (L + e) * (W + e)
print(f"area {float(area) / 10_000:.4f} m², between {float(low) / 10_000:.4f} and {float(high) / 10_000:.4f}")
rel = (high - area) / area
print(f"relative error of area {float(rel):.5%} vs sum of the lengths' relative errors {float(e / L + e / W):.5%}")
# Subtracting nearly equal measurements: the relative error explodes
a, b, err = F("1000.0"), F("998.0"), F("0.5")
print(f"difference {a - b} ± {2 * err}: relative error {float(2 * err / (a - b)):.0%} (each reading was ±{float(err / a):.2%})")
area 15.0586 m², between 15.0392 and 15.0780
relative error of area 0.12912% vs sum of the lengths' relative errors 0.12908%
difference 2 ± 1: relative error 50% (each reading was ±0.05%)
The room's area lies between 15.0392 and 15.0780 m², and its relative error (0.129 %) matches the sum of the two lengths' relative errors almost exactly, as the theorem predicts for small errors. The difference of two readings that are each good to 0.05 % is uncertain by 50 %: subtraction of close values destroys relative accuracy.
Experiment 3: units that convert and units that refuse
from fractions import Fraction as F
# Every unit as a factor to an SI base unit, with its dimension
UNITS = {"m": (1, "L"), "km": (1000, "L"), "cm": (F(1, 100), "L"), "ft": (F(3048, 10000), "L"), "in": (F(254, 10000), "L"),
"s": (1, "T"), "min": (60, "T"), "h": (3600, "T"), "kg": (1, "M"), "g": (F(1, 1000), "M"), "lb": (F(45359237, 100000000), "M")}
def convert(value, frm, to):
(f1, d1), (f2, d2) = UNITS[frm], UNITS[to]
if d1 != d2:
raise ValueError(f"can't convert {frm} to {to}: different kinds of quantity")
return F(value) * f1 / f2
print("60 km/h in m/s:", F(60) * F(1000, 1) / 3600, "=", float(F(60) * 1000 / 3600))
print("6 ft 1 in in cm:", float(convert(6, "ft", "cm") + convert(1, "in", "cm")))
print("1 m² in cm²:", (100) ** 2, "| 1 m³ in litres:", 1000, "| 1 km² in hectares:", 100)
try:
convert(5, "kg", "m")
except ValueError as e:
print("refused:", e)
print("22,300 lb of fuel is", round(float(convert(22_300, "lb", "kg"))), "kg, not 22,300 kg")
60 km/h in m/s: 50/3 = 16.666666666666668
6 ft 1 in in cm: 185.42
1 m² in cm²: 10000 | 1 m³ in litres: 1000 | 1 km² in hectares: 100
refused: can't convert kg to m: different kinds of quantity
22,300 lb of fuel is 10115 kg, not 22,300 kg
Storing each unit as a factor to a base unit, with a dimension (length, time, mass), makes conversion one multiplication and makes nonsense impossible: converting kilograms to metres is refused. 60 km/h is exactly m/s. 6 ft 1 in is 185.42 cm, exactly (the inch has been defined as exactly 2.54 cm since 1959). And 22,300 pounds of fuel is only about 10,115 kg, less than half of 22,300 kg: the kind of mistake that left the 1983 airliner gliding to an emergency landing.
Experiment 4: how good is a one-figure estimate?
import random, math
def one_sig_fig(x):
p = 10 ** math.floor(math.log10(x))
return round(x / p) * p
random.seed(11)
errors = []
for _ in range(10_000):
items = [random.randint(20, 2_000) for _ in range(random.randint(5, 20))] # a shopping list, in rupees
estimate, exact = sum(one_sig_fig(x) for x in items), sum(items)
errors.append(abs(estimate - exact) / exact)
errors.sort()
print(f"median error {errors[5_000]:.1%}, 90th percentile {errors[9_000]:.1%}, worst {errors[-1]:.1%}")
print("estimates within 20%:", sum(e <= 0.2 for e in errors) / len(errors))
median error 4.0%, 90th percentile 10.2%, worst 27.3%
estimates within 20%: 0.9961
Rounding every item of a shopping list to one significant figure and adding gives a total within 4 % of the exact one half the time, within about 10 % nine times in ten, and within 20 % almost always. Errors in rounding different items go both ways and largely cancel, which is why rough estimates of sums work so well. That's plenty to catch a misplaced decimal point (a factor of 10) or a missing item (usually more than a few percent).
Worked examples
Estimating
Rounding and error
Units
Exercises
Practice
- Estimate to one significant figure, then calculate: (a) ; (b) ; (c) .
- Round 2,763.849 to (a) the nearest hundred; (b) 2 decimal places; (c) 3 significant figures; (d) 1 significant figure.
- Round 4.5, 5.5 and to whole numbers by half up (away from zero), half even, floor and ceiling.
- A length is given as 3.40 m. What range of true values does that claim? What if it were given as 3.4 m?
- Convert: (a) 72 km/h to m/s; (b) 2.5 litres to cm³; (c) 3.6 hectares to m²; (d) 5 ft 10 in to cm.
- Add 1 h 35 min 50 s and 2 h 40 min 25 s. Subtract 1 h 55 min from 4 h 20 min.
- A recipe needs 750 g of flour for 6 people. Estimate how much for 25 people, then calculate it.
Answers
- (a) ; exactly 10,028. (b) ; exactly 3,198. (c) ; exactly about 250.5.
- (a) 2,800; (b) 2,763.85; (c) 2,760; (d) 3,000.
- Half up: 5, 6, . Half even: 4, 6, . Floor: 4, 5, . Ceiling: 5, 6, .
- 3.40 m claims (to the centimetre); 3.4 m only .
- (a) 20 m/s; (b) 2,500 cm³; (c) 36,000 m²; (d) 70 in cm.
- 3 h 75 min 75 s = 3 h 76 min 15 s = 4 h 16 min 15 s. min = 2 h 25 min.
- About g (25 is about 4 times 6); exactly g.
Harder
- A Fermi estimate: how many litres of petrol are sold in India in a day? List your factors and their ranges, and say which one matters most.
- Show that rounding a number that begins 1.000… to significant figures gives a relative error of at most about , and that for a number beginning 9.99… the bound is about ten times smaller. Why does the leading digit matter?
- Two weights are measured as 52.3 kg and 51.9 kg, each ±0.1 kg. What can you say about their difference? About their ratio?
- A formula claims the distance a car travels while braking is , with in m/s and in m/s². Check the units. What would give?
- Prove that half-even rounding has no bias over the halves , and compute the bias of half up over the same numbers.
Answers
- One version: about 300 million vehicles, of which perhaps a third run on petrol and are used on a given day (), each using around 1 litre a day on average (two-wheelers use much less, cars more): about litres a day. The biggest uncertainty is the average use per vehicle and how many are in daily use. (Published figures for India's petrol consumption in the mid-2020s are of the same order: tens of millions of tonnes a year, roughly litres a day.)
- With significant figures, the rounding step is one unit in the th figure, and the error is at most half of it. If the number is about , half a unit in the th figure is , a relative error of . If it's about , the same absolute error is nearly ten times smaller relative to the value. The leading digit sets the size of the number within its power of ten, so a fixed number of significant figures gives relative precision that varies by a factor of up to 10.
- Difference kg: a relative error of 50 %, so it's barely known (it could be 0.2 or 0.6). The ratio has a relative error of about , so it's 1.0077 ± 0.004: well known, but the part that differs from 1 (0.0077) is as poorly known as the difference.
- : a length, as a distance must be. gives , a time, so it can't be a distance.
- Half even rounds to when is even (error ) and to when is odd (error ). Over there are of each, so the errors cancel: total bias 0. Half up adds every time: (Experiment 1: 10,000 halves, bias 5,000).
Challenge
- Show that rounding to a whole number with half up, then rounding the result again, can never differ from rounding once, but that rounding to 2 decimal places and then to 1 can. Find all numbers with three decimal places between 1.400 and 1.500 for which double rounding (half up, 3 places → 2 → 1) differs from single rounding.
Discussion
Rounding a whole number again changes nothing, so the first statement is immediate: the second rounding has nothing to do. Double rounding causes trouble when the first rounding creates a halfway case for the second. To 1 decimal place, the halfway point between 1.4 and 1.5 is 1.45. A three-place number rounds once to 1.5 if , else 1.4. Rounding first to two places gives 1.45 for every from 1.445 to 1.454, and 1.45 rounds (half up) to 1.5. So the numbers that differ are those from 1.445 up to 1.449: 1.445, 1.446, 1.447, 1.448, 1.449, which round once to 1.4 but twice to 1.5. In general, double rounding errs when the first rounding lands exactly on the second rounding's halfway point, which is why careful libraries round once from the exact value.
In real life
Misconceptions and limits
The model to keep
Common misconceptions
| Misconception | What's actually true | Where it's shown |
|---|---|---|
| "Rounding 2.5 always gives 3." | It depends on the rule: half even gives 2 (Python's round). |
Rules for the halfway case |
| "Rounding in stages is the same as rounding once." | 1.445 → 1.45 → 1.5, but 1.445 → 1.4. | Round once, at the end |
| "More decimal places means more accurate." | Only digits that the measurement supports mean anything; 2.50 claims more than 2.5. | Decimal places and significant figures |
| "Errors average out, so the result is as accurate as the inputs." | Worst-case errors add; differences of close values can be far less accurate than the inputs. | How errors grow; Subtracting close numbers |
| "1 m² = 100 cm²." | . | Areas and volumes |
| "To convert km/h to m/s, multiply by 3.6." | Divide by 3.6: . Write the factors and let the units cancel. | Converting: multiply by one |
| "2 h 45 min + 1 h 30 min = 3 h 75 min = 3.75 h." | 75 min = 1 h 15 min, so 4 h 15 min, which is 4.25 h. | Mixed units and carrying |
| "An estimate is a guess." | It's a calculation with deliberately rounded inputs, usually within 10 %. | Experiment 4 |
Limits and trade-offs
- Worst-case error bounds are pessimistic. Independent errors usually partly cancel; statistics replaces worst cases with typical ones (standard deviations), at the price of probabilistic statements.
- Significant figures are a rough guide. They can't express "±3 in the last place"; state an explicit uncertainty when it matters.
- Units aren't always fixed. Local land units, cooking cups and "a lakh" (exact) against "about a lakh" (rough) need context; software should store the unit explicitly, never assume it.
- Rounding rules are sometimes law. Tax, currency and accounting rules can fix the rule and the step; the arithmetic must follow them, not the most accurate method.
Revision sheet
Key ideas
- Estimate first: one or two significant figures; compatible numbers; low and high bounds. Fermi estimates: multiply rough factors; errors partly cancel.
- Decimal places (after the point) vs significant figures (from the first non-zero digit). Trailing zeros after the point are information.
- Halfway rules: half up (away from zero), half even (no bias; Python, IEEE), down/truncate, up, floor, ceiling. Round once, at the end; double rounding can change the answer.
- Absolute error (measured minus true); relative error .
- Errors combine: sums/differences add absolute errors; products/quotients add relative errors (approximately). Cancellation: close differences lose relative accuracy.
- Units are factors: convert by multiplying by one (); km/h ÷ 3.6 = m/s.
- Areas and volumes: square and cube the length factor: , L.
- Mixed units: carry 60 (time), 12 (inches), 1000 (grams); safest to convert to the smallest unit, compute, and convert back with and remainder.
- Dimensional analysis checks formulas: both sides must have the same units.
Glossary
- Estimate: a calculation with deliberately rounded inputs, to find the size of an answer quickly.
- Fermi estimate: an estimate of an unknown quantity built from rough guesses of its factors.
- Significant figures: the digits of a number from its first non-zero digit, used to express relative precision.
- Half up (round half away from zero): rounding exact halves away from zero.
- Half even (banker's rounding): rounding exact halves to the neighbour with an even last digit.
- Floor / ceiling: rounding down / up to a whole number.
- Double rounding: rounding in two stages, which can differ from rounding once.
- Absolute error: the size of the difference between an approximate value and the true value.
- Relative error: absolute error divided by the size of the true value.
- Cancellation: loss of relative accuracy when subtracting nearly equal quantities.
- Unit: a standard amount of a quantity, part of every measurement.
- Conversion factor: a fraction equal to one that changes units, such as 1000 m / 1 km.
- Dimensional analysis: checking or deriving formulas by tracking units through them.
- SI: the International System of Units, built on seven base units.