Dear all,

This issue concerning the semantic of the method `content` has not been 
resolved since it was raised by Vincent almost 2 years ago (see ticket 
#16613 <http://trac.sagemath.org/ticket/16613>). The needed changes are 
technically easy to perform, we "simply" need to reach a consensus (of 
course, not that easy ;-)). I'd like to fix it as soon as possible. For 
this, I need your opinion. The (main) question is as follows:

*Should the method `content` return an ideal or an element of the base 
ring?*

Here are the solutions proposed so far. Please vote (or comment) on the 
best choice to your mind:


   1. Make `content` return an ideal by default, with a flag (
   ideal=True/False, or gen=True/False) to change the behavior.
   2. Make `content` return an element by default, with a flag to change 
   the behavior. Raise a NotImplementedError if the flag is ideal=False but 
   the content ideal is not principal.
   3. Make `content` always return an element, create a method `
   content_ideal` to return an ideal, and implement `content` only over 
   PIDs.


Some arguments for the proposed solutions (I gave links in #16613 comment:2 
<http://trac.sagemath.org/ticket/16613#comment:2>):

Solution 1: 

   - Over any ring, one can speak about the content as ideal, so this is 
   the most mathematically valid definition.
   - This is consistent with the current behavior for the (probably) most 
   common case: dense polynomials over ZZ.

Solutions 2 & 3:

   - This is consistent with MuPAD, Maple, Mathematica, Magma, and 
   libraries Flint, Pari, NTL
   - This is the definition taken in many textbooks, including "Modern 
   Computer Algebra" (von zur Gathen & Gerhard) or "A course in computational 
   number theory" (Cohen).
   - This implies less changes of behaviors.


Solution 3: `content_ideal` is easily found by tab-exploration, in 
particular for polynomials over non-PIDs where it would be the only `
content...` method.

Finally, two side questions:

A. What kind of deprecation should be implemented?
B. What should the content (element) over QQ (or other fraction fields) be? 
Of course, 1 is a possible answer, but note that gcd(2/3, 4/5) = 2/15 for 
instance. So another possible answer is `gcd(pol.coefficients())`.


Best,
Bruno


Le lundi 30 juin 2014 15:43:23 UTC+2, John Cremona a écrit :
>
> That sounds OK -- yes, it must be possible to return the content as a 
> number without any complicated construction, especially as the content 
> (as a number) will be returned by some lower-level library such as 
> FLINT. 
>
> John 
>
> On 30 June 2014 08:53, Vincent Delecroix <[email protected] 
> <javascript:>> wrote: 
> > Dear John, 
> > 
> > Thanks for your answer. 
> > 
> > The method content for dense polynomial over ZZ is implemented at a 
> > very low level... I am sure somebody cares about its speed. In 
> > particular, I am not in favour of pol.content().gen() which needs to 
> > build the ideal. 
> > 
> > Your flag idea is nice. For the deprecation warning for dense 
> > polynomial over ZZ, I suggest by default that we have gen=None and 
> > that's raise a warning and return the previous behaviour. If the user 
> > provide either gen=True or gen=False then it is fine. 
> > 
> > Best, 
> > Vincent 
> > 
> > 2014-06-30 9:12 UTC+02:00, John Cremona <[email protected] 
> <javascript:>>: 
> >> I'm not sure about the name content_gen, or whether it is necessary if 
> >> pol.content().gen() works.  Also, I suspect that there may be quite a 
> >> lot of code out there  which this change will break.  Would it be 
> >> possible to make the change you suggest for content() but to have a 
> >> parameter flag such as 'ideal' so that by default ideal=True and the 
> >> result is an ideal, but ideal=False returns an element generating the 
> >> ideal (with an error raised if the ideal is not principal, or always 
> >> over a non-PID)?  Then, there could be a period of deprecation during 
> >> which the default over ZZ was ideal=False (but ideal=True over all 
> >> other rings). 
> >> 
> >> It's more complicated but perhaps better in the long run.  This 
> >> happened to me before....and I survived. 
> >> 
> >> John 
> >> 
> >> On 29 June 2014 22:32, Vincent Delecroix <[email protected] 
> <javascript:>> wrote: 
> >>> Hello, 
> >>> 
> >>> While reviewing #16516 I bumped into the following bug 
> >>> {{{ 
> >>> sage: R.<x> = PolynomialRing(ZZ, sparse=True) 
> >>> sage: (3*x^5 + 3).content() 
> >>> Principal ideal (3) of Integer Ring 
> >>> sage: R.<x> = PolynomialRing(ZZ, sparse=False) 
> >>> sage: (3*x^5 + 3).content() 
> >>> 3 
> >>> }}} 
> >>> It is documented in the corresponding methods but it prevents anybody 
> >>> to write generic code for integer polynomials. 
> >>> 
> >>> I would suggest to have ".content()" always returning an ideal (which 
> >>> is defined over any ring) and having ".content_gen()" to be working 
> >>> over PID. 
> >>> 
> >>> Does anybody has objections or suggestions related to that? 
> >>> 
> >>> Best 
> >>> Vincent 
> >>> 
> >>> -- 
> >>> You received this message because you are subscribed to the Google 
> Groups 
> >>> "sage-devel" group. 
> >>> To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >>> email to [email protected] <javascript:>. 
> >>> To post to this group, send email to [email protected] 
> <javascript:>. 
> >>> Visit this group at http://groups.google.com/group/sage-devel. 
> >>> For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> Groups 
> >> "sage-devel" group. 
> >> To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >> email to [email protected] <javascript:>. 
> >> To post to this group, send email to [email protected] 
> <javascript:>. 
> >> Visit this group at http://groups.google.com/group/sage-devel. 
> >> For more options, visit https://groups.google.com/d/optout. 
> >> 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "sage-devel" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > Visit this group at http://groups.google.com/group/sage-devel. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" 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 https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to