Newton's Method:

Newton's Method is a technique for approximating a root to an equation of the form \(f(x)=0\). What is required is an initial estimate for the root, called \(x_1\), and an iterative formula: $$x_{n+1} = x_n - \frac{f(x_n)}{f^{\prime}(x_n)}$$ This produces a sequence \(x_1, x_2, x_3, \ldots \) which converges to the root (hopefully).

An implementation of Newton's Method is shown in the code block below. You can change the function \(f\), and the initial guess \(x_1\). Clicking evaluate will run two iterations of Newton's method and return the next two approximations.

Run the calculations yourself...

Feel free to add some more lines of code to find more iterations - just duplicate the last two lines of code and update the index:

x4=N(NewtonIt(x3));
print(x4);

Using a loop to compute more iterations...

If you have Python programming experience you could write a for loop to automate the iterations. Replace everything from the initial guess down (line 6 and below) with something like:

xn=1;                      # initial guess
print(xn);
for i in range(10):
    xn=N(NewtonIt(xn),digits=20)
    print(xn);
This will produce 10 iterations, each value given to 20 decimal places.

You could get even fancier and run a while loop where the stopping condition is that two iterations agree to some specified number of decimal places.

If you prefer a pure Python implementation of Newton's Method here is an jupyter notebook version of this webpage: Newtons-Method.ipynb Upload this file to a jypyter server of your choice to interact with it.