You are on page 1of 32

Math 306,307 - Programming & Numerical Methods

Numerical Analysis through Fortran90 and C++

Sqn Ldr Athar Kharal


Humanities and Science Department
College of Aeronautical Engineering
PAF Academy Risalpur

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

1/8

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 Scientic Computing

2/8

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 Scientic Computing

3/8

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 Scientic Computing

3/8

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 Scientic Computing

3/8

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 Scientic Computing

4/8

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 Scientic Computing

4/8

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
(y

x1 )
(x2
=
y1 )
(y2

x1 )
y1 )

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

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

4/8

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
(y

x1 )
(x2
=
y1 )
(y2

x1 )
y1 )

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

(y
(x

Sqn Ldr Athar Kharal (H and S, CAE)

y1 )
x1 )

(y2
(x2

y1 )
x1 )

Fundamentals of Scientic Computing

4/8

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
(y

x1 )
(x2
=
y1 )
(y2

x1 )
y1 )

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

(y
(x
(y
or
(x

Sqn Ldr Athar Kharal (H and S, CAE)

y1 )
x1 )
f1 )
x1 )

=
=

(y2
(x2
( f2
(x2

y1 )
x1 )
f1 )
.
x1 )

Fundamentals of Scientic Computing

4/8

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

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

5/8

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

( f2
(x2

Sqn Ldr Athar Kharal (H and S, CAE)

f1 )
x1 )

(0
(x

f1 )
x1 )

Fundamentals of Scientic Computing

5/8

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

( f2
(x2

f1 )
x1 )

or x0

x1 =

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

Hence

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

5/8

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

( f2
(x2

f1 )
x1 )

or x0

x1 =

Hence
x0 = x1

Sqn Ldr Athar Kharal (H and S, CAE)

( 0 f1 )
( x x1 )
f1 (x2 x1 )
f2 f1
f (x2 x1 )
.
f2 f1

Fundamentals of Scientic Computing

5/8

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 Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

then root = x1 ; Step 10.


then root = x2 ; Step 10.

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

If f1

then root = x1 ; Step 10.


then root = x2 ; Step 10.
f2 > 0 then Print Root not in this range; Step 10.

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

4
5

If f1

then root = x1 ; Step 10.


then root = x2 ; Step 10.
f2 > 0 then Print Root not in this range; Step 10.

count = 1

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

If f1

then root = x1 ; Step 10.


then root = x2 ; Step 10.
f2 > 0 then Print Root not in this range; Step 10.

count = 1

While count 6= 0

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

If f1

then root = x1 ; Step 10.


then root = x2 ; Step 10.
f2 > 0 then Print Root not in this range; Step 10.

count = 1

While count 6= 0

Compute x0 = x1

Sqn Ldr Athar Kharal (H and S, CAE)

f (x 2 x 1 )
f2 f1

and f0

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

If f1

then root = x1 ; Step 10.


then root = x2 ; Step 10.
f2 > 0 then Print Root not in this range; Step 10.

count = 1

While count 6= 0

f (x 2 x 1 )
f2 f1

Compute x0 = x1

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)

and f0

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

If f1

then root = x1 ; Step 10.


then root = x2 ; Step 10.
f2 > 0 then Print Root not in this range; Step 10.

count = 1

While count 6= 0

f (x 2 x 1 )
f2 f1

Compute x0 = x1

If f0 f2 0 then x2 = x0 and f2 = f0 ; count = count+1;


else
x1 = x0 and f1 = f0 ; count = count+1;

If jf0 j

and f0

then write value of the root; count=0; Step 10

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

6/8

Algorithm for Regula Falsi Method


1

Choose two initial estimates of one of the roots in its vicinity and
tolerance .

Compute f1 and f2 .

If jf1 j
Else
If jf2 j

If f1

then root = x1 ; Step 10.


then root = x2 ; Step 10.
f2 > 0 then Print Root not in this range; Step 10.

count = 1

While count 6= 0

f (x 2 x 1 )
f2 f1

Compute x0 = x1

If f0 f2 0 then x2 = x0 and f2 = f0 ; count = count+1;


else
x1 = x0 and f1 = f0 ; count = count+1;

If jf0 j

10

and f0

then write value of the root; count=0; Step 10

Stop.

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

6/8

Example
We evaluate the root of f (x ) = x 2

Iteration No

x1

Sqn Ldr Athar Kharal (H and S, CAE)

x2

16 using Regula Falsi Method as:

x0

Fundamentals of Scientic Computing

7/8

Example
We evaluate the root of f (x ) = x 2

Iteration No

x1

Sqn Ldr Athar Kharal (H and S, CAE)

x2

16 using Regula Falsi Method as:

x0

Fundamentals of Scientic Computing

f1

f2

f0

7/8

Example
We evaluate the root of f (x ) = x 2

Iteration No
Initialization

x1
3.0000

Sqn Ldr Athar Kharal (H and S, CAE)

x2
4.5000

16 using Regula Falsi Method as:

x0
3.9330

f1
7.0000

Fundamentals of Scientic Computing

f2
4.2500

f0
0.5315

7/8

Example
We evaluate the root of f (x ) = x 2

16 using Regula Falsi Method as:

Iteration No
Initialization

x1
3.0000

x2
4.5000

x0
3.9330

f1
7.0000

f2
4.2500

f0
0.5315

x1

3.9330

4.5000

3.9956

0.5315

4.2500

0.0351

x0

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

7/8

Example
We evaluate the root of f (x ) = x 2

16 using Regula Falsi Method as:

Iteration No
Initialization

x1
3.0000

x2
4.5000

x0
3.9330

f1
7.0000

f2
4.2500

f0
0.5315

x1

x0

3.9330

4.5000

3.9956

0.5315

4.2500

0.0351

x1

x0

3.9956

4.5000

3.9997

0.0317

4.2500

0.0023

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

7/8

Example
We evaluate the root of f (x ) = x 2

16 using Regula Falsi Method as:

Iteration No
Initialization

x1
3.0000

x2
4.5000

x0
3.9330

f1
7.0000

f2
4.2500

f0
0.5315

x1

x0

3.9330

4.5000

3.9956

0.5315

4.2500

0.0351

x1

x0

3.9956

4.5000

3.9997

0.0317

4.2500

0.0023

x1

x0

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 Scientic Computing

7/8

Example
We evaluate the root of f (x ) = x 2

16 using Regula Falsi Method as:

Iteration No
Initialization

x1
3.0000

x2
4.5000

x0
3.9330

f1
7.0000

f2
4.2500

f0
0.5315

x1

x0

3.9330

4.5000

3.9956

0.5315

4.2500

0.0351

x1

x0

3.9956

4.5000

3.9997

0.0317

4.2500

0.0023

x1

x0

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 Scientic Computing

7/8

Thank you

Sqn Ldr Athar Kharal (H and S, CAE)

Fundamentals of Scientic Computing

8/8

You might also like