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

Bisection Regula Falsi Method

This document discusses the bisection method and false position method for finding roots of equations numerically. It provides the theory, algorithm, pseudocode and Scilab implementation of the bisection method. The lab work instructions ask students to use the provided Scilab code to: 1) Find the root of the equation x3 - 1.8x2 - 10x + 17 = 0 between 1 and 2 using the bisection method with an error tolerance of 0.5%. 2) Implement the false position method in Scilab based on the bisection code and solve the same problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
219 views3 pages

Bisection Regula Falsi Method

This document discusses the bisection method and false position method for finding roots of equations numerically. It provides the theory, algorithm, pseudocode and Scilab implementation of the bisection method. The lab work instructions ask students to use the provided Scilab code to: 1) Find the root of the equation x3 - 1.8x2 - 10x + 17 = 0 between 1 and 2 using the bisection method with an error tolerance of 0.5%. 2) Implement the false position method in Scilab based on the bisection code and solve the same problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Laboratory No.

Bisection and False Position Method


Student ID Name Date Performed

PRE-REQUISITE:

1. Knowledge of SCILAB Programming


2. Knowledge of Numerical Methods

THEORY:

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 Binary Search method and Internal Halving method, and is
similar to the concept of binary search, where the range of possible solutions is halved for each
iteration.

ALGORITHM FOR BISECTION METHOD:

Figure 1: Bisection Method


9
Step 1: Choose lower a and upper b guesses for the root such that the function changes sign over the
interval. This can be checked by ensuring that (a)(b) < 0.
Step 2: An estimate of the root c is determined by
𝑎+𝑏
𝑐=
2

Step 3: Make the following evaluations to determine in which subinterval the root lies

a) If (a)(c) < 0, the root lies in the lower subinterval. Therefore, set b = c and return to
step 2.
b) If (a)(c) > 0, the root lies in the upper subinterval. Therefore, set a = c and return to step
2.
c) If (a)(c) = 0, the root equals c, terminate the computation.

PSEUDOCODE

FUNCTION Bisect(xl, xu, es, imax)


iter = 0
xrold = ∞
DO
xr = (xl + xu)/2
IF xr ≠ 0 THEN
ea = ABS((xr – xrold)/xr)*100
END IF
DISPLAY xl, xu, xr, f(xl), f(xu), f(xr), ea test =
f(xl)*f(xr)
IF test < 0 THEN
xu = xr
ELSE IF test > 0 THEN
xl = xr
ELSE
ea =
0 END IF
xrold = xr
iter = iter + 1
IF ea < es OR iter ≥ imax EXIT
END DO
Bisect = xr
END Bisect

SCILAB IMPLEMENTATION
function [xr, ea] = bisect(xl, xu, es, imax)
//==========================================================
// This function implements the bisection algorithm for finding roots of equation in single variable
//==========================================================
// Syntax: [xr, ea] = bisect(xl, xu, es, imax)
// Input(s):
// xl = Lower guess
// xu = Upper guess
// es = Percentage value of error tolerance
// imax = Maximum number of iterations
// Output(s):
// xr = Estimated value of root at last iteration
// ea = Percentage relative approximate error at last iteration
//////////////////////////////////////////////////////////////////////////
//Initialize iteration counter
iter = 0;

//old estimate of root is unknown


xrold = %inf;

//display string
printf("Iteration \t Xr \t ea\n") ;
while (1) //this loop is ALWAYS true but will be stopped by the stopping criterion

//Bisection method
xr = (xl + xu) / 2;

//compute percentage relative approximate error


if (xr~=0) then
ea = abs((xr - xrold)/xr) * 100;
end
//print the results for each iteration
printf("%d \t %f \t %f\n",iter,xr,ea) ;

//test each interval for root and update xl and/or xu.


test = f(xl) * f(xr); //we use the f(x) function which will be defined in a separate function
if( test < 0)
xu = xr;
elseif (test > 0) then
x
l = xr;
else
ea = 0;
end

//update old estimate of the root


xrold = xr;

//update the iteration counter


iter = iter + 1;

//stopping criterion
//terminate the loop if solution is found or if maximum no. iterationis reached
if (ea < es) | (iter >= imax)
break; //end loop
end
end
endfunction

LAB WORK
Instructions: Do the following. Show your results in tabular form. Submit your implemented
scilab code together with this file in rar/zip file with filename “lastname_Activity1.rar”. Submit
your answer in Mole.

1.a Using the attached Bisection Scilab Code, write a program to find out the root of equation x3
1.8x2 10x 17  0 and roots lie between [1,2] by using Non-Linear Algebraic Method (Bisection
Method) using Scilab. Note: ((%)) is less than 𝜀𝑠 = 0.5%)

1.b The algorithm for false position is the same with bisection method. The two methods only differ in
the calculation of the estimated root (c). Implement False Position method based on the scilab code
implemented in bisection method and solve the same problem (problem 1.a).

19

You might also like