Vous êtes sur la page 1sur 9

NUMERICAL METHODS

BISECTION METHOD

Submitted by: Kyle Rhys A. Yburan college student

Submitted to: Engr. Carlo Pilapil, ECE college Teacher

TABLE OF CONTENTS

Introduction

Theorem Method Algorithm Summarized Steps

Application of Method

MATLAB Program

Flow Chart

Conclusion

Referrences

I.

Introduction

This is a survey of the basic numerical methods that are used to solve scientific problems. The emphasis is evenly divided between the analysis of the methods and their practical applications. Some convergence theorems and error bounds are proved. The course also provides an introduction to Matlab, an interactive program for numerical linear algebra, as well as practice in computer programming. One goal of the course is to show how calculus and linear algebra are used in numerical analysis.

II.

Theorem

The bisection method in mathematics is a root-finding method which repeatedly bisects an interval and then selects a subinterval in which a root must lie for further processing. It is a very simple and robust method, but it is also relatively slow. Because of this, it is often used to obtain a rough approximation to a solution which is then used as a starting point for more rapidly converging methods. The method is also called the binary search method and is similar to the Binary Search algorithm in computing, where the range of possible solutions is halved each iteration.

Method
The method is applicable when we wish to solve the equation f(x) = 0 for the real variable x, where f is a continuous function defined on an interval [a, b] and f(a) and f(b) have opposite signs. In this case a and b are said to bracket a root since, by the intermediate value theorem, the f must have at least one root in the interval (a, b). Refer to fig. 2-1.

Figure 2-1 Plot of the function At each step the method divides the interval in two by computing the midpoint c = (a+b) / 2 of the interval and the value of the function f(c) at that point. Unless c is itself a root (which is very unlikely, but possible) there are now two possibilities: either f(a) and f(c) have opposite signs and bracket a root, or f(c) and f(b) have opposite signs and bracket a root. The method selects the subinterval that is a bracket as a new interval to be used in the next step. In this way the interval that contains a zero of f is reduced in width by 50% at each step. The process is continued until the interval is sufficiently small. Explicitly, if f(a) and f(c) are opposite signs, then the method sets c as the new value for b, and if f(b) and f(c) are opposite signs then the method sets c as the new a. (If f(c)=0 then c may be taken as the solution and the process stops.) In both cases, the new f(a) and f(b) have opposite signs, so the method is applicable to this smaller interval.

Algorithm (Basic Pseudo code)


INPUT: Function f, endpoint values a, b, tolerance TOL or number of decimal places, maximum iterations NMAX CONDITIONS: a < b, either f(a) < 0 and f(b) > 0 or f(a) > 0 and f(b) < 0 OUTPUT: value which differs from a root of f(x)=0 by less than TOL N 1 While N NMAX { limit iterations to prevent infinite loop c (a + b)/2 new midpoint If (f(c) = 0 or (b a)/2 < TOL then { solution found Output(c) Stop } N N + 1 increment step counter If sign(f(c)) = sign(f(a)) then a c else b c new interval } Output("Method failed.") max number of steps exceeded

Summarized Steps
Bisect [a; b] into two halves [a; c] and [c; b] where =
+ 2

Identify the interval containing the root by checking the signs of f (a)f (c) and f (c)f (b). If f (a)f (c) < 0 then interval [a; c] has the root. Otherwise the other interval [c; b] has the root. Bisect the new interval that contains the root and repeat steps 1-3. At each step take the midpoint of the interval as the most updated approximation of the root. Stop the procedure after a specified number of iterations or when the width of the interval containing the root is less than a given tolerance ".

III.

Application of Method

Consider finding the root of f(x) = x2 - 3. Let step = 0.01, abs = 0.01 and start with the interval [1, 2]. Table 3-1. Bisection method applied to f(x) = x2 - 3. a 1.0 1.5 1.5 1.625 1.6875 1.7188 b 2.0 2.0 1.75 1.75 1.75 1.75 f(a) -2.0 -0.75 -0.75 f(b) 1.0 1.0 c = (a + b)/2 1.5 1.75 f(c) -0.75 0.062 -0.359 Update new b a a=c b=c a=c 0.5 0.25 0.125 0.0625 0.0313 0.0156 0.0078

0.0625 1.625

-0.3594 0.0625 1.6875 -0.1523 0.0625 1.7188 -0.0457 0.0625 1.7344

-0.1523 a = c -0.0457 a = c 0.0081 b = c -0.0189 a = c

1.71988/td> 1.7344 -0.0457 0.0081 1.7266

Thus, with the seventh iteration, we note that the final interval, [1.7266, 1.7344], has a width less than 0.01 and |f(1.7344)| < 0.01, and therefore we chose b = 1.7344 to be our approximation of the root. IV. MATLAB Program

%By:Kyle Rhys A. Yburan BSME-5 %Numerical Methods %Bisection Method clc msgbox('By: Kyle Rhys A. Yburan BSME-5'); disp('BISECTION METHOD CALCULATOR'); disp('a=lower limits or starting point of interval'); disp('b=upper limits or end point of interval'); disp('c=sum of a and b, divided by 2'); syms x; func = input('Please enter a expression for f(x):');

a = input('Please enter the starting point of the interval :'); b = input('Please enter the end point of the interval :'); decimalplaces=input ('Please enter the number of decimal places :'); function_value_at_a=subs(func,x,a) function_value_at_b=subs(func,x,b) check_limits=function_value_at_a*function_value_at_b; sprintf('f(%f)*f(%f) = %f',a,b,check_limits) i=0; while(1) disp('Iteration ='); disp(i) sprintf('\nThe Interval is [%f,%f]',a,b) c=(a+b)/2 termination_check=abs(a-b); sprintf('Checking Termination Condition:\n|a-c| = |%f - %f| = %f ',a,c,termination_check) if (termination_check<.5*10^-decimalplaces) break end function_value_at_c=subs(func,x,c) function_value_at_a=subs(func,x,a) check=function_value_at_c*function_value_at_a; sprintf('function value at c * function value at a = %f',check) if(check<0) disp('"Therefore root lies in lower sub-interval"----------------------------------------->') b=c end if (check>0) disp('"Therefore root lies in upper sub interval"------------------------------------------>') a=c; end i=i+1; end disp('-------------Solution---------------'); sprintf('roots=%f',c) msgbox('Submitted to: Engr. Carlo Pilapil, ECE'); msgbox('"Excellent!"');

V.

Flow Chart

Figure 4-1, Bisection Flowchart

VI.

Conclusion Determining roots using numerical method by the help of programming tool Matlab is easier than manually iterating functions.

VII.

Referrences www.matlabcentral.com en.wikipedia.org/wiki/Bisection_method www.mathworks.com/

Vous aimerez peut-être aussi