Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
    
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 Sep 20 '13 at 22:23
1  
Try sol = DSolve[eq, \[Psi], r] instead –  belisarius Sep 20 '13 at 22:58

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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