[Date Index]
[Thread Index]
[Author Index]
Re: Newby Q: How to specify reals
*To*: mathgroup at smc.vnet.net
*Subject*: [mg110591] Re: Newby Q: How to specify reals
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Sat, 26 Jun 2010 08:42:10 -0400 (EDT)
On 26 Jun 2010, at 16:10, David Park wrote:
> The Help could also better specify the use of TargetFunctions. It should say
> that it has the default value of TargetFunctions -> {Re, Im, Abs, Arg,
> Conjugate, Sign} and that Mathematica will choose among all of them by the
> internal algorithm. One might have the impression that {Re, Im} are the
> default TargetFunctions, which is not the case. For example the following
> does not give what one might expect and doesn't even expand to the usual
> form.
>
> ComplexExpand[Abs[(x + I y)^2]]
>
> Abs[x + I y]^2
>
> Maybe it's a bug or a weakness in the algorithm. Or maybe the meaning of
> "Expand" isn't quite what I wrote above. One would usually want:
>
> ComplexExpand[Abs[(x + I y)^2], TargetFunctions -> {Re, Im}]
>
> x^2 + y^2
There is no bug here at all. Look at the default value of the option TargetFunctions of ComplexExpand:
OptionValue[ComplexExpand, TargetFunctions]
{Re,Im,Abs,Arg,Conjugate,Sign}
So when you evaluate ComplexExpand[Abs[(x + I y)^2]] you are asking Mathematica to expand the expression as a sum of real and imaginary parts in terms of any of these TargetFunctions. But the expression you gave to ComplexExpand is already expanded in terms of these functions (actually one of them). Hence of course ComplexExpand does nothing. If you remove Abs from the list of allowable TargetFunctions you will get the expected expansion. The same thing will happen every time when you apply ComplexExpand to something that is already "expanded" in terms of any of the default Target Functions.
ComplexExpand[Sign[x]]
Sign[x]
ComplexExpand[Sign[x],
TargetFunctions -> {Re, Im, Abs, Arg, Conjugate}]
x/Sqrt[x^2]
ComplexExpand[Sign[x], TargetFunctions -> {Arg}]
E^(I*Arg[x])
Of course ComplexExpand will use non-listed target functions if it can't expand an expression in terms of the listed ones:
ComplexExpand[Sign[x], TargetFunctions -> {Abs}]
x/Sqrt[x^2]
Andrzej Kozlowski
Prev by Date:
**Re: Matrix multiplication (again !)**
Next by Date:
**Circuit gains**
Previous by thread:
**Re: Newby Q: How to specify reals**
Next by thread:
**calculating mean prediction bands**
| |