Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

With some algebraic manipulation and the substitute command, you can partly get what you want. Of course, I think it will depend on how big of a mess the expressions are. For your example above, the following works for me:

X=X.subs(a==S1+b)
X=X.subs(d == S2*1/S1*(1+S1)).simplify()

As you wanted, this produces S2^2 + S1 + S2 + e^S2. Unfortunately, this approach still leaves you to manually determine what S1 and S2 should be, which is not what you wanted. I'm not sure how to automate this completely as you suggest.