MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Arg[z] that works with zero argument?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50907] Re: Arg[z] that works with zero argument?
  • From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
  • Date: Mon, 27 Sep 2004 00:42:15 -0400 (EDT)
  • References: <cj32c8$55k$1@smc.vnet.net> <cj62su$qnl$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

AES/newspost <siegman at stanford.edu> wrote:
> 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).

It gives the interval [-Pi, Pi].

> 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.

Here are two different ways that work. Either use

  myArg[z_] := Map[If[Abs[#] == 0, 0, Arg[#]] &, z]

which is in essence what you were attempting above, or use

  myArg[z_] := Map[(Min[#] + Max[#])/2 &, Arg[z]]

Note that those solutions are very different in principle, and the latter
will complain about indeterminate expressions if the list contains zeros.
But either works. For example, given

myArg[{0, -1, I, 1 - 2*I, 0., 1.*^-15 + 1.*^-12*I}]

they both yield

{0, Pi, Pi/2, -ArcTan[2], 0, 1.5697963271282298}

David Cantrell


  • Prev by Date: RE: How to construct a matrix like this ?
  • Next by Date: Re: How to construct a matrix like this ?
  • Previous by thread: Re: Arg[z] that works with zero argument?
  • Next by thread: Button creating buttons