6.8.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 in a 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):

charpoly,$  $ list,$  $ matrix,$  $ minpoly,$  $ norm,$  $ order,$  $ polynomial,$  $ trace

Further documentation:

matrix( )

The matrix of right multiplication by the element on the power basis $ 1, x, x^2, \ldots, x^{d-1}$ for the number field. Thus the rows of this matrix give the images of each of the $ x^i$ .

Instances of class NumberFieldElement also have the following special methods:

__add__,$  $ __cmp__,$  $ __div__,$  $ __int__,$  $ __invert__,$  $ __long__,$  $ __mul__,$  $ __neg__,$  $ __pow__,$  $ __repr__,$  $ __sub__,$  $ _integer_,$  $ _pari_,$  $ _rational_

Further documentation:

__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

_pari_( [var=None])

Return PARI representation of self.

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