diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-10 15:38:20 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-10 15:38:20 +0000 |
commit | f3b8e43f43edbb0b43043178332ff43c5d99ffdf (patch) | |
tree | 19f53c07891f9fdf9e721d9340f8283f01b6ec6d | |
parent | b81e80f6bb1bcbca0faba2c3ae0704c43451762e (diff) | |
download | mpfr-f3b8e43f43edbb0b43043178332ff43c5d99ffdf.tar.gz |
[src/cbrt.c] Description of the algorithm:
* Since there was no upper bound on s, let's remove the upper bound
on m (this now matches the code).
* Replaced the FIXME by one due to the lack of upper bound on s.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13766 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/cbrt.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/cbrt.c b/src/cbrt.c index 3af3a820d..74fa4e95e 100644 --- a/src/cbrt.c +++ b/src/cbrt.c @@ -25,19 +25,19 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., /* The computation of y = x^(1/3) is done as follows: - Let x = sign * m * 2^(3*e) where m is an integer + Let x = sign * m * 2^(3*e) where m is an integer >= 2^(3n-3) with + n = PREC(y). - with 2^(3n-3) <= m < 2^(3n) where n = PREC(y) + Let s be the integer cube root of m, i.e. the maximum integer such that + m = s^3 + r with r >= 0. - and m = s^3 + r where 0 <= r and m < (s+1)^3 + The constraint m >= 2^(3n-3) allows one to have sufficient precision + for s: s >= 2^(n-1), i.e. s has at least n bits. - FIXME: In the code below, the root can be applied to a value of m - larger than 2^(3n), if PREC(x) > 3*PREC(y) up to some small constant. + FIXME: The description below is incorrect if s has more than n bits + (since n is the target precision). - we want that s has n bits i.e. s >= 2^(n-1), or m >= 2^(3n-3) - i.e. m must have at least 3n-2 bits - - then x^(1/3) = s * 2^e if r=0 + Then x^(1/3) = s * 2^e if r=0 x^(1/3) = (s+1) * 2^e if round up x^(1/3) = (s-1) * 2^e if round down x^(1/3) = s * 2^e if nearest and r < 3/2*s^2+3/4*s+1/8 |