Subject: Re: CCL:comutational precision: removing round-off errors.

From: David Santo Orcero <[email-masked]>
Date: Wed, 5 Jul 2000 21:59:12 -0300 (BRT)

Hello!

> If one takes 625 and divides this number by, lets say, 5 on a computer
> one may get one of
> two numbers that look like: 125.000000000000000001 and
> 124.4999999999999999 .
> 
> Is this true? and, if so, how does one remove possible rounding errors

 Yes, it is true.

 And there is no solution, sorry. Here is why:

 Numbers in floating point format are something like:

 Number= (-1)^sign * (1.mantisa) * base ^ (exponent - kexp)

 Mantisa can be in other format, but uses to be as (1.mantisa); after
a calculus, the number is LRed to its first digit is 1 (on binary format).
Thus, that 1 doesn't need to be almacenated on the memory of the computer.
This is called "normalized floating point". Nearly all computers uses
this.

 Base uses to be 2; kexp, as far as I renember, 127 in IEEE754 32 bits
and 1023 in IEEE754 64bits.

 0 is not representable. For this, it is used a special kind of 
representation, that allows representate +Inf, -Inf and NaN. It
allows also +0 and -0, but this is another story...

 Then, you will have a number representated as:

(sign, mantisa, exponent)

 As you see, not all numbers are exactly representated. Some
numbers that are simple on decimal representation, on floating
point would need infinite precision.

 The propagation of the error by the non-exact nature of
floating point numbers is really complex, and for really short integration
steps can be 1 or 2 order of magnitude higher that the
error for the truncation of the Taylor's serie by the integration
algorithm.

 Sorry for my bad english. Sorry also by the bad news. ;-) I hope that
this message helps.

 Yours:

David

---

From: Marcel Swart <[email-masked]>
Date: Thu, 6 Jul 2000 10:42:49 +0200

>Hello.
>produced when
>this occurs during lets say integration....

This is true, but depends on the machine on which you run the program.
However, if you use FORTRAN90, you have somewhat control of the error.
If you use selected_real_kind(15,70) to define the kind of all reals,
you can check if that kind is available on that machine.
The 15,70 means 15 decimals precision, and exponent up to power 70.

---

From: Jochen Kuepper <[email-masked]>
Date: Thu, 6 Jul 2000 14:13:59 +0200 (CEST)

Iraj Daizadeh writes:
 > Is this true? 

Yes.

 > and, if so, how does one remove possible rounding errors
 > produced when

Look up a numerics book on floating point numbers. Some good and free
docs are lying around the net ;-)

Jochen
-- 
Heinrich-Heine-Universität, Institut für Physikalische Chemie I
Universitätsstr. 1, Geb. 26.43 Raum 02.29
40225 Düsseldorf, Germany                phone ++49-211-8113681
http://www.Jochen-Kuepper.de               fax ++49-211-8115195