cvechessian
Vector Hessian of a multivariate, vector-valued function using the central difference approximation.
Back to Numerical Differentiation Toolbox Contents.
Contents
Syntax
H = cvechessian(f,x0) H = cvechessian(f,x0,h)
Description
H = cvechessian(f,x0) numerically evaluates the vector Hessian of with respect to at using the central difference approximation with a default relative step size of , where is the machine zero.
H = cvechessian(f,x0,h) numerically evaluates the vector Hessian of with respect to at using the central difference approximation with a user-specified relative step size .
Input/Output Parameters
Variable | Symbol | Description | Format | |
Input | f | multivariate, vector-valued function () | 1×1 function_handle |
|
x0 | evaluation point | n×1 double |
||
h | (OPTIONAL) relative step size (defaults to ) | 1×1 double |
||
Output | H | vector Hessian of with respect to , evaluated at | n×n×m double |
Note
- This function requires evaluations of .
Example
Approximate the vector Hessian of
at using the cvechessian function, and compare the result to the true result of
where
Approximating the Hessian,
f = @(x) [x(1)^5*x(2)+x(1)*sin(x(2))^3; x(1)^3+x(2)^4-3*x(1)^2*x(2)^2]; x0 = [5;8]; H = cvechessian(f,x0)
H(:,:,1) = 1.0e+04 * 2.0000 0.3125 0.3125 -0.0014 H(:,:,2) = -353.9999 -480.0000 -480.0000 617.9999
Defining the true vector Hessian,
H_true = zeros(2,2,2);
H_true(:,:,1) = [20*5^3*8,5*5^4+3*sin(8)^2*cos(8);5*5^4+3*sin(8)^2*...
cos(8),6*5*sin(8)*cos(8)^2-3*5*sin(8)^3];
H_true(:,:,2) = [-354,-480;-480,618];
Calculating the errors,
error = H-H_true
error(:,:,1) = 1.0e-03 * 0.0072 0.2459 0.2459 0.1293 error(:,:,2) = 1.0e-03 * 0.0920 -0.0388 -0.0388 -0.1051