#10771: gcd and lcm for fraction fields
--------------------------------+-------------------------------------------
Reporter: SimonKing | Owner: AlexGhitza
Type: defect | Status: needs_review
Priority: major | Milestone: sage-4.7
Component: basic arithmetic | Keywords: gcd lcm fraction fields
Author: Simon King | Upstream: N/A
Reviewer: Marco Streng | Merged:
Work_issues: |
--------------------------------+-------------------------------------------
Comment(by SimonKing):
Hi Marco,
Replying to [comment:3 mstreng]:
> A couple of comments:
>
> * I don't see the point of keeping a special function
{{{gcd_rational(self, other, **kwds):}}} that returns a GCD in the set
{0,1}. Why only for QQ? Why at all? Also, the difference between {{{gcd}}}
and {{{gcd_rational}}} is not explained by the word "rational". Perhaps
{{{gcd_zero_one}}} would be a more informative name.
Perhaps I am too 'conservative': I would rather rename something than to
delete it.
But I suppose it would be better to implement a gcd and an lcm as element
methods of `Fields()` -- see #9819. In that way, one could easily provide
a correct gcd/lcm behaviour for all fields, and for fraction fields of PID
one would still obtain a gcd/lcm behaviour that is not only correct but
nice.
> * Everything generalizes from principal ideal domains to unique
factorization domains (UFD's) (such as multivariate polynomial rings over
unique factorization domains) as long as they have {{{gcd}}} and {{{lcm}}}
methods implemented. Why not write "unique factorization domain" in the
documentation instead of "principal ideal domain"?
Good question. I did it by accident. However, it matches the sad fact that
the categories are a little askew here:
{{{
sage: PrincipalIdealDomains().is_subcategory(UniqueFactorizationDomains())
False # shouldn't that be "True"?
sage: PrincipalIdealDomains().is_subcategory(GcdDomains())
True
sage: UniqueFactorizationDomains().is_subcategory(GcdDomains())
True
}}}
Perhaps one should write "fraction field of an integral domain with gcd
and lcm"? Because that's what is duck typed.
> * Suppose I have a fraction field F of a ring of type R that does not
have lcm and gcd methods, or these methods exist, but raise other kinds of
errors, e.g. because the ring is not a UFD or the methods have not been
implemented. Let a and b be elements of F. Then a and b have a gcd in F
because F is a field, so I would expect a.gcd(b) to return something
(anything basically). After applying your patch, if I do {{{a.gcd(b)}}},
it is very confusing to get an {{{AttributeError: 'RElement' object has no
attribute 'gcd'}}}: I'm not interested in gcd's of RElements, only of
{{{(Fraction)FieldElements}}}. You could put your entire {{{gcd}}} and
{{{lcm}}} code between {{{try:}}} and {{{except (AttributeError,
NotImplementedError, TypeError, ValueError):}}} to return the same 0 or 1
that {{{gcd_rational}}} would (which is a mathematically correct gcd in F
after all).
If one adds a gcd and lcm for field elements (#9819) returning 0 or 1,
then your suggestion certainly makes sense.
> * trac has a `t` too much in line 1610 of ring.pyx: {{{the case of the
rational field. However, since tract ticket #10771,}}}
>
> * you write "quotient field" in the documentation. You could write
"fraction field" to avoid confusion with quotient rings, which may be
fields. This makes it more clear that you refer to the mathematical
counterpart of Sage's "{{{FractionField}}}"?
Thanks! I am about to post a new patch, and I hope that Luis as author of
#9819 does not mind if I add the case of arbitrary fields to my patch.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10771#comment:6>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.