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

Implement the 6 missing inverse trig and inverse hyperbolic functions #411

Open
postmath opened this issue Mar 28, 2022 · 5 comments
Open

Comments

@postmath
Copy link
Contributor

It would be nice to have:

  • acot(x) = pi/2 - atan(x)
  • asec(x) = pi/2 - asin(1/x)
  • acsc(x) = pi/2 - acos(1/x)
  • acoth(x) = atanh(1/x)
  • asech(x) = acosh(1/x)
  • acsch(x) = asinh(1/x)

for both arb_t and acb_t. We might want to use asymptotic series near x=0 for all except the arccotangent, and a series near the zeroes of the arctrigs, and otherwise use the definition above, or something like that.

@postmath
Copy link
Contributor Author

Of course we don't need the series near 0 because none of those functions are continuous there. And I see that arb_acos is implemented by just computing pi/2 minus the expression for arb_asin, so we can do a similar thing for all of these. That would make it relatively little work: just a straightforward implementation of the formulas here.

@postmath
Copy link
Contributor Author

And of course for the second and third formula, it's better to use acos(1/x) and asin(1/x), respectively.

@fredrik-johansson
Copy link
Collaborator

+1

I believe all cases of these functions can be implemented in numerically stable ways in terms of the existing functions. Of course for the complex versions one has to be careful with branch cuts.

@postmath
Copy link
Contributor Author

Ugh. I looked into this a little bit more and found something ugly.

The DLMF defines acot, asec, and acsc in https://dlmf.nist.gov/4.23:

  • (4.23.7) acsc(x) = asin(1/x),
  • (4.23.8) asec(x) = acos(1/x),
  • (4.23.9) acot(x) = atan(1/x).

It defined acoth, asech, and acsch in https://dlmf.nist.gov/4.37:

  • (4.37.7) acsch(x) = asinh(1/x),
  • (4.37.8) asech(x) = acosh(1/x),
  • (4.37.9) acoth(x) = atanh(1/x).

This is the same as what I (eventually) wrote above except for the arccotangent... and that's where the rub is. I realize now that there are two common definitions of the arccotangent, and they differ even on the (negative) real numbers. The DLMF definition is also used by Mathematica, gsl, julia, and your own mpmath in Python. The other definition is used on the wikipedia page and the ISO 80000 standard (which discusses the function only in terms of real numbers). So it seems that it might be most appropriate to use the DLMF definitions here.

@postmath
Copy link
Contributor Author

One correction: acoth(x) is continuous at x=0, at least within the half planes Im(x) >= 0 and Im(x) < 0. For Im(x) >= 0, it behaves like pi * i / 2 + x + x^3/3 + x^5/5 + ...; for Im(x) < 0, the sign of the constant term is opposite. The other five all diverge to some form of infinity at x=0 (unless you use the wikipedia/ISO 80000/Maple definition of acot(x); then that one is also continuous and it behaves like pi/2 - x + x^3/3 - x^5/5 + ...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants