[Haskell-cafe] rounding errors with real numbers.

Henning Thielemann lemming at henning-thielemann.de
Mon Feb 27 14:48:50 EST 2006


On Mon, 27 Feb 2006, Matthias Fischmann wrote:

> On Mon, Feb 27, 2006 at 03:11:35PM +0100, Henning Thielemann wrote:
>>
>> Is there a cancellation problem?
>
> what's a cancellation problem?

zu deutsch: Auslöschung

cancellation happens for instance here: 1 + 1e-50 - 1 == 0

>> Maybe you should use a kind of convex combination, that is
>>
>> (x-oldLower)*a + (oldUpper-x)*b
>
> i don't quite understand this either.

You have to adjust 'a' and 'b' in order to obtain 0 on x==oldLower and 1 
on x==oldUpper. The expression still depends linearly on x (plus an 
absolute term). Maybe it reduces the cancellations if the lower and the 
upper bound differ much in magnitude.


More information about the Haskell-Cafe mailing list