Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2011

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

Search the Archive

Re: Only real data

  • To: mathgroup at
  • Subject: [mg122136] Re: Only real data
  • From: Bill Rowe <readnews at>
  • Date: Sun, 16 Oct 2011 07:06:14 -0400 (EDT)
  • Delivered-to:

On 10/15/11 at 6:03 AM, HB-Kowalczyk-Schroeders at (J=C3=B6rg
Schr=C3=B6der) wrote:

>I have a problem to exclude complex solutions. I tried

>Cases[data1, Except[_Complex]]

>and got, what I expected. But when I have data like
>{0,0,-I Sqrt[3],I Sqrt[3]}
>The above doesn't work. Is this due to a different Head? Is there an
>easy way to filter the non-complex data?

Yes, the issue is

In[21]:= Head[I Sqrt[3]]

Out[21]= Times

You can filter out anything with a complex value with FreeQ as follows:

In[22]:= Cases[{0, 0, -I Sqrt[3], I Sqrt[3]}, _?(FreeQ[#,
_Complex] &)]

Out[22]= {0,0}

=46reeQ[expr, pattern] returns True when any subexpression of expr
matches pattern

  • Prev by Date: Re: How to create this kind of list
  • Next by Date: Re: How to create this kind of list
  • Previous by thread: Re: Only real data
  • Next by thread: Re: Only real data