hessian

Calculate the Hessian matrix of a function of several variables using a central-difference approximation.

This function stores its results in an n-by-n symmetric matrix, where n is the number of variables (i.e. the length of x). The function f is evaluated 1+2n$(SUP 2) times.

hessian
(
Real
Func
)
(
scope Func f
,
Real[] x
,
real scale = 1.0
,
Real[] buffer = null
)

Parameters

f Func

The function of which to calculate the Hessian.

x Real[]

The point at which to calculate the Hessian.

scale real

A "characteristic scale" over which the function changes significantly. (optional)

buffer Real[]

A buffer of size at least n(n+1)/2, for storing the Hessian matrix. (optional)

Examples

// Above, we found the gradient of f(x,y) at the point p.
// Finding the Hessian matrix is just as simple:
auto h = hessian(&f, p);

See Also

Meta