[Numpy-discussion] arctan2 with complex args

David Goldsmith David.L.Goldsmith@noaa....
Mon Apr 30 10:26:49 CDT 2007


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 or complex), 
> should be (if I still can play with sin and cos...):
>
> y = arctan(x) = 1/(2j) * log((1j-x)/(1j+x))
After a little algebra, they're the same formula (as they must be; hint: 
"rationalize" the denominator inside the log and bring the 1/2 inside 
the log, making it a square root, and finally, rewrite 1/i as -i); I 
have to run my kid to school right now, but if you want me to flesh this 
out, reply and I'll type it out and send it when I get back..

DG
>
> [ 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 
> <mailto: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 <mailto:Numpy-discussion@scipy.org>
>     http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>   



More information about the Numpy-discussion mailing list