# Element Operations

## Parent and Category

### `Parent(a): FldNumElt -> FldNum`

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

### `Type(a): FldNumElt -> Cat`

### `ExtendedType(a): FldNumElt -> Cat`

## Arithmetic

The table below lists the generic arithmetic functions on number field elements. Note that automatic coercion ensures that the binary operations `+`, `-`, `*`, and `/` may be applied to an element of a number field and an element of one of its orders; the result will be a number field element.

### `+ a: FldNumElt -> FldNumElt`

### `- a: FldNumElt -> FldNumElt`

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

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

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

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

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

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

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

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

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

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

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

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

Return `true` if the number field element $a$ is a $k$th power, (respectively square) and the root if so.

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

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

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

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

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

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

Finds an approximation of the number 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](../NumberFieldsAndOrders/ideal.md#rngordidl-in).

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

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

### `a in F: FldNumElt, FldNum -> BoolElt`

## Predicates on Elements

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

### `IsIntegral(a): FldNumElt -> BoolElt, RngIntElt`

Returns `true` if the element $a$ of a number field $F$ is contained in the ring of integers of $F$, `false` otherwise. 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. A denominator $d$ such that $d*a$ is integral is also returned on request.

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

Returns `true` if the element $a$ of the number field $F$ generates $F$ over its coefficient field.

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

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

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

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

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

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

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

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

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

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

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

### `IsPrime(a): FldNumElt -> 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 the number field $K$ and $G$ is the base field of $K$.

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

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

Returns a primitive element for the simple number field $K$, that is an element whose minimal polynomial has the same degree as the field. For a simple number field $K$ this is $K.1$ , while for non-simple fields a random element with this property is returned.

### `Generators(K): FldNum -> {FldNumElt}`

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

### `GeneratorsOverBaseRing(K): FldNum -> {FldNumElt}`

A set of generators of the number field $K$ over ${\mathbb{Q}}$.

### `GeneratorsSequence(K): FldNum -> [FldNumElt]`

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

### `GeneratorsSequenceOverBaseRing(K): FldNum -> [FldNumElt]`

A sequence of generators of the number field $K$ over ${\mathbb{Q}}$.

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

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

A sequence of generators of the number field $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

See Chapter [Number Fields and Orders](../NumberFieldsAndOrders/index-number-fields-and-orders.md#rngord-main) (on number fields and orders).

## Heights

See Chapter [Number Fields and Orders](../NumberFieldsAndOrders/index-number-fields-and-orders.md#rngord-main) (on number fields and orders).

## Norm, Trace, and Minimal Polynomial

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

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

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

The relative norm $\rm N_{L/F}(a)$ over $F$ of the element $a$ of the number field $L$ where $F$ is the field 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): FldNumElt -> FldRatElt`

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

The absolute norm $\rm N_{L/{\mathbb{Q}}}(a)$ over ${\mathbb{Q}}$ of the element $a$ of the number field $L$.

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

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

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

The relative trace ${\operatorname{Tr}}_{L/F}(a)$ over $F$ of the element $a$ of the number field $L$ where $F$ is the field 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): FldNumElt -> FldRatElt`

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

The absolute trace ${\operatorname{Tr}}_{L/{\mathbb{Q}}}(a)$ over ${\mathbb{Q}}$ of the element $a$ of the number field $L$.

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

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

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

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

Given an element $a$ from a number field, this function returns the characteristic polynomial of $a$ over ${\mathbb{Q}}$.

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

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

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

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

Given an element $a$ from a number field, this function returns the minimal polynomial of the element as a polynomial over ${\mathbb{Q}}$.

### `RepresentationMatrix(a): FldNumElt -> NumMatElt`

### `RepresentationMatrix(a, R): FldNumElt, Rng -> NumMatElt`

Return the representation matrix of the number field element $a$, that is, the matrix which represents the linear map wrt to the field basis, given by multiplication by $a$. 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): FldNumElt -> NumMatElt`

Return the representation matrix of the number field element $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-441d85)`

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

```

## Other Functions

Elements can be represented by sequences and have a product representation.

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

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

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

### `Eltseq(E, k): FldNumElt, FldNum -> [RngElt]`

### `Eltseq(E, k): FldNumElt, 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): FldNumElt -> [ FldRatElt]`

The coefficients of the number field element $e$ wrt. to the canonical $Q$ basis for its field. This is performed by iterating [`Eltseq`](#function-fldnum-eltseq) until the coefficients are rational numbers. The coefficients obtained match the coefficients wrt. to [`AbsoluteBasis`](operation.md#function-fldnum-absolutebasis).

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

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

The coefficient of the $i$th basis element in the number field element $a$.

### `ProductRepresentation(a): FldNumElt -> [ FldNumElt ], [ 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): [ FldNumElt ], [ RngIntElt ] -> FldNumElt`

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

Return the number field 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$.
