Presentation is loading. Please wait.

Presentation is loading. Please wait.

Solution of Nonlinear Equations Topic: Bisection method

Similar presentations


Presentation on theme: "Solution of Nonlinear Equations Topic: Bisection method"— Presentation transcript:

1 Solution of Nonlinear Equations Topic: Bisection method
Numerical Analysis Solution of Nonlinear Equations Topic: Bisection method

2 Bisection Method The method is known as the Bolzano method and can be called interval halving technique. The method is simple and straight-forward. Given a bracketed root, the method repeatedly halves the interval while continuing to bracket the root and it will converge on the solution.

3 Step 1 Choose xl and xu as two guesses for the root such that f(xl) f(xu) < 0, or in other words, f(x) changes sign between xl and xu.

4 Step 2 Estimate the root, xm of the equation f (x) = 0 as the mid-point between xl and xu as

5 Step 3 Now check the following
If f(xl) f(xm) < 0, then the root lies between xl and xm; then xl = xl ; xu = xm. If f(xl ) f(xm) > 0, then the root lies between xm and xu; then xl = xm; xu = xu. If f(xl) f(xm) = 0; then the root is xm. Stop the algorithm if this is true.

6 Absolute Relative Approximate Error
Step 4 New estimate Absolute Relative Approximate Error

7 Using the new upper and lower guesses from Step 3, go to Step 2.
Check if absolute relative approximate error is less than pre-specified tolerance or if maximum number of iterations is reached. Yes Stop Using the new upper and lower guesses from Step 3, go to Step 2. No

8 Example You are working for ‘DOWN THE TOILET COMPANY’ that makes floats for ABC commodes. The ball has a specific gravity of 0.6 and has a radius of 5.5 cm. You are asked to find the distance to which the ball will get submerged when floating in water.

9 Solution The equation that gives the depth ‘x’ to which the ball is submerged under water is given by Use the Bisection method of finding roots of equations to find the depth ‘x’ to which the ball is submerged under water. Conduct three iterations to estimate the root of the above equation.

10 Graph of function f(x)

11 Checking if the bracket is valid
Choose the bracket

12 Iteration #1

13 Iteration #2

14 Iteration #3

15 Convergence Table 1: Root of f(x)=0 as function of number of iterations for bisection method.

16 Bisection Method A basic loop that is used to find root between two points for a function f(x) is shown here. DO while 0.5*|x1 - x2| >= tolerance_value Set xmid =(x1 + x2)/2 IF f(xmid) of opposite sign of f(x1); Set x2 = xmid; ELSE Set x1 = xxmid; ENDIF END loop

17 Bisection Method DemoBisect: the example program does a simple bisection for a cubic polynomial equation.

18 Bisection Method Example Problem:
y(x) = a5 x5 + a4 x4 + a3 x3 + a2 x2 + a1 x + a0 Let us consider constants to be following: a0 = -2, a1 = -3, a2 = 4, a3 = 1, a4 = 0, a5 = 1 Then the function: y(x) = x5 + x3 + 4x2 - 3x - 2 First we plot this function in a range from -3 to 3 and see visually where roots are located.

19 Bisectional Method There are 3 roots (a) -2 < x < -1
(b) -1 < x < 0 (c) 0.5 < x <1.5 The graph for the function is shown here.

20 Computer Program for Bisection method
% A program in matlab % bisection method to find the roots of x^5+x^3+4*x^2-3*x-2=0 xleft = -2.0 ; xright = -1.0 ; n = 100 % Input: xleft,xright = left and right brackets of the root % n = (optional) number of iterations; default: n =15 % Output: x = estimate of the root if nargin<3, n=15; end % Default number of iterations a = xleft; b =xright; % Copy orig bracket to local variables fa = a^5 + a^3 +4*a^2 - 3*a - 2; % Initial values fb = b^5 + b^3 +4*b^2 - 3*b - 2; % Initial values fprintf(' k a xmid b f(xmid)\n'); for k=1:n xm = a + 0.5*(b-a); % Minimize roundoff in the midpoint fm = xm^5 + xm^3 +4*xm^2 - 3*xm - 2; % f(x) at midpoint fprintf('%3d %12.8f %12.8f %12.8f %12.3e\n',k,a,xm,b,fm); if sign(fm) == sign(fa) a = xm; fa = fm; else b = xm; fb = fm; end

21 Bisection Method k a xmid b f(xmid) e-001 e+000 e+000 e-001 e-002 e-001 e-001 e-002 e-003 e-002 e-003 e-003 e-004 e-004 e-004 e-005 e-005 e-006 e-005 e-005 For range of x = [-2, -1]; we see x = as root here.

22 Advantages & Disadvantages
Advatages: Always convergent The root bracket gets halved with each iteration - guaranteed. Disadvatanges: Slow convergence If one of the initial guesses is close to the root, the convergence is slower

23 Drawbacks (continued)
If a function f(x) is such that it just touches the x-axis it will be unable to find the lower and upper guesses.

24 Drawbacks (continued)
Function changes sign but root does not exist


Download ppt "Solution of Nonlinear Equations Topic: Bisection method"

Similar presentations


Ads by Google