cancel_expression
Simplifies a rational expression to canonical p/q form by cancelling common factors, making it easier to analyze or compare algebraic expressions.
Instructions
Puts a rational expression in canonical form p/q with common factors cancelled.
Uses SymPy's cancel function. Cancellation is formal: (x**2 - 1)/(x - 1)
becomes x + 1, even though the original is undefined at x = 1.
Args:
expr_key: The key of the expression (previously introduced) to cancel.
Example:
intro("x", [Assumption.REAL], [])
expr_key = introduce_expression("(x**2 - 1)/(x**2 - 2*x + 1)")
result_key = cancel_expression(expr_key)
# (x + 1)/(x - 1)
Returns:
A key for the simplified rational expression.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr_key | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |