Bug confirmed. Both Math.min() and Math.max() are broken in PI 1.8.1 when the argument of these methods is an array.
This is a regression caused by the way we implement the standard Math JavaScript object in PixInsight since version 1.8.1. In previous versions, the standard Math object was completely removed and replaced with a custom, non-ECMA compliant but much more powerful and efficient Math object. Since 1.8.1 and the integration of SpiderMonkey 24, we no longer replace the Math object because JIT-inlined Math methods are faster than our implementations, which cannot be inlined by the JIT compiler. We now preserve standard Math methods (such as Math.min() and Math.max() for example) and extend the Math object with our routines that are not part of ECMA (for example, Math.complexTimeToJD() or Math.stableSum()). Unfortunately, our custom Math.min() and Math.max() accepted nonstandard array arguments, which was a design error that we are paying now.
The fix is two new custom methods, namely:
Number Math.minElem( Array numbers )
Number Math.minElem( Number x1[, Number x2[, ..., Number xN]] )
Number Math.maxElem( Array numbers )
Number Math.maxElem( Number x1[, Number x2[, ..., Number xN]] )
that extend the Math object without causing conflicts. These methods will be available in the next version of the PixInsight Core application, and a new version of BatchPreprocessing will invoke Math.maxElem() in StackEngine.doCalibrate(). Math.min() and Math.max() will be documented correctly:
Number Math.min( Number x1[, Number x2[, ..., Number xN]] )
Number Math.max( Number x1[, Number x2[, ..., Number xN]] )
that is, according to their standard ECMA definitions.
Since this bug does not seem to be causing too many practical problems and the new version is due in a week or so, I prefer to wait instead of releasing an update. Thanks for the bug hunt.