Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5669 > unrolled thread

Re: Only real data

Started byBill Rowe <readnews@sbcglobal.net>
First post2011-10-16 11:10 +0000
Last post2011-10-16 11:10 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Only real data Bill Rowe <readnews@sbcglobal.net> - 2011-10-16 11:10 +0000

#5669 — Re: Only real data

FromBill Rowe <readnews@sbcglobal.net>
Date2011-10-16 11:10 +0000
SubjectRe: Only real data
Message-ID<j7ee3c$eie$1@smc.vnet.net>
On 10/15/11 at 6:03 AM, HB-Kowalczyk-Schroeders@t-online.de (J=C3=B6rg
Schr=C3=B6der) wrote:

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

>data1={2,3/4,1.3,=E4}
>{2,3/4,1.3,=E4}
>Cases[data1, Except[_Complex]]
>{2,3/4,1.3}

>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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web