Tolerance - Python Numerical Methods
Tolerance - Python Numerical Methods
This notebook contains an excerpt from the Python Programming and Numerical Methods - A Guide for Engineers
and Scientists, the content is also available at Berkeley Python Numerical Methods. Print to PDF
The copyright of the book belongs to Elsevier. We also have this interactive book online for a better learning
experience. The code is released under the MIT license. If you find this content useful, please consider supporting the
work on Elsevier or Amazon!
< 19.1 Root Finding Problem Statement | Contents | 19.3 Bisection Method >
Tolerance
In engineering and science, error is a deviation from an expected or computed value. Tolerance is the level of error that is
acceptable for an engineering application. We say that a computer program has converged to a solution when it has found a
solution with an error smaller than the tolerance. When computing roots numerically, or conducting any other kind of
numerical analysis, it is important to establish both a metric for error and a tolerance that is suitable for a given
engineering/science application.
For computing roots, we want an xr such that f (xr ) is very close to 0. Therefore |f (x)| is a possible choice for the measure of
error since the smaller it is, the likelier we are to a root. Also if we assume that xi is the ith guess of an algorithm for finding a
root, then |xi+1 − xi | is another possible choice for measuring error, since we expect the improvements between subsequent
guesses to diminish as it approaches a solution. As will be demonstrated in the following examples, these different choices have
their advantages and disadvantages.
TRY IT! Let error be measured by e = |f (x)| and tol be the acceptable level of error. The function f (x) = x
2
+ tol/2 has no
real roots. However, |f (0)| = tol/2 and is therefore acceptable as a solution for a root finding program.
TRY IT! Let error be measured by e = |xi+1 − xi | and tol be the acceptable level of error. The function f (x) = 1/x has no
real roots, but the guesses xi = −tol/4 and xi+1 = tol/4 have an error of e = tol/2 and is an acceptable solution for a
computer program.
Based on these observations, the use of tolerance and converging criteria must be done very carefully and in the context of the
program that uses them.
< 19.1 Root Finding Problem Statement | Contents | 19.3 Bisection Method >
© Copyright 2020.
https://pythonnumericalmethods.berkeley.edu/notebooks/chapter19.02-Tolerance.html 1/1