# Checking differential equation solution

I have this differential equation:

eq=D[ψ[r],r]+A*ψ[r]-(B/(A*r))ψ[r]==0;


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:

Simplify[eq/.sol]


Derivative still must be replaced too. If I do:

Simplify[eq/.sol/.D[sol,r]]


Then this gives True.

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

-
No, it's a different case. Look here: reference.wolfram.com/mathematica/howto/…. This states da if I do like that, it is sufficient to verify my solution. But in this particular case, I have to do an extra substitution. – Giovanni F. Sep 20 '13 at 22:23
Try sol = DSolve[eq, \[Psi], r] instead – Dr. belisarius Sep 20 '13 at 22:58

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]).