## Types in MathNet.Numerics.Differentiation

Type NumericalDerivative

Namespace MathNet.Numerics.Differentiation

Class to evaluate the numerical derivative of a function using finite difference approximations. Variable point and center methods can be initialized . This class can also be used to return function handles (delegates) for a fixed derivative order and variable. It is possible to evaluate the derivative and partial derivative of univariate and multivariate functions respectively.

### Public Constructors

#### NumericalDerivative(int points, int center)

Initialized a NumericalDerivative class.
##### Parameters
###### `int` points

Number of points for finite difference derivatives.

###### `int` center

Location of the center with respect to other points. Value ranges from zero to points-1.

#### NumericalDerivative()

Initializes a NumericalDerivative class with the default 3 point center difference method.

### Public Methods

#### Func<double, double>CreateDerivativeFunctionHandle(Func<double, double> f, int order)

Creates a function handle for the derivative of a scalar univariate function.
##### Parameters
###### `Func<double, double>` f

Input function handle.

###### `int` order

Derivative order.

##### Return
###### `Func<double, double>`

Function handle that evaluates the derivative of input function at a fixed order.

#### Func<Double[], double>CreateMixedPartialDerivativeFunctionHandle(Func<Double[], double> f, Int32[] parameterIndex, int order)

Creates a function handle for the mixed partial derivative of a multivariate function.
##### Parameters
###### `Func<Double[], double>` f

Input function handle.

###### `Int32[]` parameterIndex

Vector of indices for the independent variables at descending derivative orders.

###### `int` order

Highest derivative order.

##### Return
###### `Func<Double[], double>`

Function handle that evaluates the fixed mixed partial derivative of input function at fixed order.

#### Func<Double[], double>CreatePartialDerivativeFunctionHandle(Func<Double[], double> f, int parameterIndex, int order)

Creates a function handle for the partial derivative of a multivariate function.
##### Parameters
###### `Func<Double[], double>` f

Input function handle.

###### `int` parameterIndex

Index of the independent variable for partial derivative.

###### `int` order

Derivative order.

##### Return
###### `Func<Double[], double>`

Function handle that evaluates partial derivative of input function at a fixed order.

#### doubleEvaluateDerivative(Double[] points, int order, double stepSize)

Evaluates the derivative of equidistant points using the finite difference method.
##### Parameters
###### `Double[]` points

Vector of points StepSize apart.

###### `int` order

Derivative order.

###### `double` stepSize

Finite difference step size.

##### Return
###### `double`

Derivative of points of the specified order.

#### doubleEvaluateDerivative(Func<double, double> f, double x, int order, Nullable<double> currentValue)

Evaluates the derivative of a scalar univariate function.
Supplying the optional argument currentValue will reduce the number of function evaluations required to calculate the finite difference derivative.
##### Parameters

Function handle.

###### `double` x

Point at which to compute the derivative.

###### `int` order

Derivative order.

###### `Nullable<double>` currentValue

Current function value at center.

##### Return
###### `double`

Function derivative at x of the specified order.

#### doubleEvaluateMixedPartialDerivative(Func<Double[], double> f, Double[] x, Int32[] parameterIndex, int order, Nullable<double> currentValue)

Evaluates the mixed partial derivative of variable order for multivariate functions.
This function recursively uses EvaluatePartialDerivative to evaluate mixed partial derivative. Therefore, it is more efficient to call EvaluatePartialDerivative for higher order derivatives of a single independent variable.
##### Parameters
###### `Func<Double[], double>` f

Multivariate function handle.

###### `Double[]` x

Points at which to evaluate the derivative.

###### `Int32[]` parameterIndex

Vector of indices for the independent variables at descending derivative orders.

###### `int` order

Highest order of differentiation.

###### `Nullable<double>` currentValue

Current function value at center.

##### Return
###### `double`

Function mixed partial derivative at x of the specified order.

#### doubleEvaluatePartialDerivative(Func<Double[], double> f, Double[] x, int parameterIndex, int order, Nullable<double> currentValue)

Evaluates the partial derivative of a multivariate function.
##### Parameters
###### `Func<Double[], double>` f

Multivariate function handle.

###### `Double[]` x

Vector at which to evaluate the derivative.

###### `int` parameterIndex

Index of independent variable for partial derivative.

###### `int` order

Derivative order.

###### `Nullable<double>` currentValue

Current function value at center.

##### Return
###### `double`

Function partial derivative at x of the specified order.

#### voidResetEvaluations()

Resets the evaluation counter.

### Public Properties

#### doubleBaseStepSize get; set;

Sets and gets the base finite difference step size. This assigned value to this parameter is only used if StepType is set to RelativeX. However, if the StepType is Relative, it will contain the base step size computed from Epsilon based on the finite difference order.

#### intCenter get; set;

Sets and gets the location of the center point for the finite difference derivative.

#### doubleEpsilon get; set;

Sets and gets the base finite difference step size. This parameter is only used if StepType is set to Relative. By default this is set to machine epsilon, from which BaseStepSize is computed.

#### intEvaluations get; set;

Number of times a function is evaluated for numerical derivatives.

#### doubleStepSize get; set;

Sets and gets the finite difference step size. This value is for each function evaluation if relative step size types are used. If the base step size used in scaling is desired, see Epsilon.
Setting then getting the StepSize may return a different value. This is not unusual since a user-defined step size is converted to a base-2 representable number to improve finite difference accuracy.

#### StepTypeStepType get; set;

Type of step size for computing finite differences. If set to absolute, dx = h. If set to relative, dx = (1+abs(x))*h^(2/(order+1)). This provides accurate results when h is approximately equal to the square-root of machine accuracy, epsilon.