Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: More strange behavior by ComplexExpand

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60607] Re: [mg60603] More strange behavior by ComplexExpand
  • From: Andrzej Kozlowski <andrzej at yhc.att.ne.jp>
  • Date: Thu, 22 Sep 2005 02:08:04 -0400 (EDT)
  • References: <200509210720.DAA08138@smc.vnet.net>
  • Reply-to: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Sender: owner-wri-mathgroup at wolfram.com

On 21 Sep 2005, at 16:20, Raul Martinez wrote:

> To Mathgroup,
>
> I use Mathematica 5.2 with Mac OS X (Tiger).
>
> Add the following to a recent thread on the sometimes strange
> behavior of ComplexExpand.
>
> I used ComplexExpand with an argument in which all the variables in
> the argument of the function are real. Since ComplexExpand is
> supposed to assume that all variables are real by default, one would
> expect ComplexExpand to return the expression without change, but it
> doesn't. Instead, here is what it does:
>
> In[1]:=
>
>      ComplexExpand[ (a / Pi)^(1/4) Exp[ (-(a t^2)/2 ] ]
>
> Out[2]:=
>
>      (Exp[-a t^2] Sqrt[Exp[a t^2]] (a^2)^(1/8) Cos[Arg[a] / 4]) / Pi^
> (1/4) + i (Exp[-a t^2] Sqrt[Exp[a t^2]] (a^2)^(1/8) Sin[Arg[a] /
> 4]) / Pi^(1/4).
>
> I have inserted parentheses in a few places to improve the legibility
> of the expressions.
>
> ComplexExpand treats the variable "a" as complex, but "t" as real.
> This is puzzling to say the least. Moreover, it renders a^(1/4) as
> (a^2)^(1/8), which seems bizarre.
>
> My interest is not in obtaining the correct result, which is easy to
> do. Rather, I bring this up as yet another example of the
> unreliability of ComplexExpand. In case anyone is wondering why I
> would use ComplexExpand on an expression I know to be real, the
> reason is that the expression in question is a factor in a larger
> expression that contains complex variables. Applied to the larger
> expression, ComplexExpand returned an obviously incorrect expansion
> that I traced to the treatment of the example shown above.
>
> I welcome comments and suggestions.
>
> Thanks in advance,
>
> Raul Martinez
>
>
>
>
>
>
>


First of all, the expression returned by ComplexExpand is correct.  
One can check it with FullSimplify (which does not make use of  
ComplexExpand so this is not a circular argument):


FullSimplify[(a/Pi)^(1/4)*Exp[-(a*t^2)/2] ==
    ComplexExpand[(a/Pi)^(1/4)*Exp[-(a*t^2)/2]], (a | t) â?? Reals]

True

If you do not trust this you can try a numerical test:

In[8]:=
ComplexExpand[(a/Pi)^(1/4)*Exp[-(a*t^2)/2]] - (a/Pi)^(1/4)*Exp[- 
(a*t^2)/2] /.
   {a -> Random[], t -> Random[]}

Out[8]=
0.

So I can't see any way in which you can make the claim that:

> Applied to the larger
> expression, ComplexExpand returned an obviously incorrect expansion
> that I traced to the treatment of the example shown above.


It cannot be that returning a correct answer is the cause of "an  
obviously incorrect expansion". In fact, I strongly suspect that what  
you claim to be incorrect is not so, but of course since you have not  
included the expression we can't check it.

Now, turning to the behaviour of ComplexExpand; I do not agree with  
any of your points. First, I do not agree that:

> Since ComplexExpand is
> supposed to assume that all variables are real by default, one would
> expect ComplexExpand to return the expression without change, but it
> doesn't.

No. Complex expand expands, even if all the parameters are assumed to  
be real (real is also complex), e.g.


ComplexExpand[(a + b)^2]


a^2 + 2*b*a + b^2

The difference between ComplexExpand and just Expand in the case or  
real parameters is that ComplexExpand will expand more expressions  
because it is allowed to use complex numbers in the answer it  
returns, which expand is not. Thus


Expand[a^(1/4)]


a^(1/4)


ComplexExpand[a^(1/4)]


(a^2)^(1/8)*Cos[Arg[a]/4] + I*(a^2)^(1/8)*Sin[Arg[a]/4]


This expression is completely correct. ComplexExpand is allowed to  
return imaginary numbers in its output, even if the input is real.  
Since a is a real number Arg[a] can be either 0 or Pi and this is one  
way to express this fact. This expansion is not obtainable without  
using imaginary numbers. Moreover, such expansions can be extremly  
useful

To sum up: I find no merit in your complaint about the behaviour of   
ComplexExpand.

Andrzej Kozlowski


  • Prev by Date: Re: A Su Doku solver
  • Next by Date: Re: More strange behavior by ComplexExpand
  • Previous by thread: More strange behavior by ComplexExpand
  • Next by thread: Re: Re: More strange behavior by ComplexExpand