Numerical methods for solving a nonlinear equation: The secant method
Implementation of the secant method (programming assignment)
Implement the secant method in Python, i.e. define the following Python function:
def secant_solve(f, a, b, tol=0.001, maxiter=100):
"""
Find the zero of a function f between a and b using the
Secant Method with tolerance tol (default: 0.001) and
maximum number of iterations equal to maxiter (default: 1000)
"""
In addition to approximating a zero, make sure that the function also returns the number of iterations required. Apply the secant_solve
function to the polynomial on the interval once with the default value of the tolerance to see if everything works correctly.
Then apply the Python function to create a table of the number of iterations required for tolerance . Verify that this method works faster than the methods discussed earlier.
Unlock full access