Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
From your example it seems the result of min should be an interval that goes from the min of the lower bounds to the min of the upper bounds, right? How would it work with intervals such as Interval[{min1, max1}, {min2, max2}, ...]? – Rojo Nov 2 '13 at 1:56
In any case, I doubt there's a built-in – Rojo Nov 2 '13 at 1:57
@Rojo A sense-in? – Dr. belisarius Nov 2 '13 at 2:21
Since there is probably not a built-in, why don't you rephrase the question to ask how to write the custom function? You might get a better method than what you're using now. – Mr.Wizard Nov 2 '13 at 7:28
@payne First you need to specify exactly, how this Minand Max on intervals should work, because the situation is similar to 2d vectors or complex numbers, where no ordering relation exist. – halirutan Nov 2 '13 at 12:10
up vote 4 down vote accepted

Edit: A slightly shorter version.

minInterval[i_] := Interval[Min /@ Transpose[i[[All, 1]]]]
maxInterval[i_] := Interval[Max /@ Transpose[i[[All, 1]]]]


minInterval@{Interval[{3, 4}], Interval[{2, 5}], Interval[{2, 4}] }
maxInterval@{Interval[{3, 4}], Interval[{7, 8}] }

Interval[{2, 4}]

Initial Suggestion:

share|improve this answer
That's exactly what I was looking for (for simple intervals). I wanted to (a) make sure I wasn't missing a built-in, and (b) understand a better Mathematica-ish idiom for doing this. Thanks! – payne Nov 2 '13 at 20:16
I think you forgot to wrap the output in Interval in your edit version – Rojo Nov 3 '13 at 4:19
@Rojo Yes, I did. Thanks for the heads-up. – DavidC Nov 3 '13 at 14:14

Yet another solution

minInterval = Interval @@ MapThread[Min, List @@@ #, 2] &;

minInterval@{Interval[{1, 2}], Interval[{5, 6}], Interval[{9, 10}]}
Interval[{1, 2}]

It works also for unions of intervals (if you need to find the minimum union)

minInterval@{Interval[{1,2}, {3,4}], Interval[{5,6}, {7,8}], Interval[{9,10}, {11,12}]}
Interval[{1, 2}, {3, 4}]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.