# How can I exclude endpoints of intervals?

I have list of intervals:

Jintervals = {Interval[{18.9, 21.}], Interval[{21., 23.1}]}


I need to exclude the endpoints - [18.9,21.), [21.,23.1)

Wrong -

IntervalMemberQ[Jintervals[], 21]

(* True *)

IntervalMemberQ[Jintervals[], 21]

(* True *)


Thanks.

• Interval does not support open intervals. Nevertheless, what would you like to do with those open intervals if you had them? Perhaps we could find a way around it that still works for you. – MarcoB Mar 22 '16 at 21:01
• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dr. belisarius Mar 22 '16 at 21:09
• @MarcoB I am building a distribution function of continuous random variable – xhF731 Mar 22 '16 at 21:11
• @PiPiPARU OK, and how do the open intervals factor into your code? Perhaps if you can show us some code you are working on, we could provide better help. – MarcoB Mar 22 '16 at 21:24
• Couldn't the language use Except to support open endpoints, eg Interval[{0,Except}] ==> [0,1). No problem with representation, what about interval computation? – alancalvitti Mar 22 '16 at 22:04

A possible cause of a mental block in this scenario is to think that we need to find a way to include all numbers that are infinitely close to our endpoints. Since we are working on a computer though our numbers are not continuous, so we are actually dealing with a discrete set of numbers. What we need to do is create a new interval where the boundaries are as close as possible to the endpoints given the capability of our computer to differentiate between numbers. Take a look at this:

int = Interval[{18.9 (1 + $MachineEpsilon), 21 (1 -$MachineEpsilon)}];
{IntervalMemberQ[int, 18.9], IntervalMemberQ[int, 21]}


{True, True}

int = Interval[{18.9 (1 + 2 $MachineEpsilon), 21 (1 - 2$MachineEpsilon)}];
{IntervalMemberQ[int, 18.9], IntervalMemberQ[int, 21]}


{False, False}

What this shows is that the capability of IntervalMemberQ to distinguish between endpoints is up to a factor of (1 +- 2 $MachineEpsilon). This is also very close to the computer system's ability to differentiate between numbers, which it can do up to a factor of (1 +-$MachineEpsilon). i.e. it is about as good as it's going to get.

• +1)...I don't know why we get True in your first example.But I think ImplicitRegion can get a excat open interval. – yode Mar 23 '16 at 1:36