0% found this document useful (0 votes)
345 views3 pages

Bisection Method

1) The bisection method is used to find the root of a function f(x) given lower and upper bounds that bracket the root. 2) It works by repeatedly taking the midpoint of the bounds as an estimate for the root and narrowing the bounds based on whether f(x) is positive or negative at the midpoint. 3) The process repeats until the bounds converge within a specified tolerance or a maximum number of iterations is reached.

Uploaded by

Hazmi Bcool
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
345 views3 pages

Bisection Method

1) The bisection method is used to find the root of a function f(x) given lower and upper bounds that bracket the root. 2) It works by repeatedly taking the midpoint of the bounds as an estimate for the root and narrowing the bounds based on whether f(x) is positive or negative at the midpoint. 3) The process repeats until the bounds converge within a specified tolerance or a maximum number of iterations is reached.

Uploaded by

Hazmi Bcool
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Bisection Method (C&C 4th, 5.2, p.

116) Given lower and upper bounds, xl and xu which bracket the root: f(x1) f(xu) < 0 1) Estimate the Root by midpoint: x r 2) Revise the bracket: f(xl) f(xr) < 0, f(x1) f(xr) > 0, xr > xu, xr > xl
xrnew x old r
new xr

xl xu 2

3) Repeat steps 1-2 until: (a) | f(xr) | < (c) x u xl f(x) (b) a < s , with a
100%

(d) maximum # of iterations is reached

f(x)

xr

xl xu 2

f(xu) f(xr (x1) )

f(xu)

(x1) (xu) f(xr) f(x1) x f(x1) f(xr) > 0 xr => xl

f(x1)

(xr (xu) x )

Summary of Bisection Method Advantages: 1. Simple 2. Good estimate of maximum error x xu E max 1 2 3. Convergence guaranteed
i 1 i Emax 0.5 Emax

Disadvantages: 1. Slow 2. Requires initial interval around root: Use graph of function, incremental search, or trial & error

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

format long; x = sym('x'); expr = input('Please enter the equation : '); fx = sym(expr); x1 = input('Please enter value of X1 : '); x2 = input('Please enter value of X2 : '); iter = input('Please enter number of Iterations : '); fx1 = subs(fx,x,x1); fx2 = subs(fx,x,x2); x3 = 0; counter = 0; fid=fopen('c:\bisection.csv','w'); fprintf(fid,'%s\n','Iteration,x1,x2,x3,F(x1),F(x2),F(x3),Max Errors'); if fx1*fx2 &gt;= 0 message = 'x1 and x2 values are not valid for desired root'; disp(message) else

while ((counter == 0 || abs(x1-x2) &gt; 0.000001 || subs(fx,x,x3) == 0) &amp;&amp; c &lt;= iter) counter = counter + 1; x3 = (x1 + x2) / 2; fprintf(fid,'%d,',counter); fprintf(fid,'%5.8f,',x1);

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

fprintf(fid,'%5.8f,',x2); fprintf(fid,'%5.8f,',x3); fprintf(fid,'%5.8f,',subs(fx,x,x1)); fprintf(fid,'%5.8f,',subs(fx,x,x2)); fprintf(fid,'%5.8f,',subs(fx,x,x3)); fprintf(fid,'%5.8f\n',abs((x2-x1)/(2^counter))); x3 = (x1 + x2) / 2; if subs(fx,x,x3) * subs(fx,x,x1)&lt; 0 x2 = x3; else x1 = x3; end end end sprintf('The root of the equation using Bisection method is :: %d', x3) fclose(fid);

You might also like