Iteration of functions: Finding zeros via the Newton-Raphson method

Theory Implementation of the Newton-Raphson method

Implement the Newton-Raphson method in a programming language, i.e., define someting like the following Python function:

def Newton_solve(f, fp, x0, tol=0.001, maxiter=100):
    """
    Find a zero of the function f using the Newton-Raphson Method 
starting in x0, with tolerance tol (default: 0.001), and maximum number of iterations equal to maxiter (default: 100).
fp denotes the derivate of f """

Make sure that your function returns the number of iterations required in addition to the approximation found.

  1. Apply the function Newton_solve to the polynomial \(x^2-x-1\) with starting value \(1.0\) to approximate the golden ratio \(\tfrac{1}{2}\!(1+\sqrt{5})\approx 1.61803398875\) in 9 significant digits. How many iterations do you need?

  2. Apply the function Newton_solve to polynomial \(x^3+x^2-2\) with starting value \(1.5\).
    After how many steps did you determine the zero point \(1\) in 10 significant digits?
    Explain what happens when you choose \(-1.5\) as your starting value.

  3. Apply function Newton_solve to polynomial \(x^3-3x^2+2\) with starting value \(1.77\).
    After how many steps did you determine the zero point \(1\) in 10 significant digits?
    What happens when you choose \(1.78\) as your starting value?

About us ⋅ Help ⋅ Privacy ⋅ Terms and conditions
Copyright © 2023 SOWISO