       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:= ComplexExpand[Re[1/a], {a}]//InputForm
Out//InputForm= Re[a]/Abs[a]^2

In:= ComplexExpand[Re[(a + z)^2], {a, z}]//InputForm
Out//InputForm= -(Im[a] + Im[z])^2 + (Re[a] + Re[z])^2

In:= ComplexExpand[Re[1/a]]//InputForm
Out//InputForm= a^(-1)

In:= ComplexExpand[Re[(a + z)^2]]//InputForm
Out//InputForm= (a + z)^2

In:= ComplexExpand[Re[(a + z)^2], {z}]//InputForm
Out//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
In:= ComplexExpand[Abs[a]]//InputForm
Out//InputForm= (a^2)^(1/2)

In:= ComplexExpand[Abs[x*y]]//InputForm
Out//InputForm= (x^2)^(1/2)*(y^2)^(1/2)

```

• Prev by Date: RE: My posting about Optional command
• Next by Date: Re: Yet more Timing[10000!] ...