# Class MultivariateFiniteDifference

java.lang.Object
dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction
dev.nm.analysis.differentiation.multivariate.MultivariateFiniteDifference
All Implemented Interfaces:
Function<Vector,Double>, RealScalarFunction

public class MultivariateFiniteDifference extends AbstractRealScalarFunction
A partial derivative of a multivariate function is the derivative with respect to one of the variables with the others held constant. This implementation applies recursively the (first order) finite difference on the function. For example, ${\partial^2 \over \partial x_1 \partial x_2} = {\partial \over \partial x_2}({\partial \over \partial x_1})$ Each of the two univariate derivatives is computed using the central difference method.

## Nested classes/interfaces inherited from interface dev.nm.analysis.function.Function

Function.EvaluationException
• ## Constructor Summary

Constructors
Constructor
Description
MultivariateFiniteDifference(RealScalarFunction f, int[] varidx)
Construct the partial derivative of a multi-variable function.
• ## Method Summary

Modifier and Type
Method
Description
Double
evaluate(Vector x)
Evaluate numerically the partial derivative of f at point x.
double
evaluate(Vector x, double h)
Evaluate numerically the partial derivative of f at point x with step size h.

### Methods inherited from class dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction

dimensionOfDomain, dimensionOfRange

### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ## Constructor Details

• ### MultivariateFiniteDifference

public MultivariateFiniteDifference(RealScalarFunction f, int[] varidx)
Construct the partial derivative of a multi-variable function.

For example, varidx = new int[]{1, 2} means $f_{x_1,x_2} = {\partial^2 \over \partial x_2 \partial x_1} = {\partial \over \partial x_2}({\partial \over \partial x_1})$

Parameters:
f - the real multivariate function to take derivative of
varidx - the variable indices of the derivative, counting from 1 up to the domain dimension of f
• ## Method Details

• ### evaluate

public Double evaluate(Vector x)
Evaluate numerically the partial derivative of f at point x.

Make sure that h and x+h are representable in floating point precision so that the difference between x+h and x is exactly h.

Parameters:
x - the point to evaluate the derivative at
Returns:
the numerical partial derivative of f at point x
x - the point to evaluate the derivative of f at
h - the step size