Upload
hamza-ashraf
View
293
Download
2
Embed Size (px)
DESCRIPTION
Numerical analysis.
Citation preview
Math 307 - Programming & Numerical MethodsNumerical Analysis through 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 / 11
Roots of an equation: Bisection Method
De�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:
I How we know these two are the roots of this equation?I Answer: Wait!
I What is a root, graphically?I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Roots of an equation: Bisection MethodDe�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:
I How we know these two are the roots of this equation?I Answer: Wait!
I What is a root, graphically?I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Roots of an equation: Bisection MethodDe�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:
I How we know these two are the roots of this equation?I Answer: Wait!
I What is a root, graphically?I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Roots of an equation: Bisection MethodDe�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:
I How we know these two are the roots of this equation?I Answer: Wait!
I What is a root, graphically?I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Roots of an equation: Bisection MethodDe�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:I How we know these two are the roots of this equation?
I Answer: Wait!
I What is a root, graphically?I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Roots of an equation: Bisection MethodDe�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:I How we know these two are the roots of this equation?I Answer: Wait!
I What is a root, graphically?I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Roots of an equation: Bisection MethodDe�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:I How we know these two are the roots of this equation?I Answer: Wait!
I What is a root, graphically?
I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Roots of an equation: Bisection MethodDe�nitionFor the equation f (x) , a value x = x0 is said to be its root if f (x0) = 0.
Example
Suppose we have equation x2 � 3x + 1.Then x = 2. 62 and x = 0.382 arethe two roots of this equation because�
x2 � 3x + 1�jx=2.62 = �7. 6� 10�5 t 0
and�x2 � 3x + 1
�jx=0.382 = �8. 92� 10�6 t 0.
Questions:I How we know these two are the roots of this equation?I Answer: Wait!
I What is a root, graphically?I Answer: Value of x for which f (x) intersects the x-axis.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 2 / 11
Lets see some examples:
Here is plot ofx2 � 3x + 1
Example
1 1 2 3 4
2
1
1
2
x
y
Roots: 0.38 and 2.62
Here is another plot forx3 � 9x2 + 23x � 15. Weshall call this eq. as CAEequation. Why?
Example
2 4 6
4
2
2
4
x
y
Roots: ?, ?, ?
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 3 / 11
Lets see some examples:
Here is plot ofx2 � 3x + 1
Example
1 1 2 3 4
2
1
1
2
x
y
Roots: 0.38 and 2.62
Here is another plot forx3 � 9x2 + 23x � 15. Weshall call this eq. as CAEequation. Why?
Example
2 4 6
4
2
2
4
x
y
Roots: ?, ?, ?
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 3 / 11
Lets see some examples:
Here is plot ofx2 � 3x + 1
Example
1 1 2 3 4
2
1
1
2
x
y
Roots: 0.38 and 2.62
Here is another plot forx3 � 9x2 + 23x � 15. Weshall call this eq. as CAEequation. Why?
Example
2 4 6
4
2
2
4
x
y
Roots: ?, ?, ?
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 3 / 11
Lets see some examples:
Here is plot ofx2 � 3x + 1
Example
1 1 2 3 4
2
1
1
2
x
y
Roots: 0.38 and 2.62
Here is another plot forx3 � 9x2 + 23x � 15. Weshall call this eq. as CAEequation. Why?
Example
2 4 6
4
2
2
4
x
y
Roots: ?, ?, ?
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 3 / 11
Example
Here is another plot of x5 � 52x4 + 945x3 � 7094x2 + 20 600x � 14 400
5 10 15 20
5000
10000
15000
20000
x
y
Make the word out of roots?
Announcement:
I Make the word and get a gift of my choice. Guess, what my choice is?
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 4 / 11
Example
Here is another plot of x5 � 52x4 + 945x3 � 7094x2 + 20 600x � 14 400
5 10 15 20
5000
10000
15000
20000
x
y
Make the word out of roots?
Announcement:I Make the word and get a gift of my choice. Guess, what my choice is?
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 4 / 11
Sign-jumps and Roots
De�nitionFor two points xi and xj , if f (xi ) and f (xj ) have opposite signs, then wesay that f (x) has a sign-jump in the interval [xi , xj ] .
ProblemIs there some relation between the roots and sign-jumps of f (x) ?
10 200
10000
20000
x
y
Look for sign-jumps
SolutionIf there is a sign-jump in some interval of x-axis, then there always lies aroot in that interval.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 11
Sign-jumps and Roots
De�nitionFor two points xi and xj , if f (xi ) and f (xj ) have opposite signs, then wesay that f (x) has a sign-jump in the interval [xi , xj ] .
ProblemIs there some relation between the roots and sign-jumps of f (x) ?
10 200
10000
20000
x
y
Look for sign-jumps
SolutionIf there is a sign-jump in some interval of x-axis, then there always lies aroot in that interval.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 11
Sign-jumps and Roots
De�nitionFor two points xi and xj , if f (xi ) and f (xj ) have opposite signs, then wesay that f (x) has a sign-jump in the interval [xi , xj ] .
ProblemIs there some relation between the roots and sign-jumps of f (x) ?
10 200
10000
20000
x
y
Look for sign-jumps
SolutionIf there is a sign-jump in some interval of x-axis, then there always lies aroot in that interval.
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 11
Sign-jumps and Roots
De�nitionFor two points xi and xj , if f (xi ) and f (xj ) have opposite signs, then wesay that f (x) has a sign-jump in the interval [xi , xj ] .
ProblemIs there some relation between the roots and sign-jumps of f (x) ?
10 200
10000
20000
x
y
Look for sign-jumps
SolutionIf there is a sign-jump in some interval of x-axis, then there always lies aroot in that interval.Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 5 / 11
Metohd of Bisection
1 Check some values of f (x) to �nd a sign jump and get searchinterval as [a, b] .
2 If f (a) = 0 or f (b) = 0 then root is a or b. Stop. Otherwise proceedforward.
3 Calculate x0 =a+ b2, check if jf (x0)j � δ, if not then proceed
4 Check sign jump in [a, x0] and [x0, b] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 11
Metohd of Bisection
1 Check some values of f (x) to �nd a sign jump and get searchinterval as [a, b] .
2 If f (a) = 0 or f (b) = 0 then root is a or b. Stop. Otherwise proceedforward.
3 Calculate x0 =a+ b2, check if jf (x0)j � δ, if not then proceed
4 Check sign jump in [a, x0] and [x0, b] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 11
Metohd of Bisection
1 Check some values of f (x) to �nd a sign jump and get searchinterval as [a, b] .
2 If f (a) = 0 or f (b) = 0 then root is a or b. Stop. Otherwise proceedforward.
3 Calculate x0 =a+ b2, check if jf (x0)j � δ, if not then proceed
4 Check sign jump in [a, x0] and [x0, b] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 11
Metohd of Bisection
1 Check some values of f (x) to �nd a sign jump and get searchinterval as [a, b] .
2 If f (a) = 0 or f (b) = 0 then root is a or b. Stop. Otherwise proceedforward.
3 Calculate x0 =a+ b2, check if jf (x0)j � δ, if not then proceed
4 Check sign jump in [a, x0] and [x0, b] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 6 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2]
i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.
As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.
Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Example
We �nd a real root of the equation f (x) = x3 � x � 1, within j.01j ofexact value.
SolutionFor getting an initial guess of a and b, let us look for some sign-jumps:
x 0 1 2f (x) �1 �1 5
Hence a real root lies in the interval [1, 2] i.e. a = 1, b = 2.
So the �rst approximation to the exact root is x0 =a+ b2
=1+ 22
= 1. 5.
Now we have to check if x0 is itself a root or not.As f (1.5) = 0.875 > .001, hence 1.5 is not a root it is just an improvedapproximation.Hence the root is either in sub-interval : [a, x0] = [1, 1.5] or in[x0, b] = [1.5, 2] .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 7 / 11
Solution
For this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as:
x1 =a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.
x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01,
hence
our required root isx7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
SolutionFor this sign-jumps are to be checked: f (a) = �1 and f (1.5) = +0.875.So we proceed to compute x1 from [1, 1.5] as: x1 =
a+ x02
=1+ 1.52
=
1. 25,
f (x1) = f (1.25) = �0.2969 < 0.x2 =x0 + x12
=1.5+ 1.25
2= 1.3750
and f (x2) = 0.2246 and jf (x2)j 6� 0.01
x3 =x1 + x22
=1.3750+ 1.25
2= 1.3125 but f (x3) = �0.0515 and
jf (x3)j 6� 0.01
x4 =x2 + x32
= 1.3438 and f (x4) = 0.0826 and jf (x4)j 6� 0.01.
x5 =x3 + x42
= 1.3282 and f (x5) = 0.0146 and jf (x5)j 6� 0.01
x6 =x5 + x42
= 1.3204 and f (x6) = �0.0186 and jf (x6)j 6� 0.01
x7 =x6 + x52
= 1.3243 and f (x7) = �0.0018 and jf (x7)j < 0.01, henceour required root is
x7 = 1.3243. �
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 8 / 11
Algorithm1 Choose xl and xu as two guesses for the root such thatf (xl ) f (xu) < 0, or in other words, f (x) changes sign between xland xu .
2 Estimate the root, xm of the equation f (x) = 0 as the mid-pointbetween xl and xm as
xm =xl + xu2
.
3 Now check the following:
1 If f (xl ) f (xm) = 0 then root is xm , stop further computation.
2 If f (xl ) f (xm) < 0 then root lies between xl and xm ; then xl = xl andxu = xm .
3 If f (xl ) f (xm) > 0 then root lies between xm and xu ; then xl = xmand xu = xu .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 9 / 11
Algorithm1 Choose xl and xu as two guesses for the root such thatf (xl ) f (xu) < 0, or in other words, f (x) changes sign between xland xu .
2 Estimate the root, xm of the equation f (x) = 0 as the mid-pointbetween xl and xm as
xm =xl + xu2
.
3 Now check the following:
1 If f (xl ) f (xm) = 0 then root is xm , stop further computation.
2 If f (xl ) f (xm) < 0 then root lies between xl and xm ; then xl = xl andxu = xm .
3 If f (xl ) f (xm) > 0 then root lies between xm and xu ; then xl = xmand xu = xu .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 9 / 11
Algorithm1 Choose xl and xu as two guesses for the root such thatf (xl ) f (xu) < 0, or in other words, f (x) changes sign between xland xu .
2 Estimate the root, xm of the equation f (x) = 0 as the mid-pointbetween xl and xm as
xm =xl + xu2
.
3 Now check the following:
1 If f (xl ) f (xm) = 0 then root is xm , stop further computation.
2 If f (xl ) f (xm) < 0 then root lies between xl and xm ; then xl = xl andxu = xm .
3 If f (xl ) f (xm) > 0 then root lies between xm and xu ; then xl = xmand xu = xu .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 9 / 11
Algorithm1 Choose xl and xu as two guesses for the root such thatf (xl ) f (xu) < 0, or in other words, f (x) changes sign between xland xu .
2 Estimate the root, xm of the equation f (x) = 0 as the mid-pointbetween xl and xm as
xm =xl + xu2
.
3 Now check the following:
1 If f (xl ) f (xm) = 0 then root is xm , stop further computation.
2 If f (xl ) f (xm) < 0 then root lies between xl and xm ; then xl = xl andxu = xm .
3 If f (xl ) f (xm) > 0 then root lies between xm and xu ; then xl = xmand xu = xu .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 9 / 11
Algorithm1 Choose xl and xu as two guesses for the root such thatf (xl ) f (xu) < 0, or in other words, f (x) changes sign between xland xu .
2 Estimate the root, xm of the equation f (x) = 0 as the mid-pointbetween xl and xm as
xm =xl + xu2
.
3 Now check the following:
1 If f (xl ) f (xm) = 0 then root is xm , stop further computation.
2 If f (xl ) f (xm) < 0 then root lies between xl and xm ; then xl = xl andxu = xm .
3 If f (xl ) f (xm) > 0 then root lies between xm and xu ; then xl = xmand xu = xu .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 9 / 11
Algorithm1 Choose xl and xu as two guesses for the root such thatf (xl ) f (xu) < 0, or in other words, f (x) changes sign between xland xu .
2 Estimate the root, xm of the equation f (x) = 0 as the mid-pointbetween xl and xm as
xm =xl + xu2
.
3 Now check the following:
1 If f (xl ) f (xm) = 0 then root is xm , stop further computation.
2 If f (xl ) f (xm) < 0 then root lies between xl and xm ; then xl = xl andxu = xm .
3 If f (xl ) f (xm) > 0 then root lies between xm and xu ; then xl = xmand xu = xu .
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 9 / 11
4. Find the new estimate of root
xm =xl + xu2
.
5. Repeat Step 3-4 untill jf (xm)j < δ (where δ is the user de�ned errortolerance) or the number of iterations m � M (where M is the maximumnumber of iterations allowed by the user).
Thank you
Sqn Ldr Athar Kharal (H and S, CAE) Fundamentals of Scienti�c Computing 11 / 11