MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: IntervalComplement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70337] Re: [mg70317] IntervalComplement
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 13 Oct 2006 01:30:45 -0400 (EDT)
  • References: <200610120938.FAA04776@smc.vnet.net>

On 12 Oct 2006, at 18:38, Chris Chiasson wrote:

> Has anyone implemented this function before? I need something that  
> can do this.
>
> (IntervalComplement is to IntervalUnion as Complement is to Union)
>
> -- 
> http://chris.chiasson.name/
>


I think this should do it:

IntervalComplement[s_Interval, t_Interval] := Module[{FromInterval,  
y, p},
FromInterval[x_Interval] := Or @@ (x /. {a_?NumericQ, b_?NumericQ} :>
        LessEqual[a, y, b]); p = ((CylindricalDecomposition 
[FromInterval[s]
&& Not[FromInterval[t]], y]) /. HoldPattern[Inequality[a_?NumericQ,  
Less |
               LessEqual, y, Less | LessEqual, b_?NumericQ]] :> {
       a, b}); If[Head[p] === Or, Interval @@ p, Interval[p]]]


For example:


IntervalComplement[Interval[{2,6}],Interval[{3,4}]]

Interval[{2,3},{4,6}]

Andrzej Kozlowski
Tokyo, Japan


  • Prev by Date: RE:Beginner--[Please Help]How to get coefficient list issued from a Series Command
  • Next by Date: Re: RelaTime3D
  • Previous by thread: IntervalComplement
  • Next by thread: Re: IntervalComplement