Package com.imsl.test.example.math
Class NumericalDerivativesEx5
java.lang.Object
com.imsl.math.NumericalDerivatives
com.imsl.test.example.math.NumericalDerivativesEx5
- All Implemented Interfaces:
Serializable,Cloneable
Approximates the Hessian of a function using numerical differentiation.
This example uses the same data as inNumericalDerivativesEx4. In
this example numerical differentiation is used to approximate the Hessian
matrix of \(f(y_1 ,y_2 )\).
This symmetric Hessian matrix is $$Hf = \left[ {\begin{array}{*{20}c}
{\frac{{\partial ^2 f}} {{\partial y_1^2 }}} & {\frac{{\partial ^2 f}}
{{\partial y_1 \partial y_2 }}} \\ {\frac{{\partial ^2 f}} {{\partial y_1
\partial y_2 }}} & {\frac{{\partial ^2 f}} {{\partial y_2^2 }}} \\
\end{array} } \right]$$
Our method is based on casting the matrix \(Hf\) as the 2 by 2 Jacobian
matrix of the gradient function. Each inner evaluation of the gradient
function is itself computed using NumericalDerivatives. Central
differences are used for both the inner and outer numerical differentiation.
Because of the inherent error in both processes, the expected accuracy is
about the \(4/9 = \left( {2/3} \right)^2\) power of machine precision. Note
that the approximation obtained is not symmetric. However, the difference
between the off-diagonal elements provides an error estimate of that term.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.imsl.math.NumericalDerivatives
NumericalDerivatives.Function, NumericalDerivatives.Jacobian -
Field Summary
Fields inherited from class com.imsl.math.NumericalDerivatives
ACCUMULATE, CENTRAL, ONE_SIDED, SKIP -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.imsl.math.NumericalDerivatives
evaluateJ, getPercentageFactor, getScalingFactors, getStatus, setDifferencingMethods, setInitialF, setPercentageFactor, setScalingFactors
-
Constructor Details
-
NumericalDerivativesEx5
-
-
Method Details
-
evaluateF
public double[] evaluateF(int varIndex, double[] y) Description copied from class:NumericalDerivativesThis method is provided by the user to compute the function values at the current independent variable valuesy. If the user does not override theevaluateFmethod, thenNumericalDerivatives.Function.fis used to compute the function values.- Overrides:
evaluateFin classNumericalDerivatives- Parameters:
varIndex- anintwhich indicates the index of the variable to perturb.y- adoublearray of length n, the point at which the function is to be evaluated.- Returns:
- a
doublearray of length m. The equations evaluated at the pointy.
-
main
-