p-Adic Fixed-Mod Element

p-Adic Fixed-Mod Element

Elements of p-Adic Rings with Fixed Modulus

AUTHORS:

  • David Roe
  • Genya Zaytman: documentation
  • David Harvey: doctests
class sage.rings.padics.padic_fixed_mod_element.FMElement

Bases: sage.rings.padics.padic_fixed_mod_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()
add_bigoh(absprec)

Returns a new element truncated modulo \(\pi^{\mbox{absprec}}\).

INPUT:

  • absprec – an integer

OUTPUT:

  • a new element truncated modulo \(\pi^{\mbox{absprec}}\).

EXAMPLES:

sage: R = Zp(7,4,'fixed-mod','series'); a = R(8); a.add_bigoh(1)
1 + O(7^4)
is_equal_to(_right, absprec=None)

Returns whether this element is equal to right modulo \(p^{\mbox{absprec}}\).

If absprec is None, returns if self == 0.

INPUT:

  • right – a p-adic element with the same parent
  • absprec – a positive integer or None (default: None)

EXAMPLES:

sage: R = ZpFM(2, 6)
sage: R(13).is_equal_to(R(13))
True
sage: R(13).is_equal_to(R(13+2^10))
True
sage: R(13).is_equal_to(R(17), 2)
True
sage: R(13).is_equal_to(R(17), 5)
False
is_zero(absprec=None)

Returns whether self is zero modulo \(\pi^{\mbox{absprec}}\).

INPUT:

  • absprec – an integer

EXAMPLES:

sage: R = ZpFM(17, 6)
sage: R(0).is_zero()
True
sage: R(17^6).is_zero()
True
sage: R(17^2).is_zero(absprec=2)
True
list(lift_mode='simple')

Returns a list of coefficients of \(\pi^i\) starting with \(\pi^0\).

INPUT:

  • lift_mode'simple', 'smallest' or 'teichmuller' (default: 'simple':)

OUTPUT:

The list of coefficients of this element.

Note

  • Returns a list \([a_0, a_1, \ldots, a_n]\) so that each \(a_i\) is an integer and \(\sum_{i = 0}^n a_i \cdot p^i\) is equal to this element modulo the precision cap.
  • If lift_mode is 'simple', \(0 \leq a_i < p\).
  • If lift_mode is 'smallest', \(-p/2 < a_i \leq p/2\).
  • If lift_mode is 'teichmuller', \(a_i^q = a_i\), modulo the precision cap.

EXAMPLES:

sage: R = ZpFM(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),
O(7^6),
5 + 2*7 + 3*7^3 + 6*7^4 + 4*7^5 + O(7^6),
1 + O(7^6),
3 + 4*7 + 6*7^2 + 3*7^3 + 2*7^5 + O(7^6),
5 + 2*7 + 3*7^3 + 6*7^4 + 4*7^5 + O(7^6)]
sage: sum([L[i] * 7^i for i in range(len(L))])
3 + 4*7 + 4*7^2 + 4*7^4 + O(7^6)
precision_absolute()

The absolute precision of this element.

EXAMPLES:

sage: R = Zp(7,4,'fixed-mod'); a = R(7); a.precision_absolute()
4
precision_relative()

The relative precision of this element.

EXAMPLES:

sage: R = Zp(7,4,'fixed-mod'); a = R(7); a.precision_relative()
3
sage: a = R(0); a.precision_relative()
0
teichmuller_list()

Returns a list [\(a_0\), \(a_1\),..., \(a_n\)] such that

  • \(a_i^q = a_i\)
  • self.unit_part() = \(\sum_{i = 0}^n a_i \pi^i\)

EXAMPLES:

sage: R = ZpFM(5,5); R(14).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 + 5^4 + O(5^5),
2 + 5 + 2*5^2 + 5^3 + 3*5^4 + O(5^5),
1 + O(5^5),
4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + O(5^5)]
unit_part()

Returns the unit part of self.

If the valuation of self is positive, then the high digits of the result will be zero.

EXAMPLES:

sage: R = Zp(17, 4, 'fixed-mod')
sage: R(5).unit_part()
5 + O(17^4)
sage: R(18*17).unit_part()
1 + 17 + O(17^4)
sage: R(0).unit_part()
O(17^4)
sage: type(R(5).unit_part())
<type 'sage.rings.padics.padic_fixed_mod_element.pAdicFixedModElement'>
sage: R = ZpFM(5, 5); a = R(75); a.unit_part()
3 + O(5^5)
val_unit()

Returns a 2-tuple, the first element set to the valuation of self, and the second to the unit part of self.

If self == 0, then the unit part is O(p^self.parent().precision_cap()).

EXAMPLES:

sage: R = ZpFM(5,5)
sage: a = R(75); b = a - a
sage: a.val_unit()
(2, 3 + O(5^5))
sage: b.val_unit()
(5, O(5^5))
sage.rings.padics.padic_fixed_mod_element.make_pAdicFixedModElement(parent, value)

Unpickles a fixed modulus element.

EXAMPLES:

sage: from sage.rings.padics.padic_fixed_mod_element import make_pAdicFixedModElement
sage: R = ZpFM(5)
sage: a = make_pAdicFixedModElement(R, 17*25); a
2*5^2 + 3*5^3 + O(5^20)
class sage.rings.padics.padic_fixed_mod_element.pAdicCoercion_ZZ_FM

Bases: sage.rings.morphism.RingHomomorphism_coercion

The canonical inclusion from ZZ to a fixed modulus ring.

EXAMPLES:

sage: f = ZpFM(5).coerce_map_from(ZZ); f
Ring Coercion morphism:
  From: Integer Ring
  To:   5-adic Ring of fixed modulus 5^20
section()

Returns a map back to ZZ that approximates an element of this \(p\)-adic ring by an integer.

EXAMPLES:

sage: f = ZpFM(5).coerce_map_from(ZZ).section()
sage: f(ZpFM(5)(-1)) - 5^20
-1
class sage.rings.padics.padic_fixed_mod_element.pAdicConvert_FM_ZZ

Bases: sage.rings.morphism.RingMap

The map from a fixed modulus ring back to ZZ that returns the the smallest non-negative integer approximation to its input which is accurate up to the precision.

If the input is not in the closure of the image of ZZ, raises a ValueError.

EXAMPLES:

sage: f = ZpFM(5).coerce_map_from(ZZ).section(); f
Set-theoretic ring morphism:
  From: 5-adic Ring of fixed modulus 5^20
  To:   Integer Ring
class sage.rings.padics.padic_fixed_mod_element.pAdicConvert_QQ_FM

Bases: sage.categories.morphism.Morphism

The inclusion map from QQ to a fixed modulus ring that is defined on all elements with non-negative p-adic valuation.

EXAMPLES:

sage: f = ZpFM(5).convert_map_from(QQ); f
Generic morphism:
  From: Rational Field
  To:   5-adic Ring of fixed modulus 5^20
class sage.rings.padics.padic_fixed_mod_element.pAdicFixedModElement

Bases: sage.rings.padics.padic_fixed_mod_element.FMElement

INPUT:

  • parent – a pAdicRingFixedMod object.
  • x – input data to be converted into the parent.
  • absprec – ignored; for compatibility with other \(p\)-adic rings
  • relprec – ignored; for compatibility with other \(p\)-adic rings

Note

The following types are currently supported for x:

  • Integers
  • Rationals – denominator must be relatively prime to \(p\)
  • FixedMod \(p\)-adics
  • Elements of IntegerModRing(p^k) for k less than or equal to the modulus

The following types should be supported eventually:

  • Finite precision \(p\)-adics
  • Lazy \(p\)-adics
  • Elements of local extensions of THIS \(p\)-adic ring that actually lie in \(\ZZ_p\)

EXAMPLES:

sage: R = Zp(5, 20, 'fixed-mod', 'terse')

Construct from integers:

sage: R(3)
3 + O(5^20)
sage: R(75)
75 + O(5^20)
sage: R(0)
0 + O(5^20)

sage: R(-1)
95367431640624 + O(5^20)
sage: R(-5)
95367431640620 + O(5^20)

Construct from rationals:

sage: R(1/2)
47683715820313 + O(5^20)
sage: R(-7875/874)
9493096742250 + O(5^20)
sage: R(15/425)
Traceback (most recent call last):
...
ValueError: p divides denominator

Construct from IntegerMod:

sage: R(Integers(125)(3))
3 + O(5^20)
sage: R(Integers(5)(3))
3 + O(5^20)
sage: R(Integers(5^30)(3))
3 + O(5^20)
sage: R(Integers(5^30)(1+5^23))
1 + O(5^20)
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^20)

Todo

doctests for converting from other types of \(p\)-adic rings

lift()

Return an integer congruent to self modulo the precision.

Warning

Since fixed modulus elements don’t track their precision, the result may not be correct modulo \(i^{\mathrm{prec_cap}}\) if the element was defined by constructions that lost precision.

EXAMPLES:

sage: R = Zp(7,4,'fixed-mod'); a = R(8); a.lift()
8
sage: type(a.lift())
<type 'sage.rings.integer.Integer'>
multiplicative_order()

Return the minimum possible multiplicative order of self.

OUTPUT:

an integer – the multiplicative order of this element. This is the minimum multiplicative order of all elements of \(\ZZ_p\) lifting this element to infinite precision.

EXAMPLES:

sage: R = ZpFM(7, 6)
sage: R(1/3)
5 + 4*7 + 4*7^2 + 4*7^3 + 4*7^4 + 4*7^5 + O(7^6)
sage: R(1/3).multiplicative_order()
+Infinity
sage: R(7).multiplicative_order()
+Infinity
sage: R(1).multiplicative_order()
1
sage: R(-1).multiplicative_order()
2
sage: R.teichmuller(3).multiplicative_order()
6
residue(absprec=1)

Reduce self mod \(p^{\mathrm{absprec}}\).

INPUT:

  • absprec – an integer (default: 1)

OUTPUT:

element of Z/(p^prec Z)self reduced mod p^prec

EXAMPLES:

sage: R = Zp(7,4,'fixed-mod'); a = R(8); a.residue(1)
1
class sage.rings.padics.padic_fixed_mod_element.pAdicTemplateElement

Bases: sage.rings.padics.padic_generic_element.pAdicGenericElement

A class for common functionality among the \(p\)-adic template classes.

INPUT:

  • parent – a local ring or field
  • x – data defining this element. Various types are supported, including ints, Integers, Rationals, PARI p-adics, integers mod \(p^k\) and other Sage p-adics.
  • absprec – a cap on the absolute precision of this element
  • relprec – a cap on the relative precision of this element

EXAMPLES:

sage: Zp(17)(17^3, 8, 4)
17^3 + O(17^7)
lift_to_precision(absprec=None)

Returns another element of the same parent with absolute precision at least absprec, congruent to this \(p\)-adic element modulo the precision of this element.

INPUT:

  • absprec – an integer or None (default: None), the absolute precision of the result. If None, lifts to the maximum precision allowed.

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)
padded_list(n, lift_mode='simple')

Returns a list of coefficients of the uniformizer \(\pi\) starting with \(\pi^0\) up to \(\pi^n\) exclusive (padded with zeros if needed).

For a field element of valuation \(v\), starts at \(\pi^v\) instead.

INPUT:

  • n - an integer
  • lift_mode - ‘simple’, ‘smallest’ or ‘teichmuller’

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]
unit_part()

Returns the unit part of this element.

This is the \(p\)-adic element \(u\) in the same ring so that this element is \(\pi^v u\), where \(\pi\) is a uniformizer and \(v\) is the valuation of this element.

sage.rings.padics.padic_fixed_mod_element.unpickle_fme_v2(cls, parent, value)

Unpickles a capped relative element.

EXAMPLES:

sage: from sage.rings.padics.padic_fixed_mod_element import pAdicFixedModElement, unpickle_fme_v2
sage: R = ZpFM(5)
sage: a = unpickle_fme_v2(pAdicFixedModElement, R, 17*25); a
2*5^2 + 3*5^3 + O(5^20)
sage: a.parent() is R
True

Previous topic

\(p\)-Adic Capped Absolute Elements

Next topic

p-Adic Extension Element

This Page