[Date Index]
[Thread Index]
[Author Index]
Re: Possible Bug in ArcTan ?
 To: mathgroup at smc.vnet.net
 Subject: [mg64832] Re: Possible Bug in ArcTan ?
 From: "JensPeer Kuska" <kuska at informatik.unileipzig.de>
 Date: Sun, 5 Mar 2006 03:18:50 0500 (EST)
 Organization: Uni Leipzig
 References: <du6o44$5rg$1@smc.vnet.net> <du83m5$sv3$1@smc.vnet.net> <du8are$fp7$1@smc.vnet.net> <dubgv0$fm7$1@smc.vnet.net>
 Sender: ownerwrimathgroup at wolfram.com
Paul,
why you want avoid the twoargument form. The twoargument 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.
Regards
Jens
"Paul Abbott" <paul at physics.uwa.edu.au> schrieb im
Newsbeitrag news:dubgv0$fm7$1 at smc.vnet.net...
 In article <du8are$fp7$1 at smc.vnet.net>,
 "David W. Cantrell" <DWCantrell at sigmaxi.org>
wrote:

 > "JensPeer Kuska"
<kuska at informatik.unileipzig.de> wrote:
 > > Hi,
 > >
 > > why can ArcTan[] have two arguments
ArcTan[x,y]
 >
 > As the Help Browser says,
 > "taking into account which quadrant the point
(x,y) is in."
 >
 > For example, suppose you want to convert 2 +
I to polar form,
 > r*E^(I*theta). One can't simply say theta =
ArcTan[1/2]. The range of the
 > singleargument ArcTan is [Pi/2, Pi/2], i.e.,
fourth and first quadrants,
 > while our point (2, 1) is in the third
quadrant. But we can conveniently
 > say theta = ArcTan[2, 1].

 Or we can say theta = 2 ArcTan[1/(Sqrt[5]2)]
(see below).

 > Note: Some other languages implement the
twoargument form under the
 > name ATAN2. Furthermore, the order of the two
arguments is often backwards
 > compared to Mathematica's, that is,
ATAN2(y,x).

 There is another way that avoids the
twoargument form altogether. Using
 the halfangle formula for tan,

 Simplify[Tan[t/2] == Sin[t]/(Cos[t] + 1)]

 True

 then in polar coordinates, x=r Cos[t], y=r
Sin[t], r=Sqrt[x^2+y^2],

 Tan[t/2] == y/(x+r) ==> t == 2
ArcTan[y/(x+Sqrt[x^2+y^2])]

 This formula is also valid when x == 0, whereas
ArcTan[y/x] is
 problematic there (ArcTan[0,y] is ok, of
course).

 Cheers,
 Paul


_______________________________________________________________________
 Paul Abbott
Phone: 61 8 6488 2734
 School of Physics, M013
Fax: +61 8 6488 1014
 The University of Western Australia
(CRICOS Provider No 00126G)
 AUSTRALIA
http://physics.uwa.edu.au/~paul

Prev by Date:
Re: Possible Bug in ArcTan ?
Next by Date:
Re: FindInstance for sudoku
Previous by thread:
Re: Possible Bug in ArcTan ?
Next by thread:
Re: Possible Bug in ArcTan ?
 