Ask Your Question

Revision history [back]

You will have to struggle with wildcards, see examples on the page:

https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/expression.html#sage.symbolic.expression.Expression.match

If the substitution involves both right-hand side and left-hand side of the equation expr, first put everything on a single side:

e = expr.rhs() - expr.lhs() == 0

or

e = expr.rhs() / expr.lhs() == 1