P

Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.

P

P has 3 variants:

P returning Polynomial

P(
    poly: str,
    default_namespace: str | None = None,
    vars: Sequence[Expression] | None = None,
) -> Polynomial

Parse a string a polynomial, optionally, with the variable ordering specified in vars. All non-polynomial parts will be converted to new, independent variables.

Parameters

  • poly (str) The polynomial expression to parse.
  • default_namespace (str | None) The namespace assumed for unqualified symbols during parsing.
  • vars (Sequence[Expression] | None) The variables to treat as polynomial variables, in the given order.

P returning NumberFieldPolynomial

P(
    poly: str,
    minimal_poly: Polynomial,
    default_namespace: str | None = None,
    vars: Sequence[Expression] | None = None,
) -> NumberFieldPolynomial

Parse string to a polynomial, optionally, with the variables and the ordering specified in vars. All non-polynomial elements will be converted to new independent variables.

The coefficients will be converted to a number field with the minimal polynomial minimal_poly. The minimal polynomial must be a monic, irreducible univariate polynomial.

Parameters

  • poly (str) The polynomial expression to parse.
  • minimal_poly (Polynomial) The minimal polynomial that defines the algebraic extension.
  • default_namespace (str | None) The namespace assumed for unqualified symbols during parsing.
  • vars (Sequence[Expression] | None) The variables to treat as polynomial variables, in the given order.

P returning FiniteFieldPolynomial

P(
    poly: str,
    modulus: int,
    default_namespace: str | None = None,
    power: tuple[int, Expression] | None = None,
    minimal_poly: Polynomial | None = None,
    vars: Sequence[Expression] | None = None,
) -> FiniteFieldPolynomial

Parse a string to a polynomial, optionally, with the variables and the ordering specified in vars. All non-polynomial elements will be converted to new independent variables.

The coefficients will be converted to finite field elements modulo modulus. If on top a power is provided, for example (2, a), the polynomial will be converted to the Galois field GF(modulus^2) where a is the variable of the minimal polynomial of the field.

If a minimal_poly is provided, the Galois field will be created with minimal_poly as the minimal polynomial.

Parameters

  • poly (str) The polynomial expression to parse.
  • modulus (int) The modulus that defines the finite field.
  • default_namespace (str | None) The namespace assumed for unqualified symbols during parsing.
  • power (tuple[int, Expression] | None) The extension degree and generator that define the finite field.
  • minimal_poly (Polynomial | None) The minimal polynomial that defines the algebraic extension.
  • vars (Sequence[Expression] | None) The variables to treat as polynomial variables, in the given order.