| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Data.Double.Approximate
Description
Synopsis
- type SafeDouble = DoubleRelAbs 10 10
- newtype DoubleRelAbs (abs :: Nat) (rel :: Nat) = DoubleRelAbs Double
Documentation
type SafeDouble = DoubleRelAbs 10 10 Source #
Relatively safe double floating-point type with a relative error
   margin of 10 ULPs
   and an absolute margin around zero of
   10*epsilon.
Warning: All numbers within
   10*epsilon of zero will be considered zero.
>>>m_epsilon * 102.220446049250313e-15
>>>realToFrac (m_epsilon * 10) == (0::SafeDouble)False
>>>realToFrac (m_epsilon * 9) == (0::SafeDouble)True
>>>1e-20 == (5e-20 :: Double)False>>>1e-20 == (5e-20 :: SafeDouble)True
pi and sin are approximations:
>>>sin pi1.2246467991473532e-16
>>>sin pi == (0 :: Double)False
>>>sin pi == (0 :: SafeDouble)True
newtype DoubleRelAbs (abs :: Nat) (rel :: Nat) Source #
Custom double floating-point type with a relative error margin of
   rel number of
   ULPs and an
   absolute error margin of abs times
   epsilon.
The relative error margin is the primary tool for good numerical robustness and can relatively safely be set to a high number such as 100. The absolute error margin is a last ditch attempt at fixing broken algorithms and dramatically limits the resolution around zero. If possible, use a low absolute error margin.
Constructors
| DoubleRelAbs Double |