MathGroup Archive 2001

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

Search the Archive

Re: Ordering of output question

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

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

>Hello,
>	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
follows:

Clear[u, v, x, y, z, gRefCZ, gImfCZ, gEqRefCZ, gEqImfCZ,
gDomToRangeRe, 
    gDomToRangeIm];
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], " = ",
fCXY, 
    " = ", 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,
>
>JT


Sorry about that,

JT


  • 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