All problems
Secant Hessian Approximation
Problem
The secant equation in one dimension approximates the second derivative by the slope of the gradient: H ≈ (g(x1) - g(x0)) / (x1 - x0).
Given the two gradient values and the two points, return the approximation.
Hint
This is the finite-difference slope of the gradient function.
Test cases
case 1
in: [6,2,2,0]
expected: 2
case 2
in: [-1,1,1,0]
expected: -2
case 3
in: [0,0,5,1]
expected: 0
Starter codePython
def secant_hessian_approximation(g1, g0, x1, x0):
# Your code here
pass3 test cases · run your code against them in the editor