[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Major argument against providing log(-1) = #c(0 3.14...):

It provides a violation of log(a*b) = log(a)+log(b), which most
people expect to hold on the real numbers.  You may argue that
by asking for log of a negative number, the user was asking for it,
yet it is more likely than not that this came up by a programming
error, or perhaps roundoff error.  The option of computing
log (-1+0*i) (or perhaps clog(-1)), is naturally open.

I strongly suggest rational arithmetic
be both canonical (2/4 converted to 1/2) and REQUIRE 1/0, -1/0 and 0/0.
Given that the gcd(x,0) is x, there is
almost no checking needed for these peculiar numbers, representing
+inf, -inf, and undefined.  Rules like 1/inf -> 0 fall through free.

The only "extra" check is that if the denominator of a sum turns
out to be 0, one has to figure out if the answer is 1/0, -1/0, or 0/0.

Similar ideas for +-inf, und, hold for IEEE-format numbers.

I have a set of programs which implement (in Franz) a common-lisp-like
i/o scheme, rational numbers, DEC-D flonums, integers, arbitrary-precision
floating point (macsyma "bigfloat"),
and  complex numbers (of any mixture of these, eg.  #c(3.0 1/2)).
In the works is an interval arithmetic package, and a trap-handler.
There is also a compiler package in the works so that (+ ....) is
compiled with appropriate efficiency in the context of
appropriate declarations.

I would be glad to share these programs with anyone who cares to
look at the stuff.

The important transcendental functions are implemented for real
arguments of flonum and bigfloat.

Q: What did you have in mind for, for example, sqrt(rational)?
(what is the "required coercion"?)