diff options
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/const_pi.c')
-rw-r--r-- | Build/source/libs/mpfr/mpfr-src/src/const_pi.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/const_pi.c b/Build/source/libs/mpfr/mpfr-src/src/const_pi.c index 71983ccca84..26c55030d28 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/const_pi.c +++ b/Build/source/libs/mpfr/mpfr-src/src/const_pi.c @@ -1,6 +1,6 @@ /* mpfr_const_pi -- compute Pi -Copyright 1999-2019 Free Software Foundation, Inc. +Copyright 1999-2020 Free Software Foundation, Inc. Contributed by the AriC and Caramba projects, INRIA. This file is part of the GNU MPFR Library. @@ -38,6 +38,11 @@ mpfr_const_pi (mpfr_ptr x, mpfr_rnd_t rnd_mode) { return mpfr_cache (x, __gmpfr_cache_const_pi, rnd_mode); } +/* The algorithm used here is taken from Section 8.2.5 of the book + "Fast Algorithms: A Multitape Turing Machine Implementation" + by A. Schönhage, A. F. W. Grotefeld and E. Vetter, 1994. + It is a clever form of Brent-Salamin formula. */ + /* Don't need to save/restore exponent range: the cache does it */ int mpfr_const_pi_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) @@ -80,7 +85,7 @@ mpfr_const_pi_internal (mpfr_ptr x, mpfr_rnd_t rnd_mode) mpfr_sqrt (b, B, MPFR_RNDN); /* 1/2 <= b <= 1 */ mpfr_add (ap, a, b, MPFR_RNDN); /* 1 <= ap <= 2 */ mpfr_div_2ui (ap, ap, 1, MPFR_RNDN); /* exact, 1/2 <= ap <= 1 */ - mpfr_mul (Ap, ap, ap, MPFR_RNDN); /* 1/4 <= Ap <= 1 */ + mpfr_sqr (Ap, ap, MPFR_RNDN); /* 1/4 <= Ap <= 1 */ mpfr_sub (Bp, Ap, S, MPFR_RNDN); /* -1/4 <= Bp <= 3/4 */ mpfr_mul_2ui (Bp, Bp, 1, MPFR_RNDN); /* -1/2 <= Bp <= 3/2 */ mpfr_sub (S, Ap, Bp, MPFR_RNDN); |