# Position of maximum element in list under optimisation

For a list of several functions:

functions = {a[x,y,z],b[x,y,z],c[x,y,z],d[x,y,z]};


I want to maximize the maximum value of a function of three variables. This is easily done:

max = Maximize[Max[functions], {x,y,z}].


This returns the maximum value and the corresponding values x -> x0,y -> y0,z -> z0. I want the element in the list functions that corresponds to the maximum value. However, I want to determine this inside the Maximize step. Hence I am not looking for the following answer:

max = Maximize[Max[functions], {x,y,z}];
maxelement = Position[functions /. max[], max[]]


since this determines the max element separately. Instead I want to define maxelement inside the Maximize step in the definition for max.

MWE

a[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z] + 0.1 Sqrt[z]]^2);
b[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z] + 0.1 I Sqrt[z]]^2);
c[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z] + Sqrt[z]]^2);
d[x_,y_,z_] := E^(-E^(2 Im[x]) Abs[y Sqrt[1 - z]]);

functions = {a[x,y,z],b[x,y,z],c[x,y,z],d[x,y,z]};
maxvalue = Maximize[maxelement Max[functions], {x,y,z}];


where max inside the Maximize denotes the element of functions corresponding to the max value after substituting the values for x,y,z returned by maxvalue into functions.

• Could you please provide a workable numerical example ? – Lotus Dec 9 '19 at 9:35
• @Lotus, done - see updated question. – Sid Dec 9 '19 at 9:55
• What's the point of doing it this way? Can you explain what you need the index maxelement for inside Maximize? (I'm asking since this might affect potential answers) – Lukas Lang Dec 9 '19 at 11:01
• @LukasLang, simply since maxelement may change according to the output of the maximisation. – Sid Dec 9 '19 at 11:25

Perhaps not the most elegant solution, but you can make a parameter representing the index of each function, e.g. if your initial equations are:

a[x_, y_, z_] := x - x^2 - y^2 - z^2;(*Maximum of 1/4*)
b[x_, y_, z_] := 2 y - x^2 - y^2 - z^2;(*Maximum of 1*)
c[x_, y_, z_] := 3 z - x^2 - y^2 - z^2;(*Maximum of 9/4*)
d[x_, y_, z_] := 4 x + y - x^2 - y^2 - z^2;(*Maximum of 17/4*)


they would become:

a[x_, y_, z_, p_] := (x - x^2 - y^2 - z^2)*KroneckerDelta[p, 1];
b[x_, y_, z_, p_] := (2 y - x^2 - y^2 - z^2)*KroneckerDelta[p, 2];
c[x_, y_, z_, p_] := (3 z - x^2 - y^2 - z^2)*KroneckerDelta[p, 3];
d[x_, y_, z_, p_] := (4 x + y - x^2 - y^2 - z^2)*KroneckerDelta[p, 4];


with the full list and fitting process as:

functions = {a[x, y, z, p], b[x, y, z, p], c[x, y, z, p], d[x, y, z, p]};
max = Maximize[Max[functions], {x, y, z, p}]

out: {17/4,{x->2,y->1/2,z->0,p->4}}


Where p->4 indicates that the last function (d) is the maximal one.