generative-art-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Numerics.ConvergentRecursion

Description

Apply algorithms repeatedly until we’re happy with the result.

Synopsis

Documentation

retryLinearlyUntilPrecision Source #

Arguments

:: (Int -> Double)

Function of a number of iterations to perform, e.g. integration subdivisions

-> Double

Precision: relative error threshold between two iterations to accept the result

-> Double

Result

Retry applying a function until two consecutive results are close enough together.

Each attempt uses one more step than the last one (hence linearly).

retryExponentiallyUntilPrecision Source #

Arguments

:: (Int -> Double)

Function of a number of iterations to perform, e.g. integration subdivisions

-> Double

Precision: relative error threshold between two iterations to accept the result

-> Double

Result

Retry applying a function until two consecutive results are close enough together.

Each attempt uses twice as many iterations as the last one (hence exponentially).

recurseUntilPrecision Source #

Arguments

:: (Double -> Double)

Function to iterate

-> Double

Initial value

-> Double

Desired precision

-> Double 

Recursively apply a function to a value, until the relative distance between two iterations is below the precision parameter.

Find the a root of \(x^2-1=0\):

>>> let f x = x^2-1
>>> recurseUntilPrecision (Numerics.FindRoot.newtonStep 1e-3 f ) 2 1e-10
1.0