Skip to main content

Section 7.2 The meaning of a numeric solution

In what sense do we expect the equation \(f(x)=0\) to hold? Because of the round-off errors (Section 6.4), we wlll not necessarily get 0 when plugging in some number x. For example, if f = @(x) x^2-2; then we would expect f(sqrt(2)) to be 0, but actually f(sqrt(2)) produces 4.4409e-16, a small but nonzero number. We could ask for abs(f(x)) to be small, for example abs(f(x)) < eps where the Matlab command eps returns \(2^{-52}\text{,}\) the amount of round-off error one can expect for numbers of size about 1. But there are two issues with this approach:

  1. The error in computing f(x) may be much larger than eps, as round-off errors may accumulate.
  2. Very small value of f(x) do not mean that x is near a root of function f: for example, the function f = @(x) exp(-x^2); has abs(f(7)) < eps, but the equation \(f(x)=0\) has no solutions at all.

A more robust approach is to look not for a single number but for an interval \([a, b]\) that is known to contain a root of function \(f\text{.}\) If the interval is small enough, it does not really matter where in the interval the solution is. How small is small enough? There is no universal answer. For many practical purposes, \(b-a \lt 10^{-6}\) is good enough. Or we may want \(b-a \lt 10^{-12}\) to get a more accurate answer. This makes sense when the root itself is not extremely large or extremely small. But when the root is of size \(10^{20}\) we cannot possibly hope to get an interval of length \(10^{-6}\) around it, or even of length 1. Indeed, the comparison 10^20 + 1 == 10^20 evaluates as True in Matlab, meaning that it cannot tell these numbers apart because of the limitation of computer arithmetic.

For the reason mentioned in the previous paragraph, the Matlab command eps(x) gives the smallest possible size of an interval including x that can be expressed in its arithmetic. For example, eps(10^20) returns 16384, indicating we cannot expect an interval around \(10^{20}\) to be smaller than 16384. When looking for a root, a reasonable approach is to consider an interval \([a, b]\) “small enough” when b - a < 100*eps(a) where the factor 100 allows for accumulation of round-off errors during the computation.