Re: Specifying rules OR "How to do complex math in Mathematica"
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: Specifying rules OR "How to do complex math in Mathematica"
- From: danl (Daniel Lichtblau)
- Date: Sun, 3 Jul 1994 11:24:03 -0500
>Firstly, the raw Mathematica kernel is pretty stupid at doing >complex algebra of anything that contains symbols rather than just >numbers. ><...> >Mathematica does not know a priori if a symbol stands for a real or >a complex number, so is assuming that both parts may be present.... You can also use ComplexExpand. Symbols are assumed to be real unless explicitly put on the (optiuonal) "assumed-complex" list. Relevant examples are included below. Daniel Lichtblau, WRI In[6]:= ComplexExpand[Re[1/a], {a}]//InputForm Out[6]//InputForm= Re[a]/Abs[a]^2 In[7]:= ComplexExpand[Re[(a + z)^2], {a, z}]//InputForm Out[7]//InputForm= -(Im[a] + Im[z])^2 + (Re[a] + Re[z])^2 In[8]:= ComplexExpand[Re[1/a]]//InputForm Out[8]//InputForm= a^(-1) In[9]:= ComplexExpand[Re[(a + z)^2]]//InputForm Out[9]//InputForm= (a + z)^2 In[10]:= ComplexExpand[Re[(a + z)^2], {z}]//InputForm Out[10]//InputForm= -Im[z]^2 + (a + Re[z])^2 (* We cannot specify that a symbol is positive to get further get simplification, but this is still reasonably good. We could get more simplification with careful use of PowerExpand (details left to the interested reader). *) In[11]:= ComplexExpand[Abs[a]]//InputForm Out[11]//InputForm= (a^2)^(1/2) In[16]:= ComplexExpand[Abs[x*y]]//InputForm Out[16]//InputForm= (x^2)^(1/2)*(y^2)^(1/2)