Re-writing expressions

30 views
Skip to first unread message

Alexander Lindsay

unread,
May 13, 2015, 4:00:48 PM5/13/15
to sy...@googlegroups.com
Hi all,

I am taking the derivative with respect to a variable, let's call it x, of a complicated expression, let's call it y. A lot of y' can be rewritten in terms of y. In a very simple case, y = exp(x) => y' = exp(x) = y

When I take diff(y,x), obviously I get exp(x)

Is there a way for me to automatically re-write my answer in terms of y? Something along the lines of expr.rewrite(func) ? It's trivial to do it manually in this case, but for more complicated expressions it would be really neat to be able to automate this

Aaron Meurer

unread,
May 13, 2015, 4:29:54 PM5/13/15
to sy...@googlegroups.com
In general use expr.subs or expr.replace to replace one expression with another.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/91481459-5d16-47b6-a819-69c1ed608549%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Alexander Lindsay

unread,
May 14, 2015, 11:22:21 AM5/14/15
to sy...@googlegroups.com
Excellent, thanks!
Reply all
Reply to author
Forward
0 new messages