The new function MinMax is defined (first line in the documentation) as follows:
However this does not hold for an empty list
{Min[{}], Max[{}]}
MinMax[{}]
So it is self-contradicting and slightly confusing. I know MinMax says it returns {-infinity,infinity} but that does not fit into the the definitions of Min, Max and MinMax. Like other functions like ReIm and AbsArg, the function should just returns {Min[..],Max[..]} (but more optimized) like ReIm returns {Re[..],Im[..]} and AbsArg returns {Abs[..],Arg[..]}...
Take the following example, i want the minimum and maximum of those lists. It should be the same to do the MinMax on each of them, and then do the min of all the minima, and the max of all the maxima, but the function doesn't handle empty lists in a coherent way (as Min and Max by itself does).
SHMinMax[x___]:={Min[x],Max[x]}
num1={{4,7},{5,9},{11,13,2,8}};
num2=Flatten[num1];
(* all give same results as there is no 'empty' list *)
MinMax[num2]
{Min[#1],Max[#2]}&@@Transpose[MinMax/@num1]
{Min[#1],Max[#2]}&@@Transpose[SHMinMax/@num1]
(* empty list! built-in MinMax function is not coherent *)
num1={{4,7},{5,9},{11,13,2,8},{}};
num2=Flatten[num1];
MinMax[num2]
{Min[#1],Max[#2]}&@@Transpose[MinMax/@num1]
{Min[#1],Max[#2]}&@@Transpose[SHMinMax/@num1]
Note that just Min (or Max) is coherent:
num1 = {{4, 7}, {5, 9}, {11, 13, 2, 8}, {}};
num2 = Flatten[num1];
Min[num2]
Min@(Min /@ num1)
The very definition of Min[] to return infinity, has been done such that Min[3,Min[4],Min[-1,6]] or Min[3,4,-1,6] or Min[3,Min[],Min[4,-1],Min[6]] always give the same results, regardless of the order.
More confusingly is that it works differently for empty Interval objects and with empty lists.
(* built in MinMax IS coherent with empty intervals *)
{Min[Interval[]], Max[Interval[]]}
MinMax[Interval[]]
SHMinMax[Interval[]]
(* but not with empty lists *)
{Min[{}], Max[{}]}
MinMax[{}]
SHMinMax[{}]
To summarise, the choice of returning {-infinity, infinity} for MinMax[{}] is inconsistent with and incoherent with the definitions of Min[], Max[] and the function MinMax itself. And more puzzling gives also 'unusual' results for Interval objects.
I would like to know how this design choice was conceived. To me it seems very illogical and incoherent as it is now. While my own function SHMinMax which is the definition as given in the first definition of MinMax, does follow all the logic and is consistent throughout (for lists, empty lists, intervals and empty intervals!).
Please let me understand the logic!