#20062: Make _floordiv_() for power series a deprecated alias for _div_()
-------------------------------------+-------------------------------------
       Reporter:  pbruin             |        Owner:
           Type:  task               |       Status:  needs_work
       Priority:  minor              |    Milestone:  sage-7.1
      Component:  algebra            |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Peter Bruin        |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/pbruin/20062-PowerSeries_floordiv|  e9719f7399ffab100407a360c16fe0596e7f2689
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by bruno):

 Replying to [comment:3 pbruin]:
 > Why would this be necessary?  If the user calls `__floordiv__`, he
 presumably does this for a reason, i.e. expects that it behaves
 differently from `__div__`...

 One case I very often encounter is the need of an "exact division", that
 is a division when you know in advance that the result is exact.

 >
 > > That's why (I guess) there is a `__floordiv__` in the class
 `FieldElement`.
 >
 > Well, power series rings are not fields.  There is also an
 implementation of `_floordiv_` in `RingElement`, which explicitly raises
 an error saying `unsupported operand parent(s) for '//'`.  In fact, this
 error is even raised when applying `__floordiv__` to elements of `RR`:
 > {{{
 > sage: RR(1.2) // RR(2.3)
 > ...
 > TypeError: unsupported operand parent(s) for '//': 'Real Field with 53
 bits of precision' and 'Real Field with 53 bits of precision'
 > }}}

 Right. But this behavior for `RR` is currently being discussed in #15260.

 >
 > > So I would not deprecate it, but rather simply make it an (non-
 deprecated) alias of `__div__`.
 >
 > Then we should do this in general for ring elements; I don't really see
 the advantage of this...

 That's right, it is probably a bad idea to make `__floordiv__` an alias of
 `__div__` in this case.

 >
 > In my opinion, it would make more sense to make sure that power series
 rings `R` over a field, or more generally all discrete valuation rings
 `(R, v)`, are put into the category of Euclidean domains.  Then floor
 division in `R` can be implemented using Euclidean division, so `f // g =
 f / g` if `v(g) <= v(f)` and `f // g = 0` if `v(g) > v(f)`.  However, this
 has the disadvantage that it is not the same as the current
 `__floordiv__`, which (as far as I can see) is the same as `__div__`.

 You're perfectly right. My two-cent on this would be as follows:

 * `__div__` should return an element of the fraction field, as it is the
 case for elements of `ZZ` or polynomials for instance; I find the current
 situation weird:
 {{{#!python
 sage: R.<x> = QQ[[]]
 sage: (1/(1+x)).parent()
 Power Series Ring in x over Rational Field
 sage: (1/x).parent()
 Laurent Series Ring in x over Rational Field
 }}}
   while for instance for `ZZ`:
 {{{#!python
 sage: (1/1).parent() is (1/2).parent()
 True
 }}}


 * `__floordiv__` in power series rings over a field should return the
 quotient in the euclidean division, since these rings are euclidean.

 * `__floordiv__` in power series rings over `ZZ` (say) should behave the
 same way as it behaves for polynomials over `ZZ`, that is return the
 quotient in the euclidean division (as over `QQ`) but reducing each
 coefficient modulo the leading coefficient of the divisor. For instance,
 `2-3*x-x^2+O(x^3)//(2+x)` should equal `1-2*x+0*x^2+O(x^3)`.

--
Ticket URL: <http://trac.sagemath.org/ticket/20062#comment:4>
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 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-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to