You are on page 1of 46

Notation

For the sake of brevity we may write f (x0 ) as f0 or y0 and in general f (xi )
as fi or yi . Henceforth both the notations may be used interchangeably.

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 2 / 11


Root Finding by Regula Falsi

Root Finding: Regula Falsi Method


Regula Falsi Method repeatedly uses a false position of the root. This
method is also known as
False Position Method or

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 3 / 11


Root Finding by Regula Falsi

Root Finding: Regula Falsi Method


Regula Falsi Method repeatedly uses a false position of the root. This
method is also known as
False Position Method or
Linear Interpolation Method or

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 3 / 11


Root Finding by Regula Falsi

Root Finding: Regula Falsi Method


Regula Falsi Method repeatedly uses a false position of the root. This
method is also known as
False Position Method or
Linear Interpolation Method or
Method of Chords.

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 3 / 11


Derivation of Regula Falsi
This method is similar to Bisection Method but, instead of …nding the
midpoint between x1 and x2 it calculates x0 by linear interpolation.

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 4 / 11


Derivation of Regula Falsi
This method is similar to Bisection Method but, instead of …nding the
midpoint between x1 and x2 it calculates x0 by linear interpolation. The
point of intersection x0 of the chord connecting the points (x1 , y1 ) &
(x2 , y2 ) with the x-axis is calculated from the equation of the straight line
(the chord joining the two points),

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 4 / 11


Derivation of Regula Falsi
This method is similar to Bisection Method but, instead of …nding the
midpoint between x1 and x2 it calculates x0 by linear interpolation. The
point of intersection x0 of the chord connecting the points (x1 , y1 ) &
(x2 , y2 ) with the x-axis is calculated from the equation of the straight line
(the chord joining the two points),

(x x1 ) (x2 x1 )
=
(y y1 ) (y2 y1 )

where y1 = f1 = f (x1 ) and y2 = f2 = f (x2 ) .

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 4 / 11


Derivation of Regula Falsi
This method is similar to Bisection Method but, instead of …nding the
midpoint between x1 and x2 it calculates x0 by linear interpolation. The
point of intersection x0 of the chord connecting the points (x1 , y1 ) &
(x2 , y2 ) with the x-axis is calculated from the equation of the straight line
(the chord joining the two points),

(x x1 ) (x2 x1 )
=
(y y1 ) (y2 y1 )

where y1 = f1 = f (x1 ) and y2 = f2 = f (x2 ) . Hence

(y y1 ) (y2 y1 )
=
(x x1 ) (x2 x1 )

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 4 / 11


Derivation of Regula Falsi
This method is similar to Bisection Method but, instead of …nding the
midpoint between x1 and x2 it calculates x0 by linear interpolation. The
point of intersection x0 of the chord connecting the points (x1 , y1 ) &
(x2 , y2 ) with the x-axis is calculated from the equation of the straight line
(the chord joining the two points),

(x x1 ) (x2 x1 )
=
(y y1 ) (y2 y1 )

where y1 = f1 = f (x1 ) and y2 = f2 = f (x2 ) . Hence

(y y1 ) (y2 y1 )
=
(x x1 ) (x2 x1 )
(y f1 ) ( f2 f1 )
or = .
(x x1 ) (x2 x1 )

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 4 / 11


Since the chord intersects the x-axis at x0 and y = 0, we have

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 5 / 11


Since the chord intersects the x-axis at x0 and y = 0, we have

( f2 f1 ) (0 f1 )
=
(x2 x1 ) (x x1 )

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 5 / 11


Since the chord intersects the x-axis at x0 and y = 0, we have

( f2 f1 ) ( 0 f1 )
=
(x2 x1 ) ( x x1 )
f1 (x2 x1 )
or x0 x1 =
f2 f1
Hence

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 5 / 11


Since the chord intersects the x-axis at x0 and y = 0, we have

( f2 f1 ) ( 0 f1 )
=
(x2 x1 ) ( x x1 )
f1 (x2 x1 )
or x0 x1 =
f2 f1
Hence
f1 ( x2 x1 )
x0 = x1 .
f2 f1

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 5 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.
4 If f1 f2 > 0 then Print “Root not in this range”; Step 10.

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.
4 If f1 f2 > 0 then Print “Root not in this range”; Step 10.
5 count = 1

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.
4 If f1 f2 > 0 then Print “Root not in this range”; Step 10.
5 count = 1
6 While count 6= 0

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.
4 If f1 f2 > 0 then Print “Root not in this range”; Step 10.
5 count = 1
6 While count 6= 0
f (x 2 x 1 )
7 Compute x0 = x1 f2 f1 and f0

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.
4 If f1 f2 > 0 then Print “Root not in this range”; Step 10.
5 count = 1
6 While count 6= 0
f1(x2 x1 )
7 Compute x0 = x1 f2 f1 and f0
8 If f0 f2 0 then x2 = x0 and f2 = f0 ; count = count+1;
else
x1 = x0 and f1 = f0 ; count = count+1;

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.
4 If f1 f2 > 0 then Print “Root not in this range”; Step 10.
5 count = 1
6 While count 6= 0
f (x 2 x 1 )
7 Compute x0 = x1 f2 f1 and f0
8 If f0 f2 0 then x2 = x0 and f2 = f0 ; count = count+1;
else
x1 = x0 and f1 = f0 ; count = count+1;
9 If jf0 j δ then write value of the root; count=0; Step 10

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11


Algorithm for Regula Falsi Method
1 Choose two initial estimates of one of the roots in its vicinity and
tolerance δ.
2 Compute f1 and f2 .
3 If jf1 j δ then root = x1 ; Step 10.
Else
If jf2 j δ then root = x2 ; Step 10.
4 If f1 f2 > 0 then Print “Root not in this range”; Step 10.
5 count = 1
6 While count 6= 0
f(x 2 x1 )
7 Compute x0 = x1 f2 f1 and f0
8 If f0 f2 0 then x1 = x0 and f1 = f0 ; count = count+1;
else
x2 = x0 and f2 = f0 ; count = count+1;
9 If jf0 j δ then write value of the root; count=0; Step 10
10 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 6 / 11
Example
We evaluate the root of f (x ) = x 2 16 using Regula Falsi Method as:

Iteration No x1 x2 x0

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 7 / 11


Example
We evaluate the root of f (x ) = x 2 16 using Regula Falsi Method as:

Iteration No x1 x2 x0 f1 f2 f0

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 7 / 11


Example
We evaluate the root of f (x ) = x 2 16 using Regula Falsi Method as:

Iteration No x1 x2 x0 f1 f2 f0
Initialization 3.0000 4.5000 3.9330 7.0000 4.2500 0.5315

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 7 / 11


Example
We evaluate the root of f (x ) = x 2 16 using Regula Falsi Method as:

Iteration No x1 x2 x0 f1 f2 f0
Initialization 3.0000 4.5000 3.9330 7.0000 4.2500 0.5315

x1 x0 1 3.9330 4.5000 3.9956 0.5315 4.2500 0.0351

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 7 / 11


Example
We evaluate the root of f (x ) = x 2 16 using Regula Falsi Method as:

Iteration No x1 x2 x0 f1 f2 f0
Initialization 3.0000 4.5000 3.9330 7.0000 4.2500 0.5315

x1 x0 1 3.9330 4.5000 3.9956 0.5315 4.2500 0.0351

x1 x0 2 3.9956 4.5000 3.9997 0.0317 4.2500 0.0023

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 7 / 11


Example
We evaluate the root of f (x ) = x 2 16 using Regula Falsi Method as:

Iteration No x1 x2 x0 f1 f2 f0
Initialization 3.0000 4.5000 3.9330 7.0000 4.2500 0.5315

x1 x0 1 3.9330 4.5000 3.9956 0.5315 4.2500 0.0351

x1 x0 2 3.9956 4.5000 3.9997 0.0317 4.2500 0.0023

x1 x0 3 3.9997 4.5000 3.9999 0.0021 4.2500 0.0008

Hence the root

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 7 / 11


Example
We evaluate the root of f (x ) = x 2 16 using Regula Falsi Method as:

Iteration No x1 x2 x0 f1 f2 f0
Initialization 3.0000 4.5000 3.9330 7.0000 4.2500 0.5315

x1 x0 1 3.9330 4.5000 3.9956 0.5315 4.2500 0.0351

x1 x0 2 3.9956 4.5000 3.9997 0.0317 4.2500 0.0023

x1 x0 3 3.9997 4.5000 3.9999 0.0021 4.2500 0.0008

Hence the root is


x0 = 3.9999.

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 7 / 11


MATLAB Code for Regula Falsi

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi
clear all

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi
clear all
F=inline(’x^2-16’);

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi
clear all
F=inline(’x^2-16’);
a=-3;b=20;imax=20;tolf=0.001;
Fa=F(a);Fb=(b);

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi
clear all
F=inline(’x^2-16’);
a=-3;b=20;imax=20;tolf=0.001;
Fa=F(a);Fb=(b);
if abs(Fa)<=tolf
fprintf(’a=%i is the root’,a)

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi
clear all
F=inline(’x^2-16’);
a=-3;b=20;imax=20;tolf=0.001;
Fa=F(a);Fb=(b);
if abs(Fa)<=tolf
fprintf(’a=%i is the root’,a)
break
end

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi
clear all
F=inline(’x^2-16’);
a=-3;b=20;imax=20;tolf=0.001;
Fa=F(a);Fb=(b);
if abs(Fa)<=tolf
fprintf(’a=%i is the root’,a)
break
end
if abs(Fb)<=tolf
fprintf(’b=%i is the root’,b)
break
end

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi
clear all
F=inline(’x^2-16’);
a=-3;b=20;imax=20;tolf=0.001;
Fa=F(a);Fb=(b);
if abs(Fa)<=tolf
fprintf(’a=%i is the root’,a)
break
end
if abs(Fb)<=tolf
fprintf(’b=%i is the root’,b)
break
end
if Fa*Fb>0
disp(’root not in given range’)
else

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 8 / 11


MATLAB Code for Regula Falsi (cont’d)
disp(’iterations a b x f(x)’) %Cloumn Headings
for i=1:imax
x=a-(Fa*(b-a)/(Fb-Fa));

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 9 / 11


MATLAB Code for Regula Falsi (cont’d)
disp(’iterations a b x f(x)’) %Cloumn Headings
for i=1:imax
x=a-(Fa*(b-a)/(Fb-Fa));
Fx=F(x);
fprintf(’%i %7.5f %7.5f %7.5f %7.4f nn’,i,a,b,x,Fx)

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 9 / 11


MATLAB Code for Regula Falsi (cont’d)
disp(’iterations a b x f(x)’) %Cloumn Headings
for i=1:imax
x=a-(Fa*(b-a)/(Fb-Fa));
Fx=F(x);
fprintf(’%i %7.5f %7.5f %7.5f %7.4f nn’,i,a,b,x,Fx)
if abs(Fx)<=tolf
fprintf(’x=%i is the root’,x)
break
end

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 9 / 11


MATLAB Code for Regula Falsi (cont’d)
disp(’iterations a b x f(x)’) %Cloumn Headings
for i=1:imax
x=a-(Fa*(b-a)/(Fb-Fa));
Fx=F(x);
fprintf(’%i %7.5f %7.5f %7.5f %7.4f nn’,i,a,b,x,Fx)
if abs(Fx)<=tolf
fprintf(’x=%i is the root’,x)
break
end
if i==imax
fprintf(’root wasnt found in %i iterations’,i)
break
end

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 9 / 11


MATLAB Code for Regula Falsi (cont’d)
disp(’iterations a b x f(x)’) %Cloumn Headings
for i=1:imax
x=a-(Fa*(b-a)/(Fb-Fa));
Fx=F(x);
fprintf(’%i %7.5f %7.5f %7.5f %7.4f nn’,i,a,b,x,Fx)
if abs(Fx)<=tolf
fprintf(’x=%i is the root’,x)
break
end
if i==imax
fprintf(’root wasnt found in %i iterations’,i)
break
end
if Fa*Fx<0
b=x;
Fb=Fx;

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 9 / 11


MATLAB Code for Regula Falsi (cont’d)

else
a=x;
Fa=Fx;

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 10 / 11


MATLAB Code for Regula Falsi (cont’d)

else
a=x;
Fa=Fx;
end
end
end

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 10 / 11


Thank you

Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti…c Computing 11 / 11

You might also like