| Author |
Comment/Response |
Bill Simpson
|
08/28/12 5:04pm
Is this what you are trying to do?
In[1]:= exp1[r_]:=D[b[r],r]+D[n[r],r]
In[2]:= exp1[r]/.{f_[r_]->Function[r,f[1/r]],r->1/x}
Out[2]= Function[r,b′[1/r]]+Function[r,n′[1/r]]
In Mathematica, pattern matching an _ will match absolutely anything at all and pattern matching f_ will match absolutely anything at all (and name it f for you to use in the rest of the expression) so f_ is probably too general. Pattern matching f_[r_] will match any function, call it f, and match the argument of the function and call that r. That appears to be closer to what you want to do but I cannot be certain.
URL: , |
|