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

*To*: mathgroup at smc.vnet.net*Subject*: [mg80463] Re: Redefine Arg to return a value from 0 to 2 pi*From*: dh <dh at metrohm.ch>*Date*: Thu, 23 Aug 2007 01:03:24 -0400 (EDT)*References*: <faeash$f5i$1@smc.vnet.net>

Hi Chuck, it is bad practise to redefine built in funcions, you may run into troubles you did not anticipate. I think it is better to write your own version, what can be done e.g. by myArg[x_]:=Mod[Arg[x],2Pi] hope this helps, Daniel 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] >