0% found this document useful (0 votes)
411 views

Bisection Method Using Matlab Software

The document describes an experiment using the bisection method to find the root of an equation. It provides the concept of the bisection method, gives an example equation to solve (x^3 - 3x + 1), and shows the MATLAB code and output from running the code on the example. The code iteratively calculates new values of the root by bisection, tracking the lower and upper bounds at each step until the error is less than 0.001. A table shows the results across 9 iterations, converging on a root of approximately 1.532227 for the given equation and bounds.

Uploaded by

Zeffrey Aleta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
411 views

Bisection Method Using Matlab Software

The document describes an experiment using the bisection method to find the root of an equation. It provides the concept of the bisection method, gives an example equation to solve (x^3 - 3x + 1), and shows the MATLAB code and output from running the code on the example. The code iteratively calculates new values of the root by bisection, tracking the lower and upper bounds at each step until the error is less than 0.001. A table shows the results across 9 iterations, converging on a root of approximately 1.532227 for the given equation and bounds.

Uploaded by

Zeffrey Aleta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES

938 AURORA BLVD., CUBAO, QUEZON CITY

COLLEGE OF ENGINEERING AND ARCHITECTURE


DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

EXPERIMENT # 2

BISECTION METHOD

Submitted by:
ALETA, ZEFFREY JON M.

Submitted to:
ENGR. SIMON KENNETH E. SANTIAGO

DATE
JULY 27, 2017
I. CONCEPT OF THE METHOD

Bisection method is a root-finding method that repeatedly bisects an interval and then selects a
subinterval in which a root must lie for further processing. It is also the interval halving method, binary
method and the dichotomy method. The method is applicable for numerically solving the equation
f(x)=0 for the real variable x, where f is a continuous function defined on an interval [a,b] where f(a) and
f(b) have opposite signs, it is also called the xlower and the xupper value. In this case a and b are said to
bracket a root since, by the intermediate value theorem, the continuous function f must have at leas
one root in the interval (a,b).

II. EQUATION

Xlower must have a negative value of f(x) in order to continue the method also Xupper must have a
negative value.

let a = xupper and b = xlower

f(a)>0 and f(b)<0

+
X root = 2

f(x root) > 0 change the value of the xupper to x root value
f(x root) < 0 change the value of the xlower to xroot value

error =

if the error < 0.001 then the recent value of x root is the root of the equation

III. PROGRAM

CODE:
function [ ] = Bisection( )
f1 = input ('Enter equation: ','s');
f = inline(f1); %#ok<*REMFF1>
xl= input('Input lower limit: ');
while(f(xl)>0)
xl = input('Invalid limit, Input another value: ');
end
xu= input('Input upper limit: ');
while(f(xu)<0)
xu = input('Invalid limit, Input another value: ');
end

xr=(xl+xu)/2; // Formula for x roots in bisection method


error=1;
i=0;

fprintf('Iteration \t X LOWER \t X UPPER \t X ROOTS \t ERROR \n');


fprintf('%d \t \t \t %f \t %f \t %f \t %f \n', i,xl,xu,xr,error)
while(error>=0.001)
i=i+1;
xo=xr;
if(f(xr)>0)
xu=xr;
end
if(f(xr)<0)
xl=xr;
end
xr=(xu+xl)/2;
error = abs((xr-xo)/xr);

fprintf('%d \t \t \t %f \t %f \t %f \t %f \n', i,xl,xu,xr,error)

end

fprintf('The roots of the equation is %d with an error of %d',xr,error)


end
RUNNING PROGRAM:

Here user is allowed to input equations which is +

Since Bisection Method needs upper and lower limit, the user can set this by his own.
Here the limits are = ; =

This is the table of iteration where users can see the process of computing the roots.

Displaying the roots of the equation with the error computed

IV. TABLE OF RESULTS

() = 3 3 + 1 ; = 1 ; = 2

Iteration X LOWER X UPPER X ROOTS ERROR

0 1.000000 2.000000 1.500000 1.000000

1 1.500000 2.000000 1.750000 0.142857


2 1.500000 1.750000 1.625000 0.076923

3 1.500000 1.625000 1.562500 0.040000

4 1.500000 1.562500 1.531250 0.020408

5 1.531250 1.562500 1.546875 0.010101

6 1.531250 1.546875 1.539063 0.005076

7 1.531250 1.539063 1.535156 0.002545

8 1.531250 1.535156 1.533203 0.001274

9 1.531250 1.533203 1.532227 0.000637

V. INTERPRETATION

Each Iteration has a different value of x roots due to the limits and the value of the f(xroot). Each
iteration changes value whether in x lower or upper. This values are depending on the sign of the
f(xroot) which if it is negative the x lower will be change to x root while vice versa in x upper. The data
shows the iteration of collection of data and the percentage error of each.

VI. CONCLUSION & SUMMARY

After this laboratory we can conclude that bisection method in getting roots can be made by the
computer using codes and syntaxes in MATLAB. Using loop functions and iteration bisection method
can be achieved. As of the bisection method, it is pretty accurate depending on the error set by the
programmer or sometimes the user depending on the code created.

You might also like