Exercises on Root-finding Without Derivatives
Contents
Exercises on Root-finding Without Derivatives#
Exercise 1: Comparing Root-finding Methods#
Note: This builds on the previous exercise comparing the Bisection and Newton’s Methods; just adding the Secant Method.
A) Write a Python function implementing the secant method with usage
(root, errorEstimate, iterations, functionEvaluations) = secant(f, a, b, errorTolerance, maxIterations)
Update your previous implementations of the bisection method and Newton’s method to mimic this interfacce:
(root, errorEstimate, iterations, functionEvaluations) = bisection(f, a, b, errorTolerance, maxIterations)
(root, errorEstimate, iterations, functionEvaluations) = newton(f, x_0, errorTolerance, maxIterations)
Aside: the last parameter maxIterations
could be optional, with a default like maxIterations=100
.
B) Use these to solve the equation
i) with [estimated] absolute error of no more than \(10^{-8}\), and then
ii) with [estimated] absolute error of no more than \(10^{-15}\).
Note in particular how many iterations and how many function evaluations are needed.
C) Discuss: rank these methods for speed, as indicated by these experiments, and explain your ranking.
This work is licensed under Creative Commons Attribution-ShareAlike 4.0 International