I have come across a problem in Mathematica when I have tried to plot the contours of a compiled function.
f = Compile[{{x}, {y}}, x^2 + y^2];
ContourPlot[f[x, y] == 0.1, {x, y} \[Element] Disk[{0, 0}, 1]]
this works perfectly but suppose I want to only plot a single contour:
ContourPlot[f[x, y] == 0.1, {x, y} \[Element] Disk[{0, 0}, 1]]
this then returns the error
but still plots the contour correctly. Evaluating f[x, y] == 0.1
gives x^2 + y^2 == 0.1
along with the same error message as the output so it's clear that the problem is that in order to plot the contour specified Mathematica requires the equation for the contour to be in symbolic form suggesting that ContourPlot
is using a symbolic method to solve the problem.
However this is no good for anything difficult. I have a function longFunc[x,y]
which is an extremely complicated expression and hence must be compiled and evaluated numerically. When I do a simple ContourPlot
it works perfectly but if I specify a contour longFunc[x,y]==0.5
it falls back to a symbolic method and doesn't return an answer for a very long time.
So the question is: Is there an option within ContourPlot
to force Mathematica to search for a solution to the equality using a numerical method?
Thank you!
Related:
ContourPlot is slow and unwieldy and generates a large-data graphic
ContourPlot
calls? They seem to be identical. $\endgroup$