Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread David Goldsmith
Timothy Hochberg wrote: > > > 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)) =

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

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

Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread David Goldsmith
> (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 I'm forgetting (e.g., a branch cut convention or so

Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread Timothy Hochberg
On 4/30/07, David Goldsmith <[EMAIL PROTECTED]> wrote: 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

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 embar

Re: [Numpy-discussion] arctan2 with complex args

2007-04-30 Thread lorenzo bolla
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! 2. if someone of you is familiar with electromagnetic problems, in particular with Snell's law, will recognize that in case of total i

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 compl

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 lorenzo bolla
You make your point, but I would expect a behaviour similar to Mathematica or Matlab. From http://documents.wolfram.com/mathematica/functions/ArcTan "If x or y is complex, then ArcTan[x, y] gives . When , ArcTan[x, y] gives the number such that and ." Lorenzo. On 4/29/07, David Goldsmith <[EM

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

[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 (mos