Notes01 - Numerical Errors and Stability
Notes01 - Numerical Errors and Stability
Significant figures
Significant figures (or called significant digits) are the number of digits in a value, often a
measurement, that contribute to the degree of accuracy of the value. The way to count the number of
significant figures is by starting at the first non-zero digit.
Example: Both 1.23 and 0.00123 have 3 significant digits. We also round the values when reporting
the significant digits. Thus, the value of π (3.141592635…) becomes 3.14 if we want 3 significant
digits, and it becomes 3.1416 if we want 5 significant digits.
Even if certain digits are not completely known, they are still significant if they are reliable, as they
indicate the actual volume within an acceptable range of uncertainty. For instance, if someone’s
height is 187.65 cm or 1876.5 mm (measured by a ruler with the smallest interval between marks at 1
mm), the first four digits are certain and obviously significant. The last digit (5, contributing 0.5 mm)
is likewise considered significant despite its uncertainty. So, all the five digits are considered
significant.
Condition: The condition of a mathematical problem relates to its sensitivity to changes in its input
values. The relative condition number κ(x) is defined as the ratio of relative change in f to relative
change in x. That is,
κ(x) =(| (f(x+ Δx) – f(x))/f(x) |)/( |Δx/x|)
For a small Δx, we know that (f(x+ Δx) – f(x))/Δx is f’(x).
Thus, κ(x) = |x*f’(x)/f(x)|
A big (>10 or 100, depending on different situations) condition number means that the problem is ill-
conditioned.
If x and/or f(x) has several components, then f’(x) is replaced by the Jacobian matrix J(x)=əf i/əxj.
Stability: The ability of a numerical method/algorithm to produce reliable and consistent results over
a range of inputs and conditions.
It concerns how errors introduced during the execution of an algorithm affect the result, and is a
property of an algorithm rather than the problem being solved. A stable numerical algorithm will not
amplify errors or produce wildly fluctuating solutions. It is crucial for ensuring the reliability and
robustness of numerical simulations.
In solving differential equations, the stability of an integration scheme is its ability to keep the error
from growing forward in time. If the error does not grow, then the scheme is stable; otherwise it is
unstable. Some integration schemes are stable for certain choices of h and unstable for others; these
integration schemes are also referred to as unstable.
To sum up, the condition concerns the problem itself, while stability concerns the numerical
algorithm used for solving the problem. In general, an algorithm may consist of many steps
(expressed as functions), and therefore each step has its own condition. Thus, to know whether an
algorithm is stable, we may need to consider the possibility of errors introduced in each step.
For example, evaluating y = sin(x/(1-x)) can be broken into 3 steps. First, let g=1-x. Next, let h=x/g.
And finally, let y=sin(h). An algorithm is stable if every step is well-conditioned, and is unstable if
any one step is ill-conditioned.
print(xa)
print(xb)
Example 2 (Condition of a problem). Suppose f(x) = x/(1-x). So, f’(x)=1/(1-x) + x/(1-x)2 = 1/(1-x)2
The condition number κ(x) = |x*f’(x)/f(x)| = |(x/(1-x)2)/( x/(1-x))| = 1/|1-x|. We can see that, at
x=0.99, κ=100; at x=-0.99, κ=0.5025.
Thus, the problem is ill-conditioned for x being close to positive 1, and is well-condition for x being
close to negative 1.
Example 4 & 5.
https://farside.ph.utexas.edu/teaching/329/lectures/node34.html
https://pythonnumericalmethods.berkeley.edu/notebooks/chapter22.04-Numerical-Error-and-
Instability.html
For more details, consult the book by Higham (2002): Accuracy and Stability of Numerical
Algorithms.