Arbitrary/multiple precision libraries

Several years ago we discussed the possibility of adding arbitrary/multiple precision libraries to stdlib. I have been thinking of such a library again and I just did a few small experiments with the FM package by David Smith (http://dmsmith.lmu.build). It seems easy to use and reasonably complete, though I must admit I only looked at the documentation and created a very small program (my direct interest: juggling large integers to satisfy my curiosity regarding, well, patterns in digits). Anybody interested in taking this a bit further?

2 Likes

To survey what is available, here is the Multiple Precision section of my list of codes.

814-fm-2001: Algorithm 814: Fortran 90 software for floating-point multiple precision arithmetic, gamma and related functions, by David M. Smith, whose site has the latest version. Also 911-fm-2010, Algorithm 911: Multiple-Precision Exponential Integral and Related Functions, and 786-fm-1997, Algorithm 786: multiple-precision complex arithmetic and functions.

FMPFR: Fortran binding to the GNU MPFR Library multi-precision library, by Thomas Koenig

Fortran Multiple Precision Library (FMPL): by Zander Lewis

mpfun90: software by David H. Bailey that permits a new or existing Fortran 90 program to utilize multiple-precision arithmetic, or in other words a level of numeric precision that ranges from 50 digits to hundreds or thousands of digits if required. A more recent version is MPFUN2020.

MPFUN2020: thread-safe arbitrary precision package that enables one to perform floating-point computations (real and complex) to arbitrarily high numeric precision, by making only relatively minor changes to existing Fortran-90 programs (mostly changes to type statements), by David H. Bailey. All basic arithmetic operations and transcendental functions are supported, together with several special functions. FPM package by Jacob Williams here. Bailey’s High-Precision Software Directory also has DQFUN: A double-quad precision package with special functions (approx. 66 digits), QXFUN: A quad precision package with special functions (approx. 33 digits), and DDFUN: A double-double precision package with special functions (approx. 30 digits).

QD: double-double and quad-double package for Fortran and C++, by Michael Orlitzky and X. Sherry Li

Wow, I was only aware of the Fortran bindings to GNU’s MPFR library. This looks like a well-established and well-written package whose only caveat is that it does not report any licensing terms. I believe it would tremendously benefit from being fpmized and brought onto Github, but of course the author should be contacted about that.

I can try contacting him and ask about the licence. I agree that it looks like a very useful library.

1 Like

I frequently use an arbitrary precision library, but is written in C. It’s the Arb library (https://arblib.org), which has now merged to the Flint library (https://flintlib.org).
The greatest advantage I see in Arb is that it employs ball arithmetic, where the center of the ball is the arbitrary precision result you want (the evaluation of a function, an integral, etc), and the radius corresponds to the upper value of the total numerical error (truncation + round-off). In this way, you can also determine the minimal number of correct digits after a certain amount of floating-point evaluations. If the accuracy is lower than the expected, say for a double-precision value of a function, you can increase the precision and evaluate the function again.
I have been using C-interoperability to write driver routines that port the results from the Arb library to Fortran (double and quad precision).
I would like to start an interface that directly accesses Arb structures and functions from Fortran, but one difficulty is the lack of support to unsigned integers.

The FMZM library uses interval arithmetic for this. See the website for a nice short note on the technique (and some of the cases where it fails).

I have contacted David Smith, and got permission to put it on Github and turn it into an fpm package. The licence is actually contained in a LICENSE.txt file, part of the zip-file that you can download. Actually, he will be very glad if this package gets wider attention :slight_smile:

6 Likes