Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Complex -> List does not work




> Hello!
> 
> I naively tried the following way of turning a complex number into a
> couple of real numbers:
> 
>          2 + 3 I /. Complex -> List
> 
> but it gives me back
> 
>                 2 + 3 I
> 
> even though the full form of 2+3I is Complex[2,3]. The reverse however
> is possible:
> 
>    {2,3}/.List->Complex  gives  2+3I
> 
> The help browser says that "you have to use Re and Im to extract parts
> of Complex numbers".
> 
> Why this exception to the basic principles of replacement rules?

Simply becuse a complex number is a atom, like a real or integer. 
ReplaceAll[old,new] works by seraching the expression for new.  A
atomic expression has not really a Head[] -- like a nonatomic one. It
is printed in that way but in fact the atom Complex[2,3] does not
contain the symbol Complex.

Try the same with 

1 /. Integer -> List 

1.2 /. Real -> List

2/3 /. Rational ->List

a=.;
a /. Symbol -> List

if any of this works as You expect is impossible to represent the
results by Mathematica or cause a infinite recursion

Hope that helps
  Jens




  • Prev by Date: Bivariate Integrations/Assumptions error/
  • Next by Date: Re: I don't understand in Mathematic
  • Prev by thread: Re: Complex -> List does not work
  • Next by thread: Re: Complex -> List does not work