Introduction to Scientific Programming:

Computational Problem Solving Using Mathematica and C

by Joseph L. Zachary


Newton's Method Tutorial

In this tutorial we will explore Newton's method for finding the roots of equations, as explained in Chapter 14.


Simulation

We will be using a Newton's method simulator throughout this tutorial. You can start it by clicking on the following button.

If you see this, then Java is not running in your browser!
An applet would normally go here...


Finding Roots

This tutorial explores a numerical method for finding the root of an equation: Newton's method. Newton's method is discussed in Chapter 14 as a way to solve equations in one unknown that cannot be solved symbolically.

For example, suppose that we would like to solve the simple equation

 2
x  = 5
To solve this equation using Newton's method, we first manipulate it algebraically so that one side is zero.
 2
x  - 5 = 0
Finding a solution to this equation is then equivalent to finding a root of the function
        2
f(x) = x  - 5
This function is plotted in the simulation window.

We next make a guess for the root. In the simulation window, the guess is -5. The point

(guess, f(guess))
is displayed with a pink dot. The coordinates of the dot are displayed at the bottom of the simulation window.

The yellow line is tangent (to the curve whose root we are seeking) at the pink dot. Newton's method relies on the observation that this tangent line will often cross the x-axis at a point closer to a root than is the guess.

To see Newton's method in action, click on the button labeled "Step". The pink dot will slide down the tangent line until it reaches the x-axis, and it will then move vertically until it reaches the curve. A new tangent line will be displayed. The new x-coordinate of the pink dot is the new guess to the root of the function. For many functions and for many initial guesses, repeating this process a few times will yield an excellent approximation to a root.

If you click on Step a few more times, the pink dot will move closer to the point where the curve crosses the x-axis. (You can zoom in by using the mouse to drag a rectangle around the region that you'd like to enlarge. There is also a "Zoom" menu in the menu bar.) At any point of the simulation, the x-coordinate of the guess will be an approximation to the root, and the y-coordinate of the guess will be the value of the function at that guess.


Exercises

  1. You can place the guess by clicking the mouse where you would like the guess to go. Experiment with placing the guess and observing convergence.

  2. If you place the guess at -5, how many steps are required until the approximate root is good to three decimal places? (The root near -2 is -2.236067978 to ten digits.) How this compare to the behavior of the bisection method when the positive guess is at -5 and the negative guess is at 1? (You can switch to the bisection method by using the Method menu.)

  3. Use the "Function" menu to display the curve for cos(x). Notice that four different roots are displayed. What guesses lead to which roots? (Be sure to watch the coordinates of the guess. You may need to zoom out to see where the guess is.)

  4. It can be difficult to predict exactly how Newton's method will behave. Use the "Function" menu to display the curve for cos(10x) + 4x. Watch what happens if you start from the guess that is displayed by default.

  5. The function x^2 + 1 has no root. Experiment with how Newton's method behaves with it.

  6. Choose the function sin(5x) + x^2 - 3x and place the guess so between 1.2 and 2.0 so that the tangent line crosses the x-axis between 1.0 and 2.0. Step through Newton's method several times. What do you notice? What does this say about finding the roots of this function with Newton's method?

  7. Choose the function ln(x^2 - (4/5)x + 1) and zoom out by 5. There are 2 points on the function which, if you choose your first guess between these two points (excluding the function minimum and it's very close proximity), Newton's method will converge and if you choose your first guess outside these points Newton's method will diverge. What are these two points?

  8. Experiment with some of the other functions to get a feel for how Newton's method works and for how many steps it takes for it to come up with a good approximation.


Return to sample resources