The GNU Multiple Precision Floating-Point Reliable Library (GNU MPFR) is a
GNU
GNU ( ) is an extensive collection of free software (394 packages ), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operating systems popu ...
portable
C library
A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
for
arbitrary-precision binary
floating-point
In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a Sign (mathematics), signed sequence of a fixed number of digits in some Radix, base) multiplied by an integer power of that ba ...
computation with
correct rounding, based on
GNU Multi-Precision Library.
Library
MPFR's computation is both efficient and has a well-defined semantics: the functions are completely specified on all the possible operands and the results do not depend on the platform. This is done by copying the ideas from the
ANSI/IEEE-754 standard for fixed-precision floating-point arithmetic (correct rounding and exceptions, in particular). More precisely, its main features are:
* Support for special numbers:
signed zero
Signed zero is zero with an associated sign. In ordinary arithmetic, the number 0 does not have a sign, so that −0, +0 and 0 are equivalent. However, in computing, some number representations allow for the existence of two zeros, often denoted by ...
s (+0 and −0),
infinities and
not-a-number
Nan or NAN may refer to:
Places China
* Nan County, Yiyang, Hunan, China
* Nan Commandery, historical commandery in Hubei, China
Thailand
* Nan province
** Nan, Thailand, the administrative capital of Nan province
* Nan River
People Given n ...
(a single NaN is supported: MPFR does not differentiate between quiet NaNs and signaling NaNs).
* Each number has its own
precision (in bits since MPFR uses
radix
In a positional numeral system, the radix (radices) or base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal system (the most common system in use today) the radix is ten, becaus ...
2). The floating-point results are correctly rounded to the precision of the target variable, in one of the five supported rounding modes (including the four from
IEEE 754-1985
IEEE 754-1985 is a historic industry standard for representing floating-point numbers in computers, officially adopted in 1985 and superseded in 2008 by IEEE 754-2008, and then again in 2019 by minor revision IEEE 754-2019. During its 23 years, ...
).
* Supported functions: MPFR implements all mathematical functions from
C99 and other usual mathematical functions: the
logarithm
In mathematics, the logarithm of a number is the exponent by which another fixed value, the base, must be raised to produce that number. For example, the logarithm of to base is , because is to the rd power: . More generally, if , the ...
and
exponential
Exponential may refer to any of several mathematical topics related to exponentiation, including:
* Exponential function, also:
**Matrix exponential, the matrix analogue to the above
*Exponential decay, decrease at a rate proportional to value
* Ex ...
in natural base, base 2 and base 10, the log(1+x) and exp(x)−1 functions (
log1p
and
expm1
), the six
trigonometric
Trigonometry () is a branch of mathematics concerned with relationships between angles and side lengths of triangles. In particular, the trigonometric functions relate the angles of a right triangle with ratios of its side lengths. The field ...
and
hyperbolic
Hyperbolic may refer to:
* of or pertaining to a hyperbola, a type of smooth curve lying in a plane in mathematics
** Hyperbolic geometry, a non-Euclidean geometry
** Hyperbolic functions, analogues of ordinary trigonometric functions, defined u ...
functions and their inverses, the
gamma
Gamma (; uppercase , lowercase ; ) is the third letter of the Greek alphabet. In the system of Greek numerals it has a value of 3. In Ancient Greek, the letter gamma represented a voiced velar stop . In Modern Greek, this letter normally repr ...
,
zeta
Zeta (, ; uppercase Ζ, lowercase ζ; , , classical or ''zē̂ta''; ''zíta'') is the sixth letter of the Greek alphabet. In the system of Greek numerals, it has a value of 7. It was derived from the Phoenician alphabet, Phoenician letter zay ...
and
error function
In mathematics, the error function (also called the Gauss error function), often denoted by , is a function \mathrm: \mathbb \to \mathbb defined as:
\operatorname z = \frac\int_0^z e^\,\mathrm dt.
The integral here is a complex Contour integrat ...
s, the
arithmetic–geometric mean
In mathematics, the arithmetic–geometric mean (AGM or agM) of two positive real numbers and is the mutual limit of a sequence of arithmetic means and a sequence of geometric means. The arithmetic–geometric mean is used in fast algorithms f ...
, the
power (x
y) function. All those functions are correctly rounded over their complete range.
*
Subnormal number
In computer science, subnormal numbers are the subset of denormalized numbers (sometimes called denormals) that fill the arithmetic underflow, underflow gap around zero in floating-point arithmetic. Any non-zero number with magnitude smaller than ...
s are not supported, but can be emulated with the
mpfr_subnormalize
function.
MPFR is not able to track the
accuracy
Accuracy and precision are two measures of ''observational error''.
''Accuracy'' is how close a given set of measurements (observations or readings) are to their ''true value''.
''Precision'' is how close the measurements are to each other.
The ...
of numbers in a whole program or expression; this is not its goal.
Interval arithmetic
Interval arithmetic (also known as interval mathematics; interval analysis or interval computation) is a mathematical technique used to mitigate rounding and measurement errors in mathematical computation by computing function bounds. Numeri ...
packages like Arb, MPFI, or
Real RAM implementations like iRRAM, which may be based on MPFR, can do that for the user.
MPFR is dependent upon the
GNU Multiple Precision Arithmetic Library
GNU Multiple Precision Arithmetic Library (GMP) is a free software, free library for arbitrary-precision arithmetic, operating on Sign (mathematics), signed integers, Rational data type, rational numbers, and Floating-point arithmetic, floating-p ...
(GMP).
MPFR is needed to build the
GNU Compiler Collection
The GNU Compiler Collection (GCC) is a collection of compilers from the GNU Project that support various programming languages, Computer architecture, hardware architectures, and operating systems. The Free Software Foundation (FSF) distributes ...
(GCC).
Other software uses MPFR, such as
ALGLIB
ALGLIB is a cross-platform open source numerical analysis and data processing library. It can be used from several programming languages ( C++, C#, VB.NET, Python, Delphi, Java).
ALGLIB started in 1999 and has a long history of steady developm ...
,
CGAL,
FLINT
Flint, occasionally flintstone, is a sedimentary cryptocrystalline form of the mineral quartz, categorized as the variety of chert that occurs in chalk or marly limestone. Historically, flint was widely used to make stone tools and start ...
,
GNOME Calculator, the
Julia language implementation, the
Magma computer algebra system
Magma is a computer algebra system designed to solve problems in algebra, number theory, geometry and combinatorics. It is named after the algebraic structure magma. It runs on Unix-like operating systems, as well as Windows.
Introduction
Magma ...
,
Maple
''Acer'' is a genus of trees and shrubs commonly known as maples. The genus is placed in the soapberry family Sapindaceae.Stevens, P. F. (2001 onwards). Angiosperm Phylogeny Website. Version 9, June 2008 nd more or less continuously updated si ...
, GNU MPC, and
GNU Octave
GNU Octave is a scientific programming language for scientific computing and numerical computation. Octave helps in solving linear and nonlinear problems numerically, and for performing other numerical experiments using a language that is mostly ...
.
References
External links
Official MPFR web site
{{DEFAULTSORT:Mpfr
C (programming language) libraries
Computer arithmetic
Free software programmed in C
GNU Project software
Numerical libraries
Software using the GNU Lesser General Public License