summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cos.c4
-rw-r--r--src/exp_2.c3
-rw-r--r--src/log.c10
3 files changed, 8 insertions, 9 deletions
diff --git a/src/cos.c b/src/cos.c
index 36d2b0dfc..95adf4f83 100644
--- a/src/cos.c
+++ b/src/cos.c
@@ -174,7 +174,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
}
K0 = __gmpfr_isqrt (precy / 3);
- m = precy + 2 * MPFR_INT_CEIL_LOG2 (precy) + 2 * K0;
+ m = precy + 2 * MPFR_INT_CEIL_LOG2 (precy) + 2 * K0 + 4;
if (expx >= 3)
{
@@ -245,7 +245,7 @@ mpfr_cos (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
l = 2 * l + 1;
if (reduce)
l += (K == 0) ? 4 : 1;
- k = MPFR_INT_CEIL_LOG2 (l) + 2*K;
+ k = MPFR_INT_CEIL_LOG2 (l) + 2 * K;
/* now the error is bounded by 2^(k-m) = 2^(EXP(s)-err) */
exps = MPFR_GET_EXP (s);
diff --git a/src/exp_2.c b/src/exp_2.c
index cfa81083f..d0ea7a20d 100644
--- a/src/exp_2.c
+++ b/src/exp_2.c
@@ -159,7 +159,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
l = (precy - 1) / K + 1;
err = K + MPFR_INT_CEIL_LOG2 (2 * l + 18);
/* add K extra bits, i.e. failure probability <= 1/2^K = O(1/precy) */
- q = precy + err + K + 8;
+ q = precy + err + K + 10;
/* if |x| >> 1, take into account the cancelled bits */
if (expx > 0)
q += expx;
@@ -255,7 +255,6 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
break;
}
}
-
MPFR_ZIV_NEXT (loop, q);
MPFR_GROUP_REPREC_2(group, q+error_r, r, s);
}
diff --git a/src/log.c b/src/log.c
index cf0b2ec6e..c9fe138d7 100644
--- a/src/log.c
+++ b/src/log.c
@@ -103,8 +103,8 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode)
q = MPFR_PREC (r);
- /* use initial precision about q+lg(q)+5 */
- p = q + 5 + 2 * MPFR_INT_CEIL_LOG2 (q);
+ /* use initial precision about q+2*lg(q)+cte */
+ p = q + 2 * MPFR_INT_CEIL_LOG2 (q) + 10;
/* % ~(mpfr_prec_t)GMP_NUMB_BITS ;
m=q; while (m) { p++; m >>= 1; } */
/* if (MPFR_LIKELY(p % GMP_NUMB_BITS != 0))
@@ -143,19 +143,19 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode)
/* we have 7 ulps of error from the above roundings,
4 ulps from the 4/s^2 second order term,
plus the canceled bits */
- if (MPFR_LIKELY (MPFR_CAN_ROUND (tmp1, p-cancel-4, q, rnd_mode)))
+ if (MPFR_LIKELY (MPFR_CAN_ROUND (tmp1, p - cancel - 4, q, rnd_mode)))
break;
/* VL: I think it is better to have an increment that it isn't
too low; in particular, the increment must be positive even
if cancel = 0 (can this occur?). */
- p += cancel >= 8 ? cancel : 8;
+ p += cancel + MPFR_INT_CEIL_LOG2 (p);
}
else
{
/* TODO: find why this case can occur and what is best to do
with it. */
- p += 32;
+ p += MPFR_INT_CEIL_LOG2 (p);
}
MPFR_ZIV_NEXT (loop, p);