Bisection

NasimaAkhtar2 163 views 11 slides Mar 24, 2021
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

This lecture contains Bisection Method working rule, Graphical representation, Example, Pros and cons of this method and a Matlab Code.


Slide Content

Numerical Computing Bisection Method Lecture # 9 By Nasima Akhtar

Bisection Method Working Rule It begins with two values for x that bracket a root. It determines that they do in fact bracket a root because the function f(x) changes signs at these two x-values and, if f(x) is continuous. The bisection method then successively divides the initial interval in half, finds in which half the root(s) must lie, and repeats with the endpoints of the smaller interval Suppose, we wish to locate the root of an equation f ( x ) = 0 in an interval, say ( x , x 1 ). Let f ( x ) and f ( x 1 ) are of opposite signs, such that f ( x ) f ( x 1 ) < 0.

Graphical Representation of Bisection Method

Formula Derivation If f ( x 2 ) = 0, then x 2 is the desired root of f ( x ) = 0. However, if f (x 2 ) then the root may be between x and x 2 or x 2 and x 1 . As we know f( ) then, we can find which value to replace for next iteration by the following condition such as If f( )*f( then, = else = General form of this method is given by:  

Algorithm for Bisection Method

MERITS OF BISECTION METHOD The iteration using bisection method always produces a root, since the method brackets the root between two values. As iterations are conducted, the length of the interval gets halved. So one can guarantee the convergence in case of the solution of the equation. Bisection method is simple to program in a computer.

DEMERITS OF BISECTION METHOD The convergence of bisection method is slow as it is simply based on halving the interval. Cannot be applied over an interval where there is discontinuity. Cannot be applied over an interval where the function takes always value of the same sign. Method fails to determine complex roots (give only real roots) If one of the initial guesses “ ” or “ ” is closer to the exact solution, it will take larger number of iterations to reach the root.  

Example Numerical F(x)= So we consider = 1 , F(1)= - 1 F(2)=9 ------ 1 For n=2 =2 Putting in 1 = = 1.5 As f( 1.5)= 2.875 i.e F(1.5)>0   X F(x) Update Value 1 -1 2 9 1.5 2.875 1.25 0.703125 1.125 -0.2011 1.187500 0.237061 1.156250 0.014557 1.140625 -0.094143 1.156250 0.040003 X F(x) Update Value 1 -1 2 9 1.5 2.875 1.25 0.703125 1.125 -0.2011 1.187500 0.237061 1.156250 0.014557 1.140625 -0.094143 1.156250 0.040003

Example Numerical So replace with = 1 , i.e [1,1.5] = = 1.25 As f( 1.25)= 2.875 i.e F(1.25)>0 = = 1.125 As f( 1.125)= -0.2011 i.e F(1.125)<0 = = 1.187500 As f(1.187500)= 0.237061 i.e. F(1.187500)>0 = = 1.156250 As f(1.156250)= 0.014557 i.e. F(1.156250)>0   X F(x) Update Value 1 -1 2 9 1.5 2.875 1.25 0.703125 1.125 -0.2011 1.187500 0.237061 1.156250 0.014557 1.140625 -0.094143 1.156250 0.040003 X F(x) Update Value 1 -1 2 9 1.5 2.875 1.25 0.703125 1.125 -0.2011 1.187500 0.237061 1.156250 0.014557 1.140625 -0.094143 1.156250 0.040003

Matlab Code function_x =@(x) x.^3+3*x-5; x1=1; x2=2; figure(1) fplot ( function_x ,[x1 x2], 'b-' ) grid on hold on x_mid = (x1 + x2)/2; iterate=1; % fprintf ('% f',abs (- 4)) %while abs( myfunction ( x_mid ))> 0.01 while abs(x1 - x2) > 0.01 %or you can change it to number of iterations, it can be any condition if ( function_x (x2)* function_x ( x_mid ))<0 x1= x_mid ; else x2= x_mid ; end x_mid = (x1+x2)/2; % fprintf ('The root of data is %g\n' , x_mid ); iterate=iterate+1; fprintf ( '%d Approximation Bracket is [% f,%f ] gives function value % f,%f respectively and, mid value is %f\ n' ,iterate , x1,x2,function_x(x1), function_x (x2), x_mid ); end plot( x_mid,function_x ( x_mid ), 'r' ) fprintf ( 'The root of data is %f\n and iteration is %d\n' , x_mid,iterate );

Thank You 