summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2021-02-03 17:52:27 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2021-02-03 17:52:27 +0000
commit989e335afe8a4824ff64ef1269f880b3dbb6d81a (patch)
tree403efca4fb1c6b078c78f3d399704973f043a7dc /src
parenta1d8f0d2108482d3c5679cd25b27ca5c240b5be9 (diff)
downloadmpfr-989e335afe8a4824ff64ef1269f880b3dbb6d81a.tar.gz
[src/atan2u.c] fixed error analysis
git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14356 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src')
-rw-r--r--src/atan2u.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/atan2u.c b/src/atan2u.c
index 0d13a94fa..c7497a4da 100644
--- a/src/atan2u.c
+++ b/src/atan2u.c
@@ -311,13 +311,15 @@ mpfr_atan2u (mpfr_ptr z, mpfr_srcptr y, mpfr_srcptr x, unsigned long u,
}
MPFR_SET_SIGN (tmp, 1);
expt = MPFR_GET_EXP(tmp);
- /* |tmp - y/x| <= e1 := 1/2*ulp(tmp) = 2^(expt-prec-1) */
+ /* |tmp - |y/x|| <= e1 := 1/2*ulp(tmp) = 2^(expt-prec-1) */
inex |= mpfr_atanu (tmp, tmp, u, MPFR_RNDN);
- /* the derivative of atan(t) is 1/(1+t^2), thus if tmp2 is the new value
- of tmp, we have |tmp2 - atan(y/x)| <= 1/2*ulp(tmp2) + e1/(1+tmp^2) */
+ /* the derivative of atan(t) is 1/(1+t^2), thus that of atanu(t) is
+ u/(1+t^2)/(2*pi), and if tmp2 is the new value of tmp, we have
+ |tmp2 - atanu|y/x|| <= 1/2*ulp(tmp2) + e1*u/(1+tmp^2)/4 */
e = (expt < 1) ? 0 : expt - 1;
/* max(1,|tmp|) >= 2^e thus 1/(1+tmp^2) <= 2^(-2*e) */
- e = expt - 2 * e;
+ e = expt - 2 * e + MPFR_INT_CEIL_LOG2(u) - 2;
+ /* now e1*u/(1+tmp^2)/4 <= 2^(e-prec-1) */
/* |tmp2 - atanu(y/x)| <= 1/2*ulp(tmp2) + 2^(e-prec-1) */
e = (e < MPFR_GET_EXP(tmp)) ? MPFR_GET_EXP(tmp) : e;
/* |tmp2 - atanu(y/x)| <= 2^(e-prec) */