# Number field arithmetic

Number fields are provided in Nemo by Antic. This allows construction of absolute number fields and basic arithmetic computations therein.

Number fields are constructed using the AnticNumberField function. However, for convenience we define

NumberField = AnticNumberField

so that number fields can be constructed using NumberField rather than AnticNumberField.

The types of number field elements in Nemo are given in the following table, along with the libraries that provide them and the associated types of the parent objects.

LibraryFieldElement typeParent type
Antic$\mathbb{Q}[x]/(f)$nf_elemAnticNumberField

All the number field types belong to the Field abstract type and the number field element types belong to the FieldElem abstract type.

The Hecke.jl library radically expands on number field functionality, providing ideals, orders, class groups, relative extensions, class field theory, etc.

The basic number field element type used in Hecke is the Nemo/antic number field element type, making the two libraries tightly integrated.

https://thofma.github.io/Hecke.jl/stable/

## Number field functionality

The number fields in Nemo provide all of the AbstractAlgebra field functionality:

https://nemocas.github.io/AbstractAlgebra.jl/stable/field

Below, we document the additional functionality provided for number field elements.

### Constructors

In order to construct number field elements in Nemo, one must first construct the number field itself. This is accomplished with one of the following constructors.

Nemo.NumberFieldMethod
NumberField(f::fmpq_poly, s::Union{AbstractString, Char, Symbol};
cached::Bool = true, check::Bool = true)

Return a tuple $R, x$ consisting of the parent object $R$ and generator $x$ of the number field $\mathbb{Q}[x]/(f)$ where $f$ is the supplied polynomial. The supplied string s specifies how the generator of the number field should be printed.

source
Nemo.CyclotomicFieldMethod
CyclotomicField(n::Int, s::Union{AbstractString, Char, Symbol} = "z_$n", t = "_\$"; cached = true)

Return a tuple $R, x$ consisting of the parent object $R$ and generator $x$ of the $n$-th cyclotomic field, $\mathbb{Q}(\zeta_n)$. The supplied string s specifies how the generator of the number field should be printed. If provided, the string t specifies how the generator of the polynomial ring from which the number field is constructed, should be printed. If it is not supplied, a default dollar sign will be used to represent the variable.

source
Nemo.CyclotomicRealSubfieldMethod
CyclotomicRealSubfield(n::Int, s::Union{AbstractString, Char, Symbol} = "(z_$n + 1/z_$n)", t = "\$"; cached = true) Return a tuple$R, x$consisting of the parent object$R$and generator$x$of the totally real subfield of the$n$-th cyclotomic field,$\mathbb{Q}(\zeta_n)$. The supplied string s specifies how the generator of the number field should be printed. If provided, the string t specifies how the generator of the polynomial ring from which the number field is constructed, should be printed. If it is not supplied, a default dollar sign will be used to represent the variable. source Here are some examples of creating number fields and making use of the resulting parent objects to coerce various elements into those fields. Examples R, x = PolynomialRing(QQ, "x") K, a = NumberField(x^3 + 3x + 1, "a") L, b = CyclotomicField(5, "b") M, c = CyclotomicRealField(5, "c") d = K(3) f = L(b) g = L(ZZ(11)) h = L(ZZ(11)//3) k = M(x) ### Number field element constructors The easiest way of constructing number field elements is to use element arithmetic with the generator, to construct the desired element by its representation as a polynomial. See the following examples for how to do this. Examples R, x = PolynomialRing(QQ, "x") K, a = NumberField(x^3 + 3x + 1, "a") d = gen(K) f = a^2 + 2a - 7 ### Basic functionality AbstractAlgebra.mul_red!Method mul_red!(z::nf_elem, x::nf_elem, y::nf_elem, red::Bool) Multiply$x$by$y$and set the existing number field element$z$to the result. Reduction modulo the defining polynomial is only performed if red is set to true. Note that$x$and$y$must be reduced. This function is provided for performance reasons as it saves allocating a new object for the result and eliminates associated garbage collection. source AbstractAlgebra.Generic.reduce!Method reduce!(x::nf_elem) Reduce the given number field element by the defining polynomial, in-place. This only needs to be done after accumulating values computed by mul_red! where reduction has not been performed. All standard Nemo number field functions automatically reduce their outputs. source The following coercion function is provided for a number field$R$. R(f::fmpq_poly) Coerce the given rational polynomial into the number field$R$, i.e. consider the polynomial to be the representation of a number field element and return it. Conversely, if$R$is the polynomial ring to which the generating polynomial of a number field belongs, then we can coerce number field elements into the ring$R$using the following function. R(b::nf_elem) Coerce the given number field element into the polynomial ring$R$of which the number field is a quotient. Examples R, x = PolynomialRing(QQ, "x") K, a = NumberField(x^3 + 3x + 1, "a") f = R(a^2 + 2a + 3) g = K(x^2 + 2x + 1) ### Basic manipulation AbstractAlgebra.varMethod var(a::AnticNumberField) Returns the identifier (as a symbol, not a string), that is used for printing the generator of the given number field. source AbstractAlgebra.is_genMethod is_gen(a::nf_elem) Return true if the given number field element is the generator of the number field, otherwise return false. source AbstractAlgebra.coeffMethod coeff(x::nf_elem, n::Int) Return the$n$-th coefficient of the polynomial representation of the given number field element. Coefficients are numbered from$0\$, starting with the constant coefficient.

source
Base.denominatorMethod
denominator(a::nf_elem)

Return the denominator of the polynomial representation of the given number field element.

source

Examples

R, x = PolynomialRing(QQ, "x")
K, a = NumberField(x^3 + 3x + 1, "a")

d = a^2 + 2a - 7
m = gen(K)

c = coeff(d, 1)
is_gen(m)
q = degree(K)
r, s = signature(K)
v = var(R)

### Norm and trace

Examples

R, x = PolynomialRing(QQ, "x")
K, a = NumberField(x^3 + 3x + 1, "a")

c = 3a^2 - a + 1

d = norm(c)
f = tr(c)