MathGroup Archive 2006

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

Search the Archive

Re: IntervalComplement


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