prec – integer (default: 20) the precision cap of the field.
In the lattice capped case, prec can either be a
pair (relative_cap, absolute_cap) or an integer
(understood at relative cap).
Except in the floating point case, individual elements keep track of
their own precision. See TYPES and PRECISION below.

The second type of precision is absolute precision, which gives
the power of \(p\) that this element is defined modulo:

sage: a.precision_absolute()22

There are three types of \(p\)-adic fields: capped relative fields,
floating point fields and lattice precision fields.

In the capped relative case, the relative precision of an element
is restricted to be at most a certain value, specified at the
creation of the field. Individual elements also store their own
precision, so the effect of various arithmetic operations on
precision is tracked. When you cast an exact element into a
capped relative field, it truncates it to the precision cap of the
field.:

In the floating point case, elements do not track their
precision, but the relative precision of elements is truncated
during arithmetic to the precision cap of the field.

In the lattice case, precision on elements is tracked by a global
lattice that is updated after every operation, yielding better
precision behavior at the cost of higher memory and runtime usage.

PRINTING:

There are many different ways to print \(p\)-adic elements. The way
elements of a given field print is controlled by options passed in
at the creation of the field. There are five basic printing modes
(series, val-unit, terse, digits and bars), as well as various
options that either hide some information in the print
representation or sometimes make print representations more
compact. Note that the printing options affect whether different
\(p\)-adic fields are considered equal.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True) or ‘bigoh’.
The default is False for the 'floating-point' type
and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False) or ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' type
and True for all other types.

sage: Qp(5, print_mode=’val-unit’, show_prec=False)(30)
5 * 6

print_max_terms, print_sep and print_alphabet have no effect.

Equality again depends on the printing options:

sage: R==S,R==T,S==T(False, False, False)

terse: elements are displayed as an integer in base 10 or the
quotient of an integer by a power of \(p\) (still in base 10):

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False) or ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' type
and True for all other types.

sage: Qp(5, print_mode=’terse’, show_prec=False)(6)
6

print_max_terms, print_sep and print_alphabet have no effect.

Equality depends on printing options:

sage: R==S,R==T,S==T(False, False, False)

digits: elements are displayed as a string of base \(p\) digits

Restriction: you can only use the digits printing mode for
small primes. Namely, \(p\) must be less than the length of the
alphabet tuple (default alphabet has length 62).:

Observe that the significant 0’s are printed even if they are
located in front of the number. On the contrary, unknown digits
located after the comma appears as question marks.
The precision can therefore be read in this mode as well.
Here are more examples:

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘dots’
(or equivalently True) or ‘bigoh’.
The default is False for the 'floating-point' type
and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘dots’
(or equivalently True) or ‘bigoh’
The default is False for the 'floating-point' type
and True for all other types.

Given a prime power \(q = p^n\), return the unique unramified
extension of \(\QQ_p\) of degree \(n\).

INPUT:

q – integer, list, tuple or Factorization object. If q is an
integer, it is the prime power \(q\) in \(\QQ_q\). If q is a
Factorization object, it is the factorization of the prime power \(q\).
As a tuple it is the pair (p,n), and as a list it is a single
element list [(p,n)].

prec – integer (default: 20) the precision cap of the field.
Individual elements keep track of their own precision. See
TYPES and PRECISION below.

The second type of precision is absolute precision, which gives
the power of \(p\) that this element is defined modulo:

sage: b.precision_absolute()22

There are two types of unramified \(p\)-adic fields: capped relative
fields, floating point fields.

In the capped relative case, the relative precision of an element
is restricted to be at most a certain value, specified at the
creation of the field. Individual elements also store their own
precision, so the effect of various arithmetic operations on
precision is tracked. When you cast an exact element into a
capped relative field, it truncates it to the precision cap of the
field.:

There are many different ways to print \(p\)-adic elements. The way
elements of a given field print is controlled by options passed in
at the creation of the field. There are four basic printing modes
('series', 'val-unit', 'terse' and 'bars'; 'digits' is not available), as
well as various options that either hide some information in the
print representation or sometimes make print representations more
compact. Note that the printing options affect whether different
\(p\)-adic fields are considered equal.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' type
and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' type
and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' type
and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘dots’
(or equivalently True) or ‘bigoh’
The default is False for the 'floating-point' type
and True for all other types.

It is known for its numerical instability.
On the one hand, one can show that if the initial values are
invertible in \(\ZZ_p\) and known at precision \(O(p^N)\)
then all the next terms of the SOMOS sequence will be known
at the same precision as well.
On the other hand, because of the division, when we unroll
the recurrence, we loose a lot of precision. Observe:

The precision is global.
It is encoded by a lattice in a huge vector space whose dimension
is the number of elements having this parent. Precision is tracked
using automatic differentiation techniques (see [CRV2014] and
[CRV2018]).

Concretely, this precision datum is an instance of the class
sage.rings.padic.lattice_precision.PrecisionLattice.
It is attached to the parent and is created at the same time
as the parent.
(It is actually a bit more subtle because two different parents
may share the same instance; this happens for instance for a
\(p\)-adic ring and its field of fractions.)

The matrix we get is no longer diagonal, meaning that some digits
of precision are diffused among the two new elements \(x\) and \(y\).
They nevertheless show up when we compute for instance \(x+y\):

sage: x1516 + O(5^5)sage: y424 + O(5^5)sage: x+y17565 + O(5^11)

These diffused digits of precision (which are tracked but
do not appear on the printing) allow to be always sharp on
precision.

NOTE:

Each elementary operation requires significant manipulations
on the precision lattice and therefore is costly. Precisely:

The creation of a new element has a cost \(O(n)\) where \(n\)
is the number of tracked elements.

The destruction of one element has a cost \(O(m^2)\) where
\(m\) is the distance between the destroyed element and
the last one. Fortunately, it seems that \(m\) tends to
be small in general (the dynamics of the list of tracked
elements is rather close to that of a stack).

It is nevertheless still possible to manipulate several
hundred variables (e.g. square matrices of size 5 or
polynomials of degree 20).

The class PrecisionLattice provides several
features for introspection, especially concerning timings.
See history() and timings() for details.

A shortcut function to create \(p\)-adic rings where precision
is encoded by a module in a large vector space.

See documentation for Zp() for a description of the input parameters.

NOTE:

The precision is tracked using automatic differentiation
techniques (see [CRV2018] and [CRV2014]).
Floating point \(p\)-adic numbers are used for the computation
of the differential (which is then not exact).

prec – integer (default: 20) the precision cap of the
ring. In the lattice capped case, prec can either be a
pair (relative_cap, absolute_cap) or an integer
(understood at relative cap).
Except for the fixed modulus and floating point cases, individual elements
keep track of their own precision. See TYPES and PRECISION
below.

The second type of precision is absolute precision, which gives
the power of \(p\) that this element is defined modulo:

sage: a.precision_absolute()22

The third one is lattice precision.
It is not attached to a single \(p\)-adic number but is a unique
object modeling the precision on a set of \(p\)-adics, which is
typically the set of all elements within the same parent:

In the capped relative case, the relative precision of an element
is restricted to be at most a certain value, specified at the
creation of the field. Individual elements also store their own
precision, so the effect of various arithmetic operations on
precision is tracked. When you cast an exact element into a
capped relative field, it truncates it to the precision cap of the
field.:

In the capped absolute type, instead of having a cap on the
relative precision of an element there is instead a cap on the
absolute precision. Elements still store their own precisions,
and as with the capped relative case, exact elements are truncated
when cast into the ring.:

The fixed modulus type is the leanest of the \(p\)-adic rings: it is
basically just a wrapper around \(\ZZ / p^n \ZZ\) providing a unified
interface with the rest of the \(p\)-adics. This is the type you
should use if your sole interest is speed. It does not track
precision of elements.:

The floating point case is similar to the fixed modulus type
in that elements do not trac their own precision. However, relative
precision is truncated with each operation rather than absolute precision.

On the contrary, the lattice type tracks precision using lattices
and automatic differentiation. It is rather slow but provides sharp
(often optimal) results regarding precision.
We refer to the documentation of the function ZpLC() for a
small demonstration of the capabilities of this precision model.

PRINTING:

There are many different ways to print \(p\)-adic elements. The
way elements of a given ring print is controlled by options
passed in at the creation of the ring. There are five basic
printing modes (series, val-unit, terse, digits and bars), as
well as various options that either hide some information in
the print representation or sometimes make print
representations more compact. Note that the printing options
affect whether different \(p\)-adic fields are considered equal.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

sage: Zp(5, print_mode=’terse’, show_prec=False)(30)
30

print_max_terms, print_sep and print_alphabet have no effect.

Equality depends on printing options:

sage: R==S,R==T,S==T(False, False, False)

digits: elements are displayed as a string of base \(p\) digits

Restriction: you can only use the digits printing mode for small
primes. Namely, \(p\) must be less than the length of the alphabet
tuple (default alphabet has length 62).:

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘dots’
(or equivalently True) or ‘bigoh’.
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘dots’
(or equivalently True) or ‘bigoh’.
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

In the capped relative case, the relative precision of an element
is restricted to be at most a certain value, specified at the
creation of the field. Individual elements also store their own
precision, so the effect of various arithmetic operations on
precision is tracked. When you cast an exact element into a
capped relative field, it truncates it to the precision cap of the
field.:

The floating point case is similar to the fixed modulus type
in that elements do not trac their own precision. However, relative
precision is truncated with each operation rather than absolute precision.

MODULUS:

The modulus needs to define an unramified extension of \(\ZZ_p\): when it
is reduced to a polynomial over \(\GF{p}\) it should be irreducible.

The modulus can be given in a number of forms.

A polynomial.

The base ring can be \(\ZZ\), \(\QQ\), \(\ZZ_p\), \(\GF{p}\), or anything that can
be converted to \(\ZZ_p\).:

There are many different ways to print \(p\)-adic elements. The way
elements of a given field print is controlled by options passed in
at the creation of the field. There are four basic printing modes
('series', 'val-unit', 'terse' and 'bars'; 'digits' is not available), as
well as various options that either hide some information in the
print representation or sometimes make print representations more
compact. Note that the printing options affect whether different
\(p\)-adic fields are considered equal.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘bigoh’
(or equivalently True).
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

show_prec determines how the precision is printed.
It can be either ‘none’ (or equivalently False), ‘dots’
(or equivalently True) or ‘bigoh’.
The default is False for the 'floating-point' and
'fixed-mod' types and True for all other types.

Given a polynomial poly and a desired precision prec, computes
upoly and epoly so that the extension defined by poly is isomorphic
to the extension defined by first taking an extension by the unramified
polynomial upoly, and then an extension by the Eisenstein polynomial
epoly.

We need better \(p\)-adic factoring in Sage before this function can be
implemented.