Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arccosh works for much larger numbers than arccos #3595

Closed
endolith opened this issue Aug 9, 2013 · 2 comments
Closed

arccosh works for much larger numbers than arccos #3595

endolith opened this issue Aug 9, 2013 · 2 comments

Comments

@endolith
Copy link
Contributor

endolith commented Aug 9, 2013

arccosh(x) = i arccos(x), so np.arccos() and np.arccosh() should produce the same output but with real and imaginary flipped:

In [39]: arccos(0.1+0j), arccosh(0.1+0j)
Out[39]: ((1.4706289056333368-0j), 1.4706289056333368j)

In [40]: arccos(1.1+0j), arccosh(1.1+0j)
Out[40]: (0.44356825438511532j, (0.44356825438511532+0j))

but at 10**7, arccos is inaccurate:

In [47]: arccos(10**7+0j), arccosh(10**7+0j)
Out[47]: (16.805431370234086j, (16.811242831518264+0j))

and then gives up at 10**8 and outputs infs:

In [48]: arccos(10**8+0j), arccosh(10**8+0j)
Out[48]: (inf*j, (19.113827924512311+0j))

but arccosh keeps going to almost the full float range:

In [86]: arccos(10**307+0j), arccosh(10**307+0j)
Out[86]: ((-inf-inf*j), (707.58677072973194+0j))

and is still accurate

so whatever algorithm is used for arccosh could presumably be used for arccos also, just with the imaginariness flipped.

@endolith
Copy link
Contributor Author

endolith commented Aug 9, 2013

arccosh appears to be far slower though :/

In [51]: timeit cos(x)
1000 loops, best of 3: 259 us per loop

In [52]: timeit cosh(x)
1000 loops, best of 3: 638 us per loop

In [53]: timeit arccos(x)
1000 loops, best of 3: 336 us per loop

In [54]: timeit arccosh(x)
100 loops, best of 3: 3.9 ms per loop

@mattip
Copy link
Member

mattip commented Sep 14, 2019

Closing. In the examples given arccos is now the complex conjugate of arccosh. Please reopen with failures if relevant.

@mattip mattip closed this as completed Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants