2
$\begingroup$

I'm have a Abel's differential equation:

sol1 = DSolve[{y'[x]*y[x] - y[x] == 1/x^2, y[1/10] == 1/10}, y[x], x];
plot = (sol1[[1, 1]] /. y[x] -> y);
ContourPlot[plot == 0, {x, 0.1, 10}, {y, 0, 14}]

enter image description here

Works fine, but with this:

ContourPlot[(sol1[[1, 1]] /. y[x] -> y) == 0, {x, 0.1, 10}, {y, 0, 14}]

enter image description here

$\endgroup$
  • $\begingroup$ I have Mathematica 10.2.0.0 on Windows 8.1. $\endgroup$ – Mariusz Iwaniuk Oct 6 '15 at 11:27
  • $\begingroup$ Use Evaluate i.e. ContourPlot[Evaluate[(sol1[[1, 1]] /. y[x] -> y) == 0], {x, 0.1, 10}, {y, 0, 14}] $\endgroup$ – demm Oct 6 '15 at 11:57
2
$\begingroup$

The message

Mathematica graphics

occurs because the Solve command is reevaluated because sol1 is evaluated when the argument to ContourPlot is evaluated symbolically.

The message

Mathematica graphics

occurs when the argument is evaluated with numeric values substituted for x and y. (In my thinking, one should see more than one of these messages. Some testing using Check[(sol1[[1, 1]] /. y[x] -> y) - 0,...] as an argument suggests ContourPlot suppresses the message after the first time it is emitted.)

Some evidence:

Block[{x, y}, (sol1[[1, 1]] /. y[x] -> y) - 0];
Block[{x = 0.1, y = 0.}, (sol1[[1, 1]] /. y[x] -> y) - 0]

Mathematica graphics

Also, the second Block actually results in a valid call to Solve. Here is a simpler example:

Block[{x = 0.1, y = 0.},
 ((Print[#]; ReleaseHold[#]) &@
   HoldForm[Solve][y[x]^2 == x, y[x]]) /. y[x] -> y
 ]
(*
  Solve[0.[0.1]^2==0.1,0.[0.1]]
  {{0. -> -0.316228}, {0. -> 0.316228}}
*)

[Note: I assumed the OP knew that applying Evaluate to the argument would reproduce the OP's first example. I thought the question was about what was going on in the second case.]

$\endgroup$
5
$\begingroup$

This is not an answer to the error messages, but why make life so difficult for oneself when you can make it easy?

sol1 = NDSolve[{y'[x]*y[x] - y[x] == 1/x^2, y[1/10] == 1/10},y, {x, 1/10, 10}]
Plot[y[x] /. sol1, {x, 1/10, 10}]

enter image description here

Appendix

DSolvecan not solve Abel's DE. ContourPlot does this numerical, that's why you get the messages.

DSolve[{y'[x]*y[x] - y[x] == 1/x^2, y[1/10] == 1/10}, y[x], x]

enter image description here

$\endgroup$
  • $\begingroup$ Given the OP's expertise in differential equations, I expect the OP realizes this. But this answer may be helpful to others who might be able to use such a workaround. (+1) $\endgroup$ – Michael E2 Oct 6 '15 at 12:33
  • $\begingroup$ Willinski. I don't need numericall solution,only exact. $\endgroup$ – Mariusz Iwaniuk Oct 6 '15 at 12:46
  • $\begingroup$ From me too (+1), @Michael E2 $\endgroup$ – user31001 Oct 6 '15 at 12:50
  • $\begingroup$ @I_Mariusz Have you seen what you get with DSolve? $\endgroup$ – user31001 Oct 6 '15 at 12:52
  • 1
    $\begingroup$ @I_Mariusz, as noted, the result of DSolve[] indicates that the function being considered can only be represented implicitly; this is similar to the situation of the solution of $x=y\exp(y)$ (in that one has to "invent" the Lambert function to explicitly represent the solution of the transcendental equation.) $\endgroup$ – J. M. will be back soon Oct 6 '15 at 13:23

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.