Home > . > bfgsi.m

bfgsi

PURPOSE ^

H = bfgsi(H0,dg,dx)

SYNOPSIS ^

function H = bfgsi(H0,dg,dx)

DESCRIPTION ^

 H = bfgsi(H0,dg,dx)
 dg is previous change in gradient; dx is previous change in x;
 6/8/93 version that updates inverse hessian instead of hessian
 itself.
 Copyright by Christopher Sims 1996.  This material may be freely
 reproduced and modified.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function H = bfgsi(H0,dg,dx)
0002 % H = bfgsi(H0,dg,dx)
0003 % dg is previous change in gradient; dx is previous change in x;
0004 % 6/8/93 version that updates inverse hessian instead of hessian
0005 % itself.
0006 % Copyright by Christopher Sims 1996.  This material may be freely
0007 % reproduced and modified.
0008 if size(dg,2)>1
0009    dg=dg';
0010 end
0011 if size(dx,2)>1
0012    dx=dx';
0013 end
0014 Hdg = H0*dg;
0015 dgdx = dg'*dx;
0016 if (abs(dgdx) >1e-12)
0017    H = H0 + (1+(dg'*Hdg)/dgdx)*(dx*dx')/dgdx - (dx*Hdg'+Hdg*dx')/dgdx;
0018 else
0019    disp('bfgs update failed.')
0020    disp(['|dg| = ' num2str(sqrt(dg'*dg)) '|dx| = ' num2str(sqrt(dx'*dx))]);
0021    disp(['dg''*dx = ' num2str(dgdx)])
0022    disp(['|H*dg| = ' num2str(Hdg'*Hdg)])
0023    H=H0;
0024 end
0025 save H.dat H

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003