# Element Operations

## Parent and Category

### `Parent(a): FldAlgElt -> FldAlg`

### `Parent(w): RngOrdElt -> RngOrd`

### `Category(a): FldAlgElt -> Cat`

### `Category(w): RngOrdElt -> Cat`

## Arithmetic

The table below lists the generic arithmetic functions on algebraic field and order elements. Note that automatic coercion ensures that the binary operations `+`, `-`, `*`, and `/` may be applied to an element of an algebraic field and an element of one of its orders; the result will be an algebraic field element. Since division of order elements does not generally result in an order element, the operation `/` applied to two elements of an order returns an element in the field of fractions of the order; similarly if the exponent $k$ in `a^k` is negative.

For finding the value of an element mod an ideal or the inverse of an element mod an ideal see Section [Ideal Arithmetic](ideal.md#rngordidl-arith).

### `+ a: FldAlgElt -> FldAlgElt`

### `+ w: RngOrdElt -> RngOrdElt`

### `- a: FldAlgElt -> FldAlgElt`

### `- w: RngOrdElt -> RngOrdElt`

### `a + b: FldAlgElt, FldAlgElt -> FldAlgElt`

### `w + v: RngOrdElt, RngOrdElt -> RngOrdElt`

### `a - b: FldAlgElt, FldAlgElt -> FldAlgElt`

### `w - v: RngOrdElt, RngOrdElt -> RngOrdElt`

### `a * b: FldAlgElt, FldAlgElt -> FldAlgElt`

### `w * v: RngOrdElt, RngOrdElt -> RngOrdElt`

### `a / b: FldAlgElt, FldAlgElt -> FldAlgElt`

### `w / v: RngOrdElt, RngOrdElt -> FldOrdElt`

### `a ^ k: FldAlgElt, RngIntElt -> FldAlgElt`

### `w ^ k: RngOrdElt, RngIntElt -> RngOrdElt`

### `w div v: RngOrdElt, RngOrdElt -> RngOrdElt`

The quotient of the order element $w$ by the order element $v$; $v$ must divide $w$ exactly, ($v$ and $w$ must be elements of the same order).

### `Modexp(a, n, m): RngOrdElt, RngIntElt, RngIntElt -> RngOrdElt`

Given a non-negative integer $n$ and an integer $m$ greater than 1, this function returns the modular power $a^n \ mod\  m$ of the order element $a$.

### `Sqrt(a): RngOrdElt -> RngOrdElt`

### `Sqrt(a): FldAlgElt -> FldAlgElt`

### `SquareRoot(a): RngOrdElt -> RngOrdElt`

### `SquareRoot(a): FldAlgElt -> FldAlgElt`

Returns the square root of the element $a$ if it exists in the order or field containing $a$.

### `Root(a, n): RngOrdElt, RngIntElt -> RngOrdElt`

### `Root(a, n): FldAlgElt, RngIntElt -> FldAlgElt`

Returns the $n$-th root of the element $a$ if it exists in the order or field containing $a$.

### `IsPower(a, k): FldAlgElt, RngIntElt -> BoolElt, FldAlgElt`

### `IsPower(a, k): RngOrdElt, RngIntElt -> BoolElt, RngOrdElt`

### `IsSquare(a): FldAlgElt -> BoolElt, FldAlgElt`

### `IsSquare(a): RngOrdElt -> BoolElt, RngOrdElt`

Return `true` if the element $a$ is a $kth$ power, (respectively square) and the root in the order or field containing $a$ if so.

### `Denominator(a): FldAlgElt -> RngIntElt`

### `Denominator(a): RngOrdElt -> RngIntElt`

Returns the denominator of the element $a$, that is the least common multiple of the denominators of the coefficients of $a$.

### `Numerator(a): FldAlgElt -> RngIntElt`

Returns the numerator of the element $a$, that is the element multiplied by its denominator.

### `Qround(E, M): FldAlgElt, RngIntElt -> FldAlgElt`

```magma
ContFrac: BoolElt                    Default: true
```

Finds an approximation of the field element $E$ where the denominator is bounded by the integer $M$. If `ContFrac` is `true`, the approximation is computed by applying the continued fraction algorithm to the coefficients of $E$ viewed over $Q$.

## Equality and Membership

Elements may also be tested for whether they lie in an ideal of an order. See Section [Predicates on Ideals](ideal.md#rngordidl-in).

### `a eq b: FldAlgElt, FldAlgElt -> BoolElt`

### `w eq v: RngOrdElt, RngOrdElt -> BoolElt`

### `a ne b: FldAlgElt, FldAlgElt -> BoolElt`

### `w ne v: RngOrdElt, RngOrdElt -> BoolElt`

### `a in F: FldAlgElt, FldAlg -> BoolElt`

### `w in O: RngOrdElt, RngOrd -> BoolElt`

## Predicates on Elements

In addition to the generic predicates `IsMinusOne`, `IsZero` and `IsOne`, the predicates `IsIntegral` and `IsPrimitive` are defined on elements of algebraic fields and orders.

### `IsIntegral(a): FldAlgElt -> BoolElt`

### `IsIntegral(a): RngOrdElt -> BoolElt`

Returns `true` if the element $a$ of an algebraic field $F$ or of an order in $F$ is contained in the ring of integers of $F$, `false` otherwise. This is vacuously true for order elements. We use the minimal polynomial to determine the answer, which means that the calculation of the maximal order is *not* triggered if it is not known yet. When $a$ is a field element a denominator $d$ such that $d*a$ is integral is also returned on request.

### `IsPrimitive(a): FldAlgElt -> BoolElt`

### `IsPrimitive(a): RngOrdElt -> BoolElt`

Returns `true` if the element $a$ of the algebraic field $F$ or one of its orders $O$ generates $F$.

### `IsTorsionUnit(w): RngOrdElt -> BoolElt`

Returns `true` if and only if the order element $w$ is a unit of finite order.

### `IsPower(w, n): RngOrdElt, RngIntElt -> BoolElt, RngOrdElt`

Given an element $w$ in an order $O$ and an integer $n>1$, this function returns `true` if and only if there exists an element $v\in O$ such that $w=v^n$; if `true`, such an element $v$ is returned as well.

### `IsTotallyPositive(a): RngOrdElt -> BoolElt`

### `IsTotallyPositive(a): FldAlgElt -> BoolElt`

Returnes `true` iff all real embeddings of the element $a$ are positive. For elements in absolute fields this is equivalent to all real conjugates being positive.

### `IsZero(a): FldAlgElt -> BoolElt`

### `IsZero(w): RngOrdElt -> BoolElt`

### `IsOne(a): FldAlgElt -> BoolElt`

### `IsOne(w): RngOrdElt -> BoolElt`

### `IsMinusOne(a): FldAlgElt -> BoolElt`

### `IsMinusOne(w): RngOrdElt -> BoolElt`

### `IsUnit(a): FldAlgElt -> BoolElt`

### `IsUnit(w): RngOrdElt -> BoolElt`

### `IsNilpotent(a): FldAlgElt -> BoolElt`

### `IsNilpotent(a): RngOrdElt -> BoolElt`

### `IsIdempotent(a): FldAlgElt -> BoolElt`

### `IsIdempotent(a): RngOrdElt -> BoolElt`

### `IsZeroDivisor(a): FldAlgElt -> BoolElt`

### `IsZeroDivisor(a): RngOrdElt -> BoolElt`

### `IsRegular(a): FldAlgElt -> BoolElt`

### `IsRegular(a): RngOrdElt -> BoolElt`

### `IsIrreducible(a): FldAlgElt -> BoolElt`

### `IsIrreducible(a): RngOrdElt -> BoolElt`

### `IsPrime(a): FldAlgElt -> BoolElt`

### `IsPrime(a): RngOrdElt -> BoolElt`

## Field Generators

### `K . 1: FldNum -> FldNumElt`

Return the image $\alpha$ of $x$ in $G[x]/f$ where $f$ is the first defining polynomial of $K$ and $G$ is the base field of $K$.

In case of simple extensions this will be a primitive element.

### `PrimitiveElement(K): FldNum -> FldNumElt`

### `PrimitiveElement(F): FldOrd -> FldOrdElt`

Returns a primitive element for the simple algebraic field, that is an element whose minimal polynomial has the same degree as the field. For a number field $K$ this is $K.1$ but for a field of fractions this is $F!K.1$ where $K$ is the number field of $F$.

For non-simple fields, a random element is returned.

### `PrimitiveElement(O): RngOrd -> RngOrdElt`

Given an order $O$, returns a primitive element for `FieldOfFractions(O)`.

### `Generators(K): FldAlg -> [FldAlgElt]`

The list of generators of $K$ over its coefficient field, that is a sequence containing a root of each defining polynomial is returned.

### `Generators(K, k): FldAlg, FldAlg -> [FldAlgElt]`

### `Generators(K, Q): FldAlg, FldRat -> [FldAlgElt]`

A list of generators of $K$ over $k$ is returned. That is a sequence containing a root of each defining polynomial for $K$ and its subfield down to the level of $k$ is returned.

## Real and Complex Embeddings

The precision of the real and complex numbers returned by the functions below should be controlled using the optional argument `Precision` in each function. *Note:* `SetKantPrecision` should not be used for this purpose.

### `Conjugates(a): FldAlgElt -> [ FldComElt ]`

### `Conjugates(a): RngOrdElt -> [ FldComElt ]`

```magma
Precision: RngIntElt                    Default: 
```

Given an element $a$ in a number field or order, this returns a sequence of complex numbers, which are the real and complex embeddings of $a$.

When $a$ is an element of an *absolute* field or order $R$ (i.e. $R$ has base field ${\mathbb{Q}}$ or ${\mathbb{Z}}$), the number of embeddings is the degree of $R$. The $r_1$ real conjugates are listed first, followed by the $r_2$ pairs of complex conjugates.

When $a$ is an element of a *relative* field or order $R$, the sequence contains `Evaluate(a, v)` where $v$ runs through `InfinitePlaces(R)`. In particular, it contains only $r_1 + r_2$ numbers.

In both cases, the conjugates are given in a fixed ordering which depends only on (the defining polynomials of) the field or order.

### `Conjugate(a, l): FldAlgElt, RngIntElt -> FldReElt`

### `Conjugate(a, l): RngOrdElt, RngIntElt -> FldReElt`

```magma
Precision: RngIntElt                    Default: 
```

For $a$ in an *absolute* field or order, this returns `Conjugates(a)[l]`.

### `Conjugate(a, l): FldAlgElt, [RngIntElt] -> FldReElt`

```magma
Precision: RngIntElt                    Default: 
```

For $a$ in a *relative* field or order, this returns the conjugate of $a$ indexed by $l$, where $l = [l_1, \ldots, l_n]$ is a sequence of integers.

Let $K$ be the parent of $a$, defined as a tower of extensions with $n$ steps ${\mathbb{Q}}\subseteq K_1\subseteq \ldots\subseteq K_n = K$. The embedding indexed by $l$ is defined inductively: it extends the embedding $[l_1, \ldots, l_{n-1}]$ of $K_{n-1}$ and is the $l_n$th such extension. These extensions are ordered by a fixed rule, depending only on (the defining polynomials of) the field tower.

The `InfinitePlaces` of $K$ are indexed the same way.

### `AbsoluteValues(a): FldAlgElt -> [FldReElt]`

### `AbsoluteValues(a): RngOrdElt -> [FldReElt]`

This returns a sequence of $r_1 + r_2$ positive real numbers. These are the absolute values of the real and complex embeddings of the element $a$, which is required to be an element of an absolute field or order.

### `Logs(a): FldAlgElt -> [FldReElt]`

### `Logs(a): RngOrdElt -> [FldReElt]`

This returns a sequence of $r_1 + r_2$ positive real numbers. These are the natural logs of the absolute values of the real and complex embeddings of the element $a$, which is required to be a nonzero element of an absolute field or order.

### `InfinitePlaces(K): FldAlg -> [PlcNumElt]`

### `InfinitePlaces(O): RngOrd -> [PlcNumElt]`

This returns a sequence containing all the infinite places of the field. Each place corresponds to a real embedding or a pair of complex embeddings. The ordering of the places is fixed.

### `Evaluate(x, p): FldAlgElt, PlcNumElt -> RngElt`

### `Evaluate(x, p): RngOrdElt, PlcNumElt -> RngElt`

When $p$ is a finite place, this returns the image of $x$ in the residue class field corresponding to $p$.

When $p$ is an infinite place, this returns the image of $x$ under the corresponding embedding, i.e., a real or complex number. (This can also be obtained using `Conjugate` or `Conjugates`.)

### `RealEmbeddings(a): FldAlgElt -> []`

### `RealEmbeddings(a): RngOrdElt -> []`

This returns the sequence of values `Evaluate(a,p)` where $p$ runs through the real places of the field.

### `MinkowskiLattice(O): RngOrd -> Lat, Map`

### `Lattice(O): RngOrd -> Lat, Map`

```magma
Precision: RngIntElt                    Default: 
```

Given an absolute order $O$, returns the lattice determined by the real and complex embeddings of $O$.

### `MinkowskiLattice(I): RngOrdIdl -> Lat, Map`

### `Lattice(I): RngOrdIdl -> Lat, Map`

```magma
Precision: RngIntElt                    Default: 
```

Given an ideal $I$ in an absolute order, returns the lattice determined by the real and complex embeddings of $I$.

### `MinkowskiSpace(F): FldAlg -> Lat, Map`

The Minkowski vector space $V$ of the absolute field $F$ as a real vector space, with inner product given by the $T_2$-norm ([`Length`](#function-rngord-length)) on $F$, and by the embedding $F \rightarrow V$.

## Heights

The real precision of results can be controlled using `SetKantPrecision`.

### `AbsoluteLogarithmicHeight(a): FldAlgElt -> FldReElt`

### `AbsoluteLogarithmicHeight(a): RngOrdElt -> FldReElt`

Let $P$ be the minimal polynomial of the element $a$ over ${\mathbb{Z}}$, with leading coefficient $a_0$ and roots $\alpha_1, \ldots, \alpha_n$. Then the absolute logarithmic height is defined to be

$$
h(\alpha) = {1\over n} \log(a_0 \prod_{j=1}^{n} \max(1, |\alpha_j|)).
$$

### `CoefficientHeight(E): RngOrdElt -> RngIntElt`

### `CoefficientHeight(E): FldAlgElt -> RngIntElt`

Computes the coefficient height of the element $E$, that is for an element of an absolute field it returns the maximum of the denominator and the largest coefficient wrt. to the basis of the parent. For elements in relative extensions, it returns the maximal coefficient height of all the coefficients wrt. the basis of the parent.

This function indicates in some way the difficulty of operations involving this element.

### `CoefficientLength(E): RngOrdElt -> RngIntElt`

### `CoefficientLength(E): FldAlgElt -> RngIntElt`

Computes the coefficient length of the element $E$, that is for an element of an absolute field it returns the sum of the denominator and the absolute values of all coefficients wrt. to the basis of the parent. For elements in relative extensions, it returns the sum of the coefficient length of all the coefficients wrt. the basis of the parent.

This function gives an indication on the amount of memory occupied by this element.

### `Length(a): FldAlgElt -> FldReElt`

### `Length(a): RngOrdElt -> FldReElt`

Return the $T_2$-norm of the element $a$, which is a real number. This equals the sum of the (complex) norms of the conjugates of $a$.

### `Example: Discriminant (ex-19f6ce)`

It is not hard to write an alternative discriminant function, using the `Conjugates` of the basis `[O.1, O.2, ...]`.

```magma
> function disc(O)
>     B := [ Conjugates(O.i) : i in [1 .. Degree(O)] ];
>     D := Determinant(Matrix(B))^2;
>     return RealField(20) ! D;
> end function;
> _<x> := PolynomialRing(Integers());
> O := MaximalOrder(NumberField(x^4 - 420*x^2 + 40000));
> disc(O);
42025.000000000000001
> Discriminant(O);
42025

```

The function `disc` obtains a real approximation to the exact value given by `Discriminant`. Here is an alternative way of getting the $T_2$ norm returned by `Length`, using the complex `Norm` function, together with the `Conjugates` function.

```magma
> norm := func< a | &+[ Norm(Conjugates(a)[i]) : \\
>                      i in [1 .. Degree(Parent(a))] ] >;

```

## Norm, Trace, and Minimal Polynomial

The norm, trace and minimal polynomial of order and algebraic field elements can be calculated both with respect to the coefficient ring and to ${\mathbb{Z}}$ or ${\mathbb{Q}}$.

### `Norm(a): FldAlgElt -> FldAlgElt`

### `Norm(a): FldAlgElt -> FldRatElt`

### `Norm(a, R): FldAlgElt, Rng -> RngElt`

### `Norm(a): RngOrdElt -> RngOrdElt`

### `Norm(a): RngOrdElt -> RngIntElt`

### `Norm(a, R): RngOrdElt, Rng -> RngElt`

The relative norm $\rm N_{L/F}(a)$ over $F$ of the element $a$ of $L$ where $F$ is the field or order over which $L$ is defined as an extension. If $R$ is given the norm is calculated over $R$. In this case, $R$ must occur as a coefficient ring somewhere in the tower under $L$.

### `AbsoluteNorm(a): FldAlgElt -> FldRatElt`

### `NormAbs(a): FldAlgElt -> FldRatElt`

### `AbsoluteNorm(a): RngOrdElt -> FldRatElt`

### `NormAbs(a): RngOrdElt -> FldRatElt`

The absolute norm $\rm N_{L/{\mathbb{Q}}}(a)$ over ${\mathbb{Q}}$ of the element $a$ of $L$ (or one of its orders).

### `Trace(a): FldAlgElt -> FldAlgElt`

### `Trace(a): FldAlgElt -> FldRatElt`

### `Trace(a, R): FldAlgElt, Rng -> RngElt`

### `Trace(a): RngOrdElt -> RngOrdElt`

### `Trace(a): RngOrdElt -> RngIntElt`

### `Trace(a, R): RngOrdElt, Rng -> RngElt`

The relative trace ${\operatorname{Tr}}_{L/F}(a)$ over $F$ of the element $a$ of $L$ where $F$ is the field or order over which $L$ is defined as an extension. If $R$ is given the trace is computed over $R$. In this case, $R$ must occur as a coefficient ring somewhere in the tower under $L$.

### `AbsoluteTrace(a): FldAlgElt -> FldRatElt`

### `TraceAbs(a): FldAlgElt -> FldRatElt`

### `AbsoluteTrace(a): RngOrdElt -> FldRatElt`

### `TraceAbs(a): RngOrdElt -> FldRatElt`

The absolute trace ${\operatorname{Tr}}_{L/{\mathbb{Q}}}(a)$ over ${\mathbb{Q}}$ of the element $a$ of $L$ (or one of its orders).

### `CharacteristicPolynomial(a): FldAlgElt -> RngUPolElt`

### `CharacteristicPolynomial(a, R): FldAlgElt, Rng -> RngUPolElt`

### `CharacteristicPolynomial(a): RngOrdElt -> RngUPolElt`

### `CharacteristicPolynomial(a, R): RngOrdElt, Rng -> RngUPolElt`

Given an element $a$ from an algebraic field or order $L$, returns the characteristic polynomial of the element over $R$ if given or the subfield or suborder $F$ otherwise where $F$ is the field or order over which $L$ is defined as an extension.

### `AbsoluteCharacteristicPolynomial(a): FldAlgElt -> RngUPolElt`

### `AbsoluteCharacteristicPolynomial(a): RngOrdElt -> RngUPolElt`

Given an element $a$ from an algebraic field or one of its orders, this function returns the characteristic polynomial of the element. For field elements the polynomial will have coefficients in the rational field, for order elements the coefficients will be in the ring of integers.

### `MinimalPolynomial(a): FldAlgElt -> RngUPolElt`

### `MinimalPolynomial(a, R): FldAlgElt, Rng -> RngUPolElt`

### `MinimalPolynomial(a): RngOrdElt -> RngUPolElt`

### `MinimalPolynomial(a, R): RngOrdElt, Rng -> RngUPolElt`

Given an element $a$ from an algebraic field or order $L$, returns the minimal polynomial of the element over $R$ if given otherwise the subfield or suborder $F$ where $F$ is the field or order over which $L$ is defined as an extension.

### `AbsoluteMinimalPolynomial(a): FldAlgElt -> RngUPolElt`

### `AbsoluteMinimalPolynomial(a): RngOrdElt -> RngUPolElt`

Given an element $a$ from an algebraic field or one of its orders, this function returns the minimal polynomial of the element. For field elements the polynomial will have coefficients in the rational field, for order elements the coefficients will be in the ring of integers.

### `RepresentationMatrix(a): FldAlgElt -> AlgMatElt`

### `RepresentationMatrix(a, R): FldAlgElt, Rng -> AlgMatElt`

### `RepresentationMatrix(a): RngOrdElt -> AlgMatElt`

### `RepresentationMatrix(a, R): RngOrdElt, Rng -> AlgMatElt`

Return the representation matrix of $a$, that is, the matrix which represents the linear map given by multiplication by $a$. If $a$ is an order element, this matrix is with respect to the basis for the order; if $a$ is an algebraic field element, the basis for the field is used. The $i$th row of the representation matrix gives the coefficients of $aw_i$ with respect to the basis $w_1, \ldots, w_n$.

If $R$ is given the matrix is over $R$ and with respect to the basis of the order or field over $R$.

### `AbsoluteRepresentationMatrix(a): FldAlgElt -> AlgMatElt`

### `AbsoluteRepresentationMatrix(a): RngOrdElt -> AlgMatElt`

Return the representation matrix of $a$ relative to the ${\mathbb{Q}}$-basis of the field constructed using products of the basis elements, where $a$ is an element of the relative number field $L$.

Let $L_i := \sum L_{i-1} \omega_{i,j}$, $L := L_n$ and $L_0 := {\mathbb{Q}}$. Then the representation matrix is computed with respect to the ${\mathbb{Q}}$-basis $(\prod_j \omega_{i_j,j})_{i \in I}$ consisting of products of basis elements of the different levels.

### `Example: Norms Etc (ex-68a043)`

We create the norm, trace, minimal polynomial and representation matrix of the element $\alpha/2$ in the quartic field ${\mathbb{Q}}(\alpha)$.

```magma
> R<x> := PolynomialRing(Integers());
> K<y> := NumberField(x^4-420*x^2+40000);
> z := y/2;
> Norm(z), Trace(z);
2500 0
> MinimalPolynomial(z);
$.1^4 - 105*$.1^2 + 2500
> RepresentationMatrix(z);
[     0    1/2      0      0]
[     0      0    1/2      0]
[     0      0      0    1/2]
[-20000      0    210      0]

```

The awkwardness of the printing of the minimal polynomial above can be overcome by providing a parent for the polynomial, keeping in mind that it is a univariate polynomial over the rationals:

```magma
> P<t> := PolynomialRing(RationalField());
> MinimalPolynomial(z);
t^4 - 105*t^2 + 2500

```

## The Quadratic Defect

Let $K$ be a number field or the field of rationals and let $p$ be a prime ideal in the ring of integers $O$ of $K$. Further, let $K_p$ be the completion of $K$ at $p$. Every square class of $K_p^*/(K_p^*)^2$ has a representative in $K$. The following functions allow to work with these classes, without the construction of the completion $K_p$ explicitly.

### `QuadraticDefect(a, p): RngElt, RngOrdIdl -> RngIntElt`

### `QuadraticDefect(a, p): FldRatElt, RngIntElt -> RngIntElt`

### `QuadraticDefect(a, p): RngIntElt, RngIntElt -> RngIntElt`

### `QuadraticDefect(a, p): FldRatElt, RngInt -> RngIntElt`

### `QuadraticDefect(a, p): RngIntElt, RngInt -> RngIntElt`

### `RelativeQuadraticDefect(a, p): RngElt, RngOrdIdl -> RngIntElt`

### `RelativeQuadraticDefect(a, p): FldRatElt, RngIntElt -> RngIntElt`

### `RelativeQuadraticDefect(a, p): RngIntElt, RngIntElt -> RngIntElt`

### `RelativeQuadraticDefect(a, p): FldRatElt, RngInt -> RngIntElt`

### `RelativeQuadraticDefect(a, p): RngIntElt, RngInt -> RngIntElt`

For an element $a$ in $K$, let

$$
q_p(a):= \bigcap_{b \in K_p} (a - b^2) O_p
$$

be the quadratic defect of $a$ in the completion $K_p$. Further $q_p(a) / a$ is called the relative quadratic defect of $a \ne 0$ in $K_p$.

The above function computes the valuation of the (relative) quadratic defect of $a$ in $K_p$. Note that the valuation might be infinity, which happens if and only if $a$ is a square in $K_p$.

### `IsLocalSquare(a, p): RngElt, RngOrdIdl -> BoolElt`

### `IsLocalSquare(a, p): FldRatElt, RngIntElt -> BoolElt`

### `IsLocalSquare(a, p): RngIntElt, RngIntElt -> BoolElt`

### `IsLocalSquare(a, p): FldRatElt, RngInt -> BoolElt`

### `IsLocalSquare(a, p): RngIntElt, RngInt -> BoolElt`

Given an element $a$ in $K$, decide if $a$ is a square in the completion $K_p$.

### `LocalMultiplicativeGroupModSquares(p): RngOrdIdl -> ModFld, Map`

### `LocalMultiplicativeGroupModSquares(p): RngIntElt -> ModFld, Map`

Let $K$ be a number field or the rationals and let $p$ be a prime ideal of the ring of integers of $K$. Then the units of the completion modulo squares $K_p^* / (K_p^*)^2$ form a $GF(2)$-vector space $V$. This function returns $V$ and a map from $K$ to $V$ which can compute inverses.

If $V$ has rank $r$ say, then the first $r-1$ basis vectors of $V$ generate the subspace corresponding to the elements of $O^*_p / (O_p^*)^2$.

### `UnitSquareClassReps(p): RngOrdIdl -> SeqEnum`

### `UnitSquareClassReps(p): RngIntElt -> SeqEnum`

Returns a sequence of elements in $O$ that represent the elements of $O^*_p / (O_p^*)^2$.

### `NiceUnitSquareClassRepresentative(u, p): RngElt, RngOrdIdl -> RngElt`

### `NiceUnitSquareClassRepresentative(u, p): RngElt, RngIntElt -> RngElt`

Given an element in $u$ in $K$ which has $p$-adic valuation $0$, return some element $v$ in $K$ such that $uv$ is a square in $O_p^*$ and the quadratic defect of $u$ is $(v-1)O_p$.

## Other Functions

### `ElementToSequence(a): FldAlgElt -> [ FldAlgElt ]`

### `Eltseq(a): FldAlgElt -> [ FldAlgElt ]`

### `ElementToSequence(a): RngOrdElt -> [ FldOrdElt ]`

### `Eltseq(a): RngOrdElt -> [ FldOrdElt ]`

For an element $a$ of an algebraic field $F$, a sequence of coefficients of length degree of $F$ with respect to the basis is returned. For an element of an order $O$, the sequence of coefficients of the element with respect to the basis of $O$ are returned.

Note however that the universe of the sequence if always a field since in general in relative extensions integral coefficients cannot be achieved.

### `Eltseq(E, k): FldAlgElt, FldAlg -> [RngElt]`

### `Eltseq(E, k): FldAlgElt, Rng -> [RngElt]`

For an algebraic number $E\in K$ and a ring $k$ which occurs somewhere in the defining tower for $K$, return the list of coefficients of $E$ over $k$, that is, apply `Eltseq` to $E$ and to its coefficients until the list is over $k$.

### `Flat(e): FldAlgElt -> [FldRatElt]`

Given an element in a field $K$, this returns the coordinates of $e$ with respect to the `AbsoluteBasis` of $K$ over ${\mathbb{Q}}$.

### `a[i]: FldAlgElt, RngIntElt -> FldRatElt`

### `a[i]: FldAlgElt, RngIntElt -> FldAlgElt`

### `a[i]: RngOrdElt, RngIntElt -> FldRatElt`

### `a[i]: RngOrdElt, RngIntElt -> FldOrdElt`

The coefficient of the $i$th basis element in the algebraic field or order element $a$.

### `ProductRepresentation(a): RngOrdElt -> [ RngOrdElt ], [ RngIntElt ]`

### `ProductRepresentation(a): FldAlgElt -> [ FldAlgElt ], [ RngIntElt ]`

Return sequences $P$ and $E$ such that the product of elements in $P$ to the corresponding exponents in $E$ is the algebraic number $a$.

### `ProductRepresentation(P, E): [ FldAlgElt ], [ RngIntElt ] -> FldAlgElt`

### `PowerProduct(P, E): [FldAlgElt], [RngIntElt] -> FldAlgElt`

Return the element $a$ of the universe of the sequence $P$ such that $a$ is the product of elements of $P$ to the corresponding exponents in the sequence $E$.

### `Valuation(w, I): RngOrdElt, RngOrdIdl -> RngIntElt`

### `Valuation(w, I): FldAlgElt, RngOrdIdl -> RngIntElt`

Given a prime ideal $I$ and an element $w$ of an order or algebraic field, this function returns the valuation $v_I(w)$ of $w$ with respect to $I$; this valuation will be a non-negative integer. Ideals are discussed in Section [Ideals and Quotients](ideal.md#rngord-ideal).

### `Decomposition(a): RngOrdElt -> SeqEnum[<RngOrdIdl, RngIntElt>]`

### `Decomposition(a): FldOrdElt -> SeqEnum[<RngOrdIdl, RngIntElt>]`

The factorization of the order or algebraic field element $a$ into prime ideals.

### `Divisors(a): RngOrdElt -> SeqEnum[RngOrdElt]`

For an element $a$ in a maximal order return a sequence containing (up to units) all the elements which divide $a$. The elements of the sequence will be generators for all principal ideals returned by `Divisors(Parent(a)*a)`.

### `Index(a): RngOrdElt -> RngIntElt`

The index of the module ${\mathbb{Z}}[a]$ in $O$ where $a$ lies in $O$, an order over ${\mathbb{Z}}$. If $a$ is not a primitive element the index is infinite.

### `Different(a): RngOrdElt -> RngOrdElt`

The different of the element $a$ of an order of a number field.

### `DegreeOnePrimeIdeals(O, B): RngOrd, RngIntElt -> [ RngOrdIdl ]`

Given an order $O$ as well as a positive integer bound $B$, return a sequence consisting of all prime ideals in $O$ whose norm is a rational prime not exceeding the bound $B$.
