# Finding element selected in NMaximize[{Min[...], constraints},{vars}]

How can I determine which element of Min[] is being selected in a NMaximize[{Min[...], constraints},{vars}] problem? For example,

NMaximize[{Min[x, 1/(x - 1)], x >= 0, x <= 2}, {x}]
{1.61803, {x -> 1.61803}}


which is true for both elements. This is a very contrived example, though. In reality the space of elements is highly non-convex so I can't just use the answer and find the element using Select[], Position[], etc. for example. Somehow returning the position in Min[] in situ (and not post hoc) is something I was hoping for.

Addendum: I've tried using Monitor[] and Trace[] to gain some insight to what is going on but to no luck.

• What about giving the different functions different units like Meter and Hour. Should be given back together with the numerical result. Can't test it now. Apr 28 at 17:44
• @Akku14 clever! Unfortunately mathematica complains about incompatible units. I really like that suggestion though of a way to tag the elements. Apr 28 at 17:49

funcs = {x, 1/(x - 1)};

{max, arg} = NMaximize[{Min @@ funcs, x >= 0, x <= 2}, {x}]

{* {1.61803, {x -> 1.61803}} *)

Select[funcs, max == (# /. arg) &][[1]]

(* x *)


EDIT: Using NMaximize only one function is returned due to precision issues. To identify both, Maximize must be used

{max, arg} = Maximize[{Min @@ funcs, x >= 0, x <= 2}, {x}]

(* {1/2 (1 + Sqrt[5]), {x -> 1/2 (1 + Sqrt[5])}} *)

Select[funcs, max == (# /. arg) &]

(* {x, 1/(-1 + x)} *)

• Thanks, unfortunately this does not work for my problem. I tried to clarify my question. I don't think any post hoc command like Select[] or Position[] will work for my case. Apr 28 at 16:50
• Please provide an example that more accurately represents the problem. Apr 28 at 16:52
• OK I will try but as stated in the question if there is a method that does this in situ instead of having to use the provided answer first the question will be solved. Apr 28 at 16:55