Re: Re: Interval arithmetic and Dependency problems
- To: mathgroup at smc.vnet.net
- Subject: [mg96804] Re: [mg95483] Re: Interval arithmetic and Dependency problems
- From: Andy Anderson <aanderson at amherst.edu>
- Date: Wed, 25 Feb 2009 04:04:40 -0500 (EST)
- References: <gl1bng$998$1@smc.vnet.net> <200901201043.FAA16621@smc.vnet.net>
Nice to see this discussion here. I was just trying out the Interval functions for a project where I need to compare two time intervals, and noticed what is, to me, unexpected behavior. Mathematica symbolizes a disjoint interval as Interval[], and this might result from, say IntervalIntersection[Interval[{0,1}], Interval[{2,4}]]. While I would like to think of this as a "null" interval, one without any range (in particular Interval[{0,0}]), Mathematica instead treats this object as the same thing as Interval[{Infinity, -Infinity}], i.e. completely off the real line (not explained in the documentation). Therefore, Interval[{0,1}] + Interval[] == Interval[] (rather than Interval[{0,1}]) More importantly, I want to test if two intervals overlap or not. If they don't, IntervalIntersection[Interval[{0,1}], Interval[{2,4}]] == Interval[] returns True, which is fine, but if they *do* overlap, IntervalIntersection[Interval[{0,3}], Interval[{2,4}]] == Interval[] does *not* return False but rather leaves it undetermined. This seems incorrect to me under either interpretation of Interval[]. Can anyone justify this? In any case, my workaround is to instead use: Min[IntervalIntersection[Interval[{0,1}], Interval[{2,4}]]] == Infinity which behaves consistently. This turns out to be more than twice as fast as actually comparing endpoints for overlap. P.S. You know what would be nice? The option to define end points as exclusive, e.g. [2,4) which might be defined as Interval[{2,4},Exclusive->Max]. -- Andy On Jan 20, 2009, at 5:43 AM, Jean-Marc Gulliet wrote: > In article <gl1bng$998$1 at smc.vnet.net>, magma <maderri2 at gmail.com> > wrote: > [...] >> For example evaluate >> >> f[x_] := x^2 + x >> f[Interval[{-1, 1}]] >> >> and you get >> >> Interval[{-1, 2}] >> >> which is not really very good. > [...] > > Intervals are assumed to be independent, say, like two independent > variables. Therefore, what Mathematica computes in your example is > > In[1]:= Interval[{-1, 1}]^2 + Interval[{-1, 1}] > > Out[1]= Interval[{-1, 2}] > > You could think of the endpoints of the resulting interval as being > the > min and max values of a function of two variables over the region > -1<=x|y<=1. > > In[2]:= Minimize[{x^2 + y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[2]= {-1, {x -> 0, y -> -1}} > > In[3]:= Maximize[{x^2 + y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[3]= {2, {x -> -1, y -> 1}} > > This also explains the difference between x^2 (one variable) and x*x > which is rally computed as x*y (two independent variables). > > In[4]:= Minimize[{x*y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[4]= {-1, {x -> -1, y -> 1}} > > In[5]:= Maximize[{x*y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[5]= {1, {x -> -1, y -> -1}} > > Regards, > --Jean-Marc >