numeric-tools-0.2.0.1: Collection of numerical tools for integration, differentiation etc.

Portabilityportable
Stabilityexperimental
MaintainerAleksey Khudyakov <alexey.skladnoy@gmail.com>
Safe HaskellNone

Numeric.ApproxEq

Description

Different implementations of approximate equality for floating point values. There are multiple ways to implement approximate equality. They have different semantics and it's up to programmer to choose right one.

Synopsis

Documentation

eqRelativeSource

Arguments

:: (Fractional a, Ord a) 
=> a

Relative precision

-> a 
-> a 
-> Bool 

Relative difference between two numbers are less than predefined value. For example 1 is approximately equal to 1.0001 with 1e-4 precision. Same is true for 10000 and 10001.

This method of camparison doesn't work for numbers which are approximately 0. eqAbsolute should be used instead.

eqRelComplSource

Arguments

:: (RealFloat a, Ord a) 
=> a

Relative precision

-> Complex a 
-> Complex a 
-> Bool 

Relative equality for comlex numbers.

eqAbsoluteSource

Arguments

:: (Num a, Ord a) 
=> a

Absolute precision

-> a 
-> a 
-> Bool 

Difference between values is less than specified precision.

withinSource

Arguments

:: Int

Number of ULPs of accuracy desired.

-> Double 
-> Double 
-> Bool 

Compare two Double values for approximate equality, using Dawson's method.

The required accuracy is specified in ULPs (units of least precision). If the two numbers differ by the given number of ULPs or less, this function returns True.

Algorithm is based on Bruce Dawson's "Comparing floating point numbers": http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm