4.12.2.1 NumberFieldElement Objects

class NumberFieldElement
An element of a number field.
NumberFieldElement( parent, f)

INPUT:
    parent -- a number field
    f -- defines an element of a number field.

The following examples illustrate creation of elements of number fields, and some basic arithmetic.

First we define a polynomial over Q.

sage: from rational_field import RationalField
sage: from polynomial_ring import PolynomialRing
sage: from number_field import NumberField
sage: x = PolynomialRing(RationalField()).gen()
sage: f = x**2 + 1

Next we use f to define the number field.

sage: K = NumberField(f, "a"); K
Number Field with defining polynomial x^2 + 1
sage: a = K.gen()
sage: a**2
-1
sage: (a+1)**2
2*a
sage: a**2
-1
sage: z = K(5); 1/z
1/5

We create a cube root of 2.

sage: K = NumberField(x**3 - 2, "b")
sage: b = K.gen()
sage: b**3
2
sage: (b**2 + b + 1)**3
12*b^2 + 15*b + 19

Instances of class NumberFieldElement have the following methods (in addition to inherited methods and special methods):

matrix,$  $ pari

These methods are defined as follows:

matrix( )

The matrix of left multiplication by the element on the power basis $ 1, x, x^2, \ldots, x^{d-1}$ for the number field.

pari( [var=None])

Return PARI representation of self.

Instances of class NumberFieldElement also have the following special methods:

__mul__( other)

Returns the product of self and other as elements of a number field.

NOTES: In LiDIA, they build a multiplication table for the number field, so it's not necessary to reduce modulo the defining polynomial every time: src/number_fields/algebraic_num/order.cc: compute_table

See About this document... for information on suggesting changes.