1/0=inf, -1/0=minf



On 8/5/2013 10:20 AM, Henry Baker wrote:
....

> .
>
> I find 'signed zeros' to be such an abomination, that I have to reject them, as well.
As I recall, the signed zeros were intended  (a) to help form a closed 
system, and (b) to assist in interval
arithmetic.  So (/ 1 minf) = -0, etc.

But this was a compromise and Kahan's mathematical preference would be 
to have  unsigned 0 and  -0  and +0.
There aren't enough bits to do this.



>
> We are thus left with the finite rationals union {-oo} union {+oo}, which we can represent by -1/0 and 1/0 if it seems convenient.  Notice that in Common Lisp, "+oo" and "-oo" are both _symbols_, so we can declare these as constant symbols that are bound to themselves.
>
> (I don't know enough about Common Lisp's 'CLOS' (Common Lisp Object System) to know if I could change '<' to be a generic function which could be overloaded via 'defmethod' for dealing with +oo and -oo.)
Yes, it is possible to define a different package in which < can be 
overloaded. You can't mess with the
standard package's built-in arithmetic without running into problems.  
There is a (probably broken) implementation
of  generic arithmetic
http://www.cs.berkeley.edu/~fateman/generic/

I also have, separately, the code for that paper, extrat.lisp...


Actually what you do  (and I've done with the generic code) is define a 
macro for <   which expands into calls to
(two-arg-<  ...)
>
> Since I'm going to this trouble primarily for ordering purposes, the inclusion of a separate -0 makes things so much more complicated that it isn't worth doing at all.
I think that for IEEE754,   0 and -0  are equal.

>
> If you don't like the fact that (/ (/ -1/0)) == 1/0, then you can always leave (/ x/0) undefined.  Me, on the other hand, would still rather have (/ (/ x)) == x only for finite numbers.
> ---
>
> On a slightly different subject, would there be any advantage to encoding rationals not with a _pair_ (numerator,denominator), but with _four_ elements: (n,d,a,b), which represents the number n/d, but also includes a,b such that a*n+b*d=1, thus providing a 'proof' that the numerator and denominator are relatively prime ??
I know of no system that does this but it is an interesting idea. Maybe 
not so much for numeric
n and d, but for polynomial n and d.
>
> In general, the sizes of a,b are about the same as the sizes of n,d, so this essentially doubles the storage space, but with 64-bit machines, we have twice as much storage, anyway.  :-)
>
> Since gcd's are typically done all the time in rational number implementations, you get the 'multipliers' a,b _for free_.
The key question is,  if you add   n1/d1  + n2/d2, to get n3/d3 in 
lowest terms, how best to do it.
gcd( n1*d2+n2*d1, d1*d2)   is perhaps more expensive than  first 
computing   gcd(n1,d2),   gcd(n2,d1) and
dealing with the rest . I think this is, again, not a big deal with 
integers and may not pay off, but
it  is generally believed that it does for polynomials.

>
> Perhaps such a representation has already been considered for polynomials in CAS systems ?
Not known to me.
>
> At 08:14 AM 8/5/2013, Richard Fateman wrote:
>> On 8/5/2013 7:54 AM, Oliver Kullmann wrote:
>>> Also
>>>
>>> http://dl.acm.org/citation.cfm?id=1219095
>>> The rational numbers as an abstract data type
>>>
>>> could be of interest (it shows how to work well with 1/0 = 0).
>> I haven't studied this paper in detail, but since it describes an axiom system for rationals
>> in which 1/0 = 0  is a consequence, it appears that this is inappropriate for computer algebra
>> systems...  where applications seem to require that 1/0 is certainly not zero.
>>
>> Perhaps this is another example of the gap between theory and practice in computing.
>>
>> Richard.
>>
>>> There are various papers follow up on this new algebraic structure.
>>>
>>> Oliver
>>>
>>> On Mon, Aug 05, 2013 at 07:23:40AM -0700, Richard Fateman wrote:
>>>> You might look at ..
>>>> computation with the extended rational numbers...
>>>>
>>>> www.cs.berkeley.edu/~fateman/papers/extrat.pdf?
>>>> (1994)
>>>>
>>>> RJF
>>>>
>>>> On 8/5/2013 6:19 AM, Henry Baker wrote:
>>>>> I've been playing with rational numbers which allow the denominator to be zero.
>> .... snip