MathGroup Archive 2006

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

Search the Archive

Re: Complex Numbers to list of points

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72212] Re: Complex Numbers to list of points
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 14 Dec 2006 05:49:39 -0500 (EST)
  • Organization: hispeed.ch
  • References: <elosbs$ojk$1@smc.vnet.net>


Hi Andrew,

you must specify the level where your replacement should act:

Replace[{1 + 3I, 2, 1 - 3I}, x_ -> {Re[x], Im[x]}, 1]

without thi, x can matches the whole expression.

Daniel



planetmarshalluk at hotmail.com wrote:

> Hi there,

> 

> I have a list of mixed complex and real numbers returned from a function, e=

> g

> 

> {1+3i, 2, 1-3i}

> 

> I wish to convert the list to a list of points.

> 

> {1+3i,2,1-3i} /. z_Complex->{Re[z],Im[z]}

> 

> gives

> 

> {{1,3},2,{1,-3}}

> 

> Which is almost what I want, but has not dealt with the possibility of non-=

> complex numbers in the list. Is there a compact way of doing this, such wit=

> h a list of rules? Nothing obvious seems to work, the only success I have h=

> ad is splitting the list into real and complex sublists, applying rules to =

> each list individually and then recombining them, which seems like an awful=

>  lot of hard work.

> 

> What I want is

> toPoints[{1+3i, 2, 1-3i}] == {{1,3},{2,0},{1,-3}}

> 

> Any help appreciated,

> Thanks.

> 

> Andrew.

> 



  • Prev by Date: Re: Complex Numbers to list of points
  • Next by Date: Re: Deformed Matrix Product
  • Previous by thread: Re: Complex Numbers to list of points
  • Next by thread: Re: Complex Numbers to list of points