summaryrefslogtreecommitdiff
path: root/acosh.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-09-07 13:03:32 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-09-07 13:03:32 +0000
commit638a3e383474d2fc4adece21b2d35fa15f6827c1 (patch)
tree4e44f766a8209cb3a4725b0cbdaae0803c52abf4 /acosh.c
parente8b66aa2b3e6003c1716a0e3d9261142085e4e28 (diff)
downloadmpfr-638a3e383474d2fc4adece21b2d35fa15f6827c1.tar.gz
acosh.c: reduce the precision for ln(2); smaller error bound.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4830 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'acosh.c')
-rw-r--r--acosh.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/acosh.c b/acosh.c
index 01ee4cc28..669665397 100644
--- a/acosh.c
+++ b/acosh.c
@@ -93,17 +93,20 @@ mpfr_acosh (mpfr_ptr y, mpfr_srcptr x , mp_rnd_t rnd_mode)
if (mpfr_overflow_p ())
{
mpfr_t ln2;
+ mp_prec_t pln2;
/* As x is very large and the precision is not too large, we
assume that we obtain the same result by evaluating ln(2x).
We need to compute ln(x) + ln(2) as 2x can overflow. TODO:
write a proof and add an MPFR_ASSERTN. */
- mpfr_init2 (ln2, Nt);
- mpfr_log (t, x, GMP_RNDN);
- mpfr_const_log2 (ln2, GMP_RNDN);
- mpfr_add (t, t, ln2, GMP_RNDN);
+ mpfr_log (t, x, GMP_RNDN); /* err(log) < 1/2 ulp(t) */
+ pln2 = Nt - MPFR_PREC_MIN < MPFR_GET_EXP (t) ?
+ MPFR_PREC_MIN : Nt - MPFR_GET_EXP (t);
+ mpfr_init2 (ln2, pln2);
+ mpfr_const_log2 (ln2, GMP_RNDN); /* err(ln2) < 1/2 ulp(t) */
+ mpfr_add (t, t, ln2, GMP_RNDN); /* err <= 3/2 ulp(t) */
mpfr_clear (ln2);
- err = 2;
+ err = 1;
}
else
{