FiniteFieldPolynomial

FiniteFieldPolynomial()

A Symbolica polynomial over finite fields.

Methods

Name Description
adjoin Adjoin the coefficient ring of this polynomial R[a] with b, whose minimal polynomial
coefficient_list Get the coefficient list, optionally in the variables vars.
contains Check if the polynomial contains the given variable.
degree Get the degree of the polynomial in var.
derivative Take a derivative in x.
evaluate Evaluate the polynomial at the given values.
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.
parse Parse a polynomial with integer coefficients from a string.
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.
simplify_algebraic_number Find the minimal polynomial for the algebraic number represented by this polynomial
to_expression Convert the polynomial to an expression.
to_galois_field Convert the polynomial to a Galois field defined by the minimal polynomial minimal_poly.
to_integer_polynomial Convert the finite field polynomial to a polynomial with integer coefficients.
to_latex Convert the polynomial into a LaTeX string.
to_polynomial Convert a Galois field polynomial to a simple finite field polynomial.

adjoin

FiniteFieldPolynomial.adjoin(b, new_symbol=None)

Adjoin 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.

If new_symbol is provided, the variable of the new extension will be renamed to it. Otherwise, the variable of the new extension will be the same as that of b.

coefficient_list

FiniteFieldPolynomial.coefficient_list(vars=None)

Get the coefficient list, optionally in the variables vars.

Examples

>>> from symbolica import Expression
>>> 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

FiniteFieldPolynomial.contains(var)

Check if the polynomial contains the given variable.

degree

FiniteFieldPolynomial.degree(var)

Get the degree of the polynomial in var.

derivative

FiniteFieldPolynomial.derivative(x)

Take a derivative in x.

Examples

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

evaluate

FiniteFieldPolynomial.evaluate(values)

Evaluate the polynomial at the given values.

Examples

>>> from symbolica import *
>>> x, y = S('x', 'y')
>>> p = E('x*y+2*x+x^2').to_polynomial(modulus=5)
>>> print(p.evaluate([2, 3]))
4

extended_gcd

FiniteFieldPolynomial.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).

Examples

>>> from symbolica import *
>>> E('(1+x)(20+x)').to_polynomial(modulus=5).extended_gcd(E('x^2+2').to_polynomial(modulus=5))

yields (1, 3+4*x, 3+x).

factor

FiniteFieldPolynomial.factor()

Factorize the polynomial.

Examples

>>> from symbolica import Expression
>>> 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

FiniteFieldPolynomial.factor_square_free()

Compute the square-free factorization of the polynomial.

Examples

>>> from symbolica import Expression
>>> 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

FiniteFieldPolynomial.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

FiniteFieldPolynomial.gcd(*rhs)

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

get_minimal_polynomial

FiniteFieldPolynomial.get_minimal_polynomial()

Get the minimal polynomial of the algebraic extension.

get_variables

FiniteFieldPolynomial.get_variables()

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

groebner_basis

FiniteFieldPolynomial.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

FiniteFieldPolynomial.integrate(x)

Integrate the polynomial in x.

Examples

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

lcoeff

FiniteFieldPolynomial.lcoeff()

Get the leading coefficient.

Examples

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

Yields 3.

nterms

FiniteFieldPolynomial.nterms()

Get the number of terms.

parse

FiniteFieldPolynomial.parse(arg, vars, prime, default_namespace='python')

Parse a polynomial with integer coefficients from a string. The input must be written in an expanded format and a list of all the variables must be provided.

If these requirements are too strict, use Expression.to_polynomial() or RationalPolynomial.parse() instead.

Examples

>>> e = Polynomial.parse('3*x^2+y+y*4', ['x', 'y'], 5)

Raises

Name Type Description
ValueError If the input is not a valid Symbolica polynomial.

primitive

FiniteFieldPolynomial.primitive()

Get the primitive part of the polynomial, i.e., the polynomial with a leading coefficient of 1.

Examples

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

Yields x^2+2*x+3.

quot_rem

FiniteFieldPolynomial.quot_rem(rhs)

Divide self by rhs, returning the quotient and remainder.

reduce

FiniteFieldPolynomial.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

FiniteFieldPolynomial.reorder(order)

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

replace

FiniteFieldPolynomial.replace(x, v)

Replace the variable x with a polynomial v.

Examples

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

resultant

FiniteFieldPolynomial.resultant(rhs, var)

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

simplify_algebraic_number

FiniteFieldPolynomial.simplify_algebraic_number(minimal_poly)

Find the minimal polynomial for the algebraic number represented by this polynomial expressed in the number field defined by minimal_poly.

Examples

>>> from symbolica import *
>>> (min_poly, rep2, rep23) = P('a^2-2').adjoin(P('b^2-3'))
>>> rep2.simplify_algebraic_number(min_poly)

Yields b^2-2.

to_expression

FiniteFieldPolynomial.to_expression()

Convert the polynomial to an expression.

to_galois_field

FiniteFieldPolynomial.to_galois_field(minimal_poly)

Convert the polynomial to a Galois field defined by the minimal polynomial minimal_poly.

to_integer_polynomial

FiniteFieldPolynomial.to_integer_polynomial(symmetric_representation=True)

Convert the finite field polynomial to a polynomial with integer coefficients.

to_latex

FiniteFieldPolynomial.to_latex()

Convert the polynomial into a LaTeX string.

to_polynomial

FiniteFieldPolynomial.to_polynomial()

Convert a Galois field polynomial to a simple finite field polynomial.