Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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

I have 4 variables of integer a, b, c, d which could define 2 intervals:

[min(a, b), max(a, b)] and [min(c, d), max(c, d)]

Could anyone tell me if it is possible by only using the functions mix and max and [] to represent the intersection of these 2 intervals? The definition of these functions are as following:

min(x, y) = x if x < y, y otherwise
max(x, y) = x if x > y, y otherwise
[x, y] = {i is integer | x <= i <= y}. so when x > y, [x, y] = empty

Going forward, is it possible by only using the functions mix and max to represent the union of these 2 intervals?

Thank you very much!

Edit1: as the comments suggest, the intersection may be empty under some condition. So I just added a function [].

share|cite|improve this question
The interval is nonempty if and only if either $\max(a,b)\ge\min(c,d)$ or $\min(a,b)\le\max(c,d)$. – anon Jul 25 '11 at 14:12
Perhaps others will understand the question better, but could you give an example of what you mean. For example if we have (a,b,c,d)=(1,2,3,4) then your intersection is non-existent, but your union is (1,2) U (3,4). So what kind of min(...) or max(...) argument do you want? – picakhu Jul 25 '11 at 14:14
up vote 2 down vote accepted

If you define $[u,v] = \emptyset$ when $u > v$, then

$$\begin{array}{c}[\min(a,b),\max(a,b)] \cap [\min(c,d), \max(c,d)] \\ = [\max(\min(a,b),\min(c,d)), \min(\max(a,b),\max(c,d))].\end{array}$$

Also, if the intervals overlap, then

$$[\min(a,b),\max(a,b)] \cup [\min(c,d), \max(c,d)] = [\min(a,b,c,d), \max(a,b,c,d)].$$

(If the intervals do not overlap, their union will not be an interval.)

share|cite|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.