public class NumericalDerivativesEx5 extends NumericalDerivatives
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.NumericalDerivatives.Function, NumericalDerivatives.Jacobian
ACCUMULATE, CENTRAL, ONE_SIDED, SKIP
Constructor and Description |
---|
NumericalDerivativesEx5(NumericalDerivatives.Function fcn) |
Modifier and Type | Method and Description |
---|---|
double[] |
evaluateF(int varIndex,
double[] y)
This method is provided by the user to compute the function values at
the current independent variable values
y . |
static void |
main(String[] args) |
evaluateJ, getPercentageFactor, getScalingFactors, getStatus, setDifferencingMethods, setInitialF, setPercentageFactor, setScalingFactors
public NumericalDerivativesEx5(NumericalDerivatives.Function fcn)
public double[] evaluateF(int varIndex, double[] y)
NumericalDerivatives
y
. If the user
does not override the evaluateF
method, then
NumericalDerivatives.Function.f
is used to compute the
function values.evaluateF
in class NumericalDerivatives
varIndex
- an int
which indicates the index of the
variable to perturb.y
- a double
array of length n, the point
at which the function is to be evaluated.double
array of length m. The
equations evaluated at the point y
.public static void main(String[] args)
Copyright © 2020 Rogue Wave Software. All rights reserved.