UNDERGRADUATE COMPUTATIONAL ENGINEERING AND SCIENCE

UCES

"Roots and Newton's Algorithm"

Course:   Methods and Analysis in UCES

Prerequisites:

  1. Math:   Calculus 2
  2. Computing:   Maple and conditional loops
  3. Science:   Physics

Objectives:

  1. Math:   Analysis of convergence
  2. Computing:   Conditional loops
  3. Science:   Heat transfer

General Information: We establish quadratic and local convergence of Newton's algorithm for a single function of one variable. This will later be generalized to N functions and N unknowns.

Contact Person:   R. E. White, NCSU, white@math.ncsu.edu

Revision Date:   8-3-94

Copyright ©1994, R. E. White. All rights reserved.

Return to Table of Contents


2.7   Roots and Newton's Algorithm

2.7.1.   Introduction.

Newton's algorithm is one of the most important numerical schemes because, under appropriate conditions, it has local convergence and quadratic convergence properties. Local convergence means that if the initial guess is sufficiently close to the root, then the algorithm will converge to the solution. This is in contrast to the Picard algorithm (recall our attempts to find the square root of 2). Quadratic convergence means that the error at the next step will be proportional to the square of the error at the current step. In general, the Picard algorithm only has first order convergence where the error at the next step is proportional to just the error at the present step (see the proof of the Picard convergence theorem).


2.7.2.   Applied Area.

We give two applications. The Euler-Trapezoid algorithm is used to solve the stiff differential equation which models a mass falling through a viscous medium. A second application evolves from continuum solution to a Newton's law of cooling model with heat source.

Application to a Falling Mass Through a Viscous Medium. Consider a mass which is falling through a viscous medium. There will be two forces: one from gravity, mg, and a second from the viscous medium, -ku2. Here the speed of the mass is denoted by u, and the k is a constant which reflects the mass and the viscosity of the medium. Newton's law of motion then gives the differential equation

m ut = mg - k u2.

If k or u is initially very large, then this will be a stiff differential equation. As time evolves, the speed will approach u = (mg/k)1/2 .

In the Euler-Trapezoid algorithm we can use Newton's algorithm in place of the Picard algorithm which may require some constraint on the step size. We must replace the fixed point problem u = g(u) by a root problem F(u) = g(u) - u = 0. The inner loop of the Euler-Trapezoid algorithm should be replaced by the Newton scheme to solve

F(u) = u(k) + (h/2)*(oldf + f((k+1)*h,u)) - u = 0.

For the initial guess, we can choose the previous speed u(k) which should be relatively close to this root.

Application to Newton's Law of Cooling with Heat Source. Consider the differential equation ut = c(usur - u) + d where d represents a heat source such as a chemical reaction in a well stirred liquid. The exact solution can be found by separation of variables, and it is u(t) = D + (u(0) - D)e-ct where D = D(c) = usur + d/c. If c is not given, it can be found by making a second observation u = u(t). This gives a nonlinear equation for c of the form

0 = F(c) = (u - D(c))/(u(0) - D(c)) - e-ct.

This has at least one solution because F(0) = 1 - e < 0 and F() > 0 provided u, u(0) > usur .


2.7.3.   Model.

The model has either the form of a fixed point x = g(x) or a root of f(x) = 0 where f or g are given functions. Newton's method is formulated for the root problem, but clearly the fixed point problem can be written as a root problem when one defines f(x) = x - g(x).


2.7.4.   Method.

The idea behind Newton's algorithm is to approximate the function f(x) at a given point by a straight line. Then find the root of the equation associated with this straight line. One continues to repeat this until little change in approximated roots is observed.

Figure: Newton's Algorithm

The equation for the straight line at the mth iteration is

(y - f(xm ))/(x - xm ) = f'(xm ).

Define xm+1 so that y = 0 where the straight line intersects the x axis

(0 - f(xm ))/(xm+1 - xm ) = f'(xm ).

Solve for xm+1 to obtain Newton's algorithm

xm+1 = xm - f(xm )/f'(xm ). (1)

There are two common stopping criteria for Newton's algorithm. First, is the common absolute error which requires two successive iterates to be close. The second measures how close the function is to zero.

Newton's Algorithm.

    choose xold, eps1 > 0 and eps2 > 0
    for m = 1, maxit
        xnew = xold - f(xold)/f'(xold)
        if |xnew - xold| < eps1 and |f(xnew)| < eps2 go to end
	xold = xnew
    endloop
    end.

Newton's Algorithm for Euler-Trapezoid Method.

    for m = 1, maxit
        F = u(k) + (h/2)*(oldf + f((k+1)*h,oldu)) - oldu
        FP = (h/2) fu((k+1)*h,oldu) - 1
        newu = oldu - F/FP
        if |oldu - newu| < eps go to end
        oldu = newu
    endloop.

Example. Consider f(x) = 2 - x2 = 0. The derivative of f is -2x, and the iteration in (1) can be viewed as a special Picard algorithm where g(x) = x - (2 - x2 )/(-2x). We let x0 = 1. The iterates did converge and did so quadratically.

Table: Quadratic Convergence
m xm error = Em Em/(E(m-1)2 )
0 1.0 .414213
1 1.5 .085786 2.000005
2 1.4166666 .002453 3.000097
3 1.4142156 .000002 3.008604


Example. Consider f(x) = x1/3 - 1. The derivative of f is (1/3)x-2/3. The corresponding Picard iterative function is g(x) = -2x + 3x2/3. The next table illustrates the local convergence for a variety of initial guesses.

Table: Local Convergence
x0 = initial guess m = iter. for conv.   x0 = initial guess m = iter. for conv.
10.0 no conv.   00.1 4
05.0 no conv.   -0.5 6
04.0 6   -0.8 8
03.0 5   -0.9 20
01.8 3   -1.0 no conv.


2.7.5.   Implementation.

We consider the differential equation for the mass falling through a viscous medium which exerts a force -.5u2 where u is the speed of the mass. If the mass is one unit, then the equation of motion is ut = 32 - .5u2 . Assume its initial speed is 100. We use the Euler-Trapezoid algorithm with Newton's method to solve the fixed point problem at each time step.

Maple Code for Euler-Trapezoid Algorithm with Newton Solver.

  Input Data:
        > t:='t':
        > u:='u':
        > f:=(t,u)->32 -.5*u*u;
		
        
        > fp:=(t,u)->-u;
		
        
        > t0:=0:
        > u0:=100:
        > T:=.20:
        > K:=10:

  Define Procedure EULERTN:
        > EULERTN:=proc(f,fp,t0,u0,T,K)
        > t(0):= t0:
        > h:=T/K:
        > u(0):= u0:
        > eps:=.0001:
        > maxm:= 50:
        > for k from 0 to K do
        >     oldf:=f(t(k),u(k)):
	>     oldu:=u(k):
	>     t(k+1):= t(k) + h:
	>     test:=1:
	>     for m from 1 to maxm while(test > eps) do
	>         F:=u(k) + (h/2)*(oldf + f(t(k+1),oldu)) - oldu:
	>         FP:= (h/2)*fp(t(k+1),oldu)-1:
	>         newu:= oldu - F/FP:
	>         test:= abs(oldu - newu):
	>         oldu:=newu:
	>     od:
	>     u(k+1) :=newu:
	> od:
	> end:

	Output Data:
		> with(plots):
		> EULERTN(f,fp,0,100,.2,10):
		> L:=[seq([t(n),u(n)],n=0..10)]:
		> EULERTN(f,fp,0,100,.20,20):
		> LL:=[seq([t(n),u(n)],n=0..20)]:
		> EULERTN(f,fp,0,100,.20,40):
		> LLL:=[seq([t(n),u(n)],n=0..40)]:
		> plot({L,LL,LLL},x=0..(.2));

Figure: Speed versus Time: K = 10, 20, 40


2.7.6.   Assessment.

In the above examples we noted that Newton's algorithm was a special case of the Picard algorithm with g(x) = x - f(x)/f'(x). In order to show that g(x) is contractive, we need to have |g'(x)| < 1.

g'(x) = 1 - ((f'(x))2 - f(x)f''(x))/(f'(x)2 ) = f(x)(f''(x)/(f'(x)2 ). (2)

If x is a solution of f(x) = 0 and f(x) is continuous, then we can make f(x) as small as we wish by choosing x close to x. So, if in (2) f''(x)/(f'(x)2 ) is bounded, then g(x) will be contractive for x near x. Under the conditions listed in the following theorem this establishes the local convergence.

Newton's Convergence Theorem. Consider f(x) = 0 and assume x is such a root. If f'(x) is not zero, f''(x) is continuous on an interval containing x, then

(i).   for x0 suitably close to x Newtons's algorithm converges to the x

(ii).   the algorithm converges quadratically, that is,

| xm+1 - x | [max |f''(x)|/(2 min |f'(x)|)] |xm - x|2. (3)

Proof. In order to prove the quadratic convergence in (3), we use the extended mean value theorem where a = xm and x = x :

0 = f(x) = f(xm ) + f'(xm ) (x - xm ) + (f''(c)/2) (x - xm )2 .

Divide the above by f'(xm ) and use the definition of xm+1 in (1) to get

0 = -(xm+1 - xm) + (x - xm) + (f''(c)/(2f'((xm)) (x - xm)2

= -(xm+1 - x) + (f''(c)/(2f'((xm)) (x - xm)2.

Since f'(x) for some interval about x must be bounded away from zero, and f''(x) and f'(x) are continuous, the inequality in (3) must hold.


2.7.7.   Homework.

  1. Use Newton's algorithm to solve 0 = 7 - x3. Observe quadratic convergence.

  2. Use Newton's algorithm to solve the algebraic equation for the one liter can problem with a seam on one end. This problem was discussed when we introduced the bisection algorithm.

  3. In the proof of the Newton's convergence theorem explain why the coefficient of |xm - x|2 in the inequality (3) is bounded.

  4. Consider the Euler-Trapezoid algorithm with Newton's method to solve the fixed point problems. Apply this to the radiative cooling problem in the previous section.

  5. Consider the above heat source problem with d = 10, c = 1, usur = 100 and u(0) = 212 . Find a root. Is it the only root?