Skip to content
Symi Docs
Python
On this page

Polynomial queries

These take ordinary expressions plus a variable name; the named variable becomes the main polynomial variable and every other free variable rides along symbolically in the coefficients. An expression that is not polynomial in the variable (a transcendental call of it, a non-integer power of it) makes the query decline — None for degree, an error for the others.

degree#

Default context

degree(
    input_expression: ExpressionLike,
    variable: VariableLike,
) -> Optional[int]
Calling forms

Explicit context: Context.degree

degree(
    input_expression: ExpressionLike,
    variable: VariableLike,
) -> Optional[int]

Degree in variable. None when the expression is not polynomial in variable or is identically zero (the zero polynomial has no degree under the core convention).

leading_coefficient#

Default context

leading_coefficient(
    input_expression: ExpressionLike,
    variable: VariableLike,
) -> Expression
Calling forms

Explicit context: Context.leading_coefficient

leading_coefficient(
    input_expression: ExpressionLike,
    variable: VariableLike,
) -> Expression

Coefficient of the highest power of variable; may contain the other free variables. Errors on non-polynomial or zero input.

coefficient#

Default context

coefficient(
    input_expression: ExpressionLike,
    variable: VariableLike,
    power: int,
) -> Expression
Calling forms

Explicit context: Context.coefficient

coefficient(
    input_expression: ExpressionLike,
    variable: VariableLike,
    power: int,
) -> Expression

Coefficient of variable^power; integer 0 when the term is absent. Errors on non-polynomial input.

polynomial_gcd#

Default context

polynomial_gcd(
    a: ExpressionLike,
    b: ExpressionLike,
    variable: VariableLike,
) -> Expression
Calling forms

Explicit context: Context.polynomial_gcd

polynomial_gcd(
    a: ExpressionLike,
    b: ExpressionLike,
    variable: VariableLike,
) -> Expression

Greatest common divisor of the two expressions as polynomials in variable (primitive, with the core's sign normalisation). Errors when either input is not polynomial in variable.

resultant#

Default context

resultant(
    a: ExpressionLike,
    b: ExpressionLike,
    variable: VariableLike,
) -> Expression
Calling forms

Explicit context: Context.resultant

resultant(
    a: ExpressionLike,
    b: ExpressionLike,
    variable: VariableLike,
) -> Expression

Resultant with respect to variable; zero exactly when the two polynomials share a root (over the algebraic closure). Errors on non-polynomial input.

isolate_real_roots#

Default context

isolate_real_roots(
    input_expression: ExpressionLike,
    variable: VariableLike,
) -> list[tuple[Expression, Expression]]
Calling forms

Explicit context: Context.isolate_real_roots

isolate_real_roots(
    input_expression: ExpressionLike,
    variable: VariableLike,
) -> list[tuple[Expression, Expression]]

One (lower, upper) rational isolating interval per distinct real root, sorted ascending; a collapsed pair (r, r) marks an exact rational root. Requires a non-zero univariate polynomial with rational coefficients. Notes: WASM returns IsolatingInterval objects with lower/upper getters.

isolating_interval (WASM result class)#

lower#

Not exposed by the Python bindings. Available as UniffiIsolatingInterval.lower in Kotlin, UniffiIsolatingInterval.lower in Swift, api::results::IsolatingInterval::lower in Rust.

upper#

Not exposed by the Python bindings. Available as UniffiIsolatingInterval.upper in Kotlin, UniffiIsolatingInterval.upper in Swift, api::results::IsolatingInterval::upper in Rust.

Gröbner bases and ideals#

These operate over the polynomial ring Q[variables]\mathbb{Q}[\text{variables}]. Generators are passed as an expression list; the ring variables are named by a string list; the monomial order is named by a string ("lexicographic" / "lex", "degree_lexicographic" / "deglex", or "degree_reverse_lexicographic" / "degrevlex", the computational default). Any generator that is not a polynomial over Q\mathbb{Q} in the named variables — a transcendental call, a non-integer power, an unnamed symbol, or an irrational coefficient — makes the operation decline cleanly (Python None, WASM null); it never returns a wrong or partial answer. Within Q[variables]\mathbb{Q}[\text{variables}] the results are exact and complete: a returned basis is the canonical reduced Gröbner basis, membership is a genuine decision, and elimination is exact by the Elimination Theorem.

Performance. The basis is computed by F4 (Faugère's batched Macaulay-matrix reduction), with a signature-based engine (F5 / GVW) available internally; the reference Buchberger algorithm is retained as the differential oracle these are checked against. The choice of engine is an internal acceleration only: the result is identical to the reference Buchberger basis for every input, and the monomial-order argument and the whole binding surface are unchanged. These entry points simply run faster — there is no new method to call.

groebner_basis#

Default context

groebner_basis(
    generators: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]
Calling forms

Explicit context: Context.groebner_basis

groebner_basis(
    generators: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]

The canonical reduced Gröbner basis of the ideal <generators> under the named monomial order — monic, autoreduced, and sorted, so it is unique for the (ideal, order) pair. None when any generator is outside Q[variables]\mathbb{Q}[\text{variables}].

ideal_membership#

Default context

ideal_membership(
    element: ExpressionLike,
    generators: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[bool]
Calling forms

Explicit context: Context.ideal_membership

ideal_membership(
    element: ExpressionLike,
    generators: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[bool]

Whether element lies in the ideal <generators>, decided by reducing it to its normal form modulo the Gröbner basis (zero exactly when it is a member). The verdict is independent of the order. None when the element or a generator is outside Q[variables]\mathbb{Q}[\text{variables}].

ideal_sum#

Default context

ideal_sum(
    generators_left: Iterable[ExpressionLike],
    generators_right: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]
Calling forms

Explicit context: Context.ideal_sum

ideal_sum(
    generators_left: Iterable[ExpressionLike],
    generators_right: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]

A Gröbner basis of the ideal sum I + J, the ideal generated by the two generator lists together. None on a non-Q[variables]\mathbb{Q}[\text{variables}] generator.

ideal_product#

Default context

ideal_product(
    generators_left: Iterable[ExpressionLike],
    generators_right: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]
Calling forms

Explicit context: Context.ideal_product

ideal_product(
    generators_left: Iterable[ExpressionLike],
    generators_right: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]

A Gröbner basis of the ideal product IJI J, generated by all pairwise products of the two generator lists. None on a non-Q[variables]\mathbb{Q}[\text{variables}] generator.

ideal_intersection#

Default context

ideal_intersection(
    generators_left: Iterable[ExpressionLike],
    generators_right: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]
Calling forms

Explicit context: Context.ideal_intersection

ideal_intersection(
    generators_left: Iterable[ExpressionLike],
    generators_right: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    order: Optional[str] = None,
) -> Optional[list[Expression]]

A generating set of the ideal intersection I∩JI \cap J, computed by the standard tag-variable elimination construction tI+(1−t)Jt I + (1-t) J. None on a non-Q[variables]\mathbb{Q}[\text{variables}] generator.

elimination_ideal#

Default context

elimination_ideal(
    generators: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    eliminate: Iterable[VariableLike],
) -> Optional[list[Expression]]
Calling forms

Explicit context: Context.elimination_ideal

elimination_ideal(
    generators: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    eliminate: Iterable[VariableLike],
) -> Optional[list[Expression]]

A Gröbner basis of the elimination ideal ⟨generators⁡⟩∩Q[surviving variables]\langle\operatorname{generators}\rangle \cap \mathbb{Q}[\text{surviving variables}], projecting away the variables named in eliminate via the Elimination Theorem (a block order ranks the eliminated variables high and the generators free of them are kept). Exact: it neither drops nor introduces components. None on a non-Q[variables]\mathbb{Q}[\text{variables}] generator. Example: eliminating t from {x−t2,y−t3}\{x - t^2, y - t^3\} returns the twisted-cubic implicit equation y2−x3y^2 - x^3.

Order change and implicitisation#

These consume a Gröbner basis rather than compute one from scratch. The order change runs the standard FGLM algorithm; implicitisation is parameter elimination with the rational-parametrisation saturation wired in.

change_monomial_order#

Default context

change_monomial_order(
    basis: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    source_order: str,
    target_order: str,
) -> Optional[list[Expression]]
Calling forms

Explicit context: Context.change_monomial_order

change_monomial_order(
    basis: Iterable[ExpressionLike],
    variables: Iterable[VariableLike],
    source_order: str,
    target_order: str,
) -> Optional[list[Expression]]

Convert a Gröbner basis of a zero-dimensional ideal from source_order to target_order by FGLM (Faugère–Gianni–Lazard–Mora) — linear algebra in the finite-dimensional quotient ring Q[variables]/I\mathbb{Q}[\text{variables}]/I, far cheaper than computing the target basis directly (the msolve route to a lexicographic basis is a cheap degrevlex basis followed by this conversion). The result is the canonical reduced Gröbner basis under target_order, identical to a direct groebner_basis call. None when the ideal is positive-dimensional (the quotient ring is infinite-dimensional, so FGLM does not apply) or any generator is outside Q[variables]\mathbb{Q}[\text{variables}].

implicitize#

Default context

implicitize(
    coordinates: Iterable[VariableLike],
    parameters: Iterable[VariableLike],
    parametric_expressions: Iterable[ExpressionLike],
) -> Optional[list[Expression]]
Calling forms

Explicit context: Context.implicitize

implicitize(
    coordinates: Iterable[VariableLike],
    parameters: Iterable[VariableLike],
    parametric_expressions: Iterable[ExpressionLike],
) -> Optional[list[Expression]]

The implicit ideal of a parametric curve or surface xi=fi(parameters⁡)x_i = f_i(\operatorname{parameters}) (the i-th coordinate paired with the i-th parametric expression), returned as a generator list over Q[coordinates]\mathbb{Q}[\text{coordinates}] — the elimination of the parameters (Cox–Little–O'Shea ch. 3). A polynomial parametrisation eliminates the parameters directly; a rational one fi=pi/qif_i = p_i/q_i clears denominators and saturates by the denominator product through a fresh tag variable, so the eliminant is the true implicit equation rather than a multiple carrying spurious components. None when a parametric expression is outside Q(parameters⁡)\mathbb{Q}(\operatorname{parameters}) or there are no parameters. Examples: {x=t2,y=t3}\{x = t^2, y = t^3\} returns y2−x3y^2 - x^3; {x=(1−t2)/(1+t2),y=2t/(1+t2)}\{x = (1 - t^2)/(1 + t^2), y = 2t/(1 + t^2)\} returns x2+y2−1x^2 + y^2 - 1.

Example#

Polynomial structure is read through explicit generators.

Python
import symi

x = symi.symbol("x")
polynomial = x**3 - 2 * x + 1

print(symi.degree(polynomial, "x"))
print(symi.leading_coefficient(polynomial, "x"))
print(symi.coefficient(polynomial, "x", 1))
print(symi.polynomial_gcd(x**2 - 1, x - 1, "x"))
print(symi.resultant(x**2 - 1, x - 1, "x"))

Symi documentation · Python