FiniteDifferences Class |
Namespace: Accord.Math.Differentiation
The FiniteDifferences type exposes the following members.
Name | Description | |
---|---|---|
FiniteDifferences(Int32) |
Initializes a new instance of the FiniteDifferences class.
| |
FiniteDifferences(Int32, FuncDouble, Double) |
Initializes a new instance of the FiniteDifferences class.
| |
FiniteDifferences(Int32, Int32) |
Initializes a new instance of the FiniteDifferences class.
| |
FiniteDifferences(Int32, FuncDouble, Double, Int32) |
Initializes a new instance of the FiniteDifferences class.
| |
FiniteDifferences(Int32, Int32, Double) |
Initializes a new instance of the FiniteDifferences class.
| |
FiniteDifferences(Int32, FuncDouble, Double, Int32, Double) |
Initializes a new instance of the FiniteDifferences class.
|
Name | Description | |
---|---|---|
Function |
Gets or sets the function to be differentiated.
| |
NumberOfPoints |
Gets or sets the number of points to be used when
computing the approximation. Default is 3.
| |
NumberOfVariables |
Gets the number of parameters expected by the Function to be differentiated.
| |
Order |
Gets or sets the order of the partial derivatives to be
obtained. Default is 1 (computes the first derivative).
| |
Points | Obsolete.
Obsolete. Please use NumberOfPoints instead.
| |
StepSize |
Gets or sets the relative step size used to approximate the derivatives. Default is 1e-2.
Setting this property updates the step size for all parameters at once. To adjust only a
single parameter, please refer to StepSizes instead.
| |
StepSizes |
Gets or sets the relative step sizes used to approximate the derivatives. Default is 1e-2.
|
Name | Description | |
---|---|---|
Compute(Double) | Obsolete.
Obsolete. Please use Gradient(Double) instead.
| |
Compute(Double, Double) | Obsolete.
Obsolete. Please use Gradient(Double, Double) instead.
| |
CreateCoefficients |
Creates the interpolation coefficient table for interpolated numerical differentation.
| |
Derivative(FuncDouble, Double, Double) |
Computes the derivative for a simpler unidimensional function.
| |
Derivative(FuncDouble, Double, Double, Int32) |
Computes the derivative for a simpler unidimensional function.
| |
Derivative(FuncDouble, Double, Double, Int32, Double) |
Computes the derivative for a simpler unidimensional function.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Gradient(Double) |
Computes the gradient at the given point x.
| |
Gradient(Double, Double) |
Computes the gradient at the given point x,
storing the result at result.
| |
Gradient(FuncDouble, Double, Int32, Int32) |
Obtains the gradient function for a multidimensional function.
| |
Hessian(Double) |
Computes the Hessian matrix at given point x.
| |
Hessian(Double, Double) |
Computes the Hessian matrix at given point x.
| |
Hessian(FuncDouble, Double, Int32) |
Obtains the Hessian function for a multidimensional function.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
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.
A finite difference is a mathematical expression of the form f(x + b) − f(x + a). If a finite difference is divided by b − a, one gets a difference quotient. The approximation of derivatives by finite differences plays a central role in finite difference methods for the numerical solution of differential equations, especially boundary value problems.
This class implements Newton's finite differences method for approximating the derivatives of a multivariate function. A simplified version of the class is also available for univariate functions through its Derivative static methods.
References:
// Create a simple function with two parameters: f(x,y) = x² + y Func<double[], double> function = x => Math.Pow(x[0], 2) + x[1]; // The gradient w.r.t to x should be 2x, // the gradient w.r.t to y should be 1 // Create a new finite differences calculator var calculator = new FiniteDifferences(2, function); // Evaluate the gradient function at the point (2, -1) double[] result = calculator.Compute(2, -1); // answer is (4, 1)
// Create a simple function with two parameters: f(x,y) = x² + y Func<double[], double> function = x => Math.Pow(x[0], 2) + x[1]; // The gradient w.r.t to x should be 2x, // the gradient w.r.t to y should be 1 // Create a new finite differences calculator var calculator = new FiniteDifferences(2, function); // Evaluate the gradient function at the point (2, -1) double[][] result = calculator.Hessian(new[] { 2.0, -1.0 }); // answer is [(2, 0), (0, 0)]