pal.math

## Class NumericalDerivative

• ```public class NumericalDerivative
extends Object```
approximates numerically the first and second derivatives of a function of a single variable and approximates gradient and diagonal of Hessian for multivariate functions
Author:
Korbinian Strimmer
• ### Constructor Summary

Constructors
Constructor and Description
`NumericalDerivative()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double[]` ```diagonalHessian(MultivariateFunction f, double[] x)```
determine diagonal of Hessian
`static double` ```firstDerivative(UnivariateFunction f, double x)```
determine first derivative
`static double[]` ```gradient(MultivariateFunction f, double[] x)```
`static void` ```gradient(MultivariateFunction f, double[] x, double[] grad)```
`static double` ```secondDerivative(UnivariateFunction f, double x)```
determine second derivative
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### NumericalDerivative

`public NumericalDerivative()`
• ### Method Detail

• #### firstDerivative

```public static double firstDerivative(UnivariateFunction f,
double x)```
determine first derivative
Parameters:
`f` - univariate function
`x` - argument
Returns:
first derivate at x
• #### secondDerivative

```public static double secondDerivative(UnivariateFunction f,
double x)```
determine second derivative
Parameters:
`f` - univariate function
`x` - argument
Returns:
second derivate at x

```public static double[] gradient(MultivariateFunction f,
double[] x)```
Parameters:
`f` - multivariate function
`x` - argument vector
Returns:

```public static void gradient(MultivariateFunction f,
double[] x,
Parameters:
`f` - multivariate function
`x` - argument vector
`grad` - vector for gradient
• #### diagonalHessian

```public static double[] diagonalHessian(MultivariateFunction f,
double[] x)```
determine diagonal of Hessian
Parameters:
`f` - multivariate function
`x` - argument vector
Returns:
vector with diagonal entries of Hessian