summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-12-18 17:05:28 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2017-12-18 17:05:28 +0000
commitb42cf6cb19b6159a56d6a5b067fcc83ee59042ab (patch)
tree3b73bc82e92e29158e016cbcf887005eea0e73b3
parentc98ecff322dfa606cfd9d104f8b01eed1667330b (diff)
downloadmpfr-b42cf6cb19b6159a56d6a5b067fcc83ee59042ab.tar.gz
[doc/algorithms.tex,src/tanh.c] Fixed the bound, in particular from
the recent improvements in the error analysis. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@12007 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--doc/algorithms.tex4
-rw-r--r--src/tanh.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/doc/algorithms.tex b/doc/algorithms.tex
index c2bb689ad..3010a2738 100644
--- a/doc/algorithms.tex
+++ b/doc/algorithms.tex
@@ -1892,7 +1892,9 @@ $|\theta_5| \leq 2^{-p}$.
Since $2^k+4 \leq 2^{{\rm max}(3,k+1)}$,
the relative error on $s$ is thus bounded by $2^{{\rm max}(4,k+2)-p}$.
-The condition $2^k+4 \leq 2^{p/2}$ is checked in the code.
+The condition $2^k+4 \leq 2^{p/2}$ is checked in the code with
+${\rm max}(3,k+1) \leq \lfloor p/2 \rfloor$, so that:
+\[2^k+4 \leq 2^{{\rm max}(3,k+1)} \leq 2^{\lfloor p/2 \rfloor} \leq 2^{p/2}.\]
\subsection{The inverse hyperbolic tangent function}
diff --git a/src/tanh.c b/src/tanh.c
index e731f2623..7182d0e79 100644
--- a/src/tanh.c
+++ b/src/tanh.c
@@ -131,10 +131,12 @@ mpfr_tanh (mpfr_ptr y, mpfr_srcptr xt , mpfr_rnd_t rnd_mode)
d = d - MPFR_GET_EXP (te);
mpfr_div (t, te, t, MPFR_RNDN); /* (exp(2x)-1)/(exp(2x)+1) */
- /* Calculation of the error, see algorithms.tex */
- d = MAX(4, d + 2);
+ /* Calculation of the error, see algorithms.tex; the current value
+ of d is k in algorithms.tex. */
+ d = MAX(3, d + 1); /* d = exponent in 2^(max(3,k+1)) */
err = Nt - (d + 1);
+ /* The inequality is the condition max(3,k+1) <= floor(p/2). */
if (MPFR_LIKELY ((d <= Nt / 2) && MPFR_CAN_ROUND (t, err, Ny, rnd_mode)))
{
inexact = mpfr_set4 (y, t, rnd_mode, sign);