MathGroup Archive 2006

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

Search the Archive

Re: Possible Bug in ArcTan ?


Paul Abbott <paul at physics.uwa.edu.au> wrote:
> In article <due86a$9vj$1 at smc.vnet.net>,
>  "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de> wrote:
>
> > why you want avoid the two-argument form. The two-argument form help
> > a lot during programing, because one has not to type
> >
> > If[x=!=0,ArcTan[y/x]]
> >
> > and a division by zero is in the most programing languages
> > a very hard and evil error.
>
> There is no "division by zero" error using the form
>
>   2 ArcTan[y/(x+Sqrt[x^2+y^2])]
>
> except when x == y == 0 -- where the result is undefined anyway.

First, there will be division by zero if y is zero and x is nonpositive.
See below.

Second, the very special case when both x and y are zero is interesting.
Of course, one could well argue that we should _want_ the result to be
undefined, that is, Indeterminate in Mathematica. And indeed, that's what
Paul's expression gives. But there's also a good argument that we should
want ArcTan[x,y] to be defined even when both x and y are zero. That's what
Mathematica does: ArcTan[0,0] yields Interval[{-Pi,Pi}]. IMO, the only
result which would be slightly better would be the "half-open, half-closed"
interval (-Pi, Pi], which I suppose is unavailable in Mathematica.

> However, as David Cantrell points out, this form (only) fails if y is
> zero and x is negative (returning 0 instead of Pi), and so must be
> considered separately.

Actually, when x is negative and y is zero, we also have division by zero.
But then we're dividing into zero as well, and so in Mathematica the result
is neither Pi nor 0, but rather Indeterminate.

David


  • Prev by Date: Re: Listable functions with two brackets f[][] (SubValues)
  • Next by Date: Re: Listable functions with two brackets f[][] (SubValues)
  • Previous by thread: Re: Possible Bug in ArcTan ?
  • Next by thread: Re: Possible Bug in ArcTan ?