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

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[[1]], 21]

(* True *)

IntervalMemberQ[Jintervals[[2]], 21]

(* True *)


share|improve this question
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 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 at 21:09
@MarcoB I am building a distribution function of continuous random variable – PiPiPARU Mar 22 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 at 21:24
up vote 10 down vote accepted

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.

share|improve this answer
+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 at 1:36

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.