December 3

Lecture Overview

Numerical Anaylsis

Numerical Analysis studies algorithms which use numerical computations. The primary focus is on understanding errors. There are several types of errors:

Loss of significance

One strange and interesting phenomenon is that if the same computation is performed in two different ways, the amount of error differs. For example, consider computing the following function on a \(4\)-decimal digit calculator (every computation is rounded to \(4\) decimal digits).

\[f(x) = x \left( \sqrt{x+1} - \sqrt{x} \right)\]

Consider \(x = 100\). Then \(\sqrt{100} = 10.0000\) and \(\sqrt{101} = 10.0499\) (note the rounding). Therefore the calculator computes

\[\sqrt{101} - \sqrt{100} = 10.0499 - 10.0000 = 0.0499\]

When multiplied by 100 we get

\[100 * 0.0499 = 4.9900\]

Notice the true value is \(4.98756..\). But now consider the following form of the function

\[f(x) = \frac{x}{\sqrt{x+1} + \sqrt{x}}\]

This is equivalent to the first form. (To see this, multiply the original \(f\) by \(\sqrt{x+1} + \sqrt{x}\) in both the numerator and denominator.) But now, computing again on a \(4\)-decimal digit calculator,

\[\sqrt{101} + \sqrt{100} = 20.0499\]

and

\[\frac{100}{20.0499} = 4.9875\]

much closer to the actual value of \(4.987562...\).

What happened is an instance of the following principle, called the loss of significance principle. When two nearly equal values are subtracted, leading significant digits are lost. We can see this in action because \(\sqrt{101} - \sqrt{100}\) had only three significant digits and this loss of significant digits impacted our future computations. The other computation did not have a corresponding loss of significant digits and so obtained a better result.

These types of issues come up a lot, especially when we use Taylor series (which is a lot).

\[e^{-5} = 1 + \frac{(-5)}{1!} + \frac{(-5)^2}{2!} + \frac{(-5)^3}{3!} + \frac{(-5)^4}{4!} \cdots\]

Note the terms are alternating between positive and negative so if we compute using this expansion, we will have lots of significance lost. If instead we use

\[e^{-5} = \frac{1}{e^5} = \frac{1}{\text{ series for } e^5}\]

the series for \(e^5\) has only positive terms so the approximation will be much better.

Thus changing the computation has an effect on the amount of accumulated error from roundoff error. The other types of error (measurement error and approximation errors) have the same feature so that computing the same thing in different ways impacts the amount of error that is propagated.

Numerical Anaylsis in SAGE/Python

Numerical analysis in SAGE comes in several ways:

An example of the latter is towards the bottom of this article. Here is my sage worksheet: CurveFitting.sagews

Exercises