Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg80421] Re: Redefine Arg to return a value from 0 to 2 pi
  • From: markholtuk at googlemail.com
  • Date: Wed, 22 Aug 2007 04:41:13 -0400 (EDT)
  • References: <faeash$f5i$1@smc.vnet.net>

I've always got the impression from this list that it's not
necessarily a good idea to mess around with built-in commands. The
thing to do is to define your own command e.g. myArg as follows:

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

This will then do what you want:

Plot[myArg[2*Exp[I*t]], {t, 0, 4*Pi}]

I'm sorry I can't explain why your approach doesn't work, but I'm sure
one of our resident guru's can/will.

Best wishes,

Mark

On Aug 21, 10:22 am, chuck009 <dmili... at comcast.com> 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]

Mark R. Holt, BA, PhD,
Room 3.28
Molecular Cardiology,
Cardiovascular Division and
Randall Division of Cell and Molecular Biophysics,
New Hunt's House,
King's College London,
Guy's Hospital Campus,
LONDON, SE1 1UL.

Phone: +44 20 7848 6438
Fax:     +44 20 7848 6435




  • Prev by Date: Re: Re: Missing information in Mathematica 6.0 Documentation
  • Next by Date: Re: On partitioning lists by intervals
  • Previous by thread: Re: 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