Math 131 Grinnell College Fall, 2009
 
Section 1: MWF 8:00-8:50, T 11:00-11:50
Section 2: MTWF: 10:00-10:50
Calculus I
 

Calculus Lab: Newton's Method

Goals

This lab develops Newton's Method to solve equations. The lab has at least three subgoals:

Acknowledgement

This lab draws heavily upon a lab by a similar name in Learning by Discovery: A Lab Manual for Calculus, edited by Anita Solow, MAA Notes, 1993. In particular, the approach and many details here come from a 1993 lab by Anita Solow.

Background

Very few equations f(x) = 0 can be solved exactly. You have learned methods and tricks for solving equations such as x2 - 6x + 6 = 0, x4 - 5x2 + 6 = 0, and cos2x = sin x. (Spend a little time convincing yourself that you can solve these equations.) However, no general techniques exist for most equations, and we must settle for approximate solutions. The method we will study in this lab is attributed to Newton and uses the idea that the tangent line to a curve closely approximates the curve near the point of tangency.

Suppose we have a function f and we want to solve f(x) = 0. To use Newton's Method, you must have an initial guess x0. The next guess, x1, is found at the intersection of the x-axis with the tangent line to y = f(x) at (x0, f(x0)), as shown in the following figure:

Newton's Method
  1. We need to find a formula for x1.

    1. Use Δ y / Δ x to find f ' (x0), the slope of the tangent line to y = f(x), at x0, in terms of x0, x1, and f(x0).
    2. Solve for x1 to get the first iteration of Newton's Method:
      x1 = x0 - (f(x0) / f ' (x0))

      Once we have x1, we repeat the process to get x2 from x1, x3 from x2, etc. If all goes well, the xi ' s get closer and closer to the zero of f that we are seeking.

    3. Write a formula for x2 from x1.
    4. Write a formula for x3 from x2.
    5. Write a formula for xn+1 from xn.
    6. On the figure below, sketch the appropriate tangent lines and show x1, x2, and x3.
      Starting Newton's Method

Graphs and Computations

In much of the rest of this lab, you will need to use graph2d within MatLab to plot graphs and a program newtons-method.c to perform computations. The first application of Newton's Method provides background for both graph2d and newtons-method.c

  1. Apply Newton's Method to solve the equation x3 - 4x2 - 1 = 0.
    1. Graph f(x) = x3 - 4x2 - 1 = 0 using graph2d within MatLab.
      Recall that you used graph2d in the earlier lab on zooming in.
    2. Use the program newtons-method.c to compute successive guesses using Newton's Method. To use this program,
      • Click on this link for newtons-method.c
        (The program likely will appear in a separate window within an editor.)
      • Save the program to your account, giving it the name newtons-method.c
      • The program is already set up for the function f(x) = x3 - 4x2 - 1 = 0.
        Note that the function f(x) is encoded x*x*x - 4*x*x - 1 (some operations are +, -, *, / for addition, subtraction, multiplication, and division, and you can use parentheses as you wish)
        Note also that this function is placed in a return statement and the line ends with a semi-colon.
      • Open a terminal window (click on the picture of a computer monitor at the bottom of your screen).
        Within the window, compile the program (e.g., translate it to a machine-oriented format) with the statement
        gcc -o newtons-method -lm newtons-method.c
      • Run the program in the terminal window by typing the command:
        ./newtons-method
    3. The program will ask you for an initial guess. Use the graph from step a to determine a reasonable choice. What solution does the program produce?
    4. From graph2d, print the graph. Then sketch, by hand, the first three iterations of Newton's Method, based on your initial guess.
  2. You can use Newton's Method to find square roots of numbers. For example, to find the square root of n, solve the equation f(x) = 0 where f(x) = x2 - n.

    1. Find the square root of 15 using Newton's Method, specifying what value you need for x0.
    2. Check your answer with a calculator. Many calculators use Newton's Method, with an initial guess of 1, to take square roots.

Choice of Initial Guesses

The main difficulty in using Newton's Method occurs in the choice of the initial guess, x0. A poor choice can lead to a sequence x0, x1, x2, ... that does not get at all close to the solution you are seeking.

  1. Go back to the equation x3 - 4x2 - 1 = 0 from Step 2.

    1. Let x0 = 2. What seems to be happening? Sketch the first three iterations of Newton's Method on a graph of y = x3 - 4x2 - 1 = 0.
    2. Let x0 = 0. What happens?
  2. Let f(x) = x3 - x. Clearly the equation x3 - x = 0 has three solutions -1, 0, an 1 .

    1. Argue that if x0 > 1/sqrt(3), then Newton's Method will converge to the solution 1. Therefore, by symmetry, if x0 < -1/sqrt(3), Newton's Method will converge to the solution -1. Be sure to discuss what happens if x0 = -1/sqrt(3) or x0 = 1/sqrt(3).
    2. Demonstrate algebraically that if we start Newton's Method with x0 = 1/sqrt(5), then x1 = -1/sqrt(5), x2 = 1/sqrt(5). Therefore, if we start with x0 = 1/sqrt(5) or x0 = -1/sqrt(5), we do not converge to a solution. In this case, -1/sqrt(5) and 1/sqrt(5) are called period 2 points.
    3. The interesting chaotic behavior occurs when 1/sqrt(5) < x0 < 1/sqrt(3) or, by symmetry, when -1/sqrt(3) < x0 < -1/sqrt(5). Fill in the following table to convince yourself of the sensitivity of Newton's Method to the choice of x0 = 0.
      x0 = 0 Solution found
       
      0.577
      0.578
      0.460
      0.466
      0.44722
      0.44723

Another Application

  1. In this problem, we are going to find the point on the curve y = 1/x that is closest to the point (1, 0).

    1. Find the function (in the single variable x) that gives the distance from any point on the curve y = 1/x to the point (1, 0).
    2. Compute the derivative of the distance function that you found in part a.
    3. Display the necessary work to show that finding the critical points of the distance function leads to solving the equation x4 - x3 - 1 = 0.
    4. Now use Newton's Method to find all solutions to the equation x4 - x3 - 1 = 0.
    5. What point on the curve y = 1/x is closest to the point (1, 0)?

Further Exploration

  1. Another method of approximating the zeros of a function f is to use the computer to graph the function y = f(x), zoom in around a place where the graph hits the x-axis, and use the computer to digitize the coordinates of this point. Let's call this the graphical method of solving equations.

    1. Use the graphical method to solve the equation x3 - 4x2 - 1 = 0. (This is the same equation that you solved using Newton's Method n Problem 2.) Keep track of the answers that you get with successive zooming.
    2. Discuss the advantages and disadvantages that you think the graphical method has in relation to Newton's Method. Which would you rather use, and why?

Work to Turn In


This document is available on the World Wide Web as

http://www.cs.grinnell.edu/~walker/courses/131.fa09/labs/newton.shtml

created 16 August 2009
last revised 22 September 2009
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.