[Date Index]
[Thread Index]
[Author Index]
Re: Re: Redefine Arg to return a value from 0 to 2 pi
*To*: mathgroup at smc.vnet.net
*Subject*: [mg80480] Re: [mg80421] Re: Redefine Arg to return a value from 0 to 2 pi
*From*: DrMajorBob <drmajorbob at bigfoot.com>
*Date*: Thu, 23 Aug 2007 01:12:13 -0400 (EDT)
*References*: <faeash$f5i$1@smc.vnet.net> <8741959.1187814951914.JavaMail.root@m35>
*Reply-to*: drmajorbob at bigfoot.com
I think I'd use
myArg[z_] := Mod[Arg@z, 2 Pi]
Bobby
On Wed, 22 Aug 2007 03:41:13 -0500, <markholtuk at googlemail.com> wrote:
> 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
>
>
>
>
--
DrMajorBob at bigfoot.com
Prev by Date:
**Re: Newbie question on FindRoot and NIntergrate**
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:
**Unit testing in Mathematica or Wolfram Workbench**
| |