Re: IntervalComplement

*To*: mathgroup at smc.vnet.net*Subject*: [mg70374] Re: [mg70317] IntervalComplement*From*: "Chris Chiasson" <chris at chiasson.name>*Date*: Sat, 14 Oct 2006 03:08:15 -0400 (EDT)*References*: <200610120938.FAA04776@smc.vnet.net> <7B224F6E-1840-4688-8508-BAF35E1C2FE1@mimuw.edu.pl>

Andrzej Kozlowski Thanks for the reply. I wish I had your computer & math skills. :-] I also wish my second email had gone out on the same day as the first (where I provided a hacked example that worked for numeric intervals). Anyway, thanks again. On 10/12/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > > 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 > -- http://chris.chiasson.name/

**References**:**IntervalComplement***From:*"Chris Chiasson" <chris@chiasson.name>