You are on page 1of 4

Donald Henken AMS326 - Project 1 Due: 09.22.

11

Root Finding Methods - Bisection vs. Newton Problem and Description 1


Bisection Method and Newton method are popular algorithms to determine the root of a function that are applied in numerical applications. How do they work and What are the pros and cons of each? What are the relative strengths and weaknesses between them?

[Bisection Method] The Bisection method zeros in on the root of a function by evaluating it at two locations such that f (x) is positive at one location and negative at the other. The interval between the two x values is then bisected. The middle value is evaluated to determine which half the root is in. This halving process is repeated until a given tolerance is achieved. If we have three x values denoted xL , xM , and xH . Respectively they repersent low, middle, and high values for x. A requirement for the bisection method is that the root must lie between xL and xH . The basic steps for the bisection method are as follows: Plot f(x) and choose a value for x that is a good estimate of where the root can be found. From your initial guess chose a value , such that x will contain the root. Cut interval from xL to xH in half and determine which side the root is on. Repeat the process until the function evaluated at your midpoint xM is within your tolerance. The requirements to perform the Bisection method are that the root exists, in the interval there must be only one root, and you must have a range where you know the solution is.

[Newtons Method] The Newton method nds successively better approximations for the value of x at which f(x) will be zero. This is done by rst taking an initial guess of the location. This value for x is evaluated at both f (x) and the derivative of the function, f (x). Upon each itteration a new value for x is found through Equation (1).
Partial answer to Problem 1.1. Description of methods found in this section. See Analysis and Conclusion for the pros, cons, stregths, and weaknesses of the two methods.
1

x1 = x0

f (x0 ) f (x0 )

(1)

x1 represents the point where the tangent line to the function evaluated at x0 intersects with the x-axis. This process is repeated and can be generalized as follows.2 xn+1 = xn f (xn ) f (xn ) (2)

Successive itterations following equation (2) are continued until the function evaluated at xn+1 is within an acceptable tolerence value. The requirements for Newtons method are that a solution exists, you have a guess for a initial starting point, and that the function is well behaved.

The Program
The program tests the two root nding methods. Each method is assigned its own module in the program. The module for the Bisection method denes two Fortran functions, one is the function we are evaluating (see Eq.3) and the other is the bisection method. The Bisection method function is dened as rootB(Xest,Xoff,TOL) where the input arguments Xest, Xoff, and TOL are the estimated x value, the oset , and the tolerance. The module for the Newton method contains the same two Fortran functions with the addition of a third for analytical expression of the original functions derivative.3 (see Eq.4) The function for nding the root is dened as rootN accepting the same arguments as rootB.
3

f (x) = 1.956x x4 cos(x2 ) 2.012

(3)

f (x) =

2x5 sin(x2 ) 4x3 cos(x2 ) 3x2 log(1.956) 1.956x3

(4)

In addition to answering Problems 1.2 and 1.3, I wanted to make it easy to implement the methods into future programs where the root will need to be found. The main part of the program which makes use of the functions in the modules is at the end of the source code.

Formula and its description taken from Wikipedia If the analytical expression for the derivative is not known this Fortran function can be replaced with a numerical method for nding the derivative.
3

Results

10 f(x) g(x)=0 8

-2

-4 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2

Figure 1: Plot of Equation (3) from x = 0 to x = 2 To choose values for Xest and Xoff equation (3) was plotted in Gnuplot. The script used to generate Figure 1 should be included (project01.plt). Looking at the plot 1.45 was chosen as the estimated value of the root Xest, and noticing that the root denetly lies between x = 1.4 and x = 1.5, a the value = 0.05 was used for the value of Xoff. After the program was compiled and executed the following results were displayed.

Analysis
The program was edited to look at the convergence rates of the two methods. The value for Xoff was also changed to 0.15. The program was easily rewritten to record the number of itterations it takes for each method to come below TOL as its value changed on successive itterations. The structure of the program allowed a loop to easily be created around the functions in the main program. The tolerance was set to equal 1.0/(10.0**real(i)) where i=2:33. The program was then compiled with real numbers having quad precision, which on 3

my machine equates to 35 digits. The data for the number of itterations was then sent to a le for each method. This data can be seen in Table 1 below.

Table 1: Table showing the number of itterations for a desired tolerance. It is interesting to note that newton method found the root to 33 digits in the same number of itterations it took the bisection method to nd a value within a 2 digit tolerance. While the newton method may be quick at determining the root it does have its aws. It is essential that the function is well behaved around the root. Another aw of Newton is that at times it can nd itself in an endless oscillatory loop. Bisection method suers from the burden of linear convergence, however it is a very safe method to use. Assuming that the root is between your low and high values when starting, there is no reason why it should not be able to determine the root of the function. I would imagine that for an ecient and fast method to nd the root of a function a combination of the two should be used.

You might also like