home | index | units | counting | geometry | algebra | trigonometry & functions | calculus
analysis | sets & logic | number theory | recreational | misc | nomenclature & history | physics

Final Answers
© 2000-2008 Gérard P. Michon, Ph.D.

Rounding Numbers

To what heights would science now be raised
if Archimedes had made that discovery
 !
Carl Friedrich Gauss (1777-1855)
[ about the positional system of numeration ]
 
 border
 border

See also:

Related Links (Outside this Site)

Volume of a Tetrahedron & Programming Languages  (pdf)  by  Prof. W. Kahan.
Values of Physical Constants   (CODATA: 1973, 1986, 1998, 2002, 2006...)
Determination of  G   by  Nolting, Schurr, Schlamminger and Kündig  (2000).
 
border
border

On the Art of Rounding Numbers
A Guide to the Proper Use of Floating-Point Arithmetic

Floating-point arithmetic gives you reliable accurate results only if you know how to work around its shortcomings.  Floating-point arithmetic is not ordinary arithmetic; addition is not even associative!  There are two very demanding rules to respect:

  • Never  ever  subtract nearly equal quantities.
  • Never add many negligible quantities.

(2007-08-15)   Scientific notation
Any nonzero number is equal to a multiple of a  power of 10.

We may write any nonzero number in a  unique  way as a product of a signed coefficient  [with a magnitude at least equal to  1  and strictly less than  10 ]  by a power of 10.  The latter part is called the [decimal] order of magnitude and it can be omitted when it's equal to unity  (1 is 10 to the power of zero).  For example, the speed of light expressed in scientific notation is:

c   =   2.99792458 ´ 10 8  m/s

A very important feature of scientific notation is that trailing zeros can only occur in the coefficient  after  the decimal point  (since there's only one nonzero digit before that decimal point).  Therefore, trailing zeros are always  significant digits  in scientific notation, as dicussed in the next article  (which, incidentally, presents an example where a result can  only  be given in scientific notation if the implied precision is to be stated correctly).


Nikki  (Yahoo! 2007-08-14)   Significant Figures
On the precision implied by giving just so many significant figures.

What's the precision of the factors in the following product?
How precise is the result?  How would that result be best stated?

2.9 ´ 3.5 ´ 10.0

If nothing else is said, we can only assume that each factor is known within half a unit of the "least significant digit" given.  Trailing zeroes are significant  only  if they occur  after  the decimal point  (as is the case for the third factor above).

For example,  10.0  denotes a quantity which occurs anywhere between  9.95  and  10.05  with uniform probability.  The above product is thus:

between   2.85 ´ 3.45 ´ 9.95 = 97.83   and   2.95 ´ 3.55 ´ 10.05 = 105.25

Therefore, it's best expressed in scientific notation as  1.0´10 2.  Indeed, this denotes a quantity between 95 and 105.  Close enough and not too precise.

Do resist the temptation to write that "100", since the two trailing zeroes before the decimal point would imply that only the leading "1" is significant, which indicates a very fuzzy result  (between 50 and 150).

You can't merely give the result as  101.5  because that would be a gross misrepresentation of the precision involved.  Instead, you should state:

2.9 ´ 3.5 ´ 10.0   =   1.0 ´ 10 2

With the  standardized notation  which specifies precision via a standard deviation expressed in units of the least significant digit  (see computation) as presented in the next article, we could write:

2.9 ´ 3.5 ´ 10.0   =   101.5(13)

On 2007-09-20,  Barry  wrote:       [edited summary]
How would you report 100.0200 = 1.047128548... with the proper number of significant figures?  What about  -log(0.001178) ?

In your first expression, if the the value  0.0200  comes from rounding, it's actually between 0.01995 and 0.02005.  So the result is between 1.047008 and 1.047249.  Stating the result as 1.0471 gives the impression that the true value is between 1.04705 and 1.04715.  This is slightly  too  precise (by a factor of 2) but that's not  grossly  misleading  (so, it's OK in my book).  The alternative would be to state the result as 1.047, which is too coarse  (by a factor of 5).

If you rely solely on "significant figures" to state the precision of your results, then you're always faced with a similar choice between two different levels of precision that differ from each other by a factor of 10.  Just choose the lesser of two evils, knowing that you will occasionally have to misrepresent the precision of your result by a factor of 3 (or even slightly more).

Such unsatisfying limitations can't be circumvented within the "significant figures" scheme.  When the precision of a result has to be stated more rigourously, it's best to give either its upper and lower bounds (at a 99% confidence level) or to indicate an estimate of the standard deviation  (as a two-digit number between parentheses after the least significant digit, as discussed in the next article).

In the second example, the expression  -log(0.001178)  may denote a value between  -log(0.0011785) = 2.92867  and  -log(0.0011775) = 2.92904.  This is best reported as  2.929,  which indicates a value between 2.9285 and 2.9295.

Interestingly, logarithms are the quintessential example of a case where the number of significant figures in the result is not directly related to the number of significant figures of the input data.  In the following  pathological  example, the input has only 3 significant figures but the result does have  9  significant  figures:

log ( 7.89 ´ 10 123456 )   =   123456.897


(2007-08-14)   Standardized precision
standard deviation  is used to express uncertainty or  precision.

In many cases, the above rules concerning  significant digits  are too coarse to convey a good indication of the claimed precision.

Professionals routinely state the accuracy of their figures by giving the uncertainty expressed in units of the last figure between parentheses (see examples).

Technically, this uncertainty is expressed either as the relevant  standard deviation  or as 1/3 of the "firm" bounds you may have on either side of the mean  (both definition are equivalent if we identify "firm bounds" with the 99.73% confidence level in a normal Gaussian distribution).


Straight rounding errors are not at all "normally distributed" along a Gaussian curve.  Instead, the error is uniformly distributed over an interval whose width is equal to one unit of the least significant digit retained.  This entails a standard deviation of  1/Ö12 = 0.29  in terms of that unit.

In our previous example of a product of three rounded value, what we have to determine is the standard deviation of the following random variable:

( 2.9 + 0.1 X ) ( 3.5 + 0.1 Y ) ( 10.0 + 0.1 Z)

Where X, Y and Z are independent random variables, each uniformly distributed between  -½ and +½.  The average (mathematical expectation) of that random variable is  101.5  and its standard deviation is  1.3444711...  (HINT: this involves averaging the square of the above inside a cube of unit volume).

Thus, our product can be expressed with standardized precision as  101.50(134)  or  101.5(13).  This latter form is the more common one, since standardized precision is most often expressed with 2-digit accuracy.


(2007-08-15)   Engineering Notation
Stating a nonzero number as a multiple of a power of 1000.

Engineering notation is  superficially  similar to scientific notation.  The difference is that the exponent of 10 is restricted to a multiple of 3  (thus, the relevant power of 10 is actually a power of 1000).  For this to be possible in all cases, the coefficient is allowed to go from 1 (included) to 1000 (excluded).

Because there may be trailing zeros  before  the decimal point in engineering notation, the number of significant digits is not always clear.  This is one of the main reasons why the systematic use of the engineering notation is strongly discouraged in print, unless the above convention is used for stating precision.

By extension, we also call  engineering notation  any system resembling scientific notation where the absolute magnitude of the coefficient is not restricted to the 1-10 range  (it could, ocasionally, be more than 1000 or less than 1).  List of results spanning several orders of magnitude are sometimes more readable this way, since we can merely compare coefficients as the order of magnitude (a power of 10) remains constant.


(2007-08-07) &  Inaccuracy lurking in the quadratic formula
Alternative approaches for  robust  solutions of quadratic equations.

 Come back later, we're
 still working on this one...


(2007-08-07)   Devising  robust  formulas...
How to avoid subtracting  nearly equal  quantities.

In what follows, the number  x  need not  be small, but it  may  well be...

In each of the examples below, a straight floating-point computation of the left-hand side will lead to an unacceptable loss of precision when  x  is small.  The given substitute should be used, which is mathematically identical but won't lead to potentially nonsensical results with floating-point arithmetic.

Square Root :

Ö(a+x) - Öa   =   x / [ Ö(a+x) + Öa ]

Exponential :

e a + x - e a   =   2 sh(x/2)  e a+x/2

Cosine :   [ Usage examples:  1 | 2 ]

1  -  cos x   =   2 sin2 (x/2)

Inverse of Hyperbolic Tangent (cf. relativistic rapidity) :

Argth (a+x) - Argth (a)   =   Argth ( x / [1-a(a+x)] )

border
border
visits since August 15, 2007
 (c) Copyright 2000-2008, Gerard P. Michon, Ph.D.