Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hessian

Hessian Matrix


Description

Numerically compute the Hessian matrix.

Usage

hessian(f, x0, h = .Machine$double.eps^(1/4), ...)

Arguments

f

univariate function of several variables.

x0

point in R^n.

h

step size.

...

variables to be passed to f.

Details

Computes the hessian matrix based on the three-point central difference formula, expanded to two variables.

Assumes that the function has continuous partial derivatives.

Value

An n-by-n matrix with \frac{\partial^2 f}{\partial x_i \partial x_j} as (i, j) entry.

References

Fausett, L. V. (2007). Applied Numerical Analysis Using Matlab. Second edition, Prentice Hall.

See Also

Examples

f <- function(x) cos(x[1] + x[2])
x0 <- c(0, 0)
hessian(f, x0)

f <- function(u) {
    x <- u[1]; y <- u[2]; z <- u[3]
    return(x^3 + y^2 + z^2 +12*x*y + 2*z)
}
x0 <- c(1,1,1)
hessian(f, x0)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.