Class MultivariateFiniteDifference
java.lang.Object
dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction
dev.nm.analysis.differentiation.multivariate.MultivariateFiniteDifference
- All Implemented Interfaces:
Function<Vector,
,Double> RealScalarFunction
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.nm.analysis.function.Function
Function.EvaluationException
-
Constructor Summary
ConstructorsConstructorDescriptionMultivariateFiniteDifference
(RealScalarFunction f, int[] varidx) Construct the partial derivative of a multi-variable function. -
Method Summary
Methods inherited from class dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction
dimensionOfDomain, dimensionOfRange
-
Constructor Details
-
MultivariateFiniteDifference
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 ofvaridx
- the variable indices of the derivative, counting from 1 up to the domain dimension of f
-
-
Method Details
-
evaluate
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
- See Also:
-
evaluate
Evaluate numerically the partial derivative of f at point x with step size h. It could be challenging to automatically determine the step size h, esp. when |x| is near 0. It may, for example, require an analysis that involves f' and f''. The user may want to experiment with different hs by calling this function.- Parameters:
x
- the point to evaluate the derivative of f ath
- the step size- Returns:
- the numerical partial derivative of f at point x with step size h
-