All problems
BFGS Scalar Inverse Hessian Update
Problem
In one dimension the BFGS inverse Hessian update reduces to H_new = s / y with s = x_new - x_old and y = g_new - g_old; return the previous H when y is zero.
Given s, y, and the previous inverse Hessian h0, return the updated value.
Hint
The curvature condition y > 0 keeps the estimate positive.
Test cases
case 1
in: [1,2,1]
expected: 0.5
case 2
in: [0.5,0,3]
expected: 3
case 3
in: [-0.25,-0.5,2]
expected: 0.5
Starter codePython
def bfgs_scalar_inverse_hessian_update(s, y, h0):
# Your code here
pass3 test cases · run your code against them in the editor