# Element Constructions and Conversions

Local ring elements are implemented using a balanced mod representation. This allows small negative elements $x$ to be represented as $x$ rather than $p^k - x$ where $k$ is a $p$-adic precision.

## Constructions

To simplify the creation of elements in a local ring, various coercions are provided. The most obvious is to regard the integer ring or rational field as embedded in 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 local field not lying in the local ring, constructors are provided that create an element coercible into the ring, and which increase or decrease this element’s valuation in the field.

### `Zero(L): RngPad -> RngPadElt`

### `Zero(L): RngPadRes -> RngPadResElt`

### `Zero(L): RngPadResExt -> RngPadResExtElt`

### `Zero(L): FldPad -> FldPadElt`

Given a local ring or field $L$, create the additive identity of $L$. Note that if $L$ is an unbounded precision ring, this will only be the zero element to the default precision of the ring, and hence only an approximation to the additive identity of $L$. The valuation and hence the absolute precision of the zero of a field is infinite.

### `One(L): RngPad -> RngPadElt`

### `One(L): RngPadRes -> RngPadResElt`

### `One(L): RngPadResExt -> RngPadResExtElt`

### `One(L): FldPad -> FldPadElt`

Given a local ring or field $L$, create the multiplicative identity of $L$. Note that if $L$ is an unbounded precision structure, this will only be the one element to the default precision of the ring, and hence only an approximation to the multiplicative identity of $L$.

### `Random(L): RngPad -> RngPadElt`

### `Random(L): RngPadRes -> RngPadResElt`

### `Random(L): RngPadResExt -> RngPadResExtElt`

Given a local ring or field $L$, return a random element of $L$, which must be a quotient ring or bounded precision ring. The element will have the default precision of the ring.

### `Representative(L): RngPad -> RngPadElt`

### `Representative(L): RngPadRes -> RngPadResElt`

### `Representative(L): RngPadResExt -> RngPadResExtElt`

### `Representative(L): FldPad -> FldPadElt`

Return an element of the local ring or field $L$.

### `elt<L | u>: RngPad, RngElt -> RngPadElt`

### `elt<L | u>: RngPad, [RngElt] -> RngPadElt`

### `L ! u: RngPad, RngElt -> RngPadElt`

### `L ! u: RngPad, [RngElt] -> RngPadElt`

### `elt<L | u>: FldPad, RngElt -> FldPadElt`

### `elt<L | u>: FldPad, [RngElt] -> FldPadElt`

### `L ! u: FldPad, RngElt -> FldPadElt`

### `L ! u: FldPad, [RngElt] -> FldPadElt`

Coerce the object $u$ into the local ring or field $L$. The resulting element will have as much precision as possible. The element $u$ is allowed to be one of the following:

**(i)**
An integer.

**(ii)**
An element of ${\mathbb{Z}}/ p^m{\mathbb{Z}}$; (where $m$ is a precision).

**(iii)**
An element of the residue class field of $L$.

**(iv)**
An element of a local ring or field with something in common with $L$.

**(v)**
A rational number. If $L$ is a ring then $u$ must not have valuation in the denominator.

**(vi)**
An element of a valuation ring over the rationals with the same prime as $L$.

**(vii)**
A sequence $s$. In this case, the sequence $s$ is coerced to a sequence $t$ over the base ring or field of $L$. This sequence is coerced to $\sum_{i=1}^{\#t} t[i] L.1^{i-1}$.

### `elt<L | u, r>: RngPad, RngElt, RngIntElt -> RngPadElt`

### `elt<L | u, r>: RngPad, [RngElt], RngIntElt -> RngPadElt`

### `elt<L | u, r>: FldPad, RngElt, RngIntElt -> FldPadElt`

### `elt<L | u, r>: FldPad, [RngElt], RngIntElt -> FldPadElt`

Create an element of the local ring or field $L$ by coercing $u$ into $L$ and returning with it precision $r$.

### `elt<L | v, u, r>: RngPad, RngIntElt, RngElt, RngIntElt -> RngPadElt`

### `elt<L | v, u, r>: RngPad, RngIntElt, [RngElt], RngIntElt -> RngPadElt`

### `elt<L | v, u, r>: FldPad, RngIntElt, RngElt, RngIntElt -> FldPadElt`

### `elt<L | v, u, r>: FldPad, RngIntElt, [RngElt], RngIntElt -> FldPadElt`

Create an element of the local ring or field $L$ by coercing $u$ into $L$, multiplying by the $v$-th power of the uniformizing element and returning it with precision $r$.

### `BigO(x): RngPadElt -> RngPadElt`

### `BigO(x): FldPadElt -> FldPadElt`

### `O(x): RngPadElt -> RngPadElt`

### `O(x): FldPadElt -> FldPadElt`

For an element $x$ of a local ring or field $L$ of valuation $v$, create an element of valuation $v$ and relative precision $0$. For rings this is the zero element in the quotient $L / \pi^v L$.

### `UniformizingElement(L): RngPad -> RngPadElt`

### `UniformizingElement(L): RngPadRes -> RndPadResElt`

### `UniformizingElement(L): RngPadResExt -> RndPadResExtElt`

### `UniformizingElement(L): FldPad -> FldPadElt`

Given a local ring or field $L$, return the uniformizing element of $L$ to the default precision of $L$.

### `Example: eltcons (ex-9e5bd3)`

Here we illustrate the usage of element constructors for local fields and imprecise zeros.

```magma
> Zp := pAdicRing(5, 20);
> I<a> := UnramifiedExtension(Zp, 3);
> R<x> := PolynomialRing(I);
> L<b> := ext<I | x^3 + 5*a*x^2 + 5>;
> K<pi> := ext<BaseField(FieldOfFractions(L)) | x^2 + 5>;
> K;
Totally ramified extension defined by the polynomial x^2 + 5
 over Unramified extension defined by the polynomial x^3 + 3*x + 3
 over 5-adic field mod 5^20
> elt<K | 64>;
64 + O(pi^40)
> P := PrimeField(K);
> elt<K | 2, 3/4, 6>;
pi^2*7 + O(pi^6)
> 4*$1;
pi^2*3 + O(pi^6)
> K!3/5;
pi^-2*3 + O(pi^38)
> O(K!40^200);
O(pi^400)
> Precision($1);
0
> O(K!0);
O(pi^40)
> O(K!1);
O(1)
> R<x> := PolynomialRing(Integers());
> K<pi> := ext<pAdicField(5, 100) | x^2 + 5>;
> elt<K | 64>;
64 + O(pi^200)
> Precision($1);
200
> K!3/10;
-pi^-2*3944304526105059027058642826413931148366032175545115023851394653320311 +
O(pi^198)

```

### `Example: Eltcons Seq Weird (ex-b0924e)`

There is a subtle interplay between the default precision of rings and fields and coercion of sequences, which we demonstrate here. We construct the 5-adic field $P$, and an unramified extension of $R$. We set the default precision of $R$ to be higher than that of $P$.

```magma
> P := pAdicRing(5);
> R := ext<P | 2>;
> P`DefaultPrecision;
20
> R`DefaultPrecision := 40;
> x := Random(R);
> x;
-1579801843431963201369145587*R.1 - 680575730458975039033394769 + O(5^40)
> s := [-680575730458975039033394769, -1579801843431963201369145587];
> R!s;
-13585890629962*R.1 + 47482939261481 + O(5^20)
> P`DefaultPrecision := 40;
> R!s;
-1579801843431963201369145587*R.1 - 680575730458975039033394769 + O(5^40)

```

As can be seen from the above, it is the default precision of the base ring, not the ring itself, which determines the precision of elements created by sequences.

## Element Decomposers

### `ElementToSequence(x): RngPadElt -> [ RngElt ]`

### `ElementToSequence(x): RngPadResElt -> [ RngElt ]`

### `ElementToSequence(x): RngPadResExtElt -> [ RngElt ]`

### `ElementToSequence(x): FldPadElt -> [ RngElt ]`

### `Eltseq(x): RngPadElt -> [ RngElt ]`

### `Eltseq(x): RngPadResElt -> [ RngElt ]`

### `Eltseq(x): RngPadResExtElt -> [ RngElt ]`

### `Eltseq(x): FldPadElt -> [ RngElt ]`

### `Coefficients(x): RngPadElt -> [ RngElt ]`

### `Coefficients(x): RngPadResElt -> [ RngElt ]`

### `Coefficients(x): RngPadResExtElt -> [ RngElt ]`

### `Coefficients(x): FldPadElt -> [ RngElt ]`

Given an element $x$ of a degree $n$ extension $K$ of $L$, these functions return a sequence $s$ of elements of $L$ such that $x = \sum_{i=1}^{n} s[i] K.1^{i-1}$.

### `Coefficient(x, i): RngPadElt, RngIntElt -> RngPadElt`

### `Coefficient(x, i): RngPadResElt, RngIntElt -> RngPadResElt`

### `Coefficient(x, i): RngPadResExtElt, RngIntElt -> RngElt`

### `Coefficient(x, i): FldPadElt, RngIntElt -> FldPadElt`

Equivalent to, but more efficient than, `Coefficients(x)[i]`.

### `Example: Gal Desc (ex-716c79)`

We want to perform a Galois descent for a polynomial, i.e. we interpret the product of the Galois conjugates of a polynomial in a subring.

```magma
> p := 3;
> L<a> := UnramifiedExtension(pAdicRing(p), 4 : Cyclotomic);
> R<x> := PolynomialRing(L);
> g := x^2 + (a+a^-2)*x + (a^-1+a^3+1);
> g;
(1 + O(3^20))*x^2 + (-151999392*a^3 - 428033534*a^2 + 1509587217*a - 64512399 +
    O(3^20))*x + 2*a^3 + 307453058*a^2 - 1732356354*a - 151999391 + O(3^20)
> a2 := a^(p^2);
> g2 := R ! [ &+[Eltseq(c)[i]*a2^(i-1) : i in [1..4]] : c in Eltseq(g) ];

```

Here `Eltseq` is being used to replace occurrences of $a$ in the element by $a_2$.

```magma
> h := g * g2;
> h;
(1 + O(3^20))*x^4 + (774759822*a^3 - 1559939781*a^2 + 644136111*a + 143311364 +
    O(3^20))*x^3 + (73899384*a^3 - 333497478*a^2 + 1655979363*a + 158024680 +
    O(3^20))*x^2 + (989668189*a^3 - 661853000*a^2 - 1685887308*a + 122035547 +
    O(3^20))*x - 1630826887*a^3 - 328410694*a^2 - 175290219*a + 1601599448 +
    O(3^20)

```

The polynomial $g_2$ is the image of $g$ under the automorphism induced by the square of the Frobenius automorphism. The product $h = g g_2$ has coefficients in the unramified extension of degree 2, which is the fixed field under the square of the Frobenius and is generated by $a^{10}$. Next, we determine a representation for the polynomial $h$ with coefficients lying in this unramified extension of degree 2.

```magma
> K<b> := UnramifiedExtension(pAdicRing(p), 2 : Cyclotomic);
> S<y> := PolynomialRing(K);
> M := RMatrixSpace(PrimeRing(L), 2, 4) ! 0;
> V := RSpace(PrimeRing(L), 4);
> M[1] := V ! Eltseq(a^0);
> M[2] := V ! Eltseq(a^10);
> sol := [ Solution(M, V ! Eltseq(c)) : c in Eltseq(h) ];
> h2 := S ! [ K ! Eltseq(s) : s in sol ];
> h2;
(1 + O(3^20))*y^4 + (-1237301755*b + 505889265 + O(3^20))*y^3 + (-542504216*b +
    1258167831 + O(3^20))*y^2 + (-280210015*b - 1205051127 + O(3^20))*y +
    1213139407*b + 1602993886 + O(3^20)

```
