variable-precision-0.2.1: variable-precision floating point

Portability BangPatterns unstable claudiusmaximus@goto10.org Safe-Infered

Numeric.VariablePrecision.Algorithms

Description

Implementations of various floating point algorithms. Accuracy has not been extensively verified, and termination has not been proven.

Everything assumes that `floatRadix` is 2. This is *not* checked.

Functions taking an `accuracy` parameter may fail to terminate if `accuracy` is too small. Accuracy is measured in least significant bits, similarly to '(=~=)'.

In this documentation, basic functionality denotes that methods used are from classes:

• `Num`, `Eq`, `Ord`.

Further, basic RealFloat functionality denotes basic functionality with the addition of:

• Anything in `RealFloat` except for `atan2`.

The intention behind the used functionality documentation is to help users decide when it is appropriate to use these generic implementations to implement instances.

Synopsis

# Documentation

recodeFloat :: (RealFloat a, RealFloat b) => a -> bSource

Convert between generic `RealFloat` types more efficiently than `realToFrac`. Tries hard to preserve special values like infinities and negative zero, but any NaN payload is lost.

Uses only basic RealFloat functionality.

viaDouble :: (RealFloat a, RealFloat b) => (Double -> Double) -> a -> bSource

Lift a function from Double to generic `RealFloat` types.

(=~=) :: RealFloat a => a -> a -> Int -> BoolSource

Approximate equality. `(a =~= b) c` when adding the difference to the larger in magnitude changes at most `c` least significant mantissa bits.

Uses only basic RealFloat functionality.

Arguments

 :: RealFloat a => Int accuracy -> a -> a

Compute a reciprocal using the Newton-Raphson division algorithm, as described in http://en.wikipedia.org/wiki/Division_%28digital%29#Newton.E2.80.93Raphson_division.

Uses only basic RealFloat functionality.

Arguments

 :: RealFloat a => Int accuracy -> a -> a

Compute a square root using Newton's method.

Uses basic RealFloat functionality and '(/)'.

Arguments

 :: RealFloat a => Int accuracy -> a -> a

Compute an exponential using power series.

Uses basic RealFloat functionality, '(/)' and `recip`.

Arguments

 :: RealFloat a => Int accuracy -> a -> a

Compute a logarithm.

See `genericLog''` for algorithmic references.

Uses basic RealFloat functionality, `sqrt` and `recip`.

Arguments

 :: RealFloat a => Int accuracy -> a log 2 -> a -> a

Compute a logarithm using decomposition and a value for `log 2`.

See `genericLog''` for algorithmic references.

Uses basic RealFloat functionality, `sqrt`, and `recip`.

Arguments

 :: RealFloat a => Int accuracy -> a

Compute log 2.

See `genericLog''` for algorithmic references.

Uses basic RealFloat functionality, `sqrt` and `recip`.

Arguments

 :: RealFloat a => Int accuracy -> a value in [0.5,1) -> a

Compute a logarithm for a value in [0.5,1) using the AGM method as described in section 7 of The Logarithmic Constant: log 2 Xavier Gourdon and Pascal Sebah, May 18, 2010, http://numbers.computation.free.fr/Constants/Log2/log2.ps.

The precondition is not checked.

Uses basic RealFloat functionality, `sqrt`, and `recip`.

Arguments

 :: RealFloat a => Int accuracy -> a

Compute pi using the method described in section 8 of Multiple-precision zero-finding methods and the complexity of elementary function evaluation Richard P Brent, 1975 (revised May 30, 2010), http://arxiv.org/abs/1004.3412.

Uses basic RealFloat functionality, '(/)', and `sqrt`.

Special values implemented using basic RealFloat functionality.

sameSign :: (Ord a, Num a) => a -> a -> BoolSource

Check if two numbers have the same sign. May give a nonsense result if an argument is NaN.