# Calculate Max-Min value and corresponding parameters

I have two functions funA and funB which are also functions a,b,x,and y where a,b>= 0 and 1=<x=<2 and 0=<y=<1. Lets say a and b are fixed, and I want to find max{min(funA,funB)}in 1=<x<=2 and 0=<y=<1.

I found it by creating a table by using different step sizes for x and y.

However, I still need to find that corresponding x and y values. Can someone please help me to find those vales?

Further, I found that my method really slow and take longer time. Do you have any smarter idea to get max{min(funA,funB)} value and corresponding x and y?

funA[a_, b_, x_, y_] := y/2 Log[1 + 2 a - (2 a)/x];
funB[a_, b_, x_, y_] := y/2 Log[1 + (2 a b)/y - a b x];
maxAB[a_, b_, sx_, sy_] :=
Max[Table[
Table[Min[{funA[a, b, x, y], funB[a, b, x, y]}], {x, 1.0001,
1.9999, sx}], {y, 0.0001, 0.9999, sy}]];


Example:

In[14]:= maxAB[1.3, 0.7, 0.001, 0.002]
Out[14]= 0.254961


How about NMaximize?

NMaximize[{
Min[{funA[1.3, 0.7, x, y], funB[1.3, 0.7, x, y]}], 1 <= x <= 2 && 0 <= y <= 1},
{{x, 1, 2}, {y, 0, 1}}]


{0.254965, {x -> 1.55733, y -> 0.775248}}

To grab the max, x, and y values to later export, you can try:

Clear[x, y];
a = Range[1.3, 2, 0.1];
b = Range[0.7, 1.4, 0.1];
With[{m =
NMaximize[{Min[{funA[#[[1]], #[[2]], x, y], funB[#[[1]], #[[2]], x, y]}],
1 <= x <= 2 && 0 <= y <= 1}, {x, y}]},
{m[[1]], x /. m[[2]], y /. m[[2]]}

• @ kale Thanks a lot !!! Can you please let me know how can I extract max value, x and y separately? Because I want to Export those values to excel file for different a and b values.
– Frey
Aug 27, 2015 at 18:43
• {max, {x1, y1}} = {#[[1]], {x, y} /. #[[2]]} &@% should capture those values.
– kale
Aug 27, 2015 at 18:47
• Can you please add this to above code? I am not that good with mathematica to handle.
– Frey
Aug 27, 2015 at 18:54
• One can use NMaxValue[] and NArgMax[] separately if needed. Aug 27, 2015 at 18:59
• @Frey See update. Also, it's best to not accept the answer right away, because an awful lot of smart folks hang around here who can probably come up with more unique or efficient way to solve your problem.
– kale
Aug 27, 2015 at 19:03