# How to do a region plot with many functions [duplicate]

Hello i am trying to compare many function, i want to see witch one as the lowest value depending on 2 variables.

My solution so far is something like this:

I have 7 function: P1 P2 P3 P4 P5 P6 P7, variable are v and d:

RegionPlot[{
P1 [d, V, A] <= P2[d, V, A] &&
P1 [d, V, A] <= P3[d, V, A] &&

P1 [d, V, A] <= P4[d, V, A] &&
P1 [d, V, A] <= P5[d, V, A] &&

P1 [d, V, A] <= P6[d, V, A] &&
P1 [d, V, A] <= P7[d, V, A] ,
P2[d, V, A] < P1[d, V, A] &&
P2[d, V, A] <= P3[d, V, A] &&

P2[d, V, A] <= P4[d, V, A] &&
P2[d, V, A] <= P5[d, V, A] &&

P2[d, V, A] <= P6[d, V, A] &&
P2[d, V, A] <= P7[d, V, A],
P3[d, V, A] < P1[d, V, A] &&
P3[d, V, A] <= P2[d, V, A] &&

P3[d, V, A] <= P4[d, V, A] &&
P3[d, V, A] <= P5[d, V, A] &&

P3[d, V, A] <= P6[d, V, A] &&
P3[d, V, A] <= P7[d, V, A],
P4[d, V, A] < P1[d, V, A] &&
P4[d, V, A] <= P2[d, V, A] &&

P4[d, V, A] <= P3[d, V, A] &&
P4[d, V, A] <= P5[d, V, A] &&

P4[d, V, A] <= P6[d, V, A] &&
P4[d, V, A] <= P7[d, V, A],
P5[d, V, A] < P1[d, V, A] &&
P5[d, V, A] <= P2[d, V, A] &&

P5[d, V, A] <= P3[d, V, A] &&
P5[d, V, A] <= P4[d, V, A] &&

P5[d, V, A] <= P6[d, V, A] &&
P5[d, V, A] <= P7[d, V, A],
P6[d, V, A] < P1[d, V, A] &&
P6[d, V, A] <= P2[d, V, A] &&

P6[d, V, A] <= P3[d, V, A] &&
P6[d, V, A] <= P4[d, V, A] &&

P6[d, V, A] <= P5[d, V, A] &&
P6[d, V, A] <= P7[d, V, A],
P7[d, V, A] < P1[d, V, A] &&
P7[d, V, A] <= P2[d, V, A] &&

P7[d, V, A] <= P3[d, V, A] &&
P7[d, V, A] <= P4[d, V, A] &&

P7[d, V, A] <= P5[d, V, A] &&
P7[d, V, A] < P6[d, V, A]},
{d, 0, 2}, {V, -0.1, 0.3},
PlotStyle -> {Directive[Red], Directive[Blue], Directive[Orange],
Directive[Yellow], Directive[Purple], Directive[Green],
Directive[Black]}, PerformanceGoal -> "Speed", PlotPoints -> 20]


and i might want to compare more thna 7 function... is there a fast way to do it

thanks

• Although no one's posted Michael E2's Ordering-based solution at the previous question.
– user484
Aug 26, 2014 at 17:49
• @RahulNarain My memory must be bad. It wasn't even that long ago that I answered that Q. I've added this method to my answer, in case this one is closed. Aug 26, 2014 at 19:00

Here's a different approach to consider. Ordering[fns, 1] returns the index of the function whose value is least for given numeric values for x adn y. (Should there be a tie, it will return the first index only). We can use this in ContourPlot to plot the regions.

fns = {x + y, 2 x - y, 1 - x^2 - y^2, (x - 1)^2 + (y - 1)^2 - 2, 2 Sin[x y] - 1/2};

ContourPlot[Ordering[fns, 1], {x, -2, 2}, {y, -2, 2},
Contours -> 1/2 + Range[Length@fns - 1], MaxRecursion -> 3]


With a list of your functions

functions = {P1[d, V, A], P2[d, V, A], P3[d, V, A], P4[d, V, A], P5[d, V, A], P6[d, V, A]};


you can create a list of all combinations using

And @@ # & /@ MapIndexed[Drop,
Partition[#[[1]] < #[[2]] & /@ Tuples[functions, 2], Length @ functions]]

• I have mixed feelings about compact notation such as And @@ # & /@ , so powerful on the on hand, but on the other hand so hard to parse for new users. Aug 26, 2014 at 16:16