MathGroup Archive 2001

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

Search the Archive

Re: Ordering of output question

  • To: mathgroup at
  • Subject: [mg28252] Re: Ordering of output question
  • From: johntodd at (John Todd)
  • Date: Fri, 6 Apr 2001 01:52:59 -0400 (EDT)
  • References: <9ah6ap$>
  • Sender: owner-wri-mathgroup at

On 5 Apr 2001 03:19:53 -0400, johntodd at (John Todd) wrote:

>	I'm trying to get the output of the following to be in
>standard complex number form, i.e. a + ib:

Actually, I made a mistake in the code I originally posted and didn't
catch it because I hadn't restarted the kernel.  It should read as

Clear[u, v, x, y, z, gRefCZ, gImfCZ, gEqRefCZ, gEqImfCZ,
Clear[f, fCZ, fCXY];
x /: Im[x] = 0;
x /: Re[x] = x;
y /: Im[y] = 0;
y /: Re[y] = y;
fCZ[z_] := \[ImaginaryI] z + \[ImaginaryI];
fCXY = ComplexExpand[fCZ[x + \[ImaginaryI] y]];
gRefCZ = Re[fCXY];
gImfCZ = Im[fCXY];
gEqRefCZ = u == gRefCZ;
gEqImfCZ = v == gImfCZ;
gDomToRangeRe = Solve[gEqRefCZ, y];
gDomToRangeIm = Solve[gEqImfCZ, x];
Print["Given:\nf(z) = ", fCZ[z]];
Print["Let z = x + \[ImaginaryI]y"];

(* The following line is where my question pertains*)
Print["f(x + \[ImaginaryI]y) = ", fCZ[x + \[ImaginaryI] y], " = ",
    " = ", gRefCZ, " + \[ImaginaryI](", gImfCZ, ")."];

Print["The real part of f(z) = ", fCZ[z], " is ", gRefCZ, 
    " and the imaginary part is ", gImfCZ, "."];

>     If you evaluate the above, you'll find that the line directly
>below the commented line has its final outpu as -y + i(x + 1) which is
>what I want.  However, my means of getting it to look that way seem a
>bit inelegant,, and I feel certain there is a better way.  I do
>realize that looking at the expression with TreeForm[], I can extract
>whatever I want out of an expression, but that also seems inelegant.
>What I feel must be possible is to set up some sort of a pattern or
>transformation rule which will say in effect, "Place the output in
>this form, i.e. a + ib, regardless of what a and b are".  I ask this
>question not only for the specific example given but also in a broader
>sense because I will and have wanted to display expressions in a
>certain format, but have always had to resort to the kinds of
>contrivances already mentioned.
>     Before submitting my question I perused the sections on Patterns
>and the section on Transformation Rules in Wolfram's 4th edition Mathematica  
>book.  If I missed a glaring answer to my question, I apologize.
>Thanks again,

Sorry about that,


  • Prev by Date: Re: Re: Automatic expansion of Log[a^n] for a,nexplicit positive integers?
  • Next by Date: implicit function
  • Previous by thread: Re: Ordering of output question
  • Next by thread: Re: Re: Ordering of output question