NumberFieldPolynomial

NumberFieldPolynomial()

A Symbolica polynomial with rational coefficients.

Methods

Name Description
coefficient_list Get the coefficient list, optionally in the variables xs.
content Get the content, i.e., the GCD of the coefficients.
derivative Take a derivative in x.
extend Extend the coefficient ring of this polynomial R[a] with b, whose minimal polynomial
factor Factorize the polynomial.
factor_square_free Compute the square-free factorization of the polynomial.
gcd Compute the greatest common divisor (GCD) of two polynomials.
get_minimal_polynomial Get the minimal polynomial of the algebraic extension.
get_var_list 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.
nterms Get the number of terms in the polynomial.
pretty_str Convert the polynomial into a human-readable string, with tunable settings.
quot_rem Divide self by rhs, returning the quotient and remainder.
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.

coefficient_list

NumberFieldPolynomial.coefficient_list(xs)

Get the coefficient list, optionally in the variables xs.

Examples

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

content

NumberFieldPolynomial.content()

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

Examples

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

derivative

NumberFieldPolynomial.derivative(x)

Take a derivative in x.

Examples

>>> from symbolica import Expression
>>> x = Expression.symbol('x')
>>> p = Expression.parse('x^2+2').to_polynomial()
>>> print(p.derivative(x))

extend

NumberFieldPolynomial.extend(b)

Extend the coefficient ring of this polynomial R[a] with b, whose minimal polynomial is R[a][b] and form R[b]. Also return the new representation of a and b.

b must be irreducible over R and R[a]; this is not checked.

factor

NumberFieldPolynomial.factor()

Factorize the polynomial.

Examples

>>> from symbolica import Expression
>>> p = Expression.parse('(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(' ({})^{}'.format(f, exp))

factor_square_free

NumberFieldPolynomial.factor_square_free()

Compute the square-free factorization of the polynomial.

Examples

>>> from symbolica import Expression
>>> p = Expression.parse('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(' ({})^{}'.format(f, exp))

gcd

NumberFieldPolynomial.gcd(rhs)

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

get_minimal_polynomial

NumberFieldPolynomial.get_minimal_polynomial()

Get the minimal polynomial of the algebraic extension.

get_var_list

NumberFieldPolynomial.get_var_list()

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

groebner_basis

NumberFieldPolynomial.groebner_basis(_cls, 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 Expression
>>> x = Expression.symbol('x')
>>> p = Expression.parse('x^2+2').to_polynomial()
>>> print(p.integrate(x))

nterms

NumberFieldPolynomial.nterms()

Get the number of terms in the polynomial.

pretty_str

NumberFieldPolynomial.pretty_str(terms_on_new_line=False, color_top_level_sum=True, color_builtin_symbols=True, print_finite_field=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, latex=False)

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

Examples

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

Yields z³⁴+x^(x+2)+y⁴+f(x,x²)+128_378_127_123 z^(2/3) w² x⁻¹ y⁻¹+3/5.

quot_rem

NumberFieldPolynomial.quot_rem(rhs)

Divide self by rhs, returning the quotient and remainder.

replace

NumberFieldPolynomial.replace(x, v)

Replace the variable x with a polynomial v.

Examples

>>> from symbolica import Expression
>>> x = Expression.symbol('x')
>>> p = Expression.parse('x*y+2*x+x^2').to_polynomial()
>>> r = Expression.parse('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.

Examples

>>> from symbolica import Expression
>>> e = Expression.parse('x*y+2*x+x^2')
>>> p = e.to_polynomial()
>>> print((e - p.to_expression()).expand())

to_latex

NumberFieldPolynomial.to_latex()

Convert the polynomial into a LaTeX string.