Mathematics 161                                  Laboratory 6                             October 8, 1992
	  
Name: _____________________________   Lab Partner: ___________________________
	  
Consulted with:  ____________________________________________________________

© Lafayette College, 1994

Newton’s Method for Finding Roots

In this laboratory you will use Newton's method to solve some equations and you will investigate some of the strengths and weaknesses of that method for approximating solutions of equations.

Recall that if f(x) is a differentiable function, Newton's method uses the tangent line approximation to the graph of f to estimate the solutions of the equation f(x) = 0.  (Solutions to this equation are called roots of f.)  To get started, we make an initial estimate, x0, to a root and then generate new estimates using the x-intercept of the line tangent to the graph at the old estimate.

Part 0: A Demonstration

Preliminaries

As in preceding labs, we will use some special commands contained in the "DerivativeGraphics" package; recall, we input the package as follows:

<<i:\course\root\math161\derivative.m

How Newton's Method Works

Let's define a function whose root we know:  s(x) = x2.  In Mathematica we enter

s[x_] := x^2

What is the root of this function?

To apply Newton's method, we begin with an estimate of the root; we will use the estimate x0 = 1.  The command

NewtonAni[s,1,{x,-0.1,1},{y,-0.1,1},4]

generates an sequence of plots that animates the first four estimates to the actual root given by Newton's method.

The Newton's Method Algorithm

In class we have shown that the new Newton's method estimate for the root of f can be found in terms of the old by the formula:  xnew = xold – f(xold)/f´(xold)..

We will use Newton's method to estimate the roots of the function

f[x_] := x^3 + x^2 - 10 x - 6

Use the command below to make a sketch of the graph of f.  Notice from the graph that the equation f(x) = 0 appears to have a solution near x = –4.  Therefore, we will take –4 as our starting value for Newton's method.

Plot[f[x], {x, -5, 5}]

Enter the command below to "program" Mathematica with the Newton's method algorithm.

Clear[x];
x[0] = -4.0;
x[n_] := x[n] = x[n-1] - f[x[n-1]]/f'[x[n-1]]

(Be sure to include the decimal with the –4 in this command.)  This procedure first clears out any previous values of x, then it declares that x0 = –4.0 will be our starting point.  Finally, it gives the recurrence relation which generates new estimates of the solution of the equation.  The sequence of x[n_]:= x[n] = tells Mathematica to "remember" the values of xn, so it need only compute them once.

To get the first Newton estimate of the solution, we can type

x[1]

To get the 10th estimate, we can type

x[10]

If we want to see the values of all of 10 estimates, we can use the Table command:

Table[{n,x[n],f[x[n]]},{n,0,10}]

Here we are listing not only our estimates of the root, but also the values of f at those points.  What is a good estimate for a solution of f(x) = 0?

Type

?x

to find out what the system knows about x.  As expected, Mathematica knows the rule which we used to define x, but notice that it has also remembered the values of x which have been computed thus far.  That is the reason that we included Clear[x] in our implementation of Newton's method.  To remove these values, just reenter the command that defined x above.  (We will do this next.)

Part 1:  Basic Rootfinding

Now we want to estimate the other two solutions of f(x) = 0 which we saw in our original graph.  Look again at the graph of f generated above.  What is a good first estimate of the other negative root of f in that picture?

Use Newton's method to make a better estimate of this root.  Edit the original command to use your new initial guess, then enter it again.  Make a table with enough iterations of the method to convince yourself that you have a good estimate of the root.  What is an accurate estimate of the root?

Now use the procedure described above to find the remaining root of the given function.  Give your original and final estimates below.

Part 2: A New Function

In physics and engineering, the Bessel function of the first kind with index 0 (written
 J0(x)) is important in modeling the motion of circular objects.  In particular, knowledge of the positive zeros of the function is indispensable.  The command below will redefine f to be J0.  Use Newton's Method to find estimates to the first two positive roots of the function.

Clear[f];
f[x_] := BesselJ[0,x]

1st positve root estimate:     ___________      Actual function value:  __________________

2nd positive root estimate:  ___________       Actual function value:  __________________

Part 3:  You Can't Always Get What You Want

In this part of the lab, f is the function f(x) = x3 + x2 – 10x + 10.  Clear the old definition and enter the new one now.

Notice that this function differs only by addition of a constant from the function whose roots we found in Parts 0 & 1.  Plot its graph over the interval [–5,4].  Based on this graph, do you think that this function has positive roots?  (There is no penalty for a wrong guess here.)

Assume there is at least one positive root.  Use the method we have developed to find it.  Explain briefly the results.  Create a table of estimates to the root to assist in your explanation.

Use the animation generated by the command below to examine what happens when you use a positive initial guess in Newton's method for this function.  You must insert your initial guess as x0 for the command to work!

NewtonAni[f,x0,{x,1/2,3},{y,-.1,2},4]

Explain what happens in this application of Newton's method.  What attribute of the starting point leads to this behavior?

Part 4:  An Application

Suppose that on the first day of the month an individual deposits $100 in a bank account which pays interest at an annual rate r compounded monthly, and that this individual makes an additional deposit of $100 at the beginning of each subsequent month.  Then, at the end of month k, the balance in the account will be

(You do not need to know how to derive this result.)  Use Newton's method to estimate the interest rate, r, that will produce a balance of $20,000 at the end of 10 years.

HINT:  You first need to write the equation which is to be solved in the form f(r) = 0.

What is the function f?  Give a good first estimate for the solution r, and your final estimate as well.