This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Lecture 5 The Bisection Method and Locating Roots Bisecting and the if ... else ... end statement Recall the bisection method. Suppose that c = f ( a ) < 0 and d = f ( b ) > 0. If f is continuous, then obviously it must be zero at some x * between a and b . The bisection method then consists of looking half way between a and b for the zero of f , i.e. let x = ( a + b ) / 2 and evaluate y = f ( x ). Unless this is zero, then from the signs of c , d and y we can decide which new interval to subdivide. In particular, if c and y have the same sign, then [ x, b ] should be the new interval, but if c and y have different signs, then [ a, x ] should be the new interval. (See Figure 5.1.) Deciding to do different things in different situations in a program is called flow control . The most common way to do this is the if ... else ... end statement which is an extension of the if ... end statement we have used already. Bounding the Error One good thing about the bisection method, that we dont have with Newtons method, is that we always know that the actual solution x * is inside the current interval [ a, b ], since f ( a ) and f ( b ) have different signs. This allows us to be sure about what the maximum error can be. Precisely, the error is always less than half of the length of the current interval [ a, b ], i.e....
View
Full
Document
This note was uploaded on 02/09/2012 for the course MATH 344 taught by Professor Young,t during the Fall '08 term at Ohio University Athens.
 Fall '08
 Young,T

Click to edit the document details