| 1 | initial version |
You can use the method subs:
sage: e1 = cos(x) + sin(x) - exp(x) + x^2/3
sage: e2 = sin(x)
sage: e3 = 1/x + 1/x^2
sage: e1.subs({e2:e3})
1/3*x^2 + 1/x + 1/x^2 + cos(x) - e^x
Note though that it won't work with too complicated expressions for e2. For more on this, you may have a look to the documentation of subs in the reference manual.
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.