I have this differential equation:


And DSolve sucessfully solves it:

sol = DSolve[eq,ψ[r],r];

But when I check by replacing all, in this case it doesn't replace the derivative of the function:


Derivative still must be replaced too. If I do:


Then this gives True.

In other cases Mathematica replaced the function and its derivatives in one shot. What's happening in this case?


1 Answer 1


When you use DSolve[eq,f,x] you get a rule for the function. When you use DSolve[eq,f[x],x] you get a rule for the function evaluated at value x.

When you use f[x]->blah, Mathematica will replace all occurrences of f[x] but it will leave the occurrences of f'[x] untouched. That happens because you have not defined the function f, so Mathematica does not know that it should create another replacement rule (your D[sol,r]).

When you use f->blah, Mathematica replaces all occurrences of f and that includes not only f[x] but also Derivative[1][f][x] (which is the internal representation of f'[x]).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.