Open Intervals
Following up on this question, I was wondering whether Mma can handle open intervals. For example, the union of the intervals, $$1<x<5$$ and $$5<x<8$$
should not include the number 5. This is easy enough to do in one's head, but how can it be done, if at all, computationally?
Interval Complement
Also, is there a way to find the complement of two intervals? IntervalComplement[int1,int2,int3]
should contain all the points in int1
that are not in the other intervals.
Edit:
Let's take Mark McClure's data as an example.
int1 = x < -2 || -1 <= x < 1 || x == 3 || 4 < x <= Pi^2;
int2 = -3 <= x < 0 || x > 1;
The intervals are shown below:
The Interval Complement (drawn above in blue on the x-axis) would seem to be:
x < -3 || 0 <= x < 1
IntervalComplement
does work for closed intervals. Very nice! It seems like his code does not handle open intervals, relying, as it does, onInterval
for input. $\endgroup$ – DavidC Oct 1 '12 at 2:57NumberLinePlot[{{-\[Infinity] < x < -2, -1 < x <= 1, 4 < x <= Pi^2}}, x]
and so forth. $\endgroup$ – DavidC Jan 29 '15 at 16:06