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

• To: mathgroup at smc.vnet.net
• Subject: [mg80419] Re: Redefine Arg to return a value from 0 to 2 pi
• From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
• Date: Wed, 22 Aug 2007 04:40:08 -0400 (EDT)
• Organization: University of Maryland, Baltimore County
• References: <faeash\$f5i\$1@smc.vnet.net>

Works for me with Mathematica 6.01:
I didn't redefine Arg.

Kevin

myArg[z_] := Module[{z0 = z},
If[Im[z0] < 0,
ArcTan[Re[z0], Im[z0]] +
2*Pi, ArcTan[Re[z0],
Im[z0]]]]

p1 = ListPlot[Table[
{t, myArg[2*E^(I*t)]},
{t, 0, 4*Pi, 0.5}],
PlotStyle -> Red];
p2 = ListPlot[Table[
{t, Arg[2*E^(I*t)]},
{t, 0, 4*Pi, 0.5}],
PlotJoined -> True];
Show[p2, p1, PlotRange ->
{-2*Pi, 2*Pi}]

chuck009 wrote:
> I'm trying to redefine Arg to return a value from 0 to 2 pi.  However when I do so and then try and plot Arg[z], Mathematica seems to still use the old definition.  Can anybody help me?  This is my code:
>
> (* redefine Arg to return a value from 0 to 2 pi *)
>
> Unprotect[Arg]
> Arg[z_] := Module[{z0 = z}, If[Im[z0] < 0,
>          ArcTan[Re[z0], Im[z0]] + 2*Pi, ArcTan[Re[z0],
>            Im[z0]]]];
> Protect[Arg]
>
> (* check new definition -- this is correct *)
>
> ListPlot[Table[{t, Arg[2*Exp[I*t]]}, {t, 0, 4*Pi, 0.1}]]
>
> (* try and plot new definition of Arg -- Plot used the old definition (-pi to pi) *)
>
> Plot[Arg[2*Exp[I*t]], {t, 0, 4*Pi}]
>
> (* resore old definition of Arg *)
>
> Unprotect[Arg]
> Arg[z_] =.
> Protect[Arg]
>

• Prev by Date: Automatic save before run in Wolfram Workbench
• Next by Date: ParametricPlot3D from 5.2 to 6.0
• Previous by thread: Redefine Arg to return a value from 0 to 2 pi
• Next by thread: Re: Redefine Arg to return a value from 0 to 2 pi