I'm a little confused with how to use the output from DSolve. The following works

s = DSolve[{y'[x] == x, y[0] == 0}, y[x], x];
Plot[y[x] /. s, {x, 1, 10}]

but I don't understand how it works. I am familiar with /. a -> b which will replace a with b, but I don't get what y[x] /. s is doing?


Dsolve[], like Solve[] (but unlike Resolve[]) returns replacement rules. You are replacing the value of y[]returned by your solve command

|improve this answer|||||
  • $\begingroup$ Thanks. I see whats going on. I can declare a mapping such as map = {a->b}; then i can use this mapping variable in a any ReplaceAll command i.e a /. map or {a,a} /. map. $\endgroup$ – David McHarg Jan 26 '13 at 2:10
  • $\begingroup$ @David Yes. Replacement rules (term rewriting) are very important in Mathematica. $\endgroup$ – Dr. belisarius Jan 26 '13 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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