-
Notifications
You must be signed in to change notification settings - Fork 179
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
mp.asin is inaccurate for small complex inputs #787
Comments
Perhaps, we could just increase working precision: diff --git a/mpmath/libmp/libmpc.py b/mpmath/libmp/libmpc.py
index 2e22b22..b0893d4 100644
--- a/mpmath/libmp/libmpc.py
+++ b/mpmath/libmp/libmpc.py
@@ -609,7 +609,7 @@ def acos_asin(z, prec, rnd, n):
and by abs(a) <= 1, in order to improve the numerical accuracy.
"""
a, b = z
- wp = prec + 10
+ wp = prec + 25
# infinite real component
if a in (finf, fninf):
if b in (finf, fninf): |
Yes, but notice that the increase by
So, I think the algorithm in mpmath itself should be fixed because the same Hull et al algorithm is used elsewhere with double FP without having the defect reported here. |
Looking at the code, I see that mpmath implements the Hull et al algorithm partially on the so-called "safe" region (see p 307) but it does not handle the non-safe regions (see p 315). While some parts of the non-safe regions are ok to dismiss because of MP math, then handling the non-safe region 2 in the paper corresponds to resolving this issue. In short, asin(z) in region 2 should read:
where |
As in the title.
Reproducer:
A workaround is to increase precision:
Points z=x+yj in the following (approximate) region
of the complex plane suffer from the defect reported here.
The text was updated successfully, but these errors were encountered: