Rounding errors and their accumulation

LVL: FREE

MODULE: Number Sense and Basic Intuition

[EXEC: MICRO_CORE]

✖️ 1. Differentiating exact arithmetic from numerical approximation and measurement error

🎯 Exact vs. Approximate Numbers

  • Exact numbers come from counting or definitions (no rounding needed).
  • Approximations come from measurements or rounding (always have some error).
  • Calculators and computers use approximations for most decimals.
  • π=3.14159...\pi = 3.14159... is exact as a symbol, but 3.143.14 is an approximation.
  • Measurement tools (rulers, scales) always give approximate values.

If you count 7 apples, that's exact. If you measure 7.2 cm with a ruler, that's approximate.

💡 Counted = exact, measured = approximate!

[EXEC: DEEP_COMPUTE]

1. Differentiating exact arithmetic from numerical approximation and measurement error

Exact Arithmetic vs. Numerical Approximation

Exact arithmetic operates on values with infinite precision (e.g., 13\frac{1}{3}, 2\sqrt{2}, π\pi), yielding results that are mathematically perfect. Numerical approximation represents these values with finite precision (e.g., π3.14159\pi \approx 3.14159), introducing rounding error—the difference between the true value and its representation.

Intuition: Real-world computations and measurements cannot store infinite digits, so we truncate or round, creating small discrepancies.

Core distinctions:

  • Exact: 2+2=42 + 2 = 4 (no error)
  • Approximation: 21.414\sqrt{2} \approx 1.414 (error 0.000214\approx 0.000214)
  • Measurement error arises from instrument limitations (e.g., ruler precision to nearest mm)
  • Rounding error arises from finite digit representation

Consequence: Even simple operations accumulate error when repeated, diverging from exact results.

Example: Exact 13+13+13=1\frac{1}{3} + \frac{1}{3} + \frac{1}{3} = 1. Using 0.333+0.333+0.333=0.9990.333 + 0.333 + 0.333 = 0.999, error is 0.0010.001.

TASK_1[0 / 3]
LVL_2
RSN: DEBUG

A computer program needs to add the exact fraction 1/51/5 three times. Instead of exact arithmetic, it uses the numerical approximation 0.190.19 for each fraction. What is the total rounding error of this sum compared to the exact mathematical result?

DEEP_COMPUTE
ULTRA
[EXEC: MICRO_CORE]

✖️ 2. Absolute vs. relative error and understanding significant figures limits

📏 Absolute vs. Relative Error

  • Absolute error = true valueapproximate value|\text{true value} - \text{approximate value}| (same units as measurement).
  • Relative error = absolute errortrue value\frac{\text{absolute error}}{|\text{true value}|} (unitless, often a percentage).
  • Significant figures show how many digits are trustworthy in a number.
  • More significant figures = smaller relative error.
  • A 1 cm error is huge for measuring a phone but tiny for measuring a building.

True length = 100 cm, measured = 98 cm. Absolute error = 2 cm, relative error = 0.02 or 2 percent.

💡 Relative error tells you if the mistake matters for the scale!

[EXEC: DEEP_COMPUTE]

2. Absolute vs. relative error and understanding significant figures limits

Absolute vs. Relative Error and Significant Figures

Absolute error is the magnitude of difference between approximate value aa and true value xx: ax|a - x|. Relative error is the ratio axx\frac{|a - x|}{|x|} (for x0x \neq 0), expressing error as a fraction of the true value.

Intuition: Absolute error measures raw discrepancy; relative error measures proportional accuracy, crucial when comparing scales.

Core rules:

  • Absolute error: Eabs=axE_{\text{abs}} = |a - x|
  • Relative error: Erel=axxE_{\text{rel}} = \frac{|a - x|}{|x|} (often expressed as percentage)
  • Significant figures indicate precision: 3.143.14 has 3 sig figs; 0.003140.00314 also has 3
  • Trailing zeros after decimal count; leading zeros do not

Consequence: Small absolute errors can be large relative errors for tiny values, and vice versa.

Example: True value x=1000x = 1000, approximation a=1001a = 1001. Eabs=1E_{\text{abs}} = 1, Erel=0.001=0.1%E_{\text{rel}} = 0.001 = 0.1\%. For x=0.01x = 0.01, a=0.02a = 0.02: Eabs=0.01E_{\text{abs}} = 0.01, Erel=1=100%E_{\text{rel}} = 1 = 100\%.

TASK_1[0 / 3]
LVL_3
MOD: SANITY_CHECK

A sensor measures a temperature. The true value is x=200x = 200 degrees and the approximation is a=195a = 195 degrees.

Calculate the absolute error of this measurement.

DEEP_COMPUTE
ULTRA
[EXEC: MICRO_CORE]

✖️ 3. Light error propagation formulas and error bounds in sums/products

➕✖️ Error Propagation Rules

  • When you add or subtract, absolute errors add up.
  • When you multiply or divide, relative errors add up.
  • Error bound = worst-case total error after operations.
  • If x5±0.1x \approx 5 \pm 0.1 and y3±0.2y \approx 3 \pm 0.2, then x+y8±0.3x + y \approx 8 \pm 0.3.
  • Multiplying many approximate numbers makes relative error grow fast.

Add 2.0±0.12.0 \pm 0.1 and 3.0±0.13.0 \pm 0.1: result is 5.0±0.25.0 \pm 0.2 (errors add).

💡 Addition stacks absolute errors, multiplication stacks relative errors!

[EXEC: DEEP_COMPUTE]

3. Light error propagation formulas and error bounds in sums/products

Error Propagation in Sums and Products

Error propagation quantifies how input errors affect computed results. For sums, absolute errors add; for products, relative errors approximately add.

Intuition: Combining approximate values compounds their individual uncertainties according to the operation type.

Core formulas:

  • Sum/Difference: If a±Δaa \pm \Delta a and b±Δbb \pm \Delta b, then (a+b)±(Δa+Δb)(a + b) \pm (\Delta a + \Delta b)
  • Product: If relative errors are ϵa\epsilon_a, ϵb\epsilon_b, then abab has relative error ϵa+ϵb\approx \epsilon_a + \epsilon_b (for small errors)
  • Quotient: ab\frac{a}{b} has relative error ϵa+ϵb\approx \epsilon_a + \epsilon_b
  • Absolute error bound for sum: Ea+bEa+Eb|E_{a+b}| \leq |E_a| + |E_b|

Consequence: Errors accumulate predictably; nn additions of values with error ϵ\epsilon yield total error nϵ\approx n\epsilon.

Example: a=5.0±0.1a = 5.0 \pm 0.1, b=3.0±0.2b = 3.0 \pm 0.2. Sum: 8.0±0.38.0 \pm 0.3. Product: 15.015.0 with relative error 0.15+0.230.087=8.7%\frac{0.1}{5} + \frac{0.2}{3} \approx 0.087 = 8.7\%, so 15.0±1.315.0 \pm 1.3.

TASK_1[0 / 3]
LVL_3
MOD: SANITY_CHECK

Two measurements are given as x=12.0±0.4x = 12.0 \pm 0.4 and y=8.0±0.5y = 8.0 \pm 0.5.

What is the maximum absolute error of the sum x+yx + y?

DEEP_COMPUTE
ULTRA
[EXEC: MICRO_CORE]

✖️ 4. Catastrophic cancellation when subtracting close approximations

💥 Catastrophic Cancellation

  • Subtracting two nearly equal approximate numbers destroys accuracy.
  • The result has far fewer significant figures than the original numbers.
  • Happens because small rounding errors become huge relative to the tiny difference.
  • Avoid by rewriting formulas (e.g., use conjugates or factoring).
  • Computers suffer this badly in floating-point subtraction.

Subtract 1.23451.2340=0.00051.2345 - 1.2340 = 0.0005. If each had error ±0.0001\pm 0.0001, the answer could be off by 40 percent!

💡 Never subtract twins—they cancel the good digits and leave the junk!

[EXEC: DEEP_COMPUTE]

4. Catastrophic cancellation when subtracting close approximations

Catastrophic Cancellation

Catastrophic cancellation occurs when subtracting two nearly equal approximate numbers, causing significant digits to cancel and magnifying relative error drastically.

Intuition: If aba \approx b, then aba - b is tiny, but rounding errors in aa and bb become large relative to the small result.

Core characteristics:

  • Loss of precision: Subtracting a=1.2345a = 1.2345 and b=1.2340b = 1.2340 (each rounded) yields 0.00050.0005, but errors dominate
  • Relative error explosion: If a,ba, b have error ϵ\epsilon, result (ab)(a - b) can have relative error ϵ\gg \epsilon
  • Avoid by reformulation: Use algebraic identities (e.g., rationalize denominators)
  • Critical in numerical algorithms: Quadratic formula, derivative approximations

Consequence: Catastrophic cancellation renders results unreliable despite input precision.

Example: Compute 10001100\sqrt{10001} - 100 with 4-digit precision. 10001100.0\sqrt{10001} \approx 100.0, so 100.0100=0100.0 - 100 = 0 (wrong). Exact: 0.005\approx 0.005. Reformulate: (10001)2100210001+100=1200.0=0.005\frac{(\sqrt{10001})^2 - 100^2}{\sqrt{10001} + 100} = \frac{1}{200.0} = 0.005.

TASK_1[0 / 3]
LVL_2
RSN: DEBUG

Based on the theory, which of the following operations is most likely to cause catastrophic cancellation if the numbers are approximations?

DEEP_COMPUTE
ULTRA
[EXEC: MICRO_CORE]

✖️ 5. Applications: Floating-point arithmetic errors in computer science and trajectory deviations

💻🚀 Real-World Error Disasters

  • Floating-point arithmetic in computers rounds every calculation slightly.
  • Millions of tiny errors can accumulate into huge mistakes over time.
  • The Patriot missile failure (1991) was caused by time-rounding errors after 100 hours.
  • Spacecraft trajectories drift if position errors compound over billions of calculations.
  • Financial software must use exact decimal types to avoid cent-rounding bugs.

A rocket calculates position 1000 times per second. Even 0.000001 error per step becomes meters after an hour.

💡 Tiny errors × many steps = mission failure!

[EXEC: DEEP_COMPUTE]

5. Applications: Floating-point arithmetic errors in computer science and trajectory deviations

Applications of Rounding Error Accumulation

Floating-point arithmetic in computers represents real numbers with finite bits (e.g., IEEE 754 standard), causing rounding at each operation. Trajectory deviations occur in simulations when iterative calculations accumulate errors, diverging from true paths.

Intuition: Repeated computations magnify small errors, leading to significant discrepancies in long-running processes.

Key applications:

  • Floating-point: 0.1+0.20.30.1 + 0.2 \neq 0.3 in binary (yields 0.30000000000000004\approx 0.30000000000000004)
  • Iterative algorithms: Numerical integration, differential equations accumulate error per step
  • Trajectory simulation: Spacecraft navigation errors compound over millions of calculations
  • Financial systems: Rounding cents over billions of transactions creates discrepancies

Consequence: Critical systems require error analysis, higher precision (e.g., double vs. single), or compensated summation algorithms (e.g., Kahan summation).

Example: Summing 0.10.1 ten thousand times in floating-point yields 1000.0000000001\approx 1000.0000000001 instead of exactly 10001000, with error 1010\approx 10^{-10}.

TASK_1[0 / 3]
LVL_2
RSN: DEBUG

A programmer writes a simple script to add 0.10.1 and 0.20.2. According to the theory of floating-point arithmetic, what is the expected output?

DEEP_COMPUTE
ULTRA

AWAITING_CONFIRMATION

CONFIRM KNOWLEDGE ACQUISITION TO UPDATE SYSTEM ANALYTICS.