Obtain multiple coordinates from a function at a particular value

I have a function of the type:

F[{x_,y_}] := x^2 + y^2

One can plot this function using Plot3D:

Plot3D[F[{x,y}], {x, -2, 2}, {y, -2, 2}]

If one plots the function, it is clear that F[{x,y}] = 6 at more than one set of coordinates.

How can I obtain all sets of coordinates for which F[{x,y}] = 6?




2 Answers


Well there is a nice way to extract points:

mYcp = ContourPlot[x^2 + y^2 == 6, {x, -3, 3}, {y, -3, 3}]

Short[Cases[Normal@mYcp, Line[x_] :> x, Infinity], 20]




wow great ! thanks for sharing it, +1
– Ali Hashmi
Mar 25 at 10:52



Nice, thanks for the solution.
– user14424
Mar 25 at 11:01

Perhaps not a good job but the closest i can get to:

plot = Reap[ContourPlot[F[{x, y}], {x, -3, 3}, {y, -3, 3},
EvaluationMonitor :> If[5.95 < F[{x, y}] < 6, Sow[{x, y, F[{x, y}]}],]]][[2,1]] // #[[All, {1, 2}]] & //ListPlot[#, PlotStyle -> Red] &

Show[ContourPlot[F[{x, y}] == 6, {x, -3, 3}, {y, -3, 3}], plot]



There are certainly numerical errors associated with the way i extracted points from the plot. however, if accuracy is not a big issue, the answers will be quite reasonable
– Ali Hashmi
Mar 25 at 8:55



Hi Ali, thanks for your answer. The example I posted was a much simpler function that the one I am actually dealing with. I have now tried your approach on my function and the results don’t look too bad. Do you have any more ideas on how to improve the accuracy? Thanks, Stuart.
– user14424
Mar 25 at 9:26



Or alternatively, incorporate more points?
– user14424
Mar 25 at 9:27



search for the question titled, “getting a list of accurate coordinates from a plot”. I think someone used a mouse event to get all the coordinates by hovering the mouse over the plot. It may be more reasonable
– Ali Hashmi
Mar 25 at 9:37



Hi Ali, thanks for the help again. Looking back at your previous answer the contour plot is completely sufficient. Thanks for your help. Cheers, Stuart.
– user14424
Mar 25 at 10:31