factory-0.3.0.0: Rational arithmetic in an irrational world.

Safe HaskellSafe
LanguageHaskell2010

Factory.Math.Precision

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Defines the unit with which precision is measured, and operations on it.

Synopsis

Types

Type-synonyms

type DecimalDigits = Int Source #

A number of decimal digits; presumably positive.

Constants

linearConvergence :: ConvergenceOrder Source #

Linear convergence-rate; which may be qualified by the rate of convergence.

quadraticConvergence :: ConvergenceOrder Source #

Quadratic convergence-rate.

cubicConvergence :: ConvergenceOrder Source #

Cubic convergence-rate.

quarticConvergence :: ConvergenceOrder Source #

Quartic convergence-rate.

Functions

getIterationsRequired Source #

Arguments

:: Integral i 
=> ConvergenceOrder 
-> DecimalDigits

The precision of the initial estimate.

-> DecimalDigits

The required precision.

-> i 

The predicted number of iterations, required to achieve a specific accuracy, at a given order of convergence.

getTermsRequired Source #

Arguments

:: Integral i 
=> ConvergenceRate 
-> DecimalDigits

The additional number of correct decimal digits.

-> i 
  • The predicted number of terms which must be extracted from a series, if it is to converge to the required accuracy, at the specified linear convergence-rate.
  • The convergence-rate of a series, is the error in the series after summation of (n+1)th terms, divided by the error after only n terms, as the latter tends to infinity. As such, for a convergent series (in which the error get smaller with successive terms), it's value lies in the range 0 .. 1.
  • https://en.wikipedia.org/wiki/Rate_of_convergence.

roundTo :: (RealFrac a, Fractional f) => DecimalDigits -> a -> f Source #

Rounds the specified number, to a positive number of DecimalDigits.

promote :: Num n => n -> DecimalDigits -> n Source #

Promotes the specified number, by a positive number of DecimalDigits.

simplify Source #

Arguments

:: RealFrac operand 
=> DecimalDigits

The number of places after the decimal point, which are required.

-> operand 
-> Rational 
  • Reduces a Rational to the minimal form required for the specified number of fractional decimal places; irrespective of the number of integral decimal places.
  • A Rational approximation to an irrational number, may be very long, and provide an unknown excess precision. Whilst this doesn't sound harmful, it costs in performance and memory-requirement, and being unpredictable isn't actually useful.