On Wed, Feb 9, 2011 at 10:46 PM, daly <d...@axiom-developer.org> wrote: > On Wed, 2011-02-09 at 22:18 -0800, rjf wrote: >> You say, >> > gcd(2/1,4) returns 1 "for simplicity" (!), because 2/1 is a rational. >> > This is shockingly silly. >> >> I don't know exactly how this came up, but if 2/1 is in a different >> domain (rational) >> from 2, (integer), then gcd should probably be 1, since any non- >> zero >> rational number divides any other, and one commonly uses the positive >> "unit" 1 for >> such a case. You could argue that since you can coerce 2/1, you >> should. >> >> That's sometimes OK, but not always. >> >> Really, the issue is much broader. for example, do you also want to >> treat the complex number >> 1+0*i the same as 1? do you want to treat the floating point number >> 1.0 the same as 1? >> >> What about 1X1 matrices? >> >> Is 1^0 the same as 1^0.0 or 1.0^0 or 1.0^0.0? Do you perhaps wish >> to consider/dismiss >> the existence of number systems with signed zeros (IEEE floating-point >> standard) on the >> grounds that -0 = +0, [true, for numerical comparison] and therefore >> there should be >> only a single zero? >> >> While I don't know the exact formulation of this GCD problem, the >> issue of >> implicit coercion is one of the troubling sore spots in a system >> design, and should not >> be decided by counting up casual +1 votes. >> >> I think the Axiom people might have thought more about it than others. >> > > It is a question of domains. In Axiom you can specify the domains.
You can in Sage too. The question is whether 1 is the right answer for the domain of rational numbers. (That's what it currently does, just like Axiom, but it's not very useful.) > 2/1 is a Fraction(Integer) aka rational > 4 is an Integer > (2/1)::Integer => 2 where 2 is an Integer. > 4::Fraction(Integer) is a Fraction(Integer) > > So there are several cases: > gcd((2/1),4::Fraction(Integer)) => 1 of type Fraction(Integer) > gcd((2/1)::Integer,4)) => 2 of type PositiveInteger > gcd(2/1,4) => 1 of type Fraction(Integer) > gcd(2,4) => 2 of type PositiveInteger > gcd(2,4::Fraction(Integer)) => 1 of type Fraction(Integer) > > Tim Daly > > > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org