An Arbitrary Precision Computation Package David H
Total Page:16
File Type:pdf, Size:1020Kb
ARPREC: An Arbitrary Precision Computation Package David H. Bailey, Yozo Hida, Xiaoye S. Li and Brandon Thompson1 Lawrence Berkeley National Laboratory, Berkeley, CA 94720 Draft Date: 2002-10-14 Abstract This paper describes a new software package for performing arithmetic with an arbitrarily high level of numeric precision. It is based on the earlier MPFUN package [2], enhanced with special IEEE floating-point numerical techniques and several new functions. This package is written in C++ code for high performance and broad portability and includes both C++ and Fortran-90 translation modules, so that conventional C++ and Fortran-90 programs can utilize the package with only very minor changes. This paper includes a survey of some of the interesting applications of this package and its predecessors. 1. Introduction For a small but growing sector of the scientific computing world, the 64-bit and 80-bit IEEE floating-point arithmetic formats currently provided in most computer systems are not sufficient. As a single example, the field of climate modeling has been plagued with non-reproducibility, in that climate simulation programs give different results on different computer systems (or even on different numbers of processors), making it very difficult to diagnose bugs. Researchers in the climate modeling community have assumed that this non-reproducibility was an inevitable conse- quence of the chaotic nature of climate simulations. Recently, however, it has been demonstrated that for at least one of the widely used climate modeling programs, much of this variability is due to numerical inaccuracy in a certain inner loop. When some double-double arithmetic rou- tines, developed by the present authors, were incorporated into this program, almost all of this variability disappeared [12]. The double-double (32 digits) package mentioned above and a related quad-double (64 digits) package have been used in other scientific applications as well [13]. These include a vortex roll- up simulation [10] and a bound-state calculation of Coulomb three-body systems [11]. In each case, the computational results would have been meaningless without the additional numeric precision. In fact, the Coulomb three-body calculations eventually had to rely on arbitrary precision arithmetic software, as more than 100 digit accuracy was required. It is also expected that future analysis of vortex roll-up phenomena will require significantly more precision than provided by the quad-double package. Perhaps the most interesting applications of high precision arithmetic are in the arena of experimental mathematics. One key computation used in this research is integer relation de- tection. Given a vector x =(x1,x2,x3, ···,xn) of real or complex numbers, an integer relation algorithm finds integers ai, not all zero, such that a1x1 + a2x2 + ···+ anxn =0 At the present time, the most effective algorithm for integer relation detection is the recently discovered “PSLQ” algorithm of mathematician-sculptor Helaman Ferguson [6]. PSLQ was 1This work is supported by the Director, Office of Computational and Technology Research, Division of Math- ematical, Information, and Computational Sciences of the U.S. Department of Energy, under contract number DE-AC03-76SF00098. 1 recently named one of ten “algorithms of the century” by the editors of Computing in Science and Engineering [3]. For almost all applications of an integer relation algorithm such as PSLQ, very high precision arithmetic must be used. Such computations are typically done using 100-500 digit precision, although some problems require thousands of digits. The best-known result found using integer relation computations is the “BBP” formula for π, which was discovered in 1997 using a 2-level version of PSLQ implemented with the MPFUN multiple-precision arithmetic package [5]: ∞ π 1 4 − 2 − 1 − 1 = k k k k k k=0 16 8 +1 8 +4 8 +5 8 +6 This formula, after a minor manipulation, yields a very simple algorithm to directly compute hexadecimal or binary digits of π beginning at the n-th digit, without needing to compute any of the first n − 1 digits, and requiring only a very small amount of computer memory. Since 1997, similar formulas have been found, using PSLQ computations, for numerous other mathematical constants, including logarithms of certain integers, the Riemann zeta function evaluated at certain odd integers, arctangents of certain rational numbers, and certain constants that arise in quantum field theory. In some cases, such as Catalan’s constant, the new computer- discovered formulas are the best known formulas for computing high-precision numerical values (independent of the individual binary digit calculation property). A compendium of these “BBP- type” formulas is available online [1]. As an aside, recently it has been shown that these computer-discovered BBP-type formu- las have deep implications for the centuries-old question of whether (and why) mathematical constants such as π and log 2 are normal. Here normal base b means that every m-long string of digits in the base-b expansion appears with limiting frequency b−m, namely the frequency one would expect if the digits had been generated at random. It is easy to show using mea- sure theory that “almost all” real numbers are normal. Further, it is widely believed, based on computational√ studies, that many of the well-known constants of mathematics, including π, e, 2, log 2, log 10 and many others, are normal to commonly used number bases. But it is an embarrassing fact of modern mathematics that none of these constants has ever been proven normal to any base. Recently some significant progress was achieved in this arena. In particular, it has been demonstrated that the normality of the class of real constants for which BBP-type formulas are known (which includes π, log 2 and others), reduces to a plausible conjecture from the field of chaotic dynamics [9]. In the latest development along this line, a certain class of real numbers, uncountably infinite in number (but not yet including π), has been proven normal base 2 [9]. In another application of high-precision computing to mathematical research, PSLQ compu- tations have been used to investigate sums of the form 1 S k ( )= k 2n n>0 n n For small k, these constants are known to satisfy simple mathematical identities, such as S(4) = 17π4/3240. For many years researchers have sought generalizations of these formulas for k>4. Recently some general formulas were found using PSLQ. In particular, the constants {S(k)|k = 5 ...20} have now been evaluated in terms of multiple zeta values, which are defined by ζ s ,s , ···,s 1 ( 1 2 r)= s1 s2 sr k1 k2 ···kr k1>k2>···>kr>0 2 and multiple Clausen values of the form b sin(n1π/3) 1 M(a, b)= a n nj n1>n2>...>nb>0 1 j=1 A sample result, obtained using PSLQ, is the following: 8 8 13921 S(9) = π 2M(7, 1) + M(5, 3) + ζ(2)M(5, 1) − ζ(9) 3 9 216 6211 8101 331 8 + ζ(7)ζ(2) + ζ(6)ζ(3) + ζ(5)ζ(4) − ζ3(3) 486 648 18 9 Recently S(20) was evaluated with this methodology, which involved an integer relation problem of size n = 118. This solution required 5,000 digit arithmetic and several hours of computation on a high-end workstation. The solution is given explicitly in [6]. One other result that we shall mention here arose from the numerical discovery, using PSLQ, by British physicist David Broadhurst that (α315 − 1)(α210 − 1)(α126 − 1)2(α90 − 1)(α3 − 1)3(α2 − 1)5(α − 1)3 α630 − 1= (α35 − 1)(α15 − 1)2(α14 − 1)2(α5 − 1)6α68 where α =1.176280818259917 ... is the larger real root of Lehmer’s polynomial 0=α10 + α9 − α7 − α6 − α5 − α4 − α3 + α +1 The relation led Broadhurst to believe that a valid ladder of polylogarithms exists at order n = 17, contrary to a suggestion in [15]. Later, he and one of the present authors were able to find 125 non-zero integers a, bj, ck, up to 292 digits in size, such that the relation 8 2j 17−2j −k aζ(17) = bj π (log α) + ck Li17(α ) j=0 k∈D(S) holds to more than 50,000 decimal digits. This set of 125 integers was found in more than more way. One of these computations was performed on the NERSC Cray T3E, a highly parallel system at Lawrence Berkeley Laboratory. In this calculation one of the present authors employed a three-level, multi-pair PSLQ algorithm, implemented using the MPFUN multiple- precision software, and using MPI for parallel execution. This computation required 50,000 decimal digit arithmetic, and approximately 44 hours on 32 CPUs of the T3E, completing after 236,713 iterations [7]. 2. Overview of the ARPREC Package The new Arbitrary Precision (ARPREC) computation package is based in part on the Fortran-90 MPFUN package [2], which in turn is based on an earlier Fortran-77 package [4]. Both of the earlier packages were targeted to a Fortran environment. With the Fortran-77 MP- FUN package, users indicate which variables are to be treated as multiple precision by means of special comments inserted in the code. A translation tool then transforms the code into a pro- gram that includes explicit calls to routines from the MPFUN library. In the Fortran-90 version of MPFUN, the object-oriented facilities built into the Fortran-90 language (notably custom datatypes and operator overloading) are exploited to provide the same functionality without the 3 need of a translation tool. In addition, the Fortran-90 version of MPFUN incorporates some advanced algorithms that provide better accuracy and performance.