diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2006-12-19 07:08:13 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2006-12-19 07:08:13 +0000 |
commit | bf422a3c603dcb575722342aa0ac6abaa7bd761a (patch) | |
tree | b4fe66661aa88991aea310be8cc8c6212298ace5 /zeta_ui.c | |
parent | 43738eacae30871d412037c725815e18693b8a49 (diff) | |
download | mpfr-bf422a3c603dcb575722342aa0ac6abaa7bd761a.tar.gz |
improved efficiency of zeta_ui(s) for 3^(-s) < 1/2*ulp(1)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@4315 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'zeta_ui.c')
-rw-r--r-- | zeta_ui.c | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -68,16 +68,32 @@ mpfr_zeta_ui (mpfr_ptr z, unsigned long m, mp_rnd_t r) } } - /* FIXME: treat also the case where zeta(m) - (1+1/2^m) < ulp(1). - For m >= 6, we have zeta(m) - (1+1/2^m) < 2^(-1.5*m), - thus if p <= 1.5*m, then zeta(m) - (1+1/2^m) < 2^(-p) - and the result is either 1 or 1+. */ + /* now treat also the case where zeta(m) - (1+1/2^m) < 1/2*ulp(1), + and the result is either 1+2^(-m) or 1+2^(-m)+2^(1-p). */ + mpfr_init2 (y, 31); + + if (m >= p / 2) /* otherwise 4^(-m) > 2^(-p) */ + { + /* the following is a lower bound for log(3)/log(2) */ + mpfr_set_str_binary (y, "1.100101011100000000011010001110"); + mpfr_mul_ui (y, y, m, GMP_RNDZ); /* lower bound for log2(3^m) */ + if (mpfr_cmp_ui (y, p + 2) >= 0) + { + mpfr_clear (y); + mpfr_set_ui (z, 1, GMP_RNDZ); + mpfr_div_2exp (z, z, m, GMP_RNDZ); + mpfr_add_ui (z, z, 1, GMP_RNDZ); + if (r != GMP_RNDU) + return -1; + mpfr_nextabove (z); + return 1; + } + } mpz_init (s); mpz_init (d); mpz_init (t); mpz_init (q); - mpfr_init2 (y, MPFR_PREC_MIN); p += MPFR_INT_CEIL_LOG2(p); /* account of the n term in the error */ |