MPFR
Encyclopedia
GNU MPFR is a portable C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 library for arbitrary-precision binary floating-point computation with correct rounding
Rounding
Rounding a numerical value means replacing it by another value that is approximately equal but has a shorter, simpler, or more explicit representation; for example, replacing $23.4476 with $23.45, or the fraction 312/937 with 1/3, or the expression √2 with 1.414.Rounding is often done on purpose to...

, based on GNU Multi-Precision Library
GNU Multi-Precision Library
The GNU Multiple Precision Arithmetic Library, also known as GMP, is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating point numbers...

. The computation is both efficient and has a well-defined semantics. It copies the ideas from the ANSI/IEEE-754
IEEE floating-point standard
IEEE 754–1985 was an industry standard for representingfloating-pointnumbers in computers, officially adopted in 1985 and superseded in 2008 byIEEE 754-2008. During its 23 years, it was the most widely used format for...

 standard for fixed-precision floating-point arithmetic. More precisely, its main features are:
  • Support for special numbers: signed zeros (−0), infinities and not-a-number
    NaN
    In computing, NaN is a value of the numeric data type representing an undefined or unrepresentable value, especially in floating-point calculations...

     (a single NaN
    NaN
    In computing, NaN is a value of the numeric data type representing an undefined or unrepresentable value, especially in floating-point calculations...

     is currently supported).
  • Each number has its own precision
    Precision (arithmetic)
    The precision of a value describes the number of digits that are used to express that value. In a scientific setting this would be the total number of digits or, less commonly, the number of fractional digits or decimal places...

     (in bits since MPFR uses radix
    Radix
    In mathematical numeral systems, the base or radix for the simplest case is the number of unique digits, including zero, that a positional numeral system uses to represent numbers. For example, for the decimal system the radix is ten, because it uses the ten digits from 0 through 9.In any numeral...

     2). The floating-point results are correctly rounded to the precision of the target variable, in any of the four IEEE-754
    IEEE floating-point standard
    IEEE 754–1985 was an industry standard for representingfloating-pointnumbers in computers, officially adopted in 1985 and superseded in 2008 byIEEE 754-2008. During its 23 years, it was the most widely used format for...

     rounding modes.
  • Supported functions: MPFR implements all mathematical functions from C99
    C99
    C99 is a modern dialect of the C programming language. It extends the previous version with new linguistic and library features, and helps implementations make better use of available computer hardware and compiler technology.-History:...

    : the logarithm
    Logarithm
    The logarithm of a number is the exponent by which another fixed value, the base, has to be raised to produce that number. For example, the logarithm of 1000 to base 10 is 3, because 1000 is 10 to the power 3: More generally, if x = by, then y is the logarithm of x to base b, and is written...

     and exponential
    Exponential function
    In mathematics, the exponential function is the function ex, where e is the number such that the function ex is its own derivative. The exponential function is used to model a relationship in which a constant change in the independent variable gives the same proportional change In mathematics,...

     in natural base, base 2 and base 10, the log(1+x) and exp(x)-1 functions (log1p and expm1), the six trigonometric
    Trigonometric function
    In mathematics, the trigonometric functions are functions of an angle. They are used to relate the angles of a triangle to the lengths of the sides of a triangle...

     and hyperbolic
    Hyperbolic function
    In mathematics, hyperbolic functions are analogs of the ordinary trigonometric, or circular, functions. The basic hyperbolic functions are the hyperbolic sine "sinh" , and the hyperbolic cosine "cosh" , from which are derived the hyperbolic tangent "tanh" and so on.Just as the points form a...

     functions and their inverses, the gamma
    Gamma function
    In mathematics, the gamma function is an extension of the factorial function, with its argument shifted down by 1, to real and complex numbers...

    , zeta and error function
    Error function
    In mathematics, the error function is a special function of sigmoid shape which occurs in probability, statistics and partial differential equations...

    s, the arithmetic geometric mean, the power
    Exponentiation
    Exponentiation is a mathematical operation, written as an, involving two numbers, the base a and the exponent n...

     (xy) function. All those functions are correctly rounded over their complete range.
  • Subnormals
    Denormal number
    In computer science, denormal numbers or denormalized numbers fill the underflow gap around zero in floating point arithmetic: any non-zero number which is smaller than the smallest normal number is 'sub-normal'.For example, if the smallest positive 'normal' number is 1×β−n In computer...

     are not supported, but can be emulated with the mpfr_subnormalize function.


MPFR is not able to track the accuracy of numbers in a whole program or expression; this is not its goal. Interval arithmetic
Interval arithmetic
Interval arithmetic, interval mathematics, interval analysis, or interval computation, is a method developed by mathematicians since the 1950s and 1960s as an approach to putting bounds on rounding errors and measurement errors in mathematical computation and thus developing numerical methods that...

 packages like MPFI, or Real RAM
Real RAM
In computing, especially computational geometry, a Real RAM is a computing machine that implements real numbers in the mathematical sense rather than the typical computing implementation . Brattka and Hertling described a theoretical implementation based on a Turing machine....

implementations like iRRAM, which may be based on MPFR, can do that for the user.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK