MathGroup Archive 2007

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

Search the Archive

Re: Redefine Arg to return a value from 0 to 2 pi

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80477] Re: Redefine Arg to return a value from 0 to 2 pi
  • From: chuck009 <dmilioto at comcast.com>
  • Date: Thu, 23 Aug 2007 01:10:40 -0400 (EDT)

> I've always got the impression from this list that
> it's not
> necessarily a good idea to mess around with built-in
> commands.

That looks very interesting Mark.  No, I mean the Molecular Cardiology.  It's like the time I was rebuilding my engine on my 84' pickup.  I got all the parts and asked the guy, "you sure these will all fit?".  He said, "if you know what you're doing they will" :).

I did get it to work by using the Hold and ReleaseHold constructs.  The code below re-defines Arg twice, once from 0 to 2pi and then from 2pi to 4pi and then integrates these changes into Log and Sqrt.  I then use these new definitions to generate the Riemann surface for Sqrt[z] directly without resorting to the usual methods to generate these surfaces.  Anyone interested, use a fresh Kernel and note how the value of Sqrt[-1-i] changes from the lower surface to the upper surface when the switch is made.  

N[Sqrt[-1 - I]]
Plot3D[Im[Sqrt[x + I*y]], {x, -1, 1}, {y, -1, 1}]
Unprotect[Arg]; 
Unprotect[Log]; 
Unprotect[Sqrt]; 
Arg[z_Complex] := Module[{z0 = z}, If[Im[z0] < 0, 
         ArcTan[Re[z0], Im[z0]] + 2*Pi, ArcTan[Re[z0], Im[z0]]]]; 
Log[z_Complex] := Log[Abs[z]] + I*Arg[z]; 
Sqrt[z_Complex] := Exp[(1/2)*(Log[Abs[z]] + I*Arg[z])]; 
Protect[Sqrt]; 
Protect[Log]; 
Protect[Arg]; 
N[Sqrt[-1 - I]]
p1 = Plot3D[ReleaseHold[Im[Hold[Sqrt[x + I*y]]]], {x, -1, 1}, 
     {y, -1, 1}]
Unprotect[Arg]; 
Unprotect[Log]; 
Unprotect[Sqrt]; 
Arg[z_Complex] := Module[{z0 = z}, If[Im[z0] > 0, 
         ArcTan[Re[z0], Im[z0]] + 2*Pi, 
    ArcTan[Re[z0], Im[z]] + 4*Pi]]; 
Log[z_Complex] := Log[Abs[z]] + I*Arg[z]; 
Sqrt[z_Complex] := Exp[(1/2)*(Log[Abs[z]] + I*Arg[z])]; 
Protect[Sqrt]; 
Protect[Log]; 
Protect[Arg]; 
p2 = Plot3D[ReleaseHold[Im[Hold[Sqrt[x + I*y]]]], {x, -1, 1}, 
     {y, -1, 1}]
Show[{p1, p2}, PlotRange -> All]


  • Prev by Date: Re: generalized 2d IFS for D_n Cartan group using MathWorld
  • Next by Date: Re: Newbie question on FindRoot and NIntergrate
  • Previous by thread: Re: Redefine Arg to return a value from 0 to 2 pi
  • Next by thread: Re: Re: Redefine Arg to return a value from 0 to 2 pi