I'm trying to use subs in maple to replace derivatives in a longer formula with 0:
subs(diff(u(r),r) = 0, formula);
It seems that if formula only involves first derivatives of u(r) this works as I expect. For example,
formula := diff(u(r),r);
subs(diff(u(r),r) = 0, formula);
0
But if formula involves second derivatives I get a diff(0,r) in the result that won't go away even when using simplify:
formula := diff(u(r),r,r);
subs(diff(u(r),r) = 0, formula);
d
-- 0
dr
(My actual formula is quite long involving first and second derivatives of two variables. I know that all derivatives with respect to a certain variable are 0 and I'd like to remove them).
One way is to use the
simplifycommand with so-called side-relations.[edit] I forgot to answer your additonal query about why you got
d/dr 0before. The answer is because you usedsubsinstead of 2-argumenteval. The former does purely syntactic substitution, and doesn't evaluate the result. The latter is the one that people often need, without knowing it, and does "evaluation at a (particular) point".You can see that any evaluation of those
d/dr 0objects will produce 0. But it's is often better practice to use 2-argument eval than it is to doeval(subs(...)). People usesubsbecause it sounds like "substitution", I guess, or they see others use it. Sometimessubsis the right tool for the job, so it's important to know the difference.