#7016: Bizarre results when taking the mod of a p-adic number
----------------------+-----------------------------------------------------
Reporter: jonhanke | Owner: tbd
Type: defect | Status: new
Priority: critical | Milestone: sage-4.1.2
Component: algebra | Keywords: padic, mod, %
Reviewer: | Author:
Merged: |
----------------------+-----------------------------------------------------
Comment(by jonhanke):
{{{
## Create a p-adic number in two ways
sage: e = 1 + O(2^20) ## Explicit creation
sage: e
1 + O(2^20)
sage: c = Qp(2)(1) ## By coercion
sage: c
1 + O(2^20)
sage: e == c
True
## Check their types
sage: type(e)
<type
'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
sage: type(c)
<type
'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
## Use the mod operation, with inconsistent results: (I expected the
integer 1 in both cases)
sage: e % 8
1 + O(2^20)
sage: c % 8
0
sage: e % 8 == c % 8
False
## Check the mod types
sage: type(e % 8)
<type
'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
sage: type(c % 8)
<type
'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
## Check their lifts
sage: e.lift()
1
sage: c.lift()
1
sage: c.lift() == e.lift()
True
sage: c.lift() % 8 == e.lift() % 8
True
}}}
Suggestions:
1) x % M returns an integer when x is a p-adic number (in Qp) and M is
an integer or raises an error if either the modulus is not a power
of p or is larger than the known precision of the number allows.
This syntax will return an error for any (non-trivial) extensions
of Qp.
2) Add a more general syntax x.reduce_mod_prime() returns an element
of FiniteField(q) whenever x is an element of an unramified
extension Qq of Qp.
3) It might also be nice to have an x.reduce_mod_prime_power(n) which
would return an element in the associated finite quotient ring
Q_q/((pi)**n), but this may not be worth the effort right now.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7016#comment:1>
Sage <http://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
-~----------~----~----~----~------~----~------~--~---