5
$\begingroup$

I have a list of (ten or so) functions of two variables (x and y, say). I would like to plot the boundaries on the x y plane where two functions have the same value - but only the two functions in the list which have the smallest values at that particular point. Can this be done? (The Physics application - I have a number of states with different energies (the list of functions), and I am trying to plot the different regions where different states are the ground state.)

Edit follows,

Thanks for your help. I have made some progress with this - functions are parabola. Here is my code so far.

Clear[a, x, y, m, n, p, l]
m[x_, y_] := x^2 + y^2;
n[x_, y_] := x^2 + (2 y + 1)^2;
p[x_, y_] := (x + 1)^2 + y^2;
l = {m[x, y], n[x, y], p[x, y]};
ContourPlot[l[[First[Ordering[l, 2]]]] == l[[Last[Ordering[l, 2]]]], {x,-4,4}, {y,-4,4}, PlotPoints -> 200]
RegionPlot[l[[Last[Ordering[l, 2]]]]-l[[First[Ordering[l, 2]]]]<0.05,{x,-4,4},{y, -4, 4},PlotPoints->200]

The ContourPlot does not work - I get a blank plot - but the RegionPlot does show the regions where the lowest two functions are approximately equal. So is this something to do with the precision at which the calculation is carried out?

I did try the solution provided by Verde - thankyou very much for that - but I didn't fully understand it, and had trouble integrating it with the rest of my code.

Any further help would be much appreciated!

Nick

$\endgroup$
3
  • 3
    $\begingroup$ Could you give some basic examples of functions and study cases? This would be helpful if given in Mathematica code. $\endgroup$ Aug 8, 2012 at 19:28
  • 2
    $\begingroup$ Sound possible. But it might be helpful for others to be sure what exactly you want if you give an example. And welcome to Mathematica.SE! $\endgroup$
    – Silvia
    Aug 8, 2012 at 19:34
  • $\begingroup$ See edit above! $\endgroup$ Aug 9, 2012 at 15:07

3 Answers 3

5
$\begingroup$

Here's one way using ContourPlot:

Clear[a, x, y, m, n, p, l]
m[x_, y_] := x^2 + y^2;
n[x_, y_] := x^2 + (2 y + 1)^2;
p[x_, y_] := (x + 1)^2 + y^2;
l = {m[x, y], n[x, y], p[x, y]};
ContourPlot[
 Evaluate[Table[l[[i]] - Min[Delete[l, i]] == 0, {i, Length[l]}]], 
 {x, -2, 2}, {y, -2, 2}, Exclusions -> None]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Wonderful - very elegant! Thank you very much indeed. $\endgroup$ Aug 9, 2012 at 16:01
2
$\begingroup$
l = {Sin[#], Sin[#] UnitBox[Norm@{#} ], 3, Sin[ Norm@#]} &;
b[l_] := Count[Chop[Min[l[x y]] - l[x y]], 0] >= 2.
RegionPlot[b[l], {x, -3, 3}, {y, -3, 3}, PlotPoints -> 100]

Mathematica graphics

$\endgroup$
2
$\begingroup$

RankedMin may be convenient in this context:

ClearAll[m, n, p, diftwomins];
m[x_, y_] := x^2 + y^2;
n[x_, y_] := x^2 + (2 y + 1)^2;
p[x_, y_] := (x + 1)^2 + y^2;
diftwomins[x_, y_] := (RankedMin[#, 2]-RankedMin[#, 1]) &@(#[x, y] & /@ {m, n, p});    
GraphicsRow[{Plot3D[diftwomins[x, y], {x, -4, 4}, {y, -4, 4}, 
    BoxRatios -> 1, PlotPoints -> 100, ImageSize -> 300],
 ContourPlot[diftwomins[x, y], {x, -4, 4}, {y, -4, 4}, 
    PlotPoints -> 200, ImageSize -> 300]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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