| 1 | initial version |
You can use the substitute or subsmethods:
sage: a, b, x, y = SR.var('a b x y')
sage: expr = x^2 + sin(x) - x*y + exp(sin(y)-x)
sage: expr
x^2 - x*y + e^(-x + sin(y)) + sin(x)
sage: expr.subs({x: a, y: b})
a^2 - a*b + e^(-a + sin(b)) + sin(a)
See also:
expr.subsexpr.substitute_functionexpr.substituteexpr.substitution_delayedTo get the documentation for those, define expr as above and type for example one of:
expr.substitute_function?browse_sage_doc(expr.substitute_function)One will give you text-mode help, and the other will render in html in a browser.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.