Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

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

share|improve this question

marked as duplicate by Rahul Narain, Öskå, Simon Woods, Mr.Wizard Aug 27 at 0:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Although no one's posted Michael E2's Ordering-based solution at the previous question. –  Rahul Narain Aug 26 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. –  Michael E2 Aug 26 at 19:00

2 Answers 2

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]

Mathematica graphics

share|improve this answer

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]]
share|improve this answer
    
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. –  rhermans Aug 26 at 16:16

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