MathGroup Archive 2009

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

Search the Archive

Re: Re[] function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105974] Re: [mg105957] Re[] function
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Tue, 29 Dec 2009 01:17:02 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200912280955.EAA01706@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

The initial input line accomplishes nothing, because Mathematica is not 
a declarative language. In fact, if you wrap that input with FullForm 
and evaluate it, you'll see that you get back just the interpretation of 
what you gave as input:

   {Rm, Xm} \[Element] Reals // FullForm
Element[Alternatives[Rm,Xm],Reals]

Second, after

    Z = (Rm*\[ImaginaryJ] Xm)/(Rm + \[ImaginaryJ]*Xm)

then the third input line, which I've changed to

    W = ComplexExpand[Z]

in effect accomplishes nothing directly useful for what you want, as 
again you would see if you looked at the result (in InputForm, to make 
it 1D for purposes of this e-mail):

    InputForm[W]
(I*Rm^2*Xm)/(Rm^2 + Xm^2) + (Rm*Xm^2)/(Rm^2 + Xm^2)

Yes, in applying ComplexExpand to Z, Mathematica has indeed regarded Rm 
and Xm as real and used that to split the number into I y + x form.

HOWEVER, Mathematica does not "remember" that it temporarily regarded Rm 
and Xm as real.  You just have another expression now involving I and 
other symbols Rm and Xm.  That's why your final input does not give what 
you expect as the real part of W.  Mathematica does not know that Rm and 
Xm are real.  So if you want the real part of W, you have to use 
ComplexExpand again:

    ComplexExpand[Re[W]] // InputForm
(Rm*Xm^2)/(Rm^2 + Xm^2)

So in fact you only need the following two input lines to get the real 
part you want:

    Z = (Rm*\[ImaginaryJ] Xm)/(Rm + \[ImaginaryJ]*Xm)
    ComplexExpand[Re[Z]]

Of course, if you have specific reals instead of symbolic Rm and Xm, 
then there's not need for ComplexExpand whatsoever.  For example:

    Re[(-2/3*\[ImaginaryJ] Sqrt[2])/(-2/3+\[ImaginaryJ]*Sqrt[2])]
-6/11

One other comment: you tread on dangerous waters when you begin using 
upper-case letters for your own variables (Z, here) or other names, as 
these may conflict with names of built-in objects.


Fabian wrote:
> Dear Group-
> 
> Why can't Mathematica evaluate "Re[]" here ?
> 
> {Rm, Xm} \[Element] Reals;
> Z = (Rm*\[ImaginaryJ] Xm)/(Rm + \[ImaginaryJ]*Xm);
> Z = ComplexExpand[Z]
> Re[Z]
> 
> -Thank you
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • References:
  • Prev by Date: Re: Replace and ReplaceAll -- simple application
  • Next by Date: Re: Re: Replace and ReplaceAll -- simple application
  • Previous by thread: Re: Re[] function
  • Next by thread: Re: Re[] function