Class NumericalDerivativesEx5

java.lang.Object
com.imsl.math.NumericalDerivatives
com.imsl.test.example.math.NumericalDerivativesEx5
All Implemented Interfaces:
Serializable, Cloneable

public class NumericalDerivativesEx5 extends NumericalDerivatives

Approximates the Hessian of a function using numerical differentiation.

This example uses the same data as in NumericalDerivativesEx4. 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:
  • Constructor Details

  • Method Details

    • evaluateF

      public double[] evaluateF(int varIndex, double[] y)
      Description copied from class: NumericalDerivatives
      This method is provided by the user to compute the function values at the current independent variable values y. If the user does not override the evaluateF method, then NumericalDerivatives.Function.f is used to compute the function values.
      Overrides:
      evaluateF in class NumericalDerivatives
      Parameters:
      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.
      Returns:
      a double array of length m. The equations evaluated at the point y.
    • main

      public static void main(String[] args)