Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|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
add comment

1 Answer

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|improve this answer
add comment

Your Answer

 
discard

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.