# Strange behavior in ContourPlot?

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}] Works fine, but with this:

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

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

The message 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] 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.]

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}] 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] • 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) – Michael E2 Oct 6 '15 at 12:33
• Willinski. I don't need numericall solution,only exact. – Mariusz Iwaniuk Oct 6 '15 at 12:46
• From me too (+1), @Michael E2 – user31001 Oct 6 '15 at 12:50
• @I_Mariusz Have you seen what you get with DSolve? – user31001 Oct 6 '15 at 12:52
• @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.) – J. M.'s technical difficulties Oct 6 '15 at 13:23