Hi everybody,

In the discussion about numerics in Haskell, several people are apparently 
assuming that you can't compute with real numbers, and that computers must 
approximate real numbers using either floating point or rationals.

However, it isn't true that computers cannot handle real numbers.  There have 
been several papers on exact real arithmetic (I believe by Corky Cartwright 
and David Lester).  The idea is to use lazy representations of unbounded data 
structures, such as continued fractions, to represent a real number.  Just as 
it's possible for a finite computer to perform certain computations on 
infinite graphs, it's also possible for it to perform certain computations on 
real numbers.  (Naturally, there are some computations that will fail to 
terminate.)

I'm not sure what the current state of this research is, but we should look 
into it.  There may be serious limitations on what you can do with exact real 
numbers in a computer, but some useful applications have been reported.  Of 
course you can't print all the digits of a real number, or ask for its least 
significant digit, but you can add them, or print them to any desired accuracy.

The Floating types should be called Floating, and the name Real should be 
reserved for numbers that actually obey the algebraic laws for real numbers.

Here's a good project for Haskell 2: study the literature on exact real 
arithmetic, and figure out whether the technology is effective enough so that 
Haskell 2 should have a Real type.  Of course it should also have the Floating 
types, and most people will use Float (rather than Real) just as most people 
use Int (rather than Integer).  However, it would be wonderful if Haskell 2 
could have Integer, Rational and Real types which satisfy the corresponding 
algebraic laws.

There need to be several flavors of complex numbers, since there are two 
orthogonal issues: (1) how to represent the complex itself (real+imaginary, 
polar representation etc.), and (2) what underlying type is used for the 
components (Float, Double, Rational, Real etc.)

John O'Donnell



Reply via email to