2 Rounding

In general, a computer is unable to store every decimal place of a real number. Real numbers are rounded . To round a number to n significant figures we look at the ( n + 1 ) th digit in the decimal expansion of the number.

For example

1 3 = 0.3333 rounded to 4 significant figures, 8 3 = 2.66667 rounded to 6 significant figures, π = 3.142 rounded to 4 significant figures.

An alternative way of stating the above is as follows

1 3 = 0.3333 rounded to 4 decimal places, 8 3 = 2.66667 rounded to 5 decimal places, π = 3.142 rounded to 3 decimal places.

Sometimes the phrases “significant figures" and “decimal places" are abbreviated as “s.f." or

“sig. fig." and “d.p." respectively.

Example 1

Write down each of these numbers rounding them to 4 decimal places:

0.12345 , 0.44444 , 0.5555555 , 0.000127351 , 0.000005

Solution

0.1235 , 0.4444 , 0.5556 , 0.0001 , 0.0000

Example 2

Write down each of these numbers, rounding them to 4 significant figures:

0.12345 , 0.44444 , 0.5555555 , 0.000127351 , 25679

Solution

0.1235 , 0.4444 , 0.5556 , 0.0001274 , 25680

Task!

Write down each of these numbers, rounding them to 3 decimal places:

0.87264 , 0.1543 , 0.889412 , 0.5555

0.873 , 0.154 , 0.889 , 0.556

2.1 Rounding error

Clearly, rounding a number introduces an error. Suppose we know that some quantity x is such that

x = 0.762143 6 d.p.

Based on what we know about the rounding process we can deduce that

x = 0.762143 ± 0.5 × 1 0 6 .

This is typical of what can occur when dealing with numerical methods. We do not know what value x takes, but we have an error bound describing the furthest x can be from the stated value 0.762143 . Error bounds are necessarily pessimistic. It is very likely that x is closer to 0.762143 than 0.5 × 1 0 6 , but we cannot assume this, we have to assume the worst case if we are to be certain that the error bound is safe.

Key Point 2

Rounding a number to n decimal places introduces an error that is no larger (in magnitude) than

1 2 × 1 0 n

Note that successive rounding can increase the associated rounding error, for example

12.3456 = 12.3 (1 d.p.) , 12.3456 = 12.346 (3 d.p.) = 12.35 (2 d.p.) = 12.4 (1 d.p.) .

2.2 Accumulated rounding error

Rounding error can sometimes grow as calculations progress. Consider these examples.

Example 3

Let x = 22 7 and y = π . It follows that, to 9 decimal places

x = 3.142857143 y = 3.141592654 x + y = 6.284449797 x y = 0.001264489
  1. Round x and y to 7 significant figures. Find x + y and x y .
  2. Round x and y to 3 significant figures. Find x + y and x y .
Solution
  1. To 7 significant figures x = 3.142857 and y = 3.141593 and it follows that, with this rounding of the numbers x + y = 6.284450 x y = 0 . 001264 .

    The outputs ( x + y and x y ) are as accurate to as many decimal places as the inputs ( x and y ). Notice however that the difference x y is now only accurate to 4 significant figures.

  2. To 3 significant figures x = 3.14 and y = 3.14 and it follows that, with this rounding of the numbers x + y = 6.28 x y = 0.

    This time we have no significant figures accurate in x y .

In Example 3 there was loss of accuracy in calculating x y . This shows how rounding error can grow with even simple arithmetic operations. We need to be careful when developing numerical methods that rounding error does not grow. What follows is another case when there can be a loss of accurate significant figures.

Task!

This Task involves solving the quadratic equation

x 2 + 30 x + 1 = 0

  1. Use the quadratic formula to show that the two solutions of x 2 + 30 x + 1 = 0 are x = 15 ± 224 .
  2. Write down the two solutions to as many decimal places as your calculator will allow.
  3. Now round 224 to 4 significant figures and recalculate the two solutions.
  4. How many accurate significant figures are there in the solutions you obtained with the rounded approximation to 224 ?
  1. From the quadratic formula x = 30 ± 3 0 2 4 2 = 15 ± 1 5 2 1 = 15 ± 224 as required.
  2. 15 + 224 = 0.03337045291 is one solution and 15 224 = 29.96662955 is the other, to 10 significant figures.
  3. Rounding 224 to 4 significant figures gives

    15 + 224 = 15 + 14.97 = 0.03 15 224 = 15 14.97 = 29.97

  4. The first of these is only accurate to 1 sig. fig., the second is accurate to 4 sig. fig.
Task!

In the previous Task it was found that rounding to 4 sig. fig. led to a result with a large error for the smaller root of the quadratic equation. Use the fact that for the general quadratic

a x 2 + b x + c = 0

the product of the two roots is c a to determine the smaller root with improved accuracy.

Here a = 1 , b = 30 , c = 1 so the product of the roots = c a = 1 . So starting from the rounded value 29.97 for the larger root we obtain the smaller root to be 1 29.97 0.03337 with 4 sig. fig. accuracy.

(This indirect method is often built into computer software to increase accuracy.)