Numerical methods for solving a nonlinear equation: Regula falsi method
Implementation of the regula falsi method (programming assignment)
Implement the regula falsi method in Python, that is, define the following Python function:
def regula_falsi_solve(f, a, b, tol=0.001, maxiter=100):
"""
Find the zero of a function f between a and b using the
Regula Falsi Method with tolerance tol (default: 0.001) and
maximum number of iterations equal to maxiter (default: 1000)
"""
In addition to the approximation of the zero, make sure that the function also returns the number of iterations needed. Apply the regula_falsi_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 there is indeed a linear relationship between the number of iterations required and the natural number at a tolerance of .
Unlock full access