factor_expression
Factors polynomials and rational expressions over rationals, Gaussian rationals, or a finite field, returning a key to the factored result for symbolic algebra workflows.
Instructions
Factors a polynomial or rational expression using SymPy's factor function.
By default the factorization is over the rationals. Equations are factored side by side.
Args:
expr_key: The key of the expression (previously introduced) to factor.
gaussian: If True, factor over the Gaussian rationals Q(i), e.g. x**2 + 1 = (x - i)(x + i).
modulus: Optional prime p to factor over the finite field GF(p).
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("x**6 - 1")
result_key = factor_expression(expr_key)
# (x - 1)(x + 1)(x^2 - x + 1)(x^2 + x + 1)
Returns:
A key for the factored expression.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| modulus | No | ||
| expr_key | Yes | ||
| gaussian | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |