exact-real alternatives and similar packages
Based on the "Math" category.
Alternatively, view exact-real alternatives based on common mentions on social networks and blogs.
-
vector
An efficient implementation of Int-indexed arrays (both mutable and immutable), with a powerful loop optimisation framework . -
statistics
A fast, high quality library for computing with statistics in Haskell. -
HerbiePlugin
GHC plugin that improves Haskell code's numerical stability -
hgeometry
HGeometry is a library for computing with geometric objects in Haskell. It defines basic geometric types and primitives, and it implements some geometric data structures and algorithms. The main two focusses are: (1) Strong type safety, and (2) implementations of geometric algorithms and data structures that have good asymptotic running time guarantees. -
dimensional
Dimensional library variant built on Data Kinds, Closed Type Families, TypeNats (GHC 7.8+). -
computational-algebra
General-Purpose Computer Algebra System as an EDSL in Haskell -
matrix
A Haskell native implementation of matrices and their operations. -
mwc-random
A very fast Haskell library for generating high quality pseudo-random numbers. -
numhask
A haskell numeric prelude, providing a clean structure for numbers and operations that combine them. -
vector-space
Vector & affine spaces, linear maps, and derivatives -
poly
Fast polynomial arithmetic in Haskell (dense and sparse, univariate and multivariate, usual and Laurent) -
cf
"Exact" real arithmetic for Haskell using continued fractions (Not formally proven correct) -
optimization
Some numerical optimization methods implemented in Haskell -
rampart
:european_castle: Determine how intervals relate to each other. -
safe-decimal
Safe and very efficient arithmetic operations on fixed decimal point numbers -
equational-reasoning
Agda-style equational reasoning in Haskell -
sbvPlugin
Formally prove properties of Haskell programs using SBV/SMT. -
polynomial
Haskell library for manipulating and evaluating polynomials -
monoid-subclasses
Subclasses of Monoid with a solid theoretical foundation and practical purposes -
eigen
Haskel binding for Eigen library. Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms. -
vector-th-unbox
Deriver for unboxed vectors using Template Haskell -
manifold-random
Coordinate-free hypersurfaces as Haskell types
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of exact-real or a related project?
README
exact-real
Exact real arithmetic implemented by fast binary Cauchy sequences.
Motivating Example
Compare evaluating Euler's identity with a Float
:
Note that you'll need the DataKinds
extension turned on to evaluate the
examples in this readme.
λ> let i = 0 :+ 1
λ> exp (i * pi) + 1 :: Complex Float
0.0 :+ (-8.742278e-8)
... and with a CReal
:
λ> import Data.CReal
λ> let i = 0 :+ 1
λ> exp (i * pi) + 1 :: Complex (CReal 0)
0 :+ 0
Implementation
CReal
's phantom type parameter n :: Nat
represents the precision at which
values should be evaluated at when converting to a less precise representation.
For instance the definition of x == y
in the instance for Eq
evaluates x -
y
at precision n
and compares the resulting Integer
to zero. I think that
this is the most reasonable solution to the fact that lots of of operations
(such as equality) are not computable on the reals but we want to pretend that
they are for the sake of writing useful programs. Please see the
Caveats section for more information.
The CReal
type is an instance of Num
, Fractional
, Floating
, Real
,
RealFrac
, RealFloat
, Eq
, Ord
, Show
and Read
. The only functions not
implemented are a handful from RealFloat
which assume the number is
implemented with a mantissa and exponent.
There is a comprehensive test suite to test the properties of these classes.
The performance isn't terrible on most operations but it's obviously not nearly
as speedy as performing the operations on Float
or Double
. The only two
super slow functions are asinh
and atanh
at the moment.
Caveats
The implementation is not without its caveats however. The big gotcha is that
although internally the CReal n
s are represented exactly, whenever a value is
extracted to another type such as a Rational
or Float
it is evaluated to
within 2^-p
of the true value.
For example when using the CReal 0
type (numbers within 1 of the true value)
one can produce the following:
λ> 0.5 == (1 :: CReal 0)
True
λ> 0.5 * 2 == (1 :: CReal 0) * 2
False
Contributing
Contributions and bug reports are welcome!
Please feel free to contact me on GitHub or as "jophish" on freenode.
-Joe