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.