# Class NumericalDerivative

java.lang.Object
jebl.math.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
Description
`NumericalDerivative()`

## Method Summary

Modifier and Type
Method
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)`
determine gradient
`static void`
`gradient(MultivariateFunction f, double[] x, double[] grad)`
determine gradient
`static double`
`secondDerivative(UnivariateFunction f, double x)`
determine second derivative

### Methods inherited from class Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### NumericalDerivative

public NumericalDerivative()

## Method Details

### 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

### gradient

public static double[] gradient(MultivariateFunction f, double[] x)
determine gradient

Parameters:
  `f` - multivariate function
  `x` - argument vector
Returns:
  gradient at x

### gradient

public static void gradient(MultivariateFunction f, double[] x, double[] grad)
determine gradient

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