UNDERGRADUATE COMPUTATIONAL ENGINEERING AND SCIENCE

UCES

"Nonlinear Problems and Intermediate Values"

Course:Methods and Analysis in UCES

Prerequisites:

  1. Math:   Calculus, derivative
  2. Computing:   Maple or Matlab, loops
  3. Science:   None

Objectives:

  1. Math:   Bounded monotone sequences converge
  2. Computing:   Conditional code
  3. Science:   First nonlinear problems

General Information: This section gives an algorithmic proof of the intermediate theorem. This is intimately related to the completeness axiom of the real line. In the next section the mean value theorem will be proved using the assumption of a continuous derivative and the intermediate value theorem. This sets the foundations for establishing various orders of convergence for solving nonlinear problems, numerical integration and numerical solution of differential equations.

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

Revision Date:   7-29-94

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

Return to Table of Contents


2.1   Nonlinear Problems and Intermediate Values

2.1.1.   Introduction.

A linear problem has the form Ax = d where A and d do not depend on the unknown x. In this lecture we will study nonlinear problems of the form f(x) = 0 where x is a single unknown real number, and f is a real valued function. Later we will look at more complicated nonlinear problems where there are more than one unknown and more than one nonlinear equation. A simple example is f(x) = x2- 2 = 0 whose solution we were told is the square root of 2. But, how does one compute the square root of 2?


2.1.2.   Applied Area.

A one liter can is to be made from the same material on the sides, bottom and top. The top material must have a slightly larger radius than the bottom so that a seam can be formed. The problem is to find the height, h, and radius, r, so that the total surface area will be a minimum, or a minimum cost.

The one liter constraint can be written as

r2h = 1000.

The total surface area is from the bottom, sides and top with extra radius, d,

A = r2 + 2rh + (r + d)2.

From the constraint let h = 1000/(r2) so that the area is a function of only r

A(r) = r2 + 2000/r + (r + d)2.

Then compute the derivative and set it equal to zero

A'(r) = 0 = -2000/r2 + 2(r + (r + d)).

Thus we must solve the cubic equation

f(r) = 0 = -1000 + (2r3 + r2d).

If there was no seam, d would be zero and the root is easy to find r = (1000/2)1/3 . Since d is positive, f evaluated at this r will be positive. Also, f(0) is negative. So, if the graph has no breaks between f((1000/2)1/3 ) > 0 and f(0) < 0, we should have a solution between x = (1000/2)1/3 and x = 0.


2.1.3.   Model.

The model is very simple: find x such that f(x) is zero. In linear problems we can find a solution in a finite number of steps provided a solution exists. Nonlinear problems generally require some sort of approximation process which we only stop when convinced that there will be no further significant improvement in the approximation. Nonlinear problems also may have no real solution such as x2 + 1 = 0, or they may have multiple real solutions such as x2 - 1 = 0.


2.1.4.   Method.

Suppose the graph is unbroken, that is, f is continuous. From the graph we observe there is a root between x1 and x2 , f(x1 ) > 0 , f(x2 ) < 0 and x1 < x2 . This means a better estimate for the root might be the midpoint of the interval [x1 , x2 ]. Call this xp and compute f(xp). Either f(xp) = 0 , > 0 or < 0. In the first case we are done. In the second case we may replace x1 by xp. In the last case we replace x2 by xp. Now repeat this each time dividing the interval into two equal parts and replacing the old interval by one of the half intervals that contain the root. More precisely, we have the bisection algorithm where we have stopped the algorithm if either | f(xp) | < eps1 or | xn+2 - xn+3 | < eps2. The eps1 and eps2 are "small" positive numbers and are chosen according to the required accuracy of the application.

Bisection Algorithm for the Root.

	f(x1 ) > 0 , f(x2 ) < 0 and x1 < x2
	for l = 1,maxit
		n = 2l - 1
		xp = (xn + xn+1 )/2
		if f(xp) = 0 then
			c = xp
			go to end
		endif
		if f(xp) > 0 then
			xn+2 = xp
			xn+3 = xn+1
		endif
		if f(xp) < 0 then
			xn+2 = xn
			xn+3 = xp
		endif
		if | f(xp) | < eps1 go to end
		if | xn+2 - xn+3 | < eps2 go to end
	endloop
	end.

Example. Find the square root of 2. Let f(x) = 2 - x2.

Note f(1) = 1 and f(2) = -2. So let x1 = 1 and x2 = 2.
Then xp = 1.5 and f(xp) = -.25. So, let x3 = 1 and x4 = 1.5.
The next xp = 1.25 and f(1.25) = .4375. Let x5 = 1.25 and x6 = 1.5.
Now xp = 1.375 and f(1.375) = .109375. Let x7 = 1.375 and x8 = 1.5.
Next xp = 1.4375, f(1.4375) = -.06640625, x9 = 1.375 and x10 = 1.4375.

Often it is easy to graph the function so that we know roughly where the root is Certainly, we had the graph of 2 - x2 in our mind.


2.1.5.   Implementation.

The following is an Maple code for the bisection algorithm. This is not the most efficient implementation because we want to organize the output data so that the monotone even and odd approximating sequences will become clear.

Maple Bisection Algorithm.

  Input Data for f(x) = 2 - x2:
	> x1:=1;
	> x2:=2;
	> f:=x->2-x*x;
	> with(linalg):
	
  Procedure for Algorithm is Defined:
	> BISEC:=proc(f,x1,x2)
	> eps := .001;
	> xx:=vector(40,0);
	> xx[1] := x1:
        > xx[2] := x2:
	> for l from 1 to 20 do
	> 	n:=2*l-1;
	> 	xp:=evalf((xx[n] + xx[n+1])/2);
	> if abs(f(xp)) < eps then break fi;
		> if f(xp) < 0 
		then
		xx[n+2] := xx[n]:
        	xx[n+3] := xp:
		fi;
	> if f(xp) > 0
		then
		xx[n+2] := xp:
		xx[n+3] := xx[n+1]:
		fi;
	> od;
	> end;

  Procedure is Called:
	> BISEC(f,x1,x2);

  Output is Given in Odd-Even Intervals:
	> approx_sol:=seq([xx[2*l-1],xx[2*l]],l=1..10);
		
        

The following is a shorter version of the bisection algorithm which is coded in Matlab.

Matlab Code (bisect.m).

	% choose xl and xr so that xl < xl and f(xl)*f(xr) < 0
	% define the function  f(x) = 2 -x*x in the f.m m-file
	eps = .001;
	xl = 1;
	xr = 2;
	for i=1:20
	     xm = (xl + xr)*.5;
	     fxm = f(xm); 
	     if abs(fxm)<eps
	          sol = xm;
	          break;
	     end
	     if fxm*f(xr)<0
	          xl = xm;
	     end
	     if fxm*f(xl)<0
	          xr = xm;
	     end
	end
	fxm
	sol

  Output:
	fxm =
	     4.272460937500000e-04

	sol =
	   1.41406250000000


2.1.6.   Assessment.

In the section on floating point numbers we noted that the square root of 2 or any prime number could not be a rational number. The real numbers have an additional property that the rational numbers do not have. This is called the completeness axiom, and an immediate consequence of the this is the following property.

Completeness Property of the Real Numbers.

Let xn be a sequence of real numbers.

If xn xn+1 M < , then there is a real number, x, such that xn converges to x.

Example. The square root of 2 has decimal expansion 1.41421356237...

     x1 = 1.       x4 = 1.414       .
     x2 = 1.4      x5 = 1.4142      .
     x3 = 1.41     x6 = 1.41421     M = 1.5

Since the square root of 2 is not rational, the rational numbers do not have the completeness property.

We want to present two very important consequences of the completeness property. The first will be the intermediate value theorem which will helps us establish the convergence of the bisection algorithm. In the next section we will establish the mean value theorem and some of its generalizations. The mean value theorem is a fundamental tool for the analysis of the rates of convergence of algorithms.

Figure: Intermediate Value Theorem

Intermediate Value Theorem. If f:[a,b] R is continuous on [a,b], f(a) > 0 and f(b) < 0, then there exists a c in (a,b) such that f(c) = 0.

Proof. This proof is constructive and will result in the bisection algorithm for finding roots of functions. Let x1 = a and x2 = b > a . Bisect the interval and let xp be the midpoint. Compute f(xp).

If f(xp) > 0, then let x3 = xp and x4 = x2 .
If f(xp) < 0, then let x3 = x1 and x4 = xp.
If f(xp) = 0, then we are done. In the either of the two nontrivial cases, we have

x1 x3 < x4 x2 and | x3 - x4 | | b-a |/2.
Repeat this so that for n = odd = 2l + 1
xn-2 xn < xn+1 xn-1 and | xn - xn+1 | | b-a |/2l .

By the completeness property both the even and odd sequences must converge to xodd and xeven , respectively. Since |xn - xn+1| | b-a |/2l must go to zero, xodd = xeven . Since f(x) is continuous, f(xodd ) are positive and f(xeven ) are negative, we can choose c to be the limit of the two sequences.


2.1.7.   Homework.

  1. Show that the inequality in the completeness property can be reversed.

  2. Show the inequality in the intermediate value theorem's assumptions can be reversed.

  3. Run the bisection algorithm on your computer. Use the square root of 2 example to help you debug your code.

  4. Consider the application with variable d. Find the r as a discrete function of d and graph this function.