laurent#

Utilities for manipulating (Laurent) polynomials with SymPy: - reciprocal transforms f(x) -> f(x^{-1}) - normalization for ordinary and Laurent polynomials - symmetric normalization under t ↔ 1/t - canonicalization under permutations of variables

Functions

extract_variables(expr[, prefix])

Extract variables of the form <prefix><digits> from a SymPy expression.

laurent_to_tuples(expr[, variables])

Return a list of (exponents, coefficient) where:

normalize_laurent(expr[, variables, ...])

normalize_symmetric(expr, variable)

Normalize a Laurent polynomial symmetrically in a single variable.

reciprocal(expr, var)

Return the reciprocal transform of a polynomial in a given variable.

tuples_to_laurent(pairs, variables)

Reconstruct an expanded SymPy expression from (exponents, coefficient) pairs.

reciprocal(expr, var)#

Return the reciprocal transform of a polynomial in a given variable.

Applies the substitution var → var**(-1) and expands.

Parameters:
  • expr (Expr) – SymPy expression.

  • var – The variable to invert (Symbol or its name).

Returns:

Expr – The transformed expression.

Return type:

Expr

normalize_laurent(expr, variables=None, allow_variable_sign_change=False, allow_variable_permutation=False, allow_polynomial_sign_change=False)#
Parameters:
  • expr (Expr | Poly)

  • variables (Iterable[Symbol] | Symbol | None)

  • allow_variable_sign_change (bool)

  • allow_variable_permutation (bool)

  • allow_polynomial_sign_change (bool)

extract_variables(expr, prefix=None)#

Extract variables of the form <prefix><digits> from a SymPy expression.

Examples

  • prefix=None → returns all symbols like t1, x2, a10, grouped by (prefix, index)

  • prefix=”t” → returns only t1, t2, …

Parameters:
  • expr (Expr) – SymPy expression.

  • prefix (str | None) – Optional prefix filter.

Returns:

list[Symbol] – Symbols sorted by (prefix, numeric index).

Return type:

list[Symbol]