Ch2.3.4 Error Propagation and Stability

Errors Outlined So Far

  • Round-off error (machine eps, human, measurement)
  • Cancellation (loss of significance)
  • Underflow
  • Overflow

title

Error Propagation

  • A single instance of these errors may occur when using a calculator.
  • We are also interested in how errors propagate and grow through large scale algorithm.

title

Example With Ruler

  • Consider a physical measurement with a ruler, with marks every millimeter.
  • Natural limitation of precision where no measurement of greater precision than a millimeter is possible.

title

Example: Measurement Will Have Error

  • A length measurement \( l \) will necessarily include some error.
  • We will say that \( l' = l \pm \epsilon \) where \( l \) is the true length, \( l' \) is the measured length, and \( \epsilon \) is some error.
  • In this case, max | \( \epsilon \) | = 0.5 mm.

title

Example: Shaded Error

  • A length measurement \( l \) will necessarily include some error.
  • The potential error area is shaded in figure.

title title

Example: Error Accumulation

  • Even if we accept this error, it can cause trouble.
  • Errors are additive when adding measurements.
  • Error can grow through accumulation.

title

title

Example: Adding Two Measurements

  • For two length measurements, assume for simplicity that

\[ \begin{align*} l_1 &= l_{1}^{'} \pm \epsilon \\ l_2 &= l_{2}^{'} \pm \epsilon \end{align*} \]

  • It follows that

\[ \begin{align*} l_1 + l_2 &= ( l_{1}^{'} \pm \epsilon ) + (l_{2}^{'} \pm \epsilon) \\ &= l_{1}^{'} + l_{2}^{'} \pm 2\epsilon \end{align*} \]

  • Max combined error is 2(0.5 mm) = 1 mm.

Example: Combined Error Shaded

  • Combined error area illustrated by shaded region.
  • Error is growing linearly: two summations gives 2\( \epsilon \), while three summations would give 3 \( \epsilon \), etc.

title title

Example: Finding Area

  • Other situations can amplify error more extremely.
  • Imagine two measurements, length \( l \) and height \( h \), with a desire to find the surface area.
  • Then

\[ \begin{align*} l \times h &= ( l' \pm \epsilon ) \times (h' \pm \epsilon) \\ &= l'h' \pm ( l'\epsilon + h'\epsilon + \epsilon^2) \end{align*} \]

  • The combined error is \( l'\epsilon + h'\epsilon + \epsilon^2 \).

Example: Combined Error Shaded

  • The combined error is \( l'\epsilon + h'\epsilon + \epsilon^2 \).
  • Combined error area illustrated by shaded region.
  • If \( \epsilon = 0.5 \) mm, then combined potential error is more than half the length and height added together, in square millimeters.

title

Error Growth in Algorithms Similar

  • Through these examples, we can see the affects of compounding errors.
  • When a value is subject to machine error, through floating point representation or through some other source, the same error propagation patterns emerge.

\[ \begin{align*} l \times h &= ( l' \pm \epsilon ) \times (h' \pm \epsilon) \\ &= l'h' \pm ( l'\epsilon + h'\epsilon + \epsilon^2) \\ & \cong l'h' \end{align*} \]

Error Growth and Error Analysis

  • If one of source values, such as the height, had overflowed, and was now represented as Inf, then final result would be Inf.
  • The same thing can happen with NaN.
  • While these results are obviously unnatural, they arise just as easily through mistake as they do through actual results.
  • An accidental log(0) returns -Inf, and if buried within a larger calculation, we can be left scratching our heads for a few minutes as we look for what went wrong.
log(0)
[1] -Inf

Numerical Stability in Algorithms

  • This leads to the search for numerical stability, another important goal of numerical analysis.
  • A numerically stable algorithm has the property that approximation errors, from whatever source, are not amplified by algorithm.

title

Numerical Stability in Algorithms

  • For a numerically stable algorithm, small changes in input produce small changes in ouput.
  • With a house, we measure and build.

title

title

Numerical Stability in Algorithms

  • For a numerically unstable algorithm, small changes in input can result in drastic and unexpectedly large changes in ouput.

title

title

Small Changes In, Small Changes Out

  • Depending on problem, large output change for small input change may be expected.
  • This happens for an exponential function, and is inherent to the problem rather than an algorithm attribute.
f <- function(x) {exp(x)}
x1 <- 10
x2 <- 10.1
c(f(x1), f(x2))
[1] 22026.47 24343.01

Boundaries and Singularities

  • Numerically stable algorithms behave in expected ways near singularity, and only produce incorrect results at singularities.

title

Errors Growing Without Bound

  • A numerically unstable program is not well behaved in this sense, such as those that magnify inherent errors without bound.

title

Nonlinearity and Turbulence

  • Fluid flow is often modeled using differential equations, but typically can only be solved using numerical methods.
  • Turbulence can be difficult to solve for numerically.

title

Nonlinearity and Turbulence

title

Domain and Problem Dependency

  • Some algorithms may be stable for some input domains, but not others.
  • Further, it is possible for the problem to be ill-conditioned, in which case any algorithm will be unstable.

title

Numerical Stability

  • Sometimes problem areas can be identified ahead of time.
  • In other cases, instabilities are best observed experimentally.
  • Observing how an algorithm behaves and produces results for different inputs is a key aspect of numerical analysis.

title