[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation and new issues

Tim Peters tim.one@comcast.net
Thu, 03 Oct 2002 12:50:38 -0400


[Oren Tirosh]
> Comparisons could produce a third boolean value called 'Undetermined':

Why?  What real numeric problem are you trying to solve?

> result = A>B
> if result is Undetermined:
>    print "Sorry, difference between A and B is below the error margin"
>    print "I cannot determine which one is greater."
> else:
>    print "%s is greater than %s" % tuple(('BA','AB')[result])

> [Taking off absurdly-purist-hat :-]
>
> This actually gives me a serious idea: a floating-point type that helps
> keep track of error magnitude. It's a pair of floats (like a complex
> number) where the second number is an estimate or limit on the absolute
> value of errors in the first and is updated by all operators.

It's called interval arithmetic; about 30 years ago I had to implement it
for a numerical analysis class assignment, in assembler for a Univac 1108;
the interface to the Fortran compiler indeed tricked it into storing the
bounds in complex numbrs; *efficient* support for interval arithmetic is why
the 754 std requires the directed (to-plus-inf, to-minus-inf) rounding
modes; it hasn't caught on, and the current incarnation of the 754 committee
is thinking about removing this requirement; in the hands of an expert it
can be very powerful; in the hands of a non-expert, the usual result is that
the error bounds grow so large as to render the computation useless.

> An error tracking replacement for the math module would also be required.

    http://www.uni-karlsruhe.de/~iam/html/language/pxsc.html

A single-rounding dot product proved crucial to their successes.