Hello, 2015-01-25 4:01 UTC+01:00, Álinson S Xavier <[email protected]>: > When using the xgcd function with rational numbers (that turn out to be > integers), Sage returns non-integer numbers. > > sage: xgcd(Rational(17),Rational(2)) > (1, 1/17, 0) > sage: xgcd(17,2) > (1, 1, -8) > > I certainly did not expect this behaviour. > Is this a bug? I am using version 6.4.1.
The thing is that the definition of the gcd depends on the ambient ring and not only on the numbers sage: xgcd(4,2) (2, 0, 1) sage: xgcd(Rational(4),Rational(2)) # same numbers!! (1, 1/4, 0) And from the documentation xgcd(a,b) Return a triple "(g,s,t)" such that g = s * a+t * b = gcd(a,b). The above statement is not complete since it should have been more precise about where belong the elements (g,s,t). Anyway, the answer you got is perfectly valid and it would actually make confusion to not return the trivial answer (1, 1/a, 0) in the case of fields. Do you still think this is a bug? Best, Vincent -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
