Re: IntervalComplement
- To: mathgroup at smc.vnet.net
- Subject: [mg70370] Re: IntervalComplement
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sat, 14 Oct 2006 03:07:49 -0400 (EDT)
- References: <16827153.1160739396547.JavaMail.root@web01ps>
On 13 Oct 2006, at 20:36, someone wrote:
> I thought I?d share a bit of an insight into why the
> IntervalComplement was never included in Mathematica.
>
> The reason is rather obvious; the implementation of Interval, as it
> stands now, does NOT allow for a consistent definition of
> IntervalComplement.
>
> Consider,
>
> In[1]:= a = Interval[{5, 5}];
> IntervalMemberQ[a, 5]
> Out[2]= True
>
> Thus, 5 belongs to the interval a.
>
> Let?s assume that a complement of this Interval, with respect to
> (say) Real number set, could be expressed using Mathematica
> Interval type as,
>
> In[3]:= c = Interval[{-Infinity, 5}, {5, Infinity}];
> IntervalMemberQ[c, 5]
> Out[4]= True
>
> Thus, 5 also belongs to the interval c.
>
> This leads to a contradiction; a number (5) cannot belong to an
> interval and its complement simultaneously.
>
> Thus, c = Interval[{-Infinity, 5}, {5, Infinity}] is not a complement
> of a = Interval[{5, 5}].
>
> Philipp
Of course I realized when I posted my version of IntervalComplement
that Mathematica did not distinguish between open and closed
intervals and hence IntervalComplement of two sets would have to mean
the set of points in one intervel that do not belong to the other
except, possibly at end points. But I think you are mistaken in
believing that this is the reason why this function is not
implemented in Mathematica. If you still think so then you should
explain why IntervalIntersection is implmented in the following way:
s=Interval[{2,3}];t=Interval[{3,4}];
IntervalMemberQ[#,3]&/@{s,t}
{True,True}
IntervalIntersection[s,t]
Interval[]
I should also add that I did not include intervals whose endpoint are
Infinity or -Infinity in my code, but it is not hard to modify the
definition to work in this case, since CylindricalDecomposition does
work with infinite cylinders:
CylindricalDecomposition[(3<x<Infinity)&&Not[-Infinity<x<10],x]
x>=10
So one needs to change the code, replacing patterns like b_?NumericQ
with
b_?NumericQ|Infinity and so on, and change also make the last
replacement rule more general so that it will convert answers such
as y>10 to Interval[{10,Infinity}] etc. It is quite obvious how to
do it, but as it is tedious and I am not sure anybody really needs it
I won't bother with implementing it.
Andrzej Kozlowski