Portability  portable 

Stability  experimental 
Maintainer  Aleksey Khudyakov <alexey.skladnoy@gmail.com> 
Safe Haskell  None 
Numerical differentiation. diffRichardson
is preferred way to
calculate derivative.
 data DiffRes = DiffRes {
 diffRes :: Double
 diffPrecision :: Double
 diffRichardson :: (Double > Double) > Double > Double > DiffRes
 diffSimple :: (Double > Double) > Double > (Double, Double) > Double
 diffSimmetric :: (Double > Double) > Double > Double > Double
 representableDelta :: Double > Double > Double
Differentiation
Differentiation result
DiffRes  

:: (Double > Double)  Function 
> Double  Delta 
> Double  Point at which evaluate differential 
> DiffRes 
Calculate derivative using Richaradson's deferred approach to limit. This is a preferred method for numeric differentiation since it's most precise. Function could be evaluated up to 20 times.
Initial step size should be chosen fairly big. Too small one will result reduced precision, too big one in nonsensical answer.
Fast but imprecise
:: (Double > Double)  Function to differentiate 
> Double  Delta 
> (Double, Double)  Coordinate and function value at this point 
> Double 
Simplest form of differentiation. Should be used only when
function evaluation is prohibitively expensive and already
computed value at point x
should be reused.
f'(x) = f(x+h)  f(x) / h
:: (Double > Double)  Function to differentiate 
> Double  Delta 
> Double  Point at which evaluate differential 
> Double 
Simple differentiation. It uses simmetric rule and provide reasonable accuracy. It's suitable when function evaluation is expensive and precision could be traded for speed.
f'(x) = f(xh) + f(x+h) / 2h
Utils
For number x
and small h
return such h'
that x+h'
and x
differ by representable number
References
 Ridders, C.J.F. 1982, Accurate computation of F`(x) and F`(x)F``(x), Advances in Engineering Software, vol. 4, no. 2, pp. 7576.