C# Class Accord.Math.Differentiation.FiniteDifferences

Derivative approximation by finite differences.

Numerical differentiation is a technique of numerical analysis to produce an estimate of the derivative of a mathematical function or function subroutine using values from the function and perhaps other knowledge about the function.

References: Trent F. Guidry, Calculating derivatives of a function numerically. Available on: http://www.trentfguidry.net/post/2009/07/12/Calculate-derivatives-function-numerically.aspx

Show file Open project: accord-net/framework Class Usage Examples

Public Methods

Method Description
Compute ( ) : double[]

Computes the gradient at the given point x.

Compute ( double x, double gradient ) : void

Computes the gradient at the given point x, storing the result at gradient.

CreateCoefficients ( int points ) : ].double[][

Creates the interpolation coefficients.

Derivative ( double>.Func function, double value ) : double

Computes the derivative for a simpler unidimensional function.

Derivative ( double>.Func function, double value, int order ) : double

Computes the derivative for a simpler unidimensional function.

Derivative ( double>.Func function, double value, int order, double stepSize ) : double

Computes the derivative for a simpler unidimensional function.

FiniteDifferences ( int variables ) : System

Initializes a new instance of the FiniteDifferences class.

FiniteDifferences ( int variables, double>.Func function ) : System

Initializes a new instance of the FiniteDifferences class.

FiniteDifferences ( int variables, double>.Func function, int order ) : System

Initializes a new instance of the FiniteDifferences class.

FiniteDifferences ( int variables, double>.Func function, int order, double stepSize ) : System

Initializes a new instance of the FiniteDifferences class.

FiniteDifferences ( int variables, int order ) : System

Initializes a new instance of the FiniteDifferences class.

FiniteDifferences ( int variables, int order, double stepSize ) : System

Initializes a new instance of the FiniteDifferences class.

Private Methods

Method Description
Interpolate ( double coefficients, double points, int order, int center, double step ) : double

Interpolates the points to obtain an estimative of the derivative at x.

derivative ( double x, int index, double output ) : double

Computes the derivative at point x_i.

init ( double>.Func func, int variables, int order, double stepSize ) : void

Method Details

Compute() public method

Computes the gradient at the given point x.
public Compute ( ) : double[]
return double[]

Compute() public method

Computes the gradient at the given point x, storing the result at gradient.
public Compute ( double x, double gradient ) : void
x double The point where to compute the gradient.
gradient double The gradient of the function evaluated at point x.
return void

CreateCoefficients() public static method

Creates the interpolation coefficients.
public static CreateCoefficients ( int points ) : ].double[][
points int The number of points in the tableau.
return ].double[][

Derivative() public static method

Computes the derivative for a simpler unidimensional function.
public static Derivative ( double>.Func function, double value ) : double
function double>.Func The function to be differentiated.
value double The value x at which the derivative should be evaluated.
return double

Derivative() public static method

Computes the derivative for a simpler unidimensional function.
public static Derivative ( double>.Func function, double value, int order ) : double
function double>.Func The function to be differentiated.
value double The value x at which the derivative should be evaluated.
order int The derivative order that should be obtained. Default is 1.
return double

Derivative() public static method

Computes the derivative for a simpler unidimensional function.
public static Derivative ( double>.Func function, double value, int order, double stepSize ) : double
function double>.Func The function to be differentiated.
value double The value x at which the derivative should be evaluated.
order int The derivative order that should be obtained. Default is 1.
stepSize double The relative step size used to approximate the derivatives. Default is 0.01.
return double

FiniteDifferences() public method

Initializes a new instance of the FiniteDifferences class.
public FiniteDifferences ( int variables ) : System
variables int The number of free parameters in the function.
return System

FiniteDifferences() public method

Initializes a new instance of the FiniteDifferences class.
public FiniteDifferences ( int variables, double>.Func function ) : System
variables int The number of free parameters in the function.
function double>.Func The function to be differentiated.
return System

FiniteDifferences() public method

Initializes a new instance of the FiniteDifferences class.
public FiniteDifferences ( int variables, double>.Func function, int order ) : System
variables int The number of free parameters in the function.
function double>.Func The function to be differentiated.
order int The derivative order that should be obtained. Default is 1.
return System

FiniteDifferences() public method

Initializes a new instance of the FiniteDifferences class.
public FiniteDifferences ( int variables, double>.Func function, int order, double stepSize ) : System
variables int The number of free parameters in the function.
function double>.Func The function to be differentiated.
order int The derivative order that should be obtained. Default is 1.
stepSize double The relative step size used to approximate the derivatives. Default is 0.01.
return System

FiniteDifferences() public method

Initializes a new instance of the FiniteDifferences class.
public FiniteDifferences ( int variables, int order ) : System
variables int The number of free parameters in the function.
order int The derivative order that should be obtained. Default is 1.
return System

FiniteDifferences() public method

Initializes a new instance of the FiniteDifferences class.
public FiniteDifferences ( int variables, int order, double stepSize ) : System
variables int The number of free parameters in the function.
order int The derivative order that should be obtained. Default is 1.
stepSize double The relative step size used to approximate the derivatives. Default is 0.01.
return System