p-adic ring and field elements are implemented using a balanced mod representation. This allows negative elements to have infinite precision in an infinite precision ring and, if x is a small negative integer, allows it to be represented as x rather than p^m - - x where m is a precision.
Infinite precision elements are implemented using exact quotients. They are stored as numerator (may have valuation) and denominator (must have valuation zero). This means that two infinite precision elements can be divided and the result will still have infinite precision.
To simplify the creation of elements in a p-adic ring, various coercions are provided. The most obvious is to regard the integer ring or rational field as embedded into the p-adic ring or field. But there is a range of coercions available, including that of elements from the residue class field.
To create an element of a p-adic field not lying in the p-adic ring, constructors are provided that create an element of the ring and allow multiplication of this by the appropriate power of the prime.
For descriptions not given please refer to Section Constructions.
Given an element u, coerce it into the p-adic ring or field P. The resulting element will have as much precision as it can. The element u is allowed to be one of the followingThe elt-constructor is the (left) inverse (for ring elements) to the sequence constructor Eltseq described below.
- an integer;
- an element of Z / p^mZ; (where m is a precision)
- an element of GF(p);
- an element of a local ring or field with something in common with P. Note that coercing from a local field to p-adic field may result in precision loss to the order of the valuation of the element.
- a rational number. If P is a ring then u must not have valuation in the denominator.
- an element of a valuation ring over the rationals with prime the same as P.
- a sequence s of integers. The sequence s is interpreted as the p-adic expansion of an element in L. The elements of the sequence must have absolute value less than p. The element sum_(i=1)^(#s) s[i] * p^(i - 1) is returned.
Create an element of the p-adic ring or field P by coercing u into P and returning with it precision r. The list of possibilities for u above apply here.
Create an element of the p-adic ring or field P by coercing u into P and multiplying by the v-th power of the uniformizing element. This is equivalent to P.1^v * elt< P | u >. If u is an integer this will be taken to be the elt<P | u, r> constructor.
Create an element of the p-adic ring or field P by coercing u into P, multiplying by the v-th power of the uniformizing element and returning it with precision r. This is equivalent to elt<P | elt<P | v, u>, r>.
For an element x of valuation v, create an element of valuation v and relative precision 0. For rings this is the zero element in the quotient P / (P.1^v).
> Qp<q> := pAdicField(3); > elt<Qp | 64>; 64 > elt<Qp | -3, 64, 10>; 64*q^-3 + O(q^7) > elt<Qp | 2, 3/4, 8>; -1640*q^3 + O(q^11) > elt<Qp | 2, 3/4>; q^3/4 > 4*$1; q^3 > Precision($1); Infinity > BigO(Qp!139856304^4); O(q^4) > Precision($1); 0 > O(Qp!0); 0 > O(Qp!1); O(1) > Valuation($2); Infinity
The two functions in this section differ in the universe of the sequence and the remembrance of denominators. For an element of a p-adic field, the valuation needs to be remembered to allow it to be reconstructed from the sequence with the elt-constructor described in the previous section.
The returned sequence s is the p-adic expansion of x, i.e. such that x = sum_(i=1)^(#s) s[i] * p^(i - 1 + v) where v is the valuation of a p-adic field element and zero for a ring element. The entries of s are integers in the range [ - Floor((p - 1)/2) ... Ceiling((p - 1)/2) ]. The denominator of x is discarded.This is the (right) inverse (for ring elements) to the !-operator, i.e., P ! Eltseq(x) = x.
Returns a sequence of p-adic elements x_i identical to their coercion into the residue class field such that x = sum_(i = 1) x_i * p^(i - 1 + v) where v is the valuation of a p-adic field element and zero for a ring element. These are the coefficients seen when SeriesPrinting is true for the parent of x. This sequence cannot be coerced back into the p-adic ring or field. Coefficients remembers the denominator of x.
Returns the coefficient of the ith power of the prime. This coefficient will be the i + 1 - vth entry in the sequence returned by Coefficients where v is the valuation of x if x is a field element and zero if x is a ring element. The denominator of x is remembered.
> Zp<p> := pAdicRing(5); > Qp<q> := pAdicField(3); > y := Expand(Zp!Random(ChangePrecision(Zp, 50))); > y; 12579395098865826384604888452169139 > x := elt<FieldOfFractions(Zp) | -3, y, 40>; > x; 1074651119069636779321309764*5^-3 + O(5^37) > Precision(Zp); Infinity > Zp![0, 3, 3, 1, 2, 0, 3, 4, 1, 2, 4]; 43720215 > elt<Qp | 5, [0, 2, 1, 2, 1, 0, 2]>; 536*q^6 > Coefficients($1); [ -1, -1, 0, -1, 1, -1, 1 ] > Coefficient(y, 4); 1 > Coefficients(y); [ -1, -2, 1, -2, 1, -1, -1, -2, -2, -2, -2, 1, -2, 0, 0, -2, 2, -1, 1, -2, 1, -1, 2, 1, -1, 0, -2, 2, 1, -1, -2, 0, 1, 1, 1, -1, -1, 0, -2, 1, -1, -1, 0, 0, -2, -2, -1, -2, -1, 1 ] > Eltseq(y); [ -1, -2, 1, -2, 1, -1, -1, -2, -2, -2, -2, 1, -2, 0, 0, -2, 2, -1, 1, -2, 1, -1, 2, 1, -1, 0, -2, 2, 1, -1, -2, 0, 1, 1, 1, -1, -1, 0, -2, 1, -1, -1, 0, 0, -2, -2, -1, -2, -1, 1 ] > Universe($2); 5-adic Ring > Universe($2); Integer Ring > Coefficients(y)[4 + 1 - Valuation(y)]; 1