Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: his means we must again assign a the current value of d. [> a := d; The current state in the Bisection Method is a = 0.75 and b = 1.0. We now know that c is located somewhere in the interval [0.75, 1.0]. We can keep repeating this process for a predetermined number of times or until the distance between the interval endpoints, a and b, is as small as we desire. However, this calculation is very tedious! Instead, we can use Maple’s programming facilities to write a simple routine that contains a loop. WARNING: Use Maple CLASSIC version. Maple will give you the comment Warning, premature end of input until you have finished typing all of the lines. Try entering the following lines in Maple (you do not need to type the comments). [> restart: [> f := x -> x∧5 + x -1; define the function f [> a := 0; assign the left-hand endpoint of the original interval to a [> b := 1.0; assign the right-hand endpoint of the original interval to b [> for n from 1 to 10 do do 10 iterations of the Bisection Method [> d := (a+b)/2; calculate the midpoint of the interval [> if ( evalf( f(a)*f(d) ) < 0) then b := d else a := d end if; check the sign of f at the midpoint [> end do; Maple returns the first 10 calculations of d, with the last calculated value as d = 0.7548828125. Maple tells us that c is approximately 0.7548828125. Let’s check this value of c as the root by plotting: [> plot( f(x), x = 0.750..0.760); We can also calculate f (0.7548828125) to ensure its value is close to zero: [> f(0.7548828125); It seems we have a very accurate estimate of the root c! v Copyrighted by B.A. Forrest ([email protected]) 4 Newton’s Method in Maple Error in the Bisection Method Notice that in the previous example, the initial interval [a0 , b0 ] = [0, 1] has length b0 − a0 = 1 − 0 = 1. Hence, after n bisections, the current interval has length 1 2n In general, since half of the interval length represents the maximum possible error in approximating c, after n bisections the maximum error in the approximation is b0 − a0 2n In the previous example, we ran the loop a predetermined number of times to find an approximation for c. However, we can modify this loop to stop when we reach a desired error level. Example [Bisection Method with Determined Error using Maple]: Suppose we wanted the approximation for c to have an error of at most 10−4 . Thus, we should stop the Bisection Method when...
View Full Document

This note was uploaded on 01/09/2013 for the course MATH 127 taught by Professor Prof.smith during the Winter '09 term at Waterloo.

Ask a homework question - tutors are online