Lab Report 06
Lab Report 06
Lab Report 06
Objective:
Implementation of Bisection method and False Position method in coding form to find the value
of unknown in MATLAB.
Theory:
• Bisection Method:
The bisection method is used to find the roots of a polynomial equation. It separates the
interval and subdivides the interval in which the root of the equation lies. The principle behind
this method is the intermediate theorem for continuous functions. It works by narrowing the gap
between the positive and negative intervals until it closes in on the correct answer. This method
narrows the gap by taking the average of the positive and negative intervals. It is a simple
method and it is relatively slow. The bisection method is also known as interval halving method,
root-finding method, binary search method or dichotomy method.
Let us consider a continuous function “f” which is defined on the closed interval [a, b], is given
with f(a) and f(b) of different signs. Then by intermediate theorem, there exists a point x belongs
to (a, b) for which f(x) = 0.
Follow the below procedure to get the solution for the continuous function:
The bisection method is an approximation method to find the roots of the given equation by
repeatedly dividing the interval. This method will divide the interval until the resulting interval is
found, which is extremely small.
Page |1
Lab 06 Bisection & False Position
MATLAB Code:
>>clc
>>close all
>>clear all
>>fx1= (668.06/xl)*(1-exp(-0.146843*xl))-40;
>>if fx1*fxu<0
>>disp('Guees is right')
>>else
>>break
>>end
>>for i=1:1:n
>>xr(i)=(xl+xu)/2;
>>fx1= (668.06/xl)*(1-exp(-0.146843*xl))-40;
>>fxu= (668.06/xu)*(1-exp(-0.146843*xu))-40;
>>fxr(i)=(668.06/xr(i))*(1-exp(-0.146843*xr(i)))-40;
>>xu=xr (i);
>>else if fx1*fxr(i)>0
>>xl=xr(i);
>>else
Page |2
Lab 06 Bisection & False Position
>>xr(i)
>>end
>>end
>>if i>1
>>e(i-1)
>>xr(i-1)
>>break
>>end
>>end
>>end
Screenshots:
Input:
Page |3
Lab 06 Bisection & False Position
Output:
For instance, if f (xl) is very near to zero than f (xu), it is just like that the root is
nearer to xl than to xu (as shown in the figure below). An alternate method that exploits
this graphical understanding is to join f (xl) and f (xu) by a straight line. The intersection
of this line with the x-axis gives an improved version of the root.
The way that the substitution of a curve by a straight line gives a “false position” of
the root is the actual point of the name, method of false position, or in Latin, regula falsi
method. It is additionally called the linear interpolation method. Because it takes the
same approach where two points of a function are joined with a straight line.
Page |4
Lab 06 Bisection & False Position
The difference between bisection method and false-position method is that in bisection
method, both limits of the interval have to change. This is not the case for false position method,
where one limit may stay fixed throughout the computation while the other guess converges on
the root.
MATLAB Code:
>>clc
>>clear all
>>close all
>>xl= input('Enter value of lower boundary limit');
>>xu= input('Enter value of upper boundary limit');
>>n= input('Enter number of iteration');
>>fxl=(668.06/xl)*(1-exp(-0.146843*xl))-40;
Page |5
Lab 06 Bisection & False Position
>>fxu=(668.06/xu)*(1-exp(-0.146843*xu))-40;
>>if fxl*fxu<0
>> disp('Guess is right')
>>else
>> disp('Guess is wrong')
>> break
>>end
>>for i=1:1:n
>> fxl=(668.06/xl)*(1-exp(-0.146843*xl))-40;
>> fxu=(668.06/xu)*(1-exp(-0.146843*xu))-40;
>> xr(i)=xu-(((fxu)*(xl-xu))/(fxl-fxu))
>> fxu=(668.06/xu)*(1-exp(-0.146843*xu))-40;
>> fxr(i)=(668.06/xr(i))*(1-exp(-0.146843*xr(i)))-40;
>>if fxl*fxr(i)<0
>> xu=xr(i)
>> else if fxl*fxr(i)>0
>> xl=xr(i)
>> else
>> xr(i)
>> end
>> end
>> if i>1
>> e(i)=((xr(i)-xr(i-1))/xr(i))*100;
>> e(i-1)
>> if norm(e(i))<.02
>> xr(i-1)
>> break
Page |6
Lab 06 Bisection & False Position
>> end
>> end
>>end
MATLAB Screenshots:
Input:
Output:
Page |7