[Numpy-discussion] arctan2 with complex args
lorenzo bolla
lbolla@gmail....
Mon Apr 30 09:50:33 CDT 2007
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 I still can play with sin and cos...):
y = arctan(x) = 1/(2j) * log((1j-x)/(1j+x))
[ you can get it doing: y = arctan(x) --> x = tan(y) = sin(x)/cos(x) = -1j *
(exp(1j*y)-exp(-1j*y))/(exp(1j*y)+exp(-1j*y); then let z = exp(1j*y) and
solve in z.]
I've tested the formula and it seems ok for different inputs (I've checked
that tan(arctan(x)) == x):
---------------------------
octave:56> x = 1; tan(1/2/1j*log((1j-x)/(1j+x)))
ans = 1.0000
octave:57> x = 1j; tan(1/2/1j*log((1j-x)/(1j+x)))
ans = -0 + 1i
octave:58> x = 2j; tan(1/2/1j*log((1j-x)/(1j+x)))
ans = 1.8369e-16 + 2.0000e+00i
octave:59> x = 1+2j; tan(1/2/1j*log((1j-x)/(1j+x)))
ans = 1.0000 + 2.0000i
---------------------------
hth,
L.
On 4/30/07, David Goldsmith <David.L.Goldsmith@noaa.gov> 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 I'm forgetting (e.g., a branch cut convention or
> something) why this is wrong?
>
> DG
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070430/8d5b3f5e/attachment.html
More information about the Numpy-discussion
mailing list