Function hessian
Calculate the Hessian matrix of a function of several variables using a central-difference approximation.
MatrixView!(Real,Storage.Symmetric) hessian(Real, Func)
(
scope Func f,
Real[] x,
real scale = 1.00000,
Real[] buffer = null
);
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+2n2 times.
Parameters
Name | Description |
---|---|
f | The function of which to calculate the Hessian. |
x | The point at which to calculate the Hessian. |
scale | A "characteristic scale" over which the function changes significantly. (optional) |
buffer | A buffer of size at least n(n+1)/2, for storing the Hessian matrix. (optional) |
Example
// 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
- Wikipedia: Hessian matrix.