Class NumericalDerivativesEx4

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

public class NumericalDerivativesEx4 extends NumericalDerivatives

Approximates the gradient using central divided differences.

This example uses the same data as in example NumericalDerivativesEx3. Instead of the one-sided difference, the central difference method is used. Agreement should be approximately the two-thirds power of machine precision. That agreement is achieved here. Generally this is the most accuracy one can expect using central divided differences. Note that using central differences requires essentially twice the number of evaluations of the function compared with obtaining one-sided differences. This can be a significant issue for functions that are expensive to evaluate. This example shows how to override evaluateF.
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)