Mathematica overloads the Min
and Max
functions to retrieve the lower and upper bounds of an interval.
I need functions that work properly on Interval
arguments. For example, the minimum of Interval[{3,4}]
and Interval[{2,5}]
should be Interval[{2,4}]
.
To clarify based on comments, I'm looking for the tightest possible bounds for the Min
and Max
functions, given the constraints of the intervals. For example, the Max
function of the intervals {2,3} and {7,8} will be {7,8}, because all values in the interval {7,8} are greater than any value in the interval {2,3}.
(Note: I'm not looking for an ordering relation for intervals. The Min
and Max
operations often produce new intervals. See the first example, above.)
I've written my own functions to do this, that only work for simple intervals:
intervalopf[a_Interval, b_Interval, op_] :=
Flatten[Outer[op, {Min[a], Max[a]}, {Min[b], Max[b]}]]
intervalop[a_Interval, b_Interval, op_] :=
With[{v = intervalopf[a, b, op]}, Interval[{Min[v], Max[v]}]]
Are there built-in functions I should be using?
And, how can I generalize this to intervals that are unions?
Interval[{min1, max1}, {min2, max2}, ...]
? $\endgroup$Min
andMax
on intervals should work, because the situation is similar to 2d vectors or complex numbers, where no ordering relation exist. $\endgroup$