Re: Is it a bug?
- To: mathgroup at smc.vnet.net
- Subject: [mg17633] Re: Is it a bug?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 21 May 1999 03:37:29 -0400
- References: <7hgdfs$4bu@smc.vnet.net> <7hocop$fls@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Andrzej Kozlowski has pointed out that the methods that I gave below do not
deal with I^I (which is real)
He gives the example
Cases[{Sqrt[2]*I,2+3I,b+3*I,I^I}, x_/;Not[Chop[FreeQ[x,Complex]]]]
{I*Sqrt[2], 2 + 3*I, 3*I + b, I^I}
And provides the more comprehensive solution
Cases[{1+Sqrt[2]*I,2+3I,b+3*I,I^I},_?(ComplexExpand[Im[#]]!=0&)]
{1 + I*Sqrt[2], 2 + 3*I, 3*I + b}
What I intended to send was the numerical version
Cases[{Sqrt[2]*I,2+3I,b+3*I,I^I}, x_/;Not[FreeQ[Chop[N[x]],Complex]]]
{I*Sqrt[2], 2 + 3*I, 3*I + b}
Using ComplexExpand also allows us to specify that some symbols should be
regarded as complex, provided that we change != to =!=
Cases[{b+3},_?(ComplexExpand[Im[#],{b}]=!=0&)]
{3+b}
Cases[{b+3},_?(ComplexExpand[Im[#],{b}]!=0 &)]
{}