Upload
hamza-ashraf
View
223
Download
2
Embed Size (px)
DESCRIPTION
numerical methods
Citation preview
Math 306,307 - Programming & Numerical MethodsNumerical Analysis through Fortran90 and C++
Sqn Ldr Athar Kharal
Humanities and Science DepartmentCollege of Aeronautical Engineering
PAF Academy Risalpur
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 1 / 8
NotationFor 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 / 8
Root Finding by Regula Falsi
Root Finding: Regula Falsi MethodRegula Falsi Method repeatedly uses a false position of the root. Thismethod 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 / 8
Root Finding by Regula Falsi
Root Finding: Regula Falsi MethodRegula Falsi Method repeatedly uses a false position of the root. Thismethod 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 / 8
Root Finding by Regula Falsi
Root Finding: Regula Falsi MethodRegula Falsi Method repeatedly uses a false position of the root. Thismethod 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 / 8
Derivation of Regula FalsiThis method is similar to Bisection Method but, instead of �nding themidpoint between x1 and x2 it calculates x0 by linear interpolation.
Thepoint 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)(y � y1)
=(x2 � x1)(y2 � y1)
where y1 = f1 = f (x1) and y2 = f2 = f (x2) . Hence
(y � y1)(x � x1)
=(y2 � y1)(x2 � x1)
or(y � f1)(x � x1)
=(f2 � f1)(x2 � x1)
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 4 / 8
Derivation of Regula FalsiThis method is similar to Bisection Method but, instead of �nding themidpoint between x1 and x2 it calculates x0 by linear interpolation. Thepoint 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)(y � y1)
=(x2 � x1)(y2 � y1)
where y1 = f1 = f (x1) and y2 = f2 = f (x2) . Hence
(y � y1)(x � x1)
=(y2 � y1)(x2 � x1)
or(y � f1)(x � x1)
=(f2 � f1)(x2 � x1)
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 4 / 8
Derivation of Regula FalsiThis method is similar to Bisection Method but, instead of �nding themidpoint between x1 and x2 it calculates x0 by linear interpolation. Thepoint 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)(y � y1)
=(x2 � x1)(y2 � y1)
where y1 = f1 = f (x1) and y2 = f2 = f (x2) .
Hence
(y � y1)(x � x1)
=(y2 � y1)(x2 � x1)
or(y � f1)(x � x1)
=(f2 � f1)(x2 � x1)
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 4 / 8
Derivation of Regula FalsiThis method is similar to Bisection Method but, instead of �nding themidpoint between x1 and x2 it calculates x0 by linear interpolation. Thepoint 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)(y � y1)
=(x2 � x1)(y2 � y1)
where y1 = f1 = f (x1) and y2 = f2 = f (x2) . Hence
(y � y1)(x � x1)
=(y2 � y1)(x2 � x1)
or(y � f1)(x � x1)
=(f2 � f1)(x2 � x1)
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 4 / 8
Derivation of Regula FalsiThis method is similar to Bisection Method but, instead of �nding themidpoint between x1 and x2 it calculates x0 by linear interpolation. Thepoint 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)(y � y1)
=(x2 � x1)(y2 � y1)
where y1 = f1 = f (x1) and y2 = f2 = f (x2) . Hence
(y � y1)(x � x1)
=(y2 � y1)(x2 � x1)
or(y � f1)(x � x1)
=(f2 � f1)(x2 � x1)
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 4 / 8
Since the chord intersects the x-axis at x0 and y = 0, we have
(f2 � f1)(x2 � x1)
=(0� f1)(x � x1)
or x0 � x1 = � f1 (x2 � x1)f2 � f1
Hence
x0 = x1 �f (x2 � x1)f2 � f1
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 8
Since the chord intersects the x-axis at x0 and y = 0, we have
(f2 � f1)(x2 � x1)
=(0� f1)(x � x1)
or x0 � x1 = � f1 (x2 � x1)f2 � f1
Hence
x0 = x1 �f (x2 � x1)f2 � f1
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 8
Since the chord intersects the x-axis at x0 and y = 0, we have
(f2 � f1)(x2 � x1)
=(0� f1)(x � x1)
or x0 � x1 = � f1 (x2 � x1)f2 � f1
Hence
x0 = x1 �f (x2 � x1)f2 � f1
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 8
Since the chord intersects the x-axis at x0 and y = 0, we have
(f2 � f1)(x2 � x1)
=(0� f1)(x � x1)
or x0 � x1 = � f1 (x2 � x1)f2 � f1
Hence
x0 = x1 �f (x2 � x1)f2 � f1
.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.
3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.
5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ 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= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 0
7 Compute x0 = x1 � f (x2�x1)f2�f1 and f0
8 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f0
8 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ 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 / 8
Algorithm for Regula Falsi Method1 Choose two initial estimates of one of the roots in its vicinity andtolerance δ.
2 Compute f1 and f2.3 If jf1j � δ then root = x1; Step 10.ElseIf jf2j � δ then root = x2; Step 10.
4 If f1 � f2 > 0 then Print �Root not in this range�; Step 10.5 count = 16 While count 6= 07 Compute x0 = x1 � f (x2�x1)
f2�f1 and f08 If f0 � f2 � 0 then x2 = x0 and f2 = f0; count = count+1;elsex1 = x0 and f1 = f0; count = count+1;
9 If jf0j � δ then write value of the root; count=0; Step 1010 Stop.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 8
Example
We evaluate the root of f (x) = x2 � 16 using Regula Falsi Method as:
Iteration No x1 x2 x0
f1 f2 f0Initialization 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 isx0 = 3.9999.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 8
Example
We evaluate the root of f (x) = x2 � 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 isx0 = 3.9999.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 8
Example
We evaluate the root of f (x) = x2 � 16 using Regula Falsi Method as:
Iteration No x1 x2 x0 f1 f2 f0Initialization 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 isx0 = 3.9999.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 8
Example
We evaluate the root of f (x) = x2 � 16 using Regula Falsi Method as:
Iteration No x1 x2 x0 f1 f2 f0Initialization 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 isx0 = 3.9999.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 8
Example
We evaluate the root of f (x) = x2 � 16 using Regula Falsi Method as:
Iteration No x1 x2 x0 f1 f2 f0Initialization 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 isx0 = 3.9999.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 8
Example
We evaluate the root of f (x) = x2 � 16 using Regula Falsi Method as:
Iteration No x1 x2 x0 f1 f2 f0Initialization 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
isx0 = 3.9999.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 8
Example
We evaluate the root of f (x) = x2 � 16 using Regula Falsi Method as:
Iteration No x1 x2 x0 f1 f2 f0Initialization 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 isx0 = 3.9999.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 8
Thank you
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 8