Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Apply algorithms repeatedly until we’re happy with the result.
Documentation
retryLinearlyUntilPrecision Source #
:: (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 #
:: (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 #
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