14.3 Integral basis

How do you compute an integral basis of a number field in Sage?

Sage can compute a list of elements of this number field that are a basis for the full ring of integers of a number field.

sage: x = PolynomialRing(QQ, 'x').gen()
sage: K = NumberField(x^5+10*x+1, 'a')
sage: K.integral_basis()
[1, a, a^2, a^3, a^4]

Next we compute the ring of integers of a cubic field in which 2 is an ``essential discriminant divisor'', so the ring of integers is not generated by a single element.

sage: x = PolynomialRing(QQ, 'x').gen()
sage: K = NumberField(x^3 + x^2 - 2*x + 8, 'a')
sage: K.integral_basis()
[1, a, 1/2*a^2 + 1/2*a]

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