numeric-tools-0.2.0.1: Collection of numerical tools for integration, differentiation etc.

Portabilityportable
Stabilityexperimental
MaintainerAleksey Khudyakov <alexey.skladnoy@gmail.com>
Safe HaskellNone

Numeric.Tools.Differentiation

Contents

Description

Numerical differentiation. diffRichardson is preferred way to calculate derivative.

Synopsis

Differentiation

data DiffRes Source

Differentiation result

Constructors

DiffRes 

Fields

diffRes :: Double

Derivative value

diffPrecision :: Double

Rough error estimate

diffRichardsonSource

Arguments

:: (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

diffSimpleSource

Arguments

:: (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

diffSimmetricSource

Arguments

:: (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(x-h) + f(x+h) / 2h

Utils

representableDeltaSource

Arguments

:: Double

x

-> Double

small delta

-> Double 

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. 75-76.