Prev: Docked cells and TagBoxNote / StatusArea
Next: OneStepTopReduction in System` Context in Mathematica 6+?
From: Jack L Goldberg 1 on 20 Mar 2010 03:47 Hi Folks, Can anyone explain this: In[1]:= Union[ 1 < x < 2, 3 < x < 5 ] Out[1]= 5 < x ?? I am using a MacBook Pro, OS 10.6.2 Thanks, Jack
From: rafscipio on 21 Mar 2010 03:05 On 20 Mar, 08:47, Jack L Goldberg 1 <jackg...(a)umich.edu> wrote: > Hi Folks, > > Can anyone explain this: > > In[1]:= Union[ 1 < x < 2, 3 < x < 5 ] > > Out[1]= 5 < x > > ?? > > I am using a MacBook Pro, OS 10.6.2 > > Thanks, > > Jack Hi, As u can read on help of Union function in Generalization and Extension par., "Union works with any head, not just List": In[1]:= Union[f[a, x, b], f[c, x, d]] Out[1]= f[a, b, c, d, x] In your case, considering the internal representation of the expressions, it results: In[2]:= 1 < x < 2 // FullForm Out[2]//FullForm= Less[1,x,2] In[3]:= 3 < x < 5 // FullForm Out[3]//FullForm= Less[3,x,5] Hence using formula [1] the result of your union is equivalent to: Less[1,2,3,5,x] ....and it's equivalent to 1<2<3<5<x ....and so to to 5<x Scipione
From: DC on 21 Mar 2010 03:06 For a generic head f : In[1]:= Union[f[x, y], f[y, w, z]] Out[1]= f[w, x, y, z] hence your result as FullForm[1<x<2]=Less[1,x,2]. Try In[9]:= Union[Interval[{1, 2}], Interval[{3, 5}]] Out[9]= Interval[{1, 2}, {3, 5}] -Francesco On 03/20/2010 07:47 AM, Jack L Goldberg 1 wrote: > Hi Folks, > > Can anyone explain this: > > In[1]:= Union[ 1< x< 2, 3< x< 5 ] > > Out[1]= 5< x > > ?? > > I am using a MacBook Pro, OS 10.6.2 > > Thanks, > > Jack >
From: Simon on 21 Mar 2010 03:07 Hi Jack, that's pretty cool, but it comes from using Union where you shouldn't. The full form for, say, 1<x<2 is Less[1,x,2]. Let's replace Less with some unknown function f; In[1]:= Union[f[1,x,2],f[3,x,5]] Out[1]= f[1,2,3,5,x] In[2]:= %/.f->Less Out[2]= 5<x So Union does two things - it joins to objects with the same head together AND sorts their arguments into canonical order. For Less, this doesn't really make sense. Maybe you wanted to do something like: In[3]:= Reduce[1<x<2&&3<x<5] Out[3]= False In[4]:= Simplify[1<x<2&&3<x<5] Out[4]= False Simon On Mar 20, 3:47 pm, Jack L Goldberg 1 <jackg...(a)umich.edu> wrote: > Hi Folks, > > Can anyone explain this: > > In[1]:= Union[ 1 < x < 2, 3 < x < 5 ] > > Out[1]= 5 < x > > ?? > > I am using a MacBook Pro, OS 10.6.2 > > Thanks, > > Jack
From: Chris Osborn on 21 Mar 2010 03:07 On Mar 20, 2:47 am, Jack L Goldberg 1 <jackg...(a)umich.edu> wrote: > Hi Folks, > > Can anyone explain this: > > In[1]:= Union[ 1 < x < 2, 3 < x < 5 ] > > Out[1]= 5 < x > > ?? > > I am using a MacBook Pro, OS 10.6.2 > > Thanks, > > Jack Hi Jack, Union is usually applied to lists (expressions with head "List") like: Union[ {3, 2, 1}, {4, 3} ] --> {1,2,3,4} (it sorts the elements and removes duplicates). If you apply it to inequalities it will treat the inequalities like expressions with head "Less", e.g.: Union[ Less[1, x, 2], Less[3, x, 5] ] --> Less[1, 2, 3, 5, x] Here it has sorted the elements 1, x, 2, 3, 5, and x, and removed duplicates. The simplifier notices this is equivalent to: Less[5, x] or 5 < x Chris
|
Next
|
Last
Pages: 1 2 3 Prev: Docked cells and TagBoxNote / StatusArea Next: OneStepTopReduction in System` Context in Mathematica 6+? |