[Numpy-discussion] arctan2 with complex args

Anne Archibald peridot.faceted at gmail.com
Mon Apr 30 00:29:50 EDT 2007


On 29/04/07, David Goldsmith <David.L.Goldsmith at noaa.gov> wrote:
> Far be it from me to challenge the mighty Wolfram, but I'm not sure that
> using the *formula* for calculating the arctan of a *single* complex
> argument from its real and imaginary parts makes any sense if x and/or y
> are themselves complex (in particular, does Lim(formula), as the
> imaginary part of complex x and/or y approaches zero, approach
> arctan2(realpart(x), realpart(y)?) - without going to the trouble to
> determine it one way or another, I'd be surprised if "their"
> continuation of the arctan2 function from RxR to CxC is (a. e.)
> continuous (not that I know for sure that "mine" is...).

Well, yes, in fact, theirs is continuous, and in fact analytic, except
along the branch cuts (which they describe). Formulas almost always
yield continuous functions apart from easy-to-recognize cases. (This
can be made into a specific theorem if you're determined.)

Their formula is a pretty reasonable choice, given that it's not at
all clear what arctan2 should mean for complex arguments. But for
numpy it's tempting to simply throw an exception (which would catch
quite a few programmer errors that would otherwise manifest as
nonsense numbers). Still, I suppose defining it on the complex numbers
in a way that is continuous close to the real plane allows people to
put in almost-real complex numbers and get out pretty much the answer
they expect. Does anyone have an application for which they need
arctan2 of, say, (1+i,1-i)?

Anne



More information about the NumPy-Discussion mailing list