10
$\begingroup$

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 *)

Thanks.

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – MarcoB Mar 22 '16 at 21:01
  • $\begingroup$ 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! $\endgroup$ – Dr. belisarius Mar 22 '16 at 21:09
  • $\begingroup$ @MarcoB I am building a distribution function of continuous random variable $\endgroup$ – xhF731 Mar 22 '16 at 21:11
  • $\begingroup$ @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. $\endgroup$ – MarcoB Mar 22 '16 at 21:24
  • 1
    $\begingroup$ Couldn't the language use Except to support open endpoints, eg Interval[{0,Except[1]}] ==> [0,1). No problem with representation, what about interval computation? $\endgroup$ – alancalvitti Mar 22 '16 at 22:04
10
$\begingroup$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.