For descriptions not given please refer to Section Operations on Elements.
For p-adic ring elements the usual operations for ring elements 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 v_1 + pr_2 and v_2 + pr_1, where v_i and pr_i are the valuations and precisions of the two elements, respectively.
For p-adic 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 v_x and v_y and precisions pr_x and pr_y the precision of x +- y is min(v_x + pr_x, v_y + pr_y) - val(x +- y), which may even be 0.
The result of these operations on two infinite precision elements will be an element with infinite precision.
> Zp<p> := pAdicRing(2, 20); > c := Random(Zp); > c := c/p^Valuation(c); > 1 / c; > 1/c; 500047 > c*1/c; 1 + O(p^18)In an infinite precision ring quotients appear a little differently.
> 1 / (p*c); >> 1 / (p*c); ^ Runtime error in '/': Division is not exact > p / (p*c); -24241 + O(p^19)
> Zp<p> := pAdicRing(2); > c := Expand(Zp!c); > c; -76369 > 1/c; -1/76369
It is possible to test whether two p-adic ring or field elements are equal and whether any element is in a p-adic ring or field. The existence of elements with reduced precision may cause results which are not completely intuitive at first sight.
Two elements of a p-adic ring or field are only regarded as equal, if their valuations, precisions and digits are identical. Thus, elements of reduced precision which coincide in all known digits can still be regarded as the same, even though the missing digits are unknown rather than 0.
> 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 command demonstrates the convergence of the process. The polynomial defining the unramified extension could now be obtained as the minimal polynomial of the fixed element.
p-adic ring and field elements can be tested for certain properties. There is only one zero, one and minus one in each ring or field.
The parent of a p-adic element can be retrieved, its precision accessed and changed, its valuation computed and its denominator returned. Elements of reduced precision can be turned into elements with full precision by replacing unknowns with zeros in the p-adic expansion.
> Qp<q> := pAdicField(11); > x := q + q^7; > x; 1771562*q > AbsolutePrecision(x); Infinity > RelativePrecision(x); Infinity > AbsolutePrecision(x + O(q^10)); 10 > RelativePrecision(x + O(q^10)); 9 > Expand(x + O(q^5)) eq x; false > Expand(x + O(q^5)); q > x; 1771562*q > Valuation(x); 1 > Denominator(x); 1 > Denominator(x/9); 9 > Denominator(x/99); 9 > Valuation(x/99); 0 > ChangePrecision(x, 20) eq (x + O(q^(20 + Valuation(x)))); trueThe 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.
Logarithms and exponentials can also be calculated for certain elements.
The logarithm of the element 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 0.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.
If the precision of x is infinite then the result is returned to the default precision of the ring or field.
The exponential of the p-adic element x. Note that the power series of the exponential function only converges if the valuation of x is strictly larger than 1/(p - 1).If the precision of x is infinite then the result is returned to the default precision of the ring or field.
> Qp<q> := pAdicField(13); > Zp<p> := Integers(Qp); > x := 1 + p; > time Log(x); 1499288193969767389565 + O(p^20) Time: 0.050 > x := 1 + p^5; > time Log(x); 3167511024375542395421 + O(p^20) Time: 0.010 > x := 1 + q; > time Log(x); 115329861074597491505*q + O(q^20) Time: 0.049 > x := 1 + q^6; > time Log(x); 663995423577305*q^6 + O(q^20) Time: 0.010 > x := p^2; > time Exp(x); 7844051926694268462087 + O(p^20) Time: 0.010 > x := p^10; > time Exp(x); 137858491850 + O(p^20) Time: 0.000 > x := q; > time Exp(x); 2019541981652074319142 + O(q^20) Time: 0.010 > x := q^20; > time Exp(x); 1 + O(q^20) Time: 0.000 > Qp`DefaultPrecision := 50; > time Exp(x); -24896461148775759576814825044801829714416151043291269522 + O(q^50) Time: 0.000