MathGroup Archive 1998

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

Search the Archive

Re: ComplexExpand



Jack Goldberg wrote:
> 
> Hi Group;
> 
> I have found ComplexExpand useful and sometimes necessary. (Try  DSolve[
> u''[t]+u'[t]+u[t]==0,u[t],t] to see why something like  ComplexExpand
> is necessary.) 

I should note that in version 3 DSolve handles this more nicely so one
need not post-process with ComplexExpand.


> The reason for this post is that I would like to share
> with those interested in these things, some uses that I have found for
> ComplexExpand that do not seem to be explicit in the literature that I
> have seen. Here are a group of functions that assume all variable are
> real unless explicitly stated to the contrary in the manner of
> ComplexExpand.
> 
> (1)  RealPart[z_] := ComplexExpand[ Re[z] ]
> 
> (2)  ImaginaryPart[z_] := ComplexExpand[ Im[z] ]
> 
> (3)  From these two functions it is easy to define, AbsoluteValue,
> CartesianForm and ComplexConjugate to supplement the limitations of the
> built-in functions Abs and Conjugate. For example,
> 
> CartesianForm[z_] := RealPart[z]+I*ImaginaryPart[z]

There is an in-house suggestion that we implement CartesianForm and
PolarForm functions. They would return ordered pairs of the form
{re,im} (resp. {abs,arg}).


> These functions have some amusing features.  Here is one trivial
> example. When ComplexExpand is applied to (1+2I)*Exp[I*x]  we get the
> mildly unsatisfactory
> 
>         (1+2I)*Cos[x]-(2-I)*Sin[x]
> 
> (I have been unable to use any form of Collect or Expand to separate the
> real and imaginary parts.)  However,
> 
> CartesianForm[(1+2I)*Exp[I*x]] -> Cos[x]-2Sin[x]+I(2Cos[x]+Sin[x])
> 
> does the job nicely.

Yes.

I should note that ComplexExpand doing otherwise was probably a small
bug. It works better in our development version.

In[13]:= ComplexExpand[(1+2I)*Exp[I*x]] Out[13]= (1 + I) Cos[x] - (2 -
I) Sin[x]


> I have tested these functions fairly extensively and found they work
> without untoward surprises. But in doing so I have run into a minor
> "weaknesses" of ComplexExpand that I would like to see Wolfram
> incorporate into some later version.  In particulular, ComplexExpand
> does not simplify Abs[x+I*y] nor does it simplify
> Cos[Arg[Cos[x]+I*Sin[x]]].  I would like to see this:
> 
> ComplexExpand[Abs[x+I*y]] -> Sqrt[x^2+y^2]
> 

This was a judgement call. We opted to allow Abs, etc. be used in
results except when explicitly excluded by not appearing in a
TargetFunctions list. So returning Abs[x+I*y] is okay since the job of 
ComplexExpand is to separate into real and imaginary parts and Abs[...]
is indeed explicitly real.

In[9]:= ComplexExpand[Abs[x+I*y], TargetFunctions->{Re,Im}]
              2    2
Out[9]= Sqrt[x  + y ]


> and
> 
> ComplexExpand[Cos[Arg[Cos[x]+I*Sin[x]]]] -> x

This one is more difficult.

In[7]:=  ComplexExpand[Cos[Arg[Cos[x]+I*Sin[x]]],
	TargetFunctions->{Re,Im}]
Out[7]= Cos[ArcTan[Cos[x], Sin[x]]]

Possibly Simplify or FullSimplify should be made to convert this to x.


> as well as similar identities using Sin or Tan in place of the first Cos
> in the latter formula.
> 
> I have incorporated these and similar rules into my use of  RealPart
> etc. and founda substantial simplification is possible.  Consider,
> 
> ComplexExpand[(Cos[x]+I*Sin[x])^(1/3)]
> 
> with and without these simmplification rules!
> 
> Oh yes.  After using DSolve as above, try out
> 
> RealPart[u[t]/."output of DSolve"]
> 
> I hope this is useful to someone.  If anyone out there has done some
> thinking about these issues and would like to share them with me and
> the group, I would be delighted.  I am most interested in corrections
> and improvements!
> 
> Jack Goldberg


Daniel Lichtblau
Wolfram Research



  • References:
    • ComplexExpand
      • From: Jack Goldberg <jackgold@math.lsa.umich.edu>
  • Prev by Date: Re: a^n*b^n != (a*b)^n
  • Next by Date: Re: a^n*b^n != (a*b)^n
  • Prev by thread: ComplexExpand
  • Next by thread: Re: Re: ComplexExpand