Compute the Hessian by finite differences.
Hfd = uncprb_gethesfd ( n , m , x , nprob ) Hfd = uncprb_gethesfd ( n , m , x , nprob , Hstep ) Hfd = uncprb_gethesfd ( n , m , x , nprob , Hstep , Horder )
a n x 1 matrix of doubles, the point where to compute f
the step to use for differences. If Hstep=[], uses the default step. The default step depends on the order and the machine precision %eps.
the order to use for differences (1, 2 or 4). Default Horder=2. If Horder=[], uses the default order.
the problem number
the number of variables, i.e. the size of x
the number of functions, i.e. the size of fvec
a n x 1 matrix of doubles, the gradient, df(x)/dxj, j=1, ..., n
Uses finite differences to compute the Hessian matrix. Does not exploit the structure to compute the difference.
// Get Hfd at x0 for Rosenbrock's test case nprob = 1 [n,m,x0]=uncprb_getinitf(nprob) Hfd = uncprb_gethesfd ( n , m , x0 , nprob ) // Compare with exact Hessian H = uncprb_gethesfcn(n,m,x0,nprob) norm(H-Hfd)/norm(H) // Set the step Hfd = uncprb_gethesfd ( n , m , x0 , nprob , 1.e-1 , [] ) // Set the step and the order Hfd = uncprb_gethesfd ( n , m , x0 , nprob , 1.e-1 , 4 ) // Set the order (use default step) Hfd = uncprb_gethesfd ( n , m , x0 , nprob , [] , 4 ) // Use default step and default order Hfd = uncprb_gethesfd ( n , m , x0 , nprob , [] , [] ) | ![]() | ![]() |