Let’s think a bit about what must be the easiest math problem you’ve dealt with in quite some time: adding 1 to a number. Formally, we describe this problem as a function f(x)=x+1, where x is any real number.
On a computer, x will be represented by its floating-point counterpart, fl(x). Given the property (1.1.5), we have fl(x)=x(1+ϵ) for some ε satisfying ∣ϵ∣<ϵmach/2. There is no error in representing the value 1.
Let’s suppose that we are fortunate and that the addition proceeds exactly, with no additional errors. Then the machine result is just
This error could be quite large if the denominator is small. In fact, we can make the relative error as large as we please by taking x very close to -1. This is essentially what happened in Demo 1.1.4.
You may have encountered this situation before when using significant digits for scientific calculations. Suppose we round all results to five decimal digits, and we add -1.0012 to 1.0000. The result is -0.0012, or −1.2×10−3 in scientific notation. Notice that even though both operands are specified to five digits, it makes no sense to write more than two digits in the answer because there is no information in the problem beyond their decimal places.
This phenomenon is known as subtractive cancellation, or loss of significance. We may say that three digits were “lost” in the mapping from -1.0012 to -0.0012. There’s no way the loss could be avoided, regardless of the algorithm, once we decided to round off everything to a fixed number of digits.
In double precision, all the values are represented to about 16 significant decimal digits of precision, but it’s understood that subtractive cancellation may render some of those digits essentially meaningless.
Now we consider problems more generally. As above, we represent a problem as a function f that maps a real data value x to a real result f(x). We abbreviate this situation by the notation f:R↦R, where R represents the real number set.
When the problem f is approximated in floating point on a computer, the data x is represented as a floating-point value x~=fl(x). Ignoring all other sources of error, we define the quantitative measure
which is the ratio of the relative changes in result and data. We make this expression more convenient if we recall that floating-point arithmetic gives x~=x(1+ϵ) for some value ∣ϵ∣≤ϵmach/2. Hence
Finally, we idealize what happens in a perfect computer by taking a limit as ϵmach→0.
The condition number is a ratio of the relative error of the output to the relative error of the input. It depends only on the problem and the data, not the computer or the algorithm.
Assuming that f has at least one continuous derivative, we can simplify the expression (1.2.5) through some straightforward manipulations:
In retrospect, it should come as no surprise that the change in values of f(x) due to small changes in x involves the derivative of f. In fact, if we were making measurements of changes in absolute rather than relative terms, the condition number would be simply ∣f′(x)∣.
Condition numbers of the major elementary functions are given in Table 1.2.1.
Table 1.2.1:Relative condition numbers of elementary functions
Function
Condition number
f(x)=x+c
κf(x)=∣x+c∣∣x∣
f(x)=cx
κf(x)=1
f(x)=xp
κf(x)=∣p∣
f(x)=ex
κf(x)=∣x∣
f(x)=sin(x)
κf(x)=∣xcot(x)∣
f(x)=cos(x)
κf(x)=∣xtan(x)∣
f(x)=log(x)
κf(x)=∣log(x)∣1
As you are asked to show in Exercise 4, when two functions f and g are combined in a chain as h(x)=f(g(x)), the composite condition number is
That is, whenever the data x is perturbed by a small amount, we expect that relative perturbation to be magnified by a factor of κf(x) in the result.
Large condition numbers signal when errors cannot be expected to remain comparable in size to roundoff error. We call a problem poorly conditioned or ill-conditioned when κf(x) is large, although there is no fixed threshold for the term.
If κf≈1/ϵmach, then we can expect the result to have a relative error of as much as 100% simply by expressing the data x in finite precision. Such a function is essentially not computable at this machine epsilon.
You may have noticed that for some functions, such as the square root, the condition number can be less than 1. This means that relative changes get smaller in the passage from input to output. However, every result in floating-point arithmetic is still subject to rounding error at the relative level of ϵmach. In practice, κf<1 is no different from κf=1.
Most problems have multiple input and output values. These introduce complications into the formal definition of the condition number. Rather than worry over those details here, we can still look at variations in only one output value with respect to one data value at a time.
The calculation in Example 1.2.4 generalizes to polynomials of higher degree.
The condition number of a root can be arbitrarily large. In the extreme case of a repeated root, the condition number is formally infinite, which implies that the ratio of changes in the root to changes in the coefficients cannot be bounded.
✍ Suppose that f and g are real-valued functions that have relative condition numbers κf and κg, respectively. Define a new function h(x)=f(g(x)). Show that for x in the domain of h, the relative condition number of h satisfies (1.2.9).
✍ Suppose that f is a function with relative condition number κf, and that f−1 is its inverse function. Show that the relative condition number of f−1 satisfies
✍ Referring to the derivation of (1.2.13), derive an expression for the relative condition number of a root of ax2+bx+c=0 due to perturbations in b only.
The polynomial x2−2x+1 has a double root at 1. Let r1(ϵ) and r2(ϵ) be the roots of the perturbed polynomial x2−(2+ϵ)x+1.
(a) ✍/⌨ Using a computer or calculator, make a table with rows for ϵ=10−2, 10-4, 10-6, …, 10-12 and columns for ε, r1(ϵ), r2(ϵ), ∣r1(ϵ)−1∣, and ∣r2(ϵ)−1∣.
(b) ✍ Show that the observations of part (a) satisfy
for some 0<q<1. (This supports the conclusion that κ=∞ at the double root.)
✍ Generalize (1.2.13) to finding a root of the nth degree polynomial p(x)=anxn+⋯+a1x+a0, and show that the relative condition number of a root r with respect to perturbations only in ak is