In this chapter p is always a (fixed) prime integer.

The p-adic numbers Q_p are the completion of the rational numbers with respect to the valuation ν_p( p^v ⋅ a / b) = v if p divides neither a nor b. They form a field of characteristic 0 which nevertheless shows some behaviour of the finite field with p elements.

A p-adic numbers can be represented by a "p-adic expansion" which is similar to the decimal expansion used for the reals (but written from left to right). So for example if p = 2, the numbers 1, 2, 3, 4, 1/2, and 4/5 are represented as 1(2), 0.1(2), 1.1(2), 0.01(2), 10(2), and the infinite periodic expansion 0.010110011001100...(2). p-adic numbers can be approximated by ignoring higher powers of p, so for example with only 2 digits accuracy 4/5 would be approximated as 0.01(2). This is different from the decimal approximation of real numbers in that p-adic approximation is a ring homomorphism on the subrings of p-adic numbers whose valuation is bounded from below so that rounding errors do not increase with repeated calculations.

In GAP, p-adic numbers are always represented by such approximations. A family of approximated p-adic numbers consists of p-adic numbers with a fixed prime p and a certain precision, and arithmetic with these numbers is done with this precision.

 ‣ PurePadicNumberFamily( p, precision ) ( function )

returns the family of pure p-adic numbers over the prime p with precision "digits". That is to say, the approximate value will differ from the correct value by a multiple of p^digits.

 ‣ PadicNumber( fam, rat ) ( operation )

returns the element of the p-adic number family fam that approximates the rational number rat.

p-adic numbers allow the usual operations for fields.

gap> fam:=PurePadicNumberFamily(2,20);;
0.010110011001100110011(2)
0.0101(2)
gap> 3*a;
0.0111(2)
gap> a/2;
0.101(2)
gap> a*10;
0.001(2)


See PadicNumber (68.2-2) for other methods for PadicNumber.

##### 68.1-3 Valuation
 ‣ Valuation( obj ) ( operation )

The valuation is the p-part of the p-adic number. See also PValuation (15.7-1).

 ‣ ShiftedPadicNumber( padic, int ) ( operation )

ShiftedPadicNumber takes a p-adic number padic and an integer shift and returns the p-adic number c, that is padic * p^shift.

 ‣ IsPurePadicNumber( obj ) ( category )

The category of pure p-adic numbers.

 ‣ IsPurePadicNumberFamily( fam ) ( category )

The family of pure p-adic numbers.

#### 68.2 Extensions of the p-adic Numbers

The usual Kronecker construction with an irreducible polynomial can be used to construct extensions of the p-adic numbers. Let L be such an extension. Then there is a subfield K < L such that K is an unramified extension of the p-adic numbers and L/K is purely ramified.

(For an explanation of "ramification" see for example [Neu92, Section II.7], or another book on algebraic number theory. Essentially, an extension L of the p-adic numbers generated by a rational polynomial f is unramified if f remains squarefree modulo p and is completely ramified if modulo p the polynomial f is a power of a linear factor while remaining irreducible over the p-adic numbers.)

The representation of extensions of p-adic numbers in GAP uses the subfield K.

 ‣ PadicExtensionNumberFamily( p, precision, unram, ram ) ( function )

An extended p-adic field L is given by two polynomials h and g with coefficient lists unram (for the unramified part) and ram (for the ramified part). Then L is isomorphic to Q_p[x,y]/(h(x),g(y)).

This function takes the prime number p and the two coefficient lists unram and ram for the two polynomials. The polynomial given by the coefficients in unram must be a cyclotomic polynomial and the polynomial given by ram must be either an Eisenstein polynomial or 1+x. This is not checked by GAP.

Every number in L is represented as a coefficient list w. r. t. the basis { 1, x, x^2, ..., y, xy, x^2 y, ... } of L. The integer precision is the number of "digits" that all the coefficients have.

A general comment:

The polynomials with which PadicExtensionNumberFamily is called define an extension of Q_p. It must be ensured that both polynomials are really irreducible over Q_p! For example x^2+x+1 is not irreducible over Q_p. Therefore the "extension" PadicExtensionNumberFamily(3, 4, [1,1,1], [1,1]) contains non-invertible "pseudo-p-adic numbers". Conversely, if an "extension" contains noninvertible elements then one of the defining polynomials was not irreducible.

 ‣ PadicNumber( fam, rat ) ( operation )
 ‣ PadicNumber( purefam, list ) ( operation )
 ‣ PadicNumber( extfam, list ) ( operation )

(see also PadicNumber (68.1-2)).

PadicNumber creates a p-adic number in the p-adic numbers family fam. The first form returns the p-adic number corresponding to the rational rat.

The second form takes a pure p-adic numbers family purefam and a list list of length two, and returns the number p^list[1] * list[2]. It must be guaranteed that no entry of list[2] is divisible by the prime p. (Otherwise precision will get lost.)

The third form creates a number in the family extfam of a p-adic extension. The second argument must be a list list of length two such that list[2] is the list of coefficients w.r.t. the basis { 1, ..., x^{f-1} ⋅ y^{e-1} } of the extended p-adic field and list[1] is a common p-part of all these coefficients.

gap> efam:=PadicExtensionNumberFamily(3, 5, [1,1,1], [1,1]);;


A word of warning:

Depending on the actual representation of quotients, precision may seem to "vanish". For example in PadicExtensionNumberFamily(3, 5, [1,1,1], [1,1]) the number (1.2000, 0.1210)(3) can be represented as [ 0, [ 1.2000, 0.1210 ] ] or as [ -1, [ 12.000, 1.2100 ] ] (here the coefficients have to be multiplied by p^{-1}).

So there may be a number (1.2, 2.2)(3) which seems to have only two digits of precision instead of the declared 5. But internally the number is stored as [ -3, [ 0.0012, 0.0022 ] ] and so has in fact maximum precision.

 ‣ IsPadicExtensionNumber( obj ) ( category )

The category of elements of the extended p-adic field.

gap>  efam:=PadicExtensionNumberFamily(3, 5, [1,1,1], [1,1]);;
true


 ‣ IsPadicExtensionNumberFamily( fam ) ( category )
gap> efam:=PadicExtensionNumberFamily(3, 5, [1,1,1], [1,1]);;