Re: complex numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg105912] Re: [mg105904] complex numbers
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Thu, 24 Dec 2009 20:59:43 -0500 (EST)
- References: <200912240516.AAA25894@smc.vnet.net>
Hi Jon, This is perhaps the simplest: In[1]:= ClearAll[x, y]; z = x + I*y; ComplexExpand /@ {Re[z], Im[z]} Out[2]= {x, y} You can also do this: In[3]:= Simplify[Re[z], Assumptions -> {Element[{x, y}, Reals]}] Out[3]= x In[4]:= Simplify[Im[z], Assumptions -> {Element[{x, y}, Reals]}] Out[4]= y Alternatively, you may use Algebra`ReIm` (it is now obsolete however): In[5]:= << Algebra`ReIm`; x /: Im[x] = 0; x /: Re[x] = x; y /: Im[y] = 0; y /: Re[y] = y; During evaluation of In[5]:= General::obspkg: Algebra`ReIm` is now obsolete. The legacy version being loaded may conflict with current Mathematica functionality. See the Compatibility Guide for updating information. >> In[10]:= {Re[z], Im[z]} Out[10]= {x, y} Note that the latter method assigns the properies to symbols x,y globally, the previous ones work under local assumption of x,y being real. Regards, Leonid On Thu, Dec 24, 2009 at 8:16 AM, Jon Joseph <josco.jon at gmail.com> wrote: > All: Something fundamental about complex number initialization I am > failing to understand. I wish to define a complex number > > z=x+ I y where x and y are both reals. Can someone tell me the > proper way to tell Mathematica that x, y are real so that Re[z] returns > x and Im[z] returns y? Much appreciated, Jon. > >
- References:
- complex numbers
- From: Jon Joseph <josco.jon@gmail.com>
- complex numbers