) Let y*=1,000,000 and y=999,996; then the error is Ey =|y*-y|=|1000000-999996|=4

Chapter 1:

(

and the relative error is

RE y

y* y y

4 1000000

0.000004

) Let z*=0.000012 and z=0.000009; then the error is Ez =|z*-z|=|0.000012-0.000009|=0.000003 and the relative error is

Error Analysis

1

REz

z* z z

0.000003 0.000012

4

0.25

In the practice of numerical analysis it is important to be aware that computed solutions are not exact mathematical solutions. The precision of a numerical solution can be diminished in several subtle ways. Understanding these difficulties can often guide the practitioner in the proper implementation and/or development of numerical algorithms. Definition 1.1 Suppose x is an approximation to x*. The absolute error is Ex = |x* -x|. And the relative error is REx that x*≠0 .

2

In case ( ), there is not too much difference between Ex and REx, and either could be used to determine the accuracy of x. In case ( ), the value of y is of magnitude 106, the error Ey is large, and the relative error REx is small. In this case, y would probably be considered a good approximation to y*. In case ( ), z is of magnitude 10-6 and the error Ez is the smallest of all three cases, but the relative error REz is the largest. In terms of percentage, it amounts to 25%, and thus z is a bad approximation to z*. 5

x* x , provided x

The absolute error is simply the difference between the true value and the approximate value, whereas the relative error expresses the error as a percentage of the true value. Example 1.1 Find the error and relative error in the following three cases.

Observe that as |x*| moves away from 1 (greater than or less than) the relative error REx is a better indicator than Ex of the accuracy of the approximation. Relative error is preferred for floating-point representations since it deals directly with the mantissa. Definition 1.2 The number x is said to approximate x* to d significant digits if d is the largest nonnegative integer for which

(

) Let x*=3.141592 and x=3.14; then the error is Ex =|x*-x|=|3.141592-3.14|=0.001592

and the relative error is

REx

x* x x

0.001592 3.141592

3

0.00507

REx

x* x 101d 2 x

6

Example 1.2 Determine the number of significant digits for the approximations in Example 1.1. ( ) If x*=3.141592 *

Round-off Error

A computer’s representation of real numbers is limited to the fixed precision of the mantissa. True values are sometimes not stored exactly by a computer’s representation. This is called round-off error. For example, the real number 1/3=0.33333··· was truncated when it was stored in a computer.

and x=3.14; then

REx

x x x

0.00507

1012 2

Therefore, x approximates x* to two significant digits. ( ) If y*=1,000.000 and x=999,996; then

RE y

y* y y

0.000004

105 2

Therefore, y approximates y* to six significant digits.

7

The actual number that is stored in the computer may undergo chopping or rounding of the last digit. Therefore, since the computer hardware works with only a limited number of digits in machine numbers, rounding errors are introduced and propagated in successive computations. 10

(

) If z*=0.000012 and x=0.000009; then

Loss of Significance

Consider the two numbers x=3.1415926536 and y=3.1415957341, which are nearly equal and both carry 11 decimal digits of precision. Suppose that their difference is formed: x-y=-0.0000030805. Since the first six digits of x and y are the same, their difference x-y contains only five decimal digits of precision. This phenomenon is called loss of significance or subtractive cancellation. This reduction in the precision of the final computed answer can creep in when it is not suspected. 11

REz

z* z z

100 0.25 2

Therefore, z approximates z* to one significant digits.

Truncation Error

The notion of truncation error usually refers to errors introduced when a...