[Date Index]
[Thread Index]
[Author Index]
Re: Arg[z] that works with zero argument?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg50909] Re: Arg[z] that works with zero argument?
*From*: Bill Rowe <readnewsciv at earthlink.net>
*Date*: Mon, 27 Sep 2004 00:42:19 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
On 9/26/04 at 5:31 AM, siegman at stanford.edu (AES/newspost) wrote:
>In article <cj32c8$55k$1 at smc.vnet.net>,
>Bill Rowe <readnewsciv at earthlink.net> wrote:
>
>>Did you try Arg[z] where z is a list?
>>Attributes[Arg] {Listable, NumericFunction, Protected}
>>
>>Arg[Table[Random[], {4}]] {0, 0, 0, 0}
>>The attribute Listable tells you Arg will accept a list as a
>>argument and do the right thing.
>Yes, the problem is that if some of the elements in the argument
>list of Arg[z] are zeros, the "right thing" that the standard
>version of Arg does for those elements is to return some long
>string (forget exactly what it is).
Well since Arg[z] is defined as x such that z == Abs[z] Exp[I x], it is undefined when z is 0. So, you should be getting an error message.
>If you then print the returned list in MatrixForm, these elements
>make all the columns involved become very wide. I'd like Arg[0] to
>just return 0, or maybe "*" or something like that, for those
>argument list elements that are themselves 0.
>And, you can't use some superficially plausible workaround like
>myArg[z_] := If[ Abs[z]==0, 0, Arg[z] ]
>because the initial test doesn't do what you want if z is a list.
If you want Arg[0] to be 0 and work on lists the approach above will work if you first set the attributes of myArg correctly, i.e.,
SetAttributes[myArg, Listable]
myArg[z_]:= If[Abs[z]==0, 0 Arg[z]]
will do what you want. An alternative would be to unprotect Arg then add definitions for 0, i.e.,
Unprotect[Arg];
Arg[0]=0;
Arg[0.]=0;
Protect[Arg];
Now Arg[0[ will be defined as 0.
--
To reply via email subtract one hundred and four
Prev by Date:
**Re: Re: trimming a string**
Next by Date:
**Array construction**
Previous by thread:
**Re: Arg[z] that works with zero argument?**
Next by thread:
**Re: Arg[z] that works with zero argument?**
| |