Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sec:5.2 The Bisection Method.

Similar presentations


Presentation on theme: "Sec:5.2 The Bisection Method."β€” Presentation transcript:

1 Sec:5.2 The Bisection Method

2 Sec:5.2 The Bisection Method
The root-finding problem is a process involves finding a root, or solution, of an equation of the form 𝑓 π‘₯ = 0 for a given function 𝑓 . A root of this equation is also called a zero of the function 𝑓 . In graph, the root (or zero) of a function is the x-intercept Two numerical methods for root-finding Sec(5.2): The Bisection Method root Sec(6.2): The Newton-Raphson Method

3 Sec:5.2 The Bisection Method
This technique is based on the Intermediate Value Theorem Example: Suppose 𝑓 is a continuous function defined on the interval [π‘Ž, 𝑏], with 𝑓 (π‘Ž) and 𝑓 (𝑏) of opposite sign. The Intermediate Value Theorem implies that a number 𝑝 exists in (π‘Ž, 𝑏) with 𝑓 ( 𝑝) = 0. Show that 𝑓 (π‘₯) = 10 π‘₯ 6 βˆ’149 π‘₯ 5 +10π‘₯βˆ’149 10( π‘₯ 4 +1) has a root in [12, 16] Sol: 12 16 𝒇(𝟏𝟐)=βˆ’πŸ‘πŸ’.πŸ– 𝒇(πŸπŸ”)=πŸπŸ•.πŸ”

4 Sec:5.2 The Bisection Method
Example: Use Bisection method to find the root of the function 𝑓 (π‘₯) = 10 π‘₯ 6 βˆ’149 π‘₯ 5 +10π‘₯βˆ’149 10( π‘₯ 4 +1) in [12, 16] 12 16 Change of sign -34.8 17.6 𝒙 𝟏 = True root: π‘₯ π‘Ÿ βˆ— =14.9 12 14 Change of sign 16 Iter1 𝒏 𝒙 𝒏 -34.8 -12.6 17.6 𝒙 𝟐 = 14 15 16 Iter2 Change of sign -12.6 1.5 17.6 𝒙 πŸ‘ = Change of sign 14.5 14 15 Iter3 -5.8 1.5 -12.6

5 Sec:5.2 The Bisection Method
Textbook notations 𝒙 𝒍 𝟎 𝒙 𝒖 𝟎 12 16 Change of sign βˆ† 𝒙 𝟎 = 𝒙 𝒖 𝟎 βˆ’ 𝒙 𝒍 𝟎 At the n-th iteration: -34.8 17.6 endpoints of the inteval 𝒙 𝒍 𝟏 𝒙 𝒖 𝟏 12 14 Change of sign 16 [ 𝒙 𝒍 𝒏 , 𝒙 𝒖 𝒏 ] Iter1 βˆ† 𝒙 𝟏 = 𝒙 𝒖 𝟏 βˆ’ 𝒙 𝒍 𝟏 -34.8 -12.6 17.6 Length of the interval 𝒙 𝒍 𝟐 𝒙 𝒖 𝟐 14 15 16 βˆ† 𝒙 𝒏 = 𝒙 𝒖 𝒏 βˆ’ 𝒙 𝒍 𝒏 Iter2 Change of sign βˆ† 𝒙 𝟐 = 𝒙 𝒖 𝟐 βˆ’ 𝒙 𝒍 𝟐 -12.6 1.5 17.6 = βˆ† 𝒙 𝟎 𝟐 𝒏 𝒙 𝒍 πŸ‘ 𝒙 𝒖 πŸ‘ Change of sign 14.5 14 15 Iter3 βˆ† 𝒙 πŸ‘ = 𝒙 𝒖 πŸ‘ βˆ’ 𝒙 𝒍 πŸ‘ -5.8 1.5 -12.6

6 Sec:5.2 The Bisection Method
Error Estimates for Bisection 12 16 Change of sign -34.8 17.6 𝒙 𝒓 βˆ— At the iter1: 𝒙 𝟏 = True root live inside this interval 𝒙 𝟏 βˆ’ 𝒙 𝒓 βˆ— < length of the interval 12 14 Change of sign 16 𝒙 𝟏 βˆ’ 𝒙 𝒓 βˆ— <βˆ† 𝒙 𝟏 = βˆ† 𝒙 𝟎 𝟐 Iter1 -34.8 -12.6 17.6 𝒙 𝟐 At the iter2: = 14 15 16 𝒙 𝟐 βˆ’ 𝒙 𝒓 βˆ— < length of the interval Iter2 Change of sign 𝒙 𝟐 βˆ’ 𝒙 𝒓 βˆ— <βˆ† 𝒙 𝟐 = βˆ† 𝒙 𝟎 𝟐 𝟐 -12.6 1.5 17.6 At the nth iteration: 𝒙 𝒏 βˆ’ 𝒙 𝒓 βˆ— < π’ƒβˆ’π’‚ 𝟐 𝒏 Error Estimates for Bisection 𝒙 𝒏 βˆ’ 𝒙 𝒓 βˆ— < length of the interval 𝑬 𝒂 𝒏 < π’ƒβˆ’π’‚ 𝟐 𝒏 the absolute error in the n-th iteration < π’ƒβˆ’π’‚ 𝟐 𝒏 𝒙 𝒏 βˆ’ 𝒙 𝒓 βˆ— <βˆ† 𝒙 𝒏 = βˆ† 𝒙 𝟎 𝟐 𝒏 = π’ƒβˆ’π’‚ 𝟐 𝒏

7 Sec:5.2 The Bisection Method
Error Estimates for Bisection 𝑬 𝒂 𝒏 < π’ƒβˆ’π’‚ 𝟐 𝒏 𝒏 𝒙 𝒏 𝑬 𝒂 𝒏 e-01 e-01 e-01 e-01 e-02 e-02 e-03 e-03 e-03 e-03 e-04 e-04 e-05 e-04 e-05 e-05 If πΈπ‘Ž,𝑑 =10 βˆ’4 is the desired error, this equation can be solved for 𝑛 𝑬 𝒂 𝒏 < πŸπŸ”βˆ’πŸπŸ 𝟐 𝒏 < 𝟏𝟎 βˆ’πŸ’ 𝟐 𝒏 > πŸ’ 𝟏𝟎 βˆ’πŸ’ 𝟐 𝒏 >πŸ’Γ— 𝟏𝟎 πŸ’ 𝒏> π’π’π’ˆ πŸ’Γ— 𝟏𝟎 πŸ’ π’π’π’ˆ 𝟐 =πŸπŸ“.𝟐

8 Stopping Criteria Sec:5.2 The Bisection Method
function [xr,err,yc,iter,x]=bisect_ver1(f,a,b,es) %Input: f is the function, a, b are endpts % es is the tolerance, imax is max iter %Output: c is the zero, yc= f(c) ya=f(a); yb=f(b); iter =0; if ya*yb > 0,return,end for k=1:1000 iter = iter +1; xr=(a+b)/2; yc=f(xr); x(k)=xr; if yc==0 a=xr; b=xr; elseif yb*yc>0 b=xr; yb=yc; else a=xr; ya=yc; end if b-a < es, break,end xr=(a+b)/2; err=abs(b-a); yc=f(xr); function [xr,err,yc,iter,x]=bisect_ver2(f,a,b,es) %Input: f is the function, a, b are endpts % es is the tolerance, imax is max iter %Output: c is the zero, yc= f(c) ya=f(a); yb=f(b); iter =0; if ya*yb > 0,return,end max1=1+round((log(b-a)-log(es))/log(2)); for k=1:max1 iter = iter +1; xr=(a+b)/2; yc=f(xr); x(k)=xr; if yc==0 a=xr; b=xr; elseif yb*yc>0 b=xr; yb=yc; else a=xr; ya=yc; end % if b-a < es, iter=k; break,end xr=(a+b)/2; err=abs(b-a); yc=f(xr); a=12; b=16; es=1e-4; % [xr,err,yc,iter,x]=bisect_ver2(f,a,b,es); [xr,err,yc,iter,x]=bisect_ver1(f,a,b,es); iteration = [1:iter]'; res = [ iteration, x' , x'-14.9] fprintf(' %d %14.10f %14.10e \n', res');

9 Sec:5.2 The Bisection Method


Download ppt "Sec:5.2 The Bisection Method."

Similar presentations


Ads by Google