[Haskell-cafe] ANN: variable-precision floating point
Claude Heiland-Allen
claude at goto10.org
Wed May 16 21:18:00 CEST 2012
Hi all,
I'm pleased to announce variable-precision-0.2:
http://hackage.haskell.org/package/variable-precision
There was no announcement for previous versions, as I quickly found
their flaws to be too irritating in practice.
--8<-- excerpt from the hackage page
Software floating point with type-tagged variable mantissa precision,
implemented using a strict pair of Integer and Int scaled alike to
decodeFloat.
Instances of the usual numeric type classes are provided, along with
additional operators (with carefully chosen fixities) to coerce, adjust
and reify precisions.
--8<-- end excerpt
Known shortcomings of this release:
* no implementation of (inverse) (hyperbolic) trigonometric functions
* no support for negative zero
* no support for rounding modes
* accuracy has not been extensively verified
* termination of algorithms has not been proven
The intention of this package is to be simple yet useable in the
meantime until there is a version of hmpfr[1] or fixed-precision[2] that
work without requiring a custom-compiled GHC. The design of
variable-precision was inspired by the latter, and variable-precision is
probably inferior, but the lifetime of the variable-precision package is
hopefully going to be short.
[1] http://hackage.haskell.org/package/hmpfr
[2] http://hackage.haskell.org/package/fixed-precision
I'm currently mainly using variable-precision for exploring the
Mandelbrot Set, particularly in algorithms using Newton's method (for
example, tracing external rays, where more precision is needed the
closer you get to the boundary of the set).
Thanks,
Claude
PS:
--8<-- excerpt from ghci session
Prelude Numeric.VariablePrecision> (pi :: F24) .@$ 200 $ show . (pi -)
"1.5815072737072126433832795028841971693993751058209749096292229e-6"
Prelude Numeric.VariablePrecision> (pi :: F53) .@$ 200 $ show . (pi -)
"4.1192675685652988632476805983544532308209749096292228904414057e-15"
Prelude Numeric.VariablePrecision> (2 :: F53) .@$ 200 $ show . log
"0.69314718055994530941723212145817656807550013436025525413214402"
Prelude Numeric.VariablePrecision> log 2
0.6931471805599453
Prelude Numeric.VariablePrecision> (2 :: F53) .@$ 200 $ show . exp
"7.3890560989306502272304274605750078131803155705518473240869941"
Prelude Numeric.VariablePrecision> exp 2
7.38905609893065
--8<-- end excerpt
More information about the Haskell-Cafe
mailing list