Re: Problem with ComplexExpand[Abs[]]

*To*: mathgroup at christensen.cybernetics.net*Subject*: [mg1812] Re: Problem with ComplexExpand[Abs[]]*From*: Robert Villegas <villegas>*Date*: Thu, 17 Aug 1995 00:02:50 -0400

> He is running into a problem where > > ComplexExpand[Abs[a + I b + Sqrt[a + I b]]] > > will not evaluate further. What's going on? Is there a way to expand > Sqrt[a + I b] into something of the form (d + I e) which Abs can cope > with, or has he hit against some fundamental problem with complex algebra > which says there is no general solution to this problem? Paul, ComplexExpand is happy with Abs being the outer function in the result, and doesn't look inside to see about expanding things. You can make it produce an alternative form that doesn't have Abs in it. There are six basic operators that ComplexExpand is willing to use to express its answer: {Re, Im, Abs, Arg, Conjugate, Sign}. This is besides the elementary functions and ones related to what you used in the input. If you don't tell it what to use, it will choose, and often the choice will be Abs and Arg. Use the TargetFunctions option to restrict its choice. In[36]:= ComplexExpand[Abs[a + I b + Sqrt[a + I b]], TargetFunctions->{Re, Im}] 2 2 1/4 ArcTan[a, b] 2 Out[36]= Sqrt[(a + (a + b ) Cos[------------]) + 2 2 2 1/4 ArcTan[a, b] 2 > (b + (a + b ) Sin[------------]) ] 2 It certainly won't use any outside the set you give; it may or may not need to use all the ones you gave (maybe none of them). If you have no problem in general with Abs appearing in the answer, but just need to get past the one on the outside, then ComplexExpand inside by using Map In[43]:= ComplexExpand /@ Abs[a + I b + Sqrt[a + I b]] 2 2 1/4 Arg[a + I b] Out[43]= Abs[a + (a + b ) Cos[------------] + 2 2 2 1/4 Arg[a + I b] > I (b + (a + b ) Sin[------------])] 2 and get rid of the one on the outside: In[44]:= ComplexExpand[%, TargetFunctions->{Re, Im}] 2 2 1/4 ArcTan[a, b] 2 Out[44]= Sqrt[(a + (a + b ) Cos[------------]) + 2 2 2 1/4 ArcTan[a, b] 2 > (b + (a + b ) Sin[------------]) ] 2 The same technique of "getting underneath" Abs could be applied through the whole expression, from the depths to the top, if you want: In[58]:= MapAll[ Replace[#, Abs[expr_] :> Abs @ ComplexExpand[expr]]&, Abs[a + I b + Sqrt[a + I b]] ] 2 2 1/4 Arg[a + I b] Out[58]= Abs[a + (a + b ) Cos[------------] + 2 2 2 1/4 Arg[a + I b] > I (b + (a + b ) Sin[------------])] 2 Robby Villegas