-Adic Capped Relative Elements
Elements of -Adic Rings with Capped Relative Precision
AUTHORS:
Bases: sage.rings.padics.padic_capped_relative_element.pAdicTemplateElement
Initialization.
EXAMPLES:
sage: a = Zp(5)(1/2,3); a
3 + 2*5 + 2*5^2 + O(5^3)
sage: type(a)
<type 'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
sage: TestSuite(a).run()
Returns a new element with absolute precision decreased to absprec.
INPUT:
OUTPUT:
an equal element with precision set to the minimum of self's precision and absprec
EXAMPLE:
sage: R = Zp(7,4,'capped-rel','series'); a = R(8); a.add_bigoh(1)
1 + O(7)
sage: b = R(0); b.add_bigoh(3)
O(7^3)
sage: R = Qp(7,4); a = R(8); a.add_bigoh(1)
1 + O(7)
sage: b = R(0); b.add_bigoh(3)
O(7^3)
The precision never increases::
sage: R(4).add_bigoh(2).add_bigoh(4)
4 + O(7^2)
Another example that illustrates that the precision does
not increase::
sage: k = Qp(3,5)
sage: a = k(1234123412/3^70); a
2*3^-70 + 3^-69 + 3^-68 + 3^-67 + O(3^-65)
sage: a.add_bigoh(2)
2*3^-70 + 3^-69 + 3^-68 + 3^-67 + O(3^-65)
sage: k = Qp(5,10)
sage: a = k(1/5^3 + 5^2); a
5^-3 + 5^2 + O(5^7)
sage: a.add_bigoh(2)
5^-3 + O(5^2)
sage: a.add_bigoh(-1)
5^-3 + O(5^-1)
Returns whether self is equal to right modulo
.
If absprec is None, returns True if self and right are equal to the minimum of their precisions.
INPUT:
EXAMPLES:
sage: R = Zp(5, 10); a = R(0); b = R(0, 3); c = R(75, 5)
sage: aa = a + 625; bb = b + 625; cc = c + 625
sage: a.is_equal_to(aa), a.is_equal_to(aa, 4), a.is_equal_to(aa, 5)
(False, True, False)
sage: a.is_equal_to(aa, 15)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: a.is_equal_to(a, 50000)
True
sage: a.is_equal_to(b), a.is_equal_to(b, 2)
(True, True)
sage: a.is_equal_to(b, 5)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: b.is_equal_to(b, 5)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: b.is_equal_to(bb, 3)
True
sage: b.is_equal_to(bb, 4)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: c.is_equal_to(b, 2), c.is_equal_to(b, 3)
(True, False)
sage: c.is_equal_to(b, 4)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: c.is_equal_to(cc, 2), c.is_equal_to(cc, 4), c.is_equal_to(cc, 5)
(True, True, False)
TESTS:
sage: aa.is_equal_to(a), aa.is_equal_to(a, 4), aa.is_equal_to(a, 5)
(False, True, False)
sage: aa.is_equal_to(a, 15)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: b.is_equal_to(a), b.is_equal_to(a, 2)
(True, True)
sage: b.is_equal_to(a, 5)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: bb.is_equal_to(b, 3)
True
sage: bb.is_equal_to(b, 4)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: b.is_equal_to(c, 2), b.is_equal_to(c, 3)
(True, False)
sage: b.is_equal_to(c, 4)
Traceback (most recent call last):
...
PrecisionError: Elements not known to enough precision
sage: cc.is_equal_to(c, 2), cc.is_equal_to(c, 4), cc.is_equal_to(c, 5)
(True, True, False)
Determines whether this element is zero modulo
.
If absprec is None, returns True if this element is indistinguishable from zero.
INPUT:
EXAMPLES:
sage: R = Zp(5); a = R(0); b = R(0,5); c = R(75)
sage: a.is_zero(), a.is_zero(6)
(True, True)
sage: b.is_zero(), b.is_zero(5)
(True, True)
sage: c.is_zero(), c.is_zero(2), c.is_zero(3)
(False, True, False)
sage: b.is_zero(6)
Traceback (most recent call last):
...
PrecisionError: Not enough precision to determine if element is zero
Returns a list of coefficients in a power series expansion of
self in terms of . If self is a field element, they start at
, if a ring element at
.
For each lift mode, this funciton returns a list of so
that this element can be expressed as
where is the valuation of this element when the parent is
a field, and
otherwise.
Different lift modes affect the choice of . When
lift_mode is 'simple', the resulting
will be
non-negative: if the residue field is
then they
will be integers with
; otherwise they will be
a list of integers in the same range giving the coefficients
of a polynomial in the indeterminant representing the maximal
unramified subextension.
Choosing lift_mode as 'smallest' is similar to
'simple', but uses a balanced representation .
Finally, setting lift_mode = 'teichmuller' will yield
Teichmuller representatives for the :
. In
this case the
will also be
-adic elements.
INPUT:
OUTPUT:
Note
Use slice operators to get a particular range.
EXAMPLES:
sage: R = Zp(7,6); a = R(12837162817); a
3 + 4*7 + 4*7^2 + 4*7^4 + O(7^6)
sage: L = a.list(); L
[3, 4, 4, 0, 4]
sage: sum([L[i] * 7^i for i in range(len(L))]) == a
True
sage: L = a.list('smallest'); L
[3, -3, -2, 1, -3, 1]
sage: sum([L[i] * 7^i for i in range(len(L))]) == a
True
sage: L = a.list('teichmuller'); L
[3 + 4*7 + 6*7^2 + 3*7^3 + 2*7^5 + O(7^6),
0,
5 + 2*7 + 3*7^3 + O(7^4),
1 + O(7^3),
3 + 4*7 + O(7^2),
5 + O(7)]
sage: sum([L[i] * 7^i for i in range(len(L))])
3 + 4*7 + 4*7^2 + 4*7^4 + O(7^6)
sage: R(0, 7).list()
[]
sage: R = Qp(7,4); a = R(6*7+7**2); a.list()
[6, 1]
sage: a.list('smallest')
[-1, 2]
sage: a.list('teichmuller')
[6 + 6*7 + 6*7^2 + 6*7^3 + O(7^4),
2 + 4*7 + 6*7^2 + O(7^3),
3 + 4*7 + O(7^2),
3 + O(7)]
TESTS:
Check to see that trac ticket #10292 is resolved:
sage: E = EllipticCurve('37a')
sage: R = E.padic_regulator(7)
sage: len(R.list())
19
Returns the absolute precision of this element.
This is the power of the maximal ideal modulo which this element is defined.
EXAMPLES:
sage: R = Zp(7,3,'capped-rel'); a = R(7); a.precision_absolute()
4
sage: R = Qp(7,3); a = R(7); a.precision_absolute()
4
sage: R(7^-3).precision_absolute()
0
sage: R(0).precision_absolute()
+Infinity
sage: R(0,7).precision_absolute()
7
Returns the relative precision of this element.
This is the power of the maximal ideal modulo which the unit part of self is defined.
EXAMPLES:
sage: R = Zp(7,3,'capped-rel'); a = R(7); a.precision_relative()
3
sage: R = Qp(7,3); a = R(7); a.precision_relative()
3
sage: a = R(7^-2, -1); a.precision_relative()
1
sage: a
7^-2 + O(7^-1)
sage: R(0).precision_relative()
0
sage: R(0,7).precision_relative()
0
Returns a list [,
,...,
] such that
EXAMPLES:
sage: R = Qp(5,5); R(70).list('teichmuller') #indirect doctest
[4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5),
3 + 3*5 + 2*5^2 + 3*5^3 + O(5^4),
2 + 5 + 2*5^2 + O(5^3),
1 + O(5^2),
4 + O(5)]
Returns , where this element is
.
EXAMPLES:
sage: R = Zp(17,4,'capped-rel')
sage: a = R(18*17)
sage: a.unit_part()
1 + 17 + O(17^4)
sage: type(a)
<type 'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
sage: R = Qp(17,4,'capped-rel')
sage: a = R(18*17)
sage: a.unit_part()
1 + 17 + O(17^4)
sage: type(a)
<type 'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
sage: a = R(2*17^2); a
2*17^2 + O(17^6)
sage: a.unit_part()
2 + O(17^4)
sage: b=1/a; b
9*17^-2 + 8*17^-1 + 8 + 8*17 + O(17^2)
sage: b.unit_part()
9 + 8*17 + 8*17^2 + 8*17^3 + O(17^4)
sage: Zp(5)(75).unit_part()
3 + O(5^20)
sage: R(0).unit_part()
Traceback (most recent call last):
...
ValueError: unit part of 0 not defined
sage: R(0,7).unit_part()
O(17^0)
Returns a pair (self.valuation(), self.unit_part()).
INPUT:
Note
The optional argument p is used for consistency with the valuation methods on integer and rational.
EXAMPLES:
sage: R = Zp(5); a = R(75, 20); a
3*5^2 + O(5^20)
sage: a.val_unit()
(2, 3 + O(5^18))
sage: R(0).val_unit()
Traceback (most recent call last):
...
ValueError: unit part of 0 not defined
sage: R(0, 10).val_unit()
(10, O(5^0))
Returns a base- list of digits of n.
INPUT:
n – a positive Integer.
Otherwise, the digits lie in the range to
.
prime_pow – A PowComputer giving the prime.
EXAMPLES:
sage: from sage.rings.padics.padic_capped_relative_element import base_p_list
sage: base_p_list(192837, True, Zp(5).prime_pow)
[2, 2, 3, 2, 3, 1, 2, 2]
sage: 2 + 2*5 + 3*5^2 + 2*5^3 + 3*5^4 + 5^5 + 2*5^6 + 2*5^7
192837
sage: base_p_list(192837, False, Zp(5).prime_pow)
[2, 2, -2, -2, -1, 2, 2, 2]
sage: 2 + 2*5 - 2*5^2 - 2*5^3 - 5^4 + 2*5^5 + 2*5^6 + 2*5^7
192837
Bases: sage.rings.padics.padic_capped_relative_element.CRElement
Constructs new element with given parent and value.
INPUT:
EXAMPLES:
sage: R = Zp(5, 10, 'capped-rel')
Construct from integers:
sage: R(3)
3 + O(5^10)
sage: R(75)
3*5^2 + O(5^12)
sage: R(0)
0
sage: R(-1)
4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + O(5^10)
sage: R(-5)
4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + 4*5^10 + O(5^11)
sage: R(-7*25)
3*5^2 + 3*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + 4*5^10 + 4*5^11 + O(5^12)
Construct from rationals:
sage: R(1/2)
3 + 2*5 + 2*5^2 + 2*5^3 + 2*5^4 + 2*5^5 + 2*5^6 + 2*5^7 + 2*5^8 + 2*5^9 + O(5^10)
sage: R(-7875/874)
3*5^3 + 2*5^4 + 2*5^5 + 5^6 + 3*5^7 + 2*5^8 + 3*5^10 + 3*5^11 + 3*5^12 + O(5^13)
sage: R(15/425)
Traceback (most recent call last):
...
ValueError: p divides the denominator
Construct from IntegerMod:
sage: R(Integers(125)(3))
3 + O(5^3)
sage: R(Integers(5)(3))
3 + O(5)
sage: R(Integers(5^30)(3))
3 + O(5^10)
sage: R(Integers(5^30)(1+5^23))
1 + O(5^10)
sage: R(Integers(49)(3))
Traceback (most recent call last):
...
TypeError: cannot coerce from the given integer mod ring (not a power of the same prime)
sage: R(Integers(48)(3))
Traceback (most recent call last):
...
TypeError: cannot coerce from the given integer mod ring (not a power of the same prime)
Some other conversions:
sage: R(R(5))
5 + O(5^11)
Construct from Pari objects:
sage: R = Zp(5)
sage: x = pari(123123) ; R(x)
3 + 4*5 + 4*5^2 + 4*5^3 + 5^4 + 4*5^5 + 2*5^6 + 5^7 + O(5^20)
sage: R(pari(R(5252)))
2 + 2*5^3 + 3*5^4 + 5^5 + O(5^20)
sage: R = Zp(5,prec=5)
sage: R(pari(-1))
4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5)
sage: pari(R(-1))
4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5)
sage: pari(R(0))
0
sage: R(pari(R(0,5)))
O(5^5)
# todo: doctests for converting from other types of p-adic rings
Return an integer or rational congruent to self modulo self‘s precision. If a rational is returned, its denominator will equal p^ordp(self).
EXAMPLES:
sage: R = Zp(7,4,'capped-rel'); a = R(8); a.lift()
8
sage: R = Qp(7,4); a = R(8); a.lift()
8
sage: R = Qp(7,4); a = R(8/7); a.lift()
8/7
Reduces this element modulo .
INPUT:
OUTPUT:
Element of – the reduction modulo
EXAMPLES:
sage: R = Zp(7,4,'capped-rel'); a = R(8); a.residue(1)
1
sage: R = Qp(7,4,'capped-rel'); a = R(8); a.residue(1)
1
sage: a.residue(6)
Traceback (most recent call last):
...
PrecisionError: Not enough precision known in order to compute residue.
sage: b = a/7
sage: b.residue(1)
Traceback (most recent call last):
...
ValueError: Element must have non-negative valuation in order to compute residue.
Bases: sage.rings.morphism.RingHomomorphism_coercion
The canonical inclusion from the rationals to a capped relative field.
EXAMPLES:
sage: f = Qp(5).coerce_map_from(QQ); f
Ring Coercion morphism:
From: Rational Field
To: 5-adic Field with capped relative precision 20
Returns a map back to the rationals that approximates an element by a rational number.
EXAMPLES:
sage: f = Qp(5).coerce_map_from(QQ).section()
sage: f(Qp(5)(1/4))
1/4
sage: f(Qp(5)(1/5))
1/5
Bases: sage.rings.morphism.RingHomomorphism_coercion
The canonical inclusion from the integer ring to a capped relative ring.
EXAMPLES:
sage: f = Zp(5).coerce_map_from(ZZ); f
Ring Coercion morphism:
From: Integer Ring
To: 5-adic Ring with capped relative precision 20
Returns a map back to the ring of integers that approximates an element by an integer.
EXAMPLES:
sage: f = Zp(5).coerce_map_from(ZZ).section()
sage: f(Zp(5)(-1)) - 5^20
-1
Bases: sage.rings.morphism.RingMap
The map from the capped relative ring back to the rationals that returns a rational approximation of its input.
EXAMPLES:
sage: f = Qp(5).coerce_map_from(QQ).section(); f
Set-theoretic ring morphism:
From: 5-adic Field with capped relative precision 20
To: Rational Field
Bases: sage.rings.morphism.RingMap
The map from a capped relative ring back to the ring of integers that returns the the smallest non-negative integer approximation to its input which is accurate up to the precision.
Raises a ValueError, if the input is not in the closure of the image of the integers.
EXAMPLES:
sage: f = Zp(5).coerce_map_from(ZZ).section(); f
Set-theoretic ring morphism:
From: 5-adic Ring with capped relative precision 20
To: Integer Ring
Bases: sage.categories.morphism.Morphism
The inclusion map from the rationals to a capped relative ring that is
defined on all elements with non-negative -adic valuation.
EXAMPLES:
sage: f = Zp(5).convert_map_from(QQ); f
Generic morphism:
From: Rational Field
To: 5-adic Ring with capped relative precision 20
Returns the map back to the rationals that returns the smallest non-negative integer approximation to its input which is accurate up to the precision.
EXAMPLES:
sage: f = Zp(5,4).convert_map_from(QQ).section()
sage: f(Zp(5,4)(-1))
-1
Bases: sage.rings.padics.padic_generic_element.pAdicGenericElement
A class for common functionality among the -adic template classes.
INPUT:
EXAMPLES:
sage: Zp(17)(17^3, 8, 4)
17^3 + O(17^7)
Returns another element of the same parent with absolute precision at
least absprec, congruent to this -adic element modulo the
precision of this element.
INPUT:
Note
If setting absprec that high would violate the precision cap, raises a precision error. Note that the new digits will not necessarily be zero.
EXAMPLES:
sage: R = ZpCA(17)
sage: R(-1,2).lift_to_precision(10)
16 + 16*17 + O(17^10)
sage: R(1,15).lift_to_precision(10)
1 + O(17^15)
sage: R(1,15).lift_to_precision(30)
Traceback (most recent call last):
...
PrecisionError: Precision higher than allowed by the precision cap.
sage: R(-1,2).lift_to_precision().precision_absolute() == R.precision_cap()
True
sage: R = Zp(5); c = R(17,3); c.lift_to_precision(8)
2 + 3*5 + O(5^8)
sage: c.lift_to_precision().precision_relative() == R.precision_cap()
True
Fixed modulus elements don’t raise errors:
sage: R = ZpFM(5); a = R(5); a.lift_to_precision(7)
5 + O(5^20)
sage: a.lift_to_precision(10000)
5 + O(5^20)
Returns a list of coefficients of the uniformizer
starting with
up to
exclusive (padded with
zeros if needed).
For a field element of valuation , starts at
instead.
INPUT:
EXAMPLES:
sage: R = Zp(7,4,'capped-abs'); a = R(2*7+7**2); a.padded_list(5)
[0, 2, 1, 0, 0]
sage: R = Zp(7,4,'fixed-mod'); a = R(2*7+7**2); a.padded_list(5)
[0, 2, 1, 0, 0]
For elements with positive valuation, this function will return a list with leading 0s if the parent is not a field:
sage: R = Zp(7,3,'capped-rel'); a = R(2*7+7**2); a.padded_list(5)
[0, 2, 1, 0, 0]
sage: R = Qp(7,3); a = R(2*7+7**2); a.padded_list(5)
[2, 1, 0, 0]
sage: a.padded_list(3)
[2, 1]
Returns the unit part of this element.
This is the -adic element
in the same ring so that this
element is
, where
is a uniformizer and
is
the valuation of this element.
Unpickles a capped relative element.
EXAMPLES:
sage: from sage.rings.padics.padic_capped_relative_element import unpickle_cre_v2
sage: R = Zp(5); a = R(85,6)
sage: b = unpickle_cre_v2(a.__class__, R, 17, 1, 5)
sage: a == b
True
sage: a.precision_relative() == b.precision_relative()
True
Unpickles a capped relative element.
EXAMPLES:
sage: from sage.rings.padics.padic_capped_relative_element import unpickle_pcre_v1
sage: R = Zp(5)
sage: a = unpickle_pcre_v1(R, 17, 2, 5); a
2*5^2 + 3*5^3 + O(5^7)