Skip to article frontmatterSkip to article content

Root finding

#%config InlineBackend.figure_format = 'svg'
from pylab import *

Given a continuous function f:[a,b]Rf : [a,b] \to \re, find an α[a,b]\alpha \in [a,b] such that f(α)=0f(\alpha) = 0. Such an α is called a root of ff or a zero of ff. There could be many roots for a given function. At a root, the positive and negative parts of ff cancel one another. So we have to careful about roundoff errors and care must be taken to evaluate the function so as to avoid loss of significance errors. Since we work with finite precision on the computer, we cannot expect to find an α that makes the function exactly zero. At best, we hope to keep relative error under control. In this sense, zeros far from the origin cannot be computed with great absolute accuracy. Since the purpose is to solve some problem that involves approximations, it is not necessary to exactly locate the root, and an approximation is sufficient.

1Bracketing the root

There are no general methods to find the roots of an arbitrary function. The user must have some knowledge of where the root might possibly lie. It is hence useful to first find some small interval in which we expect the root to lie.

Around a root, the function takes both positive and negative values. The IVT can be used to find an interval containing the root.