Package com.imsl.test.example.math
Class NumericalDerivativesEx4
java.lang.Object
com.imsl.math.NumericalDerivatives
com.imsl.test.example.math.NumericalDerivativesEx4
- All Implemented Interfaces:
Serializable,Cloneable
Approximates the gradient using central divided differences.
This example uses the same data as in exampleNumericalDerivativesEx3.
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:
-
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
-
NumericalDerivativesEx4
-
-
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
-