Operations on Elements

Contents

Arithmetic

For local ring elements the usual operations are available. The quotient of two elements can be computed when the result lies in the ring (i.e. the valuation of the dividend is not smaller than that of the divisor). The precision of the result is reduced by the valuation of the divisor. The result of an operation with elements of reduced precision will have as much precision as possible. For addition and subtraction this is the minimum of the precisions of the two elements. For multiplication it is the minimum of v1 + k2 and v2 + k1, where vi and ki are the valuations and precisions of the two elements, respectively.

For local field elements the operations are performed with the maximum precision possible. For multiplication and division this is the minimum of the (relative) precisions of the two elements. For addition and subtraction of elements x and y with valuations vx and vy and precisions kx and ky the precision of x ∓ y is min(vx + kx, vy + ky) - vp(x ∓ y), which may even be 0.

- x : RngPadElt -> RngPadElt
- x : RngPadResElt -> RngPadResElt
- x : RngPadResExtElt -> RngPadResExtElt
- x : FldPadElt -> FldPadElt
The negative of the element x.
x + y : RngPadElt, RngPadElt -> RngPadElt
x + y : RngPadResElt, RngPadResElt -> RngPadResElt
x + y : RngPadResExtElt, RngPadResExtElt -> RngPadResExtElt
x + y : FldPadElt, FldPadElt -> FldPadElt
The sum of the elements x and y.
x - y : RngPadElt, RngPadElt -> RngPadElt
x - y : RngPadResElt, RngPadResElt -> RngPadResElt
x - y : RngPadResExtElt, RngPadResExtElt -> RngPadResExtElt
x - y : FldPadElt, FldPadElt -> FldPadElt
The difference of the elements x and y.
x * y : RngPadElt, RngPadElt -> RngPadElt
x * y : RngPadResElt, RngPadResElt -> RngPadResElt
x * y : RngPadResExtElt, RngPadResExtElt -> RngPadResExtElt
x * y : FldPadElt, FldPadElt -> FldPadElt
The product of the elements x and y.
x ^ k : RngPadElt, RngIntElt -> RngPadElt
x ^ k : RngPadResElt, RngIntElt -> RngPadResElt
x ^ k : RngPadResExtElt, RngIntElt -> RngPadResExtElt
x ^ k : FldPadElt, RngIntElt -> FldPadElt
The k-th power of the element x. If k has valuation (when coerced) and x has precision less than that of its parent ring, the power xk will have more precision than x.
x div y : RngPadElt, RngPadElt -> RngPadElt
x div y : RngPadResElt, RngPadResElt -> RngPadResElt
x div y : RngPadResExtElt, RngPadResExtElt -> RngPadResExtElt
x div y : FldPadElt, FldPadElt -> FldPadElt
The quotient of the elements x and y. For elements of a local ring, this results in an error if the valuation of x is smaller than that of y.
x div:= y : RngPadElt, RngPadElt -> RngPadElt
x div:= y : RngPadResElt, RngPadResElt -> RngPadResElt
x div:= y : RngPadElt, RngPadElt -> RngPadElt
x div:= y : FldPadElt, FldPadElt -> FldPadElt
Mutation operation: replace the element x by its quotient upon division by y. For elements of a local ring, this results in an error if the valuation of x is smaller than that of y.
x / y : RngPadElt, RngPadElt -> RngPadElt
x / y : FldPadElt, FldPadElt -> FldPadElt
The quotient of the elements x and y. For elements of a local ring, the result will be returned in its field of fractions.
IsExactlyDivisible(x, y) : RngPadElt, RngPadElt -> BoolElt, RngPadElt
IsExactlyDivisible(x, y) : RngPadResElt, RngPadResElt -> BoolElt, RngPadResElt
IsExactlyDivisible(x, y) : RngPadResExtElt, RngPadResExtElt -> BoolElt, RngPadResExtElt
IsExactlyDivisible(x, y) : FldPadElt, FldPadElt -> BoolElt, FldPadElt
Return true if x can be exactly divided by y; in this case also return the quotient.

Example RngLoc_Division (H48E12)

Division of non-units in the ring will yield a result in the field of fractions. In that case the result has reduced precision. To ensure that the result is returned as a ring element, the operator div should be used.
> R := pAdicRing(2);
> pi := UniformizingElement(R);
> pi;
2 + O(2^20)
> 1 / pi;
2^-1 + O(2^18)
> Parent($1);
2-adic field
> 1 div pi;
>> 1 div pi;
     ^
Runtime error in 'div': Division is not exact
> IsExactlyDivisible(1, pi);
false
> IsExactlyDivisible(pi^2, pi);
true 2 + O(2^20)

Equality and Membership

It is possible to test whether two local ring or field elements are equal only in quotient rings. Equality testing in free precision rings is disabled, as there are several reasonable definitions of equality in an imprecise ring.

x eq y : RngPadResElt, RngPadResElt -> BoolElt
x eq y : RngPadResExtElt, RngPadResExtElt -> BoolElt
Given local ring or field elements x and y, return true if and only if x and y are identical in value. This operator is only defined in fixed precision rings.
x ne y : RngPadResElt, RngPadResElt -> BoolElt
x ne y : RngPadResExtElt, RngPadResExtElt -> BoolElt
Given local ring or field elements x and y, return true if and only if x and y are not identical in value. This operator is only defined in fixed precision rings.
x in L : ., RngPad -> BoolElt
x in L : ., FldPad -> BoolElt
Return true if and only if x lies in the local ring or field L.
x notin L : ., RngPad -> BoolElt
x notin L : ., FldPad -> BoolElt
Return true if and only if x does not lie in the local ring or field L.

Example RngLoc_unram-ext (H48E13)

We demonstrate how an unramified extension can be constructed from a given degree. The idea is to interpret the minimal polynomial of a primitive element in the residue class field as a polynomial over Zp. The quotient of Zp[x] by the ideal generated by this polynomial is isomorphic to the unramified extension and a := /line(x) is a first approximation for the pf - 1-th root of unity. This is improved by iterating a |-> apf until this remains fixed.
> p := 2;
> f := 5;
> Zp := pAdicRing(p, 25);
> R<x> := PolynomialRing(Zp);
> g := R ! MinimalPolynomial(GF(p,f).1);
> Q<r> := quo<R | g>;
> a := [ r, r^(p^f) ];
> while a[#a] ne a[#a-1] do
>     print a[#a];
>     Append(~a, a[#a]^(p^f));
> end while;
34*r^4 - 44*r^3 + 58*r^2 - 23*r + 36
12522914*r^4 + 12522004*r^3 - 12174790*r^2 - 8200343*r - 10407260
8242594*r^4 + 12409364*r^3 + 5143098*r^2 + 15781737*r - 3636572
5490082*r^4 + 8804884*r^3 - 11109830*r^2 + 11456361*r + 11698852
-15481438*r^4 - 5875180*r^3 + 5667386*r^2 + 7262057*r - 884060
> [ Minimum([ Valuation(c) : c in Eltseq(a[i] - a[i-1]) ]) : i in [2..#a-1] ];
[ 1, 6, 11, 16, 21 ]
The last statement demonstrates the convergence of the process. The polynomial defining the unramified extension could now easily be obtained as the minimal polynomial of the fixed element.
> U := ext<Zp | f>;
> MinimalPolynomial(U ! Eltseq(a[#a]));
x^5 - 13205240*x^4 - 3159900*x^3 - 13778593*x^2 + 9730498*x - 1

Properties

Local ring and field elements can be tested for certain properties. However, note that in free precision rings and fields, exact zero, one, and minus one elements do not exist, only approximations to such elements --- in these cases, the predicates will always return false.

IsZero(x) : RngPadElt -> BoolElt
IsZero(x) : RngPadResElt -> BoolElt
IsZero(x) : RngPadResExtElt -> BoolElt
IsZero(x) : FldPadElt -> BoolElt
Given an element x of a local ring or field, return true if and only if x is the zero element of its parent ring or field.
IsOne(x) : RngPadElt -> BoolElt
IsOne(x) : RngPadResElt -> BoolElt
IsOne(x) : RngPadResExtElt -> BoolElt
IsOne(x) : FldPadElt -> BoolElt
Given an element x of a local ring or field, return true if and only if x is the one element of its parent ring or field.

Note that this is always false for an element of a ring or field of unbounded precision.

IsMinusOne(x) : RngPadElt -> BoolElt
IsMinusOne(x) : RngPadResElt -> BoolElt
IsMinusOne(x) : RngPadResExtElt -> BoolElt
IsMinusOne(x) : FldPadElt -> BoolElt
Given an element x of a local ring or field, return true if and only if x is the minus one element of its parent ring or field.

Note that this is always false for an element of a ring or field of unbounded precision.

IsUnit(x) : RngPadElt -> BoolElt
IsUnit(x) : RngPadResElt -> BoolElt
IsUnit(x) : RngPadResExtElt -> BoolElt
IsUnit(x) : FldPadElt -> BoolElt
Given an element x of a local ring or field, return true if and only if x is a unit, that is, x has valuation 0.
IsIntegral(x) : RngPadElt -> BoolElt
IsIntegral(x) : RngPadResElt -> BoolElt
IsIntegral(x) : RngPadResExtElt -> BoolElt
IsIntegral(x) : FldPadElt -> BoolElt
Given an element x of a local ring or field, return true if and only if x has non-negative valuation.

Precision and Valuation

Note that the precision of an element may be modified.

Parent(x) : RngPadElt -> RngPad
Parent(x) : RngPadResElt -> RngPadRes
Parent(x) : RngPadResExtElt -> RngPadResExt
Parent(x) : FldPadElt -> FldPad
Return the parent local ring or field of the element x.
Precision(x) : RngPadElt -> RngIntElt
Precision(x) : RngPadResElt -> RngIntElt
Precision(x) : RngPadResExtElt -> RngIntElt
Precision(x) : FldPadElt -> RngIntElt
For a local ring element x, returns the precision to which it is known; for a local field element x, returns the precision to which its unit part is known.
AbsolutePrecision(x) : RngPadElt -> RngIntElt
AbsolutePrecision(x) : RngPadResElt -> RngIntElt
AbsolutePrecision(x) : RngPadResExtElt -> RngIntElt
AbsolutePrecision(x) : FldPadElt -> RngIntElt
Returns the precision of a local ring or field element x.
RelativePrecision(x) : RngPadElt -> RngIntElt
RelativePrecision(x) : RngPadResElt -> RngIntElt
RelativePrecision(x) : RngPadResExtElt -> RngIntElt
RelativePrecision(x) : FldPadElt -> RngIntElt
Returns the difference between the absolute precision and the valuation of the local ring or field element x.
ChangePrecision(x, k) : RngUPolElt, RngIntElt -> RngPadElt
ChangePrecision(~x, k) : RngUPolElt, RngIntElt -> RngPadElt
ChangePrecision(x, k) : RngPadElt, RngIntElt -> RngPadElt
ChangePrecision(~x, k) : RngPadElt, RngIntElt -> RngPadElt
ChangePrecision(x, k) : FldPadElt, RngIntElt -> FldPadElt
ChangePrecision(~x, k) : FldPadElt, RngIntElt -> FldPadElt
Given a local ring or field element or polynomial over a local ring or field x and a non-negative single precision integer k, change the precision of x to k. If k is smaller than the precision of x, x is truncated; if k is larger, then an element y is returned such that v(x - y) ≥k. Note that the precision of an element cannot be changed to be greater than its parent. Any attempt to do so will result in the element gaining the precision of its parent.
Expand(x) : RngPadElt -> RngPadElt
Expand(x) : FldPadElt -> FldPadElt
Change the precision of the local ring or field element x to be the maximum precision allowed by its parent. This results in an error if x is an element of an unbounded free precision ring.
Valuation(x) : RngPadElt -> RngIntElt
Valuation(x) : RngPadResElt -> RngIntElt
Valuation(x) : RngPadResExtElt -> RngIntElt
Valuation(x) : FldPadElt -> RngIntElt
Return the valuation of the local ring or field element x. This is always bounded by the absolute precision of the element.

Example RngLoc_ofe (H48E14)

The uses and properties of relative and absolute precision for field elements are illustrated here, as well as the results of Expand.
> R<x> := PolynomialRing(Integers());
> K<d> := ext<ext<pAdicField(5, 100) | 2> |  x^2 + 5>;
> x := d + d^7;
> x;
-d*124 + O(d^200)
> AbsolutePrecision(x);
200
> RelativePrecision(x);
199
> RelativePrecision(x + O(d^10));
9
> AbsolutePrecision(x + O(d^10));
10
> RelativePrecision(ChangePrecision(x, 19));
19
> RelativePrecision(ChangePrecision(x, 10));
10
> AbsolutePrecision(ChangePrecision(x, 10));
11
> Expand(ChangePrecision(x, 10));
d*3001 + O(d^201)
> Valuation(x);
1
> ChangePrecision(x, 20) - (x + O(d^21));
O(d^21)
The last two lines show that changing the precision of an element is equivalent to adding imprecision to the element effectively cancelling off all terms beyond that of relative valuation 20.

Example RngLoc_padic-precision-woes (H48E15)

As indicated above, IsOne for elements of an unbounded precision ring/field will always be false.
> IsOne(pAdicField(7)!1);
false
> IsMinusOne(pAdicField(7)!-1);
false
> IsZero(pAdicField(7)!0);
true

Logarithms and Exponentials

Log(x) : RngPadElt -> RngPadElt
Log(x) : RngPadResElt -> RngPadResElt
Log(x) : RngPadResExtElt -> RngPadResExtElt
Log(x) : FldPadElt -> FldPadElt
The logarithm of the local ring or field element x, returned to the precision of x. Note that the power series of the logarithm function only converges if the valuation of x - 1 is positive. For ring elements x, the answer lies in the ring (and not its field of fractions) only if the valuation of x - 1 is greater than or equal to the ramification degree of the ring divided by the prime.

The rate of convergence of Log is dependent on the valuation of x - 1. The greater the valuation the faster the convergence, as is illustrated in the example below.

Exp(x) : RngPadElt -> RngPadElt
Exp(x) : RngPadResElt -> RngPadResElt
Exp(x) : RngPadResExtElt -> RngPadResExtElt
Exp(x) : FldPadElt -> FldPadElt
The exponential of the local ring or field element x, returned to the precision of x. Note that the power series of the exponential function only converges if the valuation of x is strictly larger than e/(p - 1), where e is the ramification degree of the parent ring of x.

Example RngLoc_log (H48E16)

This example illustrates the relative timings of the Log function and the Exp function for rings and fields and for various valuations of x - 1 or x as appropriate.
> K := ext<pAdicField(3, 20) | x^3 + x^2 + x + 2>;
> K<d> := ext<K | x^3 + 3*x^2 + 3*x + 3>;
> L<b> := IntegerRing(K);
> x := 1 + b;
> time Log(x);
Time: 0.070
> x := 1 + b^5;
> time Log(x);
874050819*b^2 + 1624571442*b - 914550768
Time: 0.010
> RelativePrecision(Exp(Log(x)) - x);
0
> x := b^2;
> time Exp(x);
1418565628*b^2 + 1334033745*b + 905945461
Time: 0.170
> RelativePrecision(Log(Exp(x)) - x);
0
> x := b^6;
> time Exp(x);
1700312013*b^2 - 72781965*b + 1129064707
Time: 0.020
> RelativePrecision(Log(Exp(x)) - x);
0

Norm and Trace

Norm(x) : RngPadElt -> RngPadElt
Norm(x) : RngPadResElt -> RngPadResElt
Norm(x) : RngPadResExtElt -> RngElt
Norm(x) : FldPadElt -> FldPadElt
Given a local ring or field element x, return the norm of x over the base ring of its parent.
Norm(x, R) : RngPadElt, RngPad -> RngPadElt
Norm(x, R) : RngPadResElt, RngPadRes -> RngPadResElt
Norm(x, R) : RngPadResExtElt, Rng -> RngElt
Norm(x, R) : FldPadElt, FldPad -> FldPadElt
Given a local ring or field element x, return the norm of x over the local ring or field R. The ring R must be a subring of the parent of x.
Trace(x) : RngPadElt -> RngPadElt
Trace(x) : RngPadResElt -> RngPadResElt
Trace(x) : RngPadResExtElt -> RngElt
Trace(x) : FldPadElt -> FldPadElt
Given a local ring or field element x, return the trace of x over the base ring of its parent. The trace is the product of all conjugates of x.
Trace(x, R) : RngPadElt, RngPad -> RngPadElt
Trace(x, R) : RngPadResElt, RngPadRes -> RngPadResElt
Trace(x, R) : RngPadResExtElt, Rng -> RngElt
Trace(x, R) : FldPadElt, FldPad -> FldPadElt
Given a local ring or field element x, return the trace of x over the local ring or field R. The ring R must be a subring of the parent of x. The trace is the sum of all conjugates of x.
MinimalPolynomial(x) : RngPadElt -> RngUPolElt
MinimalPolynomial(x) : RngPadResElt -> RngUPolElt
MinimalPolynomial(x) : RngPadResExtElt -> RngUPolElt
MinimalPolynomial(x) : FldPadElt -> RngUPolElt
Given a local ring or field element x, return the minimal polynomial of x over the base ring of its parent.
MinimalPolynomial(x, R) : RngPadElt, RngPad -> RngUPolElt
MinimalPolynomial(x, R) : RngPadResElt, RngPadRes -> RngUPolElt
MinimalPolynomial(x, R) : RngPadResExtElt, Rng -> RngUPolElt
MinimalPolynomial(x, R) : FldPadElt, FldPad -> RngUPolElt
Given a local ring or field element x, return the minimal polynomial of x over the local ring or field R. The ring R must be a subring of the parent of x.

CharacteristicPolynomial(x) : RngPadElt -> RngUPolElt
CharacteristicPolynomial(x) : RngPadResElt -> RngUPolElt
CharacteristicPolynomial(x) : RngPadResExtElt -> RngUPolElt
Given a local ring element x, return the characteristic polynomial of x over the base ring of its parent.
CharacteristicPolynomial(x, R) : RngPadElt, RngPad -> RngUPolElt
CharacteristicPolynomial(x, R) : RngPadResElt, RngPadRes -> RngUPolElt
CharacteristicPolynomial(x, R) : RngPadResExtElt, RngPadRes -> RngUPolElt
CharacteristicPolynomial(x, R) : RngPadResExtElt, RngPadResExt -> RngUPolElt
Given a local ring or field element x, return the characteristic polynomial of x over the local ring or field R. The ring R must be a subring of the parent of x.

GaloisImage(x, i) : RngPadElt, RngIntElt -> RngPadElt
GaloisImage(x, i) : RngPadResElt, RngIntElt -> RngPadResElt
GaloisImage(x, i) : RngPadResExtElt, RngIntElt -> RngPadResExtElt
GaloisImage(x, i) : FldPadElt, RngIntElt -> FldPadElt
Given a local ring or field element x, return the image of x under the Frobenius automorphism composed with itself i times, that is, a |-> a(pi) where a is a pf - 1st root of unity of the parent of x.

Example RngLoc_agm (H48E17)

One important application of the p-adics is to counting points on elliptic curves over finite fields. This example demonstrates how a simple version of the Arithmetic-Geometric Mean (AGM) algorithm could be implemented in Magma.
> d := 50;
> FF := GF(2^d);
> E := EllipticCurve([FF | 1, 0, 0, 0, Random(FF)]);
> assert Degree(sub<BaseRing(E) | jInvariant(E)>) gt 2;
>
> n := (d + 1) div 2 + 3;
> R := ext<pAdicRing(2) | d>;
> R`DefaultPrecision := n;
>
> a6 := elt<R | jInvariant(E)^-1, 1>;
> lambda := 1 + 8 * a6;
>
> for k in [4..n] do
>     ChangePrecision(~lambda, k + 2);
>     lambda := (1 + lambda) * InverseSqrt(lambda) div 2;
> end for;
> lambda := 2 * lambda div (1 + lambda);
> Exp(Trace(Log(lambda)));
32196193 + O(2^26)
> Trace(E) mod 2^26;
32196193
EuclideanNorm(x) : RngPadResElt -> RngIntElt
EuclideanNorm(x) : RngRadResExtElt -> RngIntElt
Return the euclidean norm of the element x of a fixed precision local ring.

Power Relation (Algebraic Dependency)

By taking small linear combinations of powers of a p-adic number, one can attempt to determine if it satisfies an algebraic relation.

PowerRelation(x,n) : FldPadElt, RngIntElt -> RngUPolElt
Given a p-adic number over Qp, return a degree n relation for its powers. If this has small coefficients compared to the precision, then the element is likely an approximation to an algebraic number satisfying the return polynomial.

Teichmüller Lifts

Another important operation is the determination of the canonical Teichmüller lift of an element u in the residue field of a p-adic ring. By definition this is the unique root of unity of order prime to p which reduces to u modulo the maximal ideal.

TeichmuellerLift(u, R) : FldFinElt, RngPadResExt -> RngPadResExtElt
TeichmuellerLift(u, R) : FldFinElt, RngPadRes -> RngPadResElt
For a fixed precision quotient ring R of the p-adics or an unramified extension and a finite field element u, the function attempts to coerce u into the residue class field of R and then computes and returns its Teichmüller lift to R. This uses a fast iterative lifting method of Harley described in Chapter 12 of [C+05]. For unramified extensions this works most efficiently with Cyclotomic or Gaussian Normal bases since it uses the Frobenius operation.

V2.28, 13 July 2023