id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
21994,Change behavior of the % operator for p-adic integral elements,roed,,"In `padic_generic_element.pyx`, the documentation for `_mod_` describes two options for implementing `a%b` and `a//b`.
(2) If `b = pi^k`, the series expansion (in terms of `pi`) of `a//b` is just the series expansion of `a`, shifted over by `k` terms.
(2') The series expansion of `a % pi^k` has no terms above `pi^(k-1)`.
The conditions (2) and (2') are equivalent. But when we generalize these conditions to arbitrary `b` they diverge.
(3) For general `b`, the series expansion of `a//b` is just the series expansion of `a/b`, truncating terms with negative exponents of `pi`.
(4) For general `b`, the series expansion of `a%b` has no terms above `b.valuation() - 1`.
In order to satisfy (3), one defines
{{{
a // b = (a / b.unit_part()) >> b.valuation()
a % b = a - (a // b) * b
}}}
In order to satisfy (4), one defines
{{{
a % b = a.lift() % pi.lift()^b.valuation()
a // b = ((a - a % b) >> b.valuation()) / b.unit_part()
}}}
Currently, Sage implements option (3). The justification given is that ""it is more easily defined in terms of shifting and thus generalizes more easily to extension rings.""
On the other hand, (4) behaves better in terms of precision: the remainder in the definition (4) is always known with the maximal precision (and actually to infinite precision) while in (3) we are loosing precision for the quotient and the remainder at the same
time.
On a related note, when using definition (4), if `u` has valuation 0 then
{{{
a % (bu) = a % b
a // (bu) = (a // b) * u^(-1)
}}}
There is no corresponding simple relations if we are using definition (3).
In this ticket, we implement behavior (4) as an option and provide deprecation messages for behavior (3). ",defect,closed,major,sage-7.5,padics,fixed,padicIMA,caruso saraedum,,David Roe,Xavier Caruso,N/A,,162b44d27c5099d830accc44d3f98ba73a099940,162b44d27c5099d830accc44d3f98ba73a099940,,