There doesn’t seem to be an implementation for atan when x and y are complex numbers. The currently implement atan(y/x) is not a replacement, as it loses the information on which quadrants x and y are in.
This is important for spherical harmonics and converting to spherical coordinates in the complex domain.
atan(x::Complex,y::Complex) = - im * log( (x+y*im)/sqrt(x^2+y^2) )
You can test this does get the right quadrants with:
map(1:10000) do i
x = rand(-1.001:0.01:1.0) + rand(-1.001:0.01:1.0)*im
y = rand(-1.001:0.01:1.0) + rand(-1.001:0.01:1.0)im
r = sqrt(x^2 + y^2) # note this is a complex number
θ = atan(y,x)
norm( [x,y] - r . [cos(θ),sin(θ)] )
For several packages I now add this definition to use (what is in my field) standard coordinate transforms.
You can make a one line PR easily from Github without evening building Julia locally: just click “edit”, make the change, and “propose file change”. The CI will test you’re change, though you’ll probably need to also add tests.