Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread David Goldsmith
lorenzo bolla wrote: me! I have two cases. 1. I need that arctan2(1+0.0001j,1-0.01j) gives something close to arctan2(1,1): any decent analytic prolungation will do! This is the foreseeable use case described by Anne. In any event, I stand not only corrected, but

Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread Timothy Hochberg
On 4/30/07, David Goldsmith [EMAIL PROTECTED] wrote: (hint what is arctan(0+1j)?) Well, at the risk of embarrassing myself, using arctan(x+iy) = I get: arctan(0+1i) = -i*log((0+i*1)/sqrt(0^2 + 1^2)) = -i*log(i/1) = -i*log(i) = -i*log(exp(i*pi/2)) = -i*i*pi/2 = pi/2... Is there some reason

Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread lorenzo bolla
hold on, david. the formula I posted previously from wolfram is ArcTan[x,y] with x or y complex: its the same of arctan2(x,y). arctan is another function (even though arctan2(y,x) should be a better arctan(y/x)). the correct formula for y = arctan(x), with any x (real or complex), should be (if

Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread David Goldsmith
lorenzo bolla wrote: hold on, david. the formula I posted previously from wolfram is ArcTan[x,y] with x or y complex: its the same of arctan2(x,y). arctan is another function (even though arctan2(y,x) should be a better arctan(y/x)). the correct formula for y = arctan(x), with any x (real

Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread David Goldsmith
Timothy Hochberg wrote: On 4/30/07, *David Goldsmith* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: (hint what is arctan(0+1j)?) Well, at the risk of embarrassing myself, using arctan(x+iy) = I get: arctan(0+1i) = -i*log((0+i*1)/sqrt(0^2 + 1^2)) = -i*log(i/1) =

[Numpy-discussion] arctan2 with complex args

2007-04-29 Thread lorenzo bolla
Weird behaviour with arctan2(complex,complex). Take a look at this: In [11]: numpy.arctan2(1.,1.) Out[11]: 0.785398163397 In [12]: numpy.arctan2(1j,1j) --- exceptions.AttributeErrorTraceback

Re: [Numpy-discussion] arctan2 with complex args

2007-04-29 Thread David Goldsmith
I'll take a stab at this one; if I miss the mark, people, please chime in. What's strange here is not numpy's behavior but octave's (IMO). Remember that, over R, arctan is used in two different ways: one is simply as a map from (-inf, inf) - (-pi/2,pi/2) - here, let's call that invtan; the

Re: [Numpy-discussion] arctan2 with complex args

2007-04-29 Thread David Goldsmith
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

Re: [Numpy-discussion] arctan2 with complex args

2007-04-29 Thread Anne Archibald
On 29/04/07, David Goldsmith [EMAIL PROTECTED] 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