On 11/29/2013 3:43 PM, Bill Gosper wrote: Hi Richard, had you intended to exclude math-fun? RJFateman>No, just not sure I had "write permission"... feel free to forward. Anyway, Mathematica has the separate function PolynomialGCD. Macsyma's gcd (and originally, factor) were semantically overloaded. I can't imagine why Integrate would take the numerator and denominator of ComplexInfinity, nor any harm that could follow taking them to be 1 and 0. This I agree with, except that the cost associated with Numerator[] will be the time for user-code testing whether the argument is ComplexInfinity. I have at various times proposed that the CL rational numbers or those in Maxima be extended to include 1/0 and -1/0 and even 0/0. I may have suggested it to Wolfram people. In some ways it makes the rational arithmetic programs shorter .. just do the arithmetic and it (sometimes) comes out. e.g. 1/0 * 1/0 = 1/0. 1/2 + 1/0 = (1*0+1*2)/(2*0) = 2/0. reduce to lowest terms given gcd(2,0) is 2, gives 1/0 I think that you only have to check if the answer comes out 0/0, in which case, see if you can you do better. e.g. 1/0+1/0 comes out 0/0 so you go back and do some checking to come up with 1/0. 1/0 + -1/0 comes out 0/0, and that is probably what you want. rwg>Here's an actual piece of Lisp code doing just that: ;Closest rational to x with numerator ≤ nhi (defun bstrat (x nhi &optional (c 0) (d 1)) (multiple-value-bind (f y) (floor x) (cond ((or (> f (* 2 nhi)) (and (= f (* 2 nhi)) (>= (* c y) d))) #.(SI::make-canonical-rational 1 0)) ((>= f nhi) nhi) ((= 0 (setf r (round (* nhi y) x))) f) ((+ f (/ (bstrat (/ y) (floor (- nhi r) f) (+ d (* f c)) c)))))))
gwr
rjf>But I haven't thought about this for a while. Returning to your theme.. I think it does rely on gcd(0,n) coming out n for integer n. :) RJF PS feel free to forward this too. rwg>Holy cow, I totally forgot about nouuo. On Fri, Nov 29, 2013 at 2:52 PM, Richard Fateman <fateman@berkeley.edu>wrote:
An alternative view is that Pi (etc), is a symbol, and also a polynomial in one variable, i.e. 1*Pi^1+0*Pi^0.
Under those circumstances, GCD[1,Pi] would be 1.
Given that the reals are not a unique factorization domain, the GCD is unspecified mathematically, so programmatically you can do something like analytically continue GCD any old way that works when you wander onto some UFD, and nothing expect that otherwise works will be broken. At least that seemed to be the Macsyma philosophy.
Rationals are not a UFD either, but there is some consensus here.
Both Mathematica and Macsyma/ Maxima say that gcd(1/6,1/9) is 1/18.
Introducing Sqrt[2] is a somewhat different matter, which I'd rather not write a dissertation about, here.
I agree that Mma is accommodating at least superficially. However, redefining Numerator etc may have consequences in runtime. At least assuming that the internal routines that call Numerator now use the redefined version, what happens to, say, Integrate[]?
was it (setq nouuo t) in maclisp??
RJF
participants (1)
-
Bill Gosper