Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

subs: for function and its derivative

Hello,

if you have an expression like

y=function("y")(x)
f=diff(y,x)+5*y

and would like replace y by x^2,

I would normally call

f.subs(y==x^2).show()

But this only substitutes the y in the second term, but not the function y in the derivative. So, in order to do that I do

f.subs(y==x^2).subs(diff(y,x)==diff(x^2,x)).show()

This works and I can live with this, but I was wondering if there is a "short cut" to replace the function y in the second term as well as the function y in the derivative at the same time?

I am looking for something similar to

(D[y[x],x]+5y[x])/.y->Function[x,x^2]

in Mathematica.