AERN-Real-0.9.3: datatypes and abstractions for approximating exact real numbers




Definitions of classes that describe what is required from arbitrary precision approximations of exact real numbers.

We introduce two levels of abstraction for these approximations:

  • ERApprox = a *set* of approximated numbers whose size is measured using some fixed measure
  • ERIntApprox = an *interval* of real numbers with finitely representable endpoints

To be imported qualified, usually with the synonym RA.



class (Fractional ra, Ord ra) => ERApprox ra whereSource

A type whose elements represent sets that can be used to approximate a single extended real number with arbitrary precision.


getPrecision :: ra -> PrecisionSource

Precision is a measure of the set size.

The default interpretation:

  • If the diameter of the set is d, then the precision should be near floor(- log_2 d).

getGranularity :: ra -> GranularitySource

the lower the granularity the bigger the rounding errors

setGranularity :: Granularity -> ra -> raSource

increase or safely decrease granularity

setMinGranularity :: Granularity -> ra -> raSource

ensure granularity is not below the first arg

isEmpty :: ra -> BoolSource

true if this represents a computational error

isBottom :: ra -> BoolSource

true if this holds no information

isExact :: ra -> BoolSource

true if this is a singleton

isDisjoint :: ra -> ra -> BoolSource

isBounded :: ra -> BoolSource

true if the approximation excludes infinity

bottomApprox :: raSource

the bottom element - any number

emptyApprox :: raSource

the top element - error

refines :: ra -> ra -> BoolSource

first arg is a subset of the second arg

(/\) :: ra -> ra -> raSource

join; combining two approximations of the same number

intersectMeasureImprovement :: EffortIndex -> ra -> ra -> (ra, ra)Source

Like intersection but the second component:

  • measures improvement of the intersection relative to the first of the two approximations
  • is a positive number: 1 means no improvement, 2 means doubled precision, etc.

equalReals :: ra -> ra -> Maybe BoolSource

nothing if overlapping and not singletons

compareReals :: ra -> ra -> Maybe OrderingSource

nothing if overlapping and not singletons

leqReals :: ra -> ra -> Maybe BoolSource

nothing if overlapping on interior or by a wrong endpoint

equalApprox :: ra -> ra -> BoolSource

syntactic comparison

compareApprox :: ra -> ra -> OrderingSource

syntactic linear ordering

double2ra :: Double -> raSource



:: Int

number of relevant decimals to show

-> Bool

should show granularity

-> Bool

should show internal representation details

-> ra

the approximation to show

-> String 


class ERApprox ira => ERIntApprox ira whereSource

A type whose elements represent sets that can be used to approximate a recursive set of closed extended real number intervals with arbitrary precision.

A type whose elements represent real *intervals* that can be used to approximate a single extended real number with arbitrary precision.

Sometimes, these types can be used to approximate a closed extended real number interval with arbitrary precision. Nevetheless, this is not guaranteed.


doubleBounds :: ira -> (Double, Double)Source

floatBounds :: ira -> (Float, Float)Source

integerBounds :: ira -> (ExtendedInteger, ExtendedInteger)Source



:: Maybe ira

point to split at

-> ira

interval to split

-> (ira, ira)

left and right, overlapping on a singleton

defaultBisectPt :: ira -> iraSource

bounds :: ira -> (ira, ira)Source

returns thin approximations of endpoints, in natural order

(\/) :: ira -> ira -> iraSource

meet, usually constructing interval from approximations of its endpoints

This does not need to be the meet of the real intervals but it has to be a maximal element in the set of all ira elements that are below the two parameters.


bounds2ira :: ERIntApprox ira => ira -> ira -> iraSource



:: ERIntApprox ira 
=> ira

an interval to be split

-> [ira]

approximations of the cut points in increasing order

-> [ira] 

Split an interval to a sequence of intervals whose union is the original interval using a given sequence of cut points. The cut points are expected to be in increasing order and contained in the given interval. Violations of this rule are tolerated.

exactMiddle :: ERIntApprox ira => ira -> (ira, ira, ira, Granularity)Source

  • Return the endpoints of the interval as well as the exact midpoint.
  • To be able to do this, there may be a need to increase granularity.
  • All three singleton intervals are set to the same new granularity.



:: ERIntApprox ira 
=> (EffortIndex -> ira -> [ira])

returns a safe approximation of all extrema within the interval

-> (EffortIndex -> ira -> ira)

a function behaving well on sequences that intersect to a point

-> EffortIndex -> ira -> ira

a function behaving well on sequences that intersect to a non-empty interval

This produces a function that computes the maximal extension of the given function. A maximal extension function has the property: f(I) = { f(x) | x in I }. Here we get this property only for the limit function for its EffortIndex tending to infinity.