LAB#08: Implementation of Code of Bisection Method and Regula-Falsi Method For Solution of Transcendental Equations in MATLAB
LAB#08: Implementation of Code of Bisection Method and Regula-Falsi Method For Solution of Transcendental Equations in MATLAB
LAB#08: Implementation of Code of Bisection Method and Regula-Falsi Method For Solution of Transcendental Equations in MATLAB
1. BI-SECTION METHOD:
ALGORITHM:
Newton’s method is a popular technique for the solution of nonlinear equations, but alternative methods
exist which may be preferable in certain situations. The Bisection method is yet another technique for
finding a solution to the nonlinear equation f(x) = 0, which can be used provided that the function f is
continuous. The motivation for this technique is drawn from Bolzano’s theorem for continuous functions.
Theorem (Bolzano):
If the function f(x) is continuous in [a, b] and f(a).f(b) < 0 (i.e. the function f has values with different
signs at a and b), then a value c belongs to (a, b) exists such that f(c) = 0.
The bisection algorithm attempts to locate the value c where the plot of f crosses over zero, by checking
whether it belongs to either of the two sub-intervals [a, xm], [xm, b], where xm is the midpoint xm = (a +
b)/2
The steps to apply the bisection method to find the root of the equation f (x )=0 are
1. Choose
x ℓ and x u as two guesses for the root such that f (x ℓ )f ( x u )< 0 , or in other
x
words, f (x ) changes sign between ℓ and u .
x
2. Estimate the root,
x m , of the equation f (x )=0 as the mid-point between x ℓ and x u
as
x ℓ +x u
xm =
2
new old
xm - xm
|∈a| = | |× 100
x mnew
where
x new
m = estimated root from present iteration
x old
m = estimated root from previous iteration
MATLAB CODE:
TASK:
PROGRAM:
clc
close all
clear all
for i=1:20
xr=(xa+xb)/2; % Bisection formula
f_xr=2*xr.^3-2*xr-5
RE=abs((xr-xb)/xr)*100;
Output:
ans =
-5
ans =
235
ans =
1975
i xa xb xr f(xr) RE
2. REGULA-FALSI METHOD:
ALGORITHM:
The steps to apply the false-position method to find the root of the equation f ( x )=0 are as
follows.
x
Choose x L and U as two guesses for the root such that
f ( x L ) f ( x U ) <0
, or in other
words, f ( x )
x
changes sign between x L and U .
x U f ( x L )−x L f ( x U )
xr=
f ( x L ) −f ( xU )
If
f ( x L ) f ( x r ) <0
, then the root lies between x L and x r ; then x L =x L and x U =x r .
If
f ( x L ) f ( x r ) >0
, then the root lies between x r and
x U ; then x L =xr and x U =x U .
x U f ( x L )−x L f ( x U )
xr=
f ( x L ) −f ( xU )
where
x new
r = estimated root from present iteration
x old
r = estimated root from previous iteration
tolerance
∈s . If |∈a|>∈s , then go to step 3, else stop the algorithm. Note one should also
check
whether the number of iterations is more than the maximum number of iterations allowed. If so,
one needs to terminate the algorithm and notify the user about it.
Note that the false-position and bisection algorithms are quite similar. The only difference is the
formula used to calculate the new estimate of the root x r as shown in steps #2 and #4!
MATLAB CODE:
TASK:
PROGRAM:
clc
close all
clear all
for i=1:15
xr= ((xa*f(xb)-xb*f(xa))./(f(xb)-f(xa))); % Regula-Falsi formula
f_xr=2*xr.^3-2*xr-5;
RE=abs((xr-xb)/xr)*100;
else
xa=xr;
xb=xb;
f=
@(x)2*x.^3-2*x-5
ans =
-5
ans =
235
ans =
1975
i xa xb xr f(xr) RE
1 0.00000 10.00000 0.02525 -5.05047 39500.00000
2 0.02525 10.00000 0.05069 -5.10113 19625.84913
3 0.05069 10.00000 0.07633 -5.15176 13001.64975
4 0.07633 10.00000 0.10214 -5.20216 9690.03320
5 0.10214 10.00000 0.12815 -5.25209 7703.52597
6 0.12815 10.00000 0.15433 -5.30131 6379.63705
7 0.15433 10.00000 0.18069 -5.34958 5434.44179
8 0.18069 10.00000 0.20721 -5.39663 4725.97789
9 0.20721 10.00000 0.23390 -5.44220 4175.37741
10 0.23390 10.00000 0.26073 -5.48602 3735.31950
11 0.26073 10.00000 0.28771 -5.52779 3375.69079
12 0.28771 10.00000 0.31482 -5.56724 3076.41557
13 0.31482 10.00000 0.34204 -5.60405 2823.59510
14 0.34204 10.00000 0.36937 -5.63795 2607.30147
15 0.36937 10.00000 0.39679 -5.66863 2420.25399
Comments:
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.
Conclusion:
In this lab I concluded that Regular-Falsi Method find outs the Roots of any equation in a few
iteration as compare to Bisection Method.
Bisection method is the safest and it always converges. The bisection method is the simplest of
all other methods and is guaranteed to converge for a continuous function. It is always possible
to find the number of steps required for a given accuracy.