NumberFieldPolynomial

NumberFieldPolynomial()

A Symbolica polynomial over number fields.

Methods

Name Description
coefficient_list Get the coefficient list, optionally in the variables vars.
contains Check if the polynomial contains the given variable.
content Get the content, i.e., the GCD of the coefficients.
degree Get the degree of the polynomial in var.
derivative Take a derivative in x.
extended_gcd Compute the extended GCD of two polynomials, yielding the GCD and the Bezout coefficients s and t
factor Factorize the polynomial.
factor_square_free Compute the square-free factorization of the polynomial.
format Convert the polynomial into a human-readable string, with tunable settings.
gcd Compute the greatest common divisor (GCD) of two or more polynomials.
get_minimal_polynomial Get the minimal polynomial of the algebraic extension.
get_variables Get the list of variables in the internal ordering of the polynomial.
groebner_basis Compute the Groebner basis of a polynomial system.
integrate Integrate the polynomial in x.
lcoeff Get the leading coefficient.
nterms Get the number of terms.
primitive Get the primitive part of the polynomial, i.e., the polynomial
quot_rem Divide self by rhs, returning the quotient and remainder.
reduce Completely reduce the polynomial w.r.t the polynomials gs.
reorder Set a new variable ordering for the polynomial.
replace Replace the variable x with a polynomial v.
resultant Compute the resultant of two polynomials with respect to the variable var.
to_expression Convert the polynomial to an expression.
to_latex Convert the polynomial into a LaTeX string.
to_polynomial Convert the polynomial to a polynomial over rationals.

coefficient_list

NumberFieldPolynomial.coefficient_list(vars=None)

Get the coefficient list, optionally in the variables vars.

Examples

>>> from symbolica import *
>>> x = S('x')
>>> p = E('x*y+2*x+x^2').to_polynomial()
>>> for n, pp in p.coefficient_list(x):
>>>     print(n, pp)

contains

NumberFieldPolynomial.contains(var)

Check if the polynomial contains the given variable.

content

NumberFieldPolynomial.content()

Get the content, i.e., the GCD of the coefficients.

Examples

>>> from symbolica import *
>>> p = E('3x^2+6x+9').to_polynomial()
>>> print(p.content())

degree

NumberFieldPolynomial.degree(var)

Get the degree of the polynomial in var.

derivative

NumberFieldPolynomial.derivative(x)

Take a derivative in x.

Examples

>>> from symbolica import *
>>> x = S('x')
>>> p = E('x^2+2').to_polynomial()
>>> print(p.derivative(x))

extended_gcd

NumberFieldPolynomial.extended_gcd(rhs)

Compute the extended GCD of two polynomials, yielding the GCD and the Bezout coefficients s and t such that self * s + rhs * t = gcd(self, rhs).

factor

NumberFieldPolynomial.factor()

Factorize the polynomial.

Examples

>>> from symbolica import *
>>> p = E('(x+1)(x+2)(x+3)(x+4)(x+5)(x^2+6)(x^3+7)(x+8)(x^4+9)(x^5+x+10)').expand().to_polynomial()
>>> print('Factorization of {}:'.format(p))
>>> for f, exp in p.factor():
>>>     print('\t({})^{}'.format(f, exp))

factor_square_free

NumberFieldPolynomial.factor_square_free()

Compute the square-free factorization of the polynomial.

Examples

>>> from symbolica import *
>>> p = E('3*(2*x^2+y)(x^3+y)^2(1+4*y)^2(1+x)').expand().to_polynomial()
>>> print('Square-free factorization of {}:'.format(p))
>>> for f, exp in p.factor_square_free():
>>>     print('\t({})^{}'.format(f, exp))

format

NumberFieldPolynomial.format(
    mode=Ellipsis,
    terms_on_new_line=False,
    color_top_level_sum=True,
    color_builtin_symbols=True,
    print_ring=True,
    symmetric_representation_for_finite_field=False,
    explicit_rational_polynomial=False,
    number_thousands_separator=None,
    multiplication_operator='*',
    double_star_for_exponentiation=False,
    square_brackets_for_function=False,
    num_exp_as_superscript=True,
    precision=None,
    show_namespaces=False,
    include_attributes=False,
    max_terms=None,
    custom_print_mode=None,
)

Convert the polynomial into a human-readable string, with tunable settings.

Examples

>>> p = FiniteFieldPolynomial.parse("3*x^2+2*x+7*x^3", ['x'], 11)
>>> print(p.format(symmetric_representation_for_finite_field=True))

gcd

NumberFieldPolynomial.gcd(*rhs)

Compute the greatest common divisor (GCD) of two or more polynomials.

get_minimal_polynomial

NumberFieldPolynomial.get_minimal_polynomial()

Get the minimal polynomial of the algebraic extension.

get_variables

NumberFieldPolynomial.get_variables()

Get the list of variables in the internal ordering of the polynomial.

groebner_basis

NumberFieldPolynomial.groebner_basis(system, grevlex=True, print_stats=False)

Compute the Groebner basis of a polynomial system.

If grevlex=True, reverse graded lexicographical ordering is used, otherwise the ordering is lexicographical.

If print_stats=True intermediate statistics will be printed.

integrate

NumberFieldPolynomial.integrate(x)

Integrate the polynomial in x.

Examples

>>> from symbolica import *
>>> x = S('x')
>>> p = E('x^2+2').to_polynomial()
>>> print(p.integrate(x))

lcoeff

NumberFieldPolynomial.lcoeff()

Get the leading coefficient.

Examples

>>> from symbolica import *
>>> p = E('3x^2+6x+9').to_polynomial().lcoeff()
>>> print(p)

Yields 3.

nterms

NumberFieldPolynomial.nterms()

Get the number of terms.

primitive

NumberFieldPolynomial.primitive()

Get the primitive part of the polynomial, i.e., the polynomial with the content removed.

Examples

>>> from symbolica import *
>>> p = E('3x^2+6x+9').to_polynomial().primitive()
>>> print(p)

Yields x^2+2*x+3.

quot_rem

NumberFieldPolynomial.quot_rem(rhs)

Divide self by rhs, returning the quotient and remainder.

reduce

NumberFieldPolynomial.reduce(system, grevlex=True)

Completely reduce the polynomial w.r.t the polynomials gs. For example reducing f=y^2+x by g=[x] yields y^2.

reorder

NumberFieldPolynomial.reorder(order)

Set a new variable ordering for the polynomial. This can be used to introduce new variables as well.

replace

NumberFieldPolynomial.replace(x, v)

Replace the variable x with a polynomial v.

Examples

>>> from symbolica import *
>>> x = S('x')
>>> p = E('x*y+2*x+x^2').to_polynomial()
>>> r = E('y+1').to_polynomial())
>>> p.replace(x, r)

resultant

NumberFieldPolynomial.resultant(rhs, var)

Compute the resultant of two polynomials with respect to the variable var.

to_expression

NumberFieldPolynomial.to_expression()

Convert the polynomial to an expression.

to_latex

NumberFieldPolynomial.to_latex()

Convert the polynomial into a LaTeX string.

to_polynomial

NumberFieldPolynomial.to_polynomial()

Convert the polynomial to a polynomial over rationals.