daj
daj

Reputation: 7183

maxima CAS - how to substitute variable for an expression?

In maxima, is there a way to apply variable substitutions for a subexpression? For example, replace instances of x+y with z.

subst works for the trivial case, but not for anything more than that.

(%i92) subst(x + y = foo, x + y);
(%o93) foo
(%i94) subst(x + y = foo, x + y + z);
(%o95) z + y + x

Upvotes: 3

Views: 3908

Answers (1)

Robert Dodier
Robert Dodier

Reputation: 17574

I think ratsubst has the effect you want.

(%i2) ratsubst(foo, x+y, x+y+z);
(%o2)                               z + foo

Upvotes: 9

Related Questions