FiniteFieldPolynomial
FiniteFieldPolynomial()
A Symbolica polynomial with finite field 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 . |
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_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. |
parse | Parse a polynomial with integer coefficients from a string. |
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
FiniteFieldPolynomial.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
FiniteFieldPolynomial.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
FiniteFieldPolynomial.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))
factor
FiniteFieldPolynomial.factor()
Factorize the polynomial.
The polynomial must be univariate.
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().to_finite_field(7)
>>> print('Factorization of {}:'.format(p))
>>> for f, exp in p.factor():
>>> print(' ({})^{}'.format(f, exp))
factor_square_free
FiniteFieldPolynomial.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().to_finite_field(7)
>>> print('Square-free factorization of {}:'.format(p))
>>> for f, exp in p.factor_square_free():
>>> print(' ({})^{}'.format(f, exp))
gcd
FiniteFieldPolynomial.gcd(rhs)
Compute the greatest common divisor (GCD) of two polynomials.
get_var_list
FiniteFieldPolynomial.get_var_list()
Get the list of variables in the internal ordering of the polynomial.
groebner_basis
FiniteFieldPolynomial.groebner_basis(_cls, system, grevlex=True, print_stats=False)
Compute the Groebner basis of a polynomial system.
Examples
>>> basis = Polynomial.groebner_basis(
>>> [Expression.parse("a b c d - 1").to_polynomial(),
>>> Expression.parse("a b c + a b d + a c d + b c d").to_polynomial(),
>>> Expression.parse("a b + b c + a d + c d").to_polynomial(),
>>> Expression.parse("a + b + c + d").to_polynomial()],
>>> grevlex=True,
>>> print_stats=True
>>> )
>>> for p in basis:
>>> print(p)
Parameters
Name | Type | Description | Default |
---|---|---|---|
grevlex |
bool | If True , reverse graded lexicographical ordering is used, otherwise the ordering is lexicographical. |
True |
print_stats |
bool | If True , intermediate statistics will be printed. |
False |
integrate
FiniteFieldPolynomial.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
FiniteFieldPolynomial.nterms()
Get the number of terms in the polynomial.
parse
FiniteFieldPolynomial.parse(_cls, input, vars, prime)
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 = FiniteFieldPolynomial.parse('18*x^2+y+y*4', ['x', 'y'], 17)
Raises
Type | Description |
---|---|
ValueError | If the input is not a valid Symbolica polynomial. |
pretty_str
FiniteFieldPolynomial.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 = FiniteFieldPolynomial.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
FiniteFieldPolynomial.quot_rem(rhs)
Divide self
by rhs
, returning the quotient and remainder.
replace
FiniteFieldPolynomial.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
FiniteFieldPolynomial.resultant(rhs, var)
Compute the resultant of two polynomials with respect to the variable var
.
to_expression
FiniteFieldPolynomial.to_expression()
Convert the polynomial to an expression.
to_latex
FiniteFieldPolynomial.to_latex()
Convert the polynomial into a LaTeX string.