All problems
Damped Newton Step
Problem
A damped (Levenberg-Marquardt style) Newton step solves (H + lambda*I) d = g and moves x_new = x - d.
For the point (x, y), gradient (g1, g2), Hessian [[ha, hb], [hb, hc]], and damping lambda >= 0, return the updated point.
Hint
Adding lambda*I shrinks the step and makes the system better conditioned.
Test cases
case 1
in: [[0,0],1,1,1,0,1,0]
expected: [-1,-1]
case 2
in: [[0,0],1,1,1,0,1,1]
expected: [-0.5,-0.5]
case 3
in: [[1,1],2,2,2,0,2,0]
expected: [0,0]
case 4
in: [[2,-1],0,0,1,0,1,0]
expected: [2,-1]
Starter codePython
def damped_newton_step(point, g1, g2, ha, hb, hc, lam):
# Return the updated [x, y]
# Your code here
pass4 test cases · run your code against them in the editor