All problems
Secant Method Two Steps
Problem
The secant method iterates x_{n+1} = x_n - f(x_n) * (x_n - x_{n-1}) / (f(x_n) - f(x_{n-1})).
Given polynomial coefficients and two starting points x0, x1, return the point after two iterations.
Hint
Update the pair (x_{n-1}, x_n) twice in a loop.
Test cases
case 1
in: [[-2,0,1],0,1]
expected: 1.3333333333333335
case 2
in: [[-1,0,0,1],1,2]
expected: 1
case 3
in: [[-4,0,1],1,3]
expected: 1.9473684210526316
Starter codePython
def secant_method_two_steps(coeffs, x0, x1):
# Your code here
pass3 test cases · run your code against them in the editor