1
Numerical Methods for
Engineers
LECTURE II
By
J. D. Ankamah
UENR-Sunyani
Introduction
2
To understand that many mathematical problems
cannot be solved analytically but require numerical
methods
To use of numerical methods in solving and control
of error that may arise
Iterative Methods of Roots Finding
18
Iteratively find the root of f(x) = 0
Methods
Bisection Method
Fixed-Point Method
Newton’s Method
Secant Method
Root of a function
19
The value c is said to be a root of a function f(x) if
f(c) = 0
The root c of a function f(x) is said to be of multiplicity
k if
f(x) = g(x)(x-c)k
OR
f (c) 0, f '(c) 0, f ''( c) 0
, f ( k 1) (c) 0 but f ( k ) ( c) 0
Bisection Method
20
Intermediate-Value Theorem:
If f is a continuous function on the interval [a,b] and if
f(a) · f(b) < 0, then f must have a zero in (a,b).
Procedure for Bisection Method
21
Given the interval [a,b], if f(a) · f(b) < 0, there exist
a root in [a,b] and then find the
midpoint c = (a + b)/2
If f(a).f(c) < 0, then the root of f is in [a,c],
therefore set b ← c
Else the root is in [c,b], therefore set a ← c
If f(a)f(c) = 0, then c is the zero of f
repeat this process until a desired convergence.
Example
22
Find the root of the function f(x) = x-2sin(x) in
the interval [1,2] using the bisection method.
Theorem
23
Suppose that f ∈ C[a,b] and f(a) · f(b) < 0. The
Bisection method generates a sequence approximating
a root c of f with an approximation error
Example
Determine the number of iterations necessary to solve
f(x) = x − 2sin(x) = 0 with accuracy of 10−4 within the
interval [1,2].
Solution
24
Taking logarithms gives,
Hence the min. number of iterations needed is
Fixed Point Method
25
Definition:
Any real number r is a fixed point of a function
g(x) if g(r) = r .
Examples
zero (0) is a fixed point of sin(x), since sin(0) = 0
zero (0) is a fixed point of x2 since (0)2 = 0
one (1) is a fixed point of x2 since (1)2 = 1
Theorem:
26
Suppose that the f(x) = 0 can be written in the form
x = g(x); that is f(x) = x - g(x) = 0: Then any fixed
point of g(x) is a root of f(x) = 0
Proof:
Let r be a fixed point of g(x),
Then g(r) = r
Therefore f(r) = r – g(r) = r – r =0
Hence r is a root of f(x)
Theorem
27
Let f(x) = 0 be written in the form x = g(x).
Assume the following properties g(x):
1. For all x in [a, b]; g(x) is in [a, b];
2. g’(x) exist on (a, b) and that g'(x) k < 1
for all x in
(a, b):
Then
(i) there is a unique fixed point
r of g(x) in [a, b].
(ii) For any x0 in [a, b], the sequence xn+1 = g(xn);
k = 1, 2, 3,… converges to a fixed point r ; that is,
approaching the root of f(x) = 0:
Theorem
28
If 𝑔 satisfies the above Theorem, then bounds for
the error involved using xn to approximating the
fixed point x are given by
n
k
x xn
x1 xo
1 k
x xn k n max{xo a, b xo}
Examples
29
For some convergent fixed-point iterative scheme,
xn+1 = g(xn), on [0,1], we have x0=1 and x1=1/2
Suppose further that for all x [0,1], g '( x) 31
(a) Compute the error bound for x7
(b) Determine the minimum number of iterations
needed to approximate the fixed-point to within 10-6
using and x0=1.
Examples
30
Find the root of the following functions
in [0, 2]
Find algebraically, the fixed points of the following
i. f(x) = xln(x + 1)
ii. f(x) =
Newton’s Method
31
for a given function f(x) and initial approx x0
find the derivative f’(x)
Approximate the graph of f by suitable tangents
Then
Thus
Note:
32
Approximate root x0 must be close to the solution
The method may diverge if x0 is far
A sketch of the function f(x) can help decide on an
appropriate initial guess x0 for a particular problem
Graphical Representation of
Newton’s Method
33
34
Examples
35
Find the iterative methods based on NewtonRaphson method for finding
Find the solution of
Drawback with Newton’s method
36
The algorithm may not converge if;
The initial point (x(0)) is not close enough to the root.
The derivative at xn is close to zero
It is necessary to evaluate f’(x) at various points. This
may not be practical for some choices of the
function f.
To avoid this, use the SECANT Method
Secant Method
37
for a given function f(x) and initial approx x0 and x1
Approximate the graph of f by suitable secants
Then
Note:
38
Approximate root x0 must be close to the solution
The method may diverge if x0 is far
A sketch of the function f(x) can help decide on an
appropriate initial guess x0 for a particular
problem
39
Graphical Representation of
Secant Method
40
Examples
41
Find the smallest possible root of
with the secant method
Methods of Solving System of Eqns
42
Introduction
Direct Methods
Gaussian Elimination
Naive
Partial Pivoting
Scaled Pivoting
LU Decomposition
Doolittle's Method
Crout's Method
Cholesky Decomposition Method
43
Iterative Methods
Jacobi Method
Gauss-Seidel
Successive-Over Relaxation Method
Introduction
44
Linear System
homogeneous system if all bi’s = 0
Non - homogeneous system if NOT all bi’s is Zero(0)
Introduction
45
In Matrix for
Ax = b
Introduction
46
Augmented Matrix
Example
47
Introduction
48
Rank of a Matrix
The number of linearly Independent rows in a given
matrix.
It can also be defined as the number non-zero rows in
row reduced form of the given matrix.
Example
Two (2) dependent rows
A=
There are THREE (3) Independent Rows. Rank(A) = 3
Example Con’t
49
A=
Hence Rank (A) = 3
Three (3) non-zero rows
50
Equivalent Systems: Two linear systems are said to
be equivalent if they have the same solution set.
51
Row echelon matrix : Is a matrix whose leading
entries form a step-like pattern that moves down
and right through the matrix.
Row-reduced echelon matrix: has a property that
all leading entries are one(1) and entries below
and above leading entries are zero(0).
Elementary Row Operations
52
1) Row Replacement: Replace a row by a sum of
itself and a multiple of another.
2) Row Interchange: Interchange two rows.
3) Row Scaling: Multiply all rows by a nonzero
constant.
Direct Methods
53
Gaussian Elimination
Gaussian Elimination
54
Example:
Solve on the Board
Gaussian Elimination
55
Gaussian with Back Substitution
(Naive)
56
If first entry is zero STOP, Error
Use pivot element to eliminate all entries below it
Ignore the pivot row and column and return to the
first step with a smaller matrix
Stop when last row is erased
57
58
Mathematically;
where;
Back Substitution
59
Mathematically
Where
Then
x=b
60
k gives the # of iteration
i starts 1 after k
j starts in column # = k
Solution Types
61
Consistent System : A Systems is said to be
consistent if it has a solutions
Two Solutions
Unique (1 solution)
Infinitely many Solution
Inconsistent System : This is a Systems that has no
solutions
Solution Types
62
For two variable problem;
One solution - (when the lines intersect at a single
point)
Innitely many solutions (when the lines coincide).
No solution - (the two lines are parallel and never
intersect).
For three variable we talk of planes
Unique Solution
63
Rank of matrix A is equal to Rank of augmented
matrix
Rank of matrix A is equal to the number of Unknowns
Infinitely Many Solution
64
Rank of matrix A is equal to Rank of augmented
matrix
Rank of matrix A is NOT equal to the number of
Unknowns
No Solution
65
Rank of matrix A is NOT equal to Rank of
augmented matrix
Example
66
State for which values of k the given system will
have exactly 1 solution, infinite solutions, or no
solution.
1)
2)
Problems That May Arise
67
Pivot element is zero
In this case even though the system has solution, the
naive Gaussian elimination method will stop.
Partial Pivoting (I)
68
Replace a zero pivot element by swapping the pivot
row and the next possible row with non-zero
element in the pivot column
Then continue as in the Naïve Gaussian
Problem 1!!
69
70
71
Problems That May Arise
72
Pivot element is zero
In this case even though the system has solution, the
naive Gaussian elimination method will stop.
Pivot element is very small compared to the other
elements in the matrix
Significant errors due to rounding can occur when the
pivot element is small relative to other elements in the
pivot row/column.
Problem 2 !!
73
Solve
Actual answer
x1 = 1/3 = 0.333
x2 = 2/3 = 0.667
74
TRY
x2 = 0.66667
x1 = 0.3
x2 = 0.666667
x1 = 0.33
Partial Pivoting (II)
75
Replace a zero/small pivot element by swapping
the pivot row and the row with the LARGEST nonzero element in the pivot column
Continue as before
LU Decompositions
76
Doolittle's Method
Crout's Method
Cholesky Decomposition Method
General Steps
77
Given
Ax = b
Find L – Lower Triangular Matrix and
U – Upper Triangular Matrix
such that
A = LU
Then we have;
LUx = b
Let Ux = y (vector of the same length as x)
Solve for y in Ly = b and use y to find x in
Ux = y
Doolittle's Method
78
We want A = LDUD
Set
Multiply the right and equate corresponding terms
to find the value of m’s and u’s
Example
79
Using the Doolittle’s Method solve the linear system
80
Method 2:
1) Use Gaussian Elimination to get UD (Upper Triangular)
from A
2) Keep all the Gaussian factors used in step 1 above
3) Then, the below diagonal entries of LD are simply the
the Gaussian factor used at that stage
Example:
Crout’s Method
81
We want A = LCUC
Set
Multiply the right and equate corresponding terms
to find the values of m’s and u’s
Crout’s Method
82
Method 2
1) Use the 3 steps in Doolittle Method 2 to find UD* and
LD* from AT
2) Then LCr= (UD*)T and UCr = (LD*)T
Then continue solving the system as before
Note:
From the method above it is clear that if A is symmetric,
(i.e. A = AT) Doolittle and Crout have similar entrie and
LCr= (UD)T and UCr = (LD)T
83
Example:
Cholesky Method
84
We want A = LLT
Set
Multiply the right and equate corresponding terms to
find the values of l’s
Example
85
Convergence – Cholesky
86
The Cholesky decomposition works if matrix A is a
positive definite matrix
Symmetric Positive Definite Matrix
87
A matrix A is symmetric positive definite if it is
symmetric and if xTAx > 0 for every n-dimensional
vector x ≠ 0.
3 1
A
,
1 3
2 1 0
B 1 2 1
0 1 2
A symmetric matrix A is positive definite if its pivots
during row reduction without row exchanges are all
positive
2 1 0
3 1
A
,
1 3
B 1 2 1
0 1 2
Symmetric Positive Definite Matrix
88
A symmetric matrix A is positive definite if and only if
each of its leading principal sub-matrices has a
positive determinant.
3 1
A
,
1 3
2 1 0
B 1 2 1
0 1 2
The matrix A is positive definite if and only if A can
be factored in the form LLT, where L is lower triangular
with nonzero diagonal entries.
(i.e Cholesky Decomposition is possible)
89
The matrix A (n x n) is positive definite if all n
eigenvalues of A are positive.
If A is an n x n positive definite matrix, then
(a) A has an inverse;
(b) aii > 0, for each i = 1, 2,... , n
(c) max1k , j n akj max1i n aii
(d) (aij)2 < aiidjj, for each i .
Diagonally Dominant Matrix
90
A matrix A of dimension N x N is said to be
diagonally dominant provided that
Strictly diagonally dominant if
Example
91
A=
B=
92
C=
Find the values of 0 and 0 for which the
following matrix is strictly diagonally dominant.
In-Built Matlab functions for Solving
System of linear Equations
93
System in Matrix form Ax = b
Use x = linsolve(A,b)
Matlab LU - Decomposition
94
[L,U,p] = lu(A)
returns
L = lower triangular matrix
U = upper triangular matrix and
P = permutation matrix of the Doolittle Method
Norms
95
A vector norm on Rn is a function, . from Rn into R
with the following properties:
i.e.
96
T
l
,
l
The 2 1 and l norms for the vector x x1, x2 , x3 ,...., xn
n
x 1 xi
i 1
Example
97
Find the l2 , l1 and l norms for the vector x 1, 1,2T
Definition
98
If x x1, x2, x3 ,...., xn and y y1, y2, y3 ,...., yn
are vectors in Rn, the l2 , l1 and l distances between
x and y are defined by
T
T
n
x-y 1 x i yi
i 1
Definition
99
Iterative Solution Methods
100
Starts with an initial approximation for the solution
vector (x0)
At each iteration updates the x vector by using the
sytem Ax=b
Each iteration involves a matrix-vector product.
Iterative solution procedure
101
Write the system Ax=b in an equivalent form
x = Mx + p (like x = g(x) for fixed-point iteration)
Starting with x0, generate a sequence of
approximations {xk} iteratively by
xk = Mxk-1 + p
Representation of M and p depends on the type of
the method used
But for every method, M and p are obtained from A
and b, but in a different way
Convergence
102
As k, the sequence {xk} converges to the solution
vector under some conditions on M matrix
This imposes different conditions on matrix A for
different methods
For the same matrix A, one method may converge
while the other may diverge
Therefore for each method, the relation between A
and M should be found to decide on the
convergence
Iterative methods
103
Jacobi Iteration
Gauss-Seidel Iteration
Successive Over Relaxation (S.O.R)
SOR is a method used to accelerate the convergence
Gauss-Seidel Iteration is a special case of SOR method
Jacobi iteration
104
a11 x1 a12 x2 a1n xn b1
a21 x1 a22 x2 a2 n xn b2
an1 x1 an 2 x2 ann xn bn
x10
0
x2
0
x
0
xn
1
i 1
n
1
(b1 a12 x20 a1n xn0 )
k
k 1
k 1
xi
a ij x j
a11
bi a ij x j
a ii
j 1
j i 1
1
x12
(b2 a21 x10 a23 x30 a2 n xn0 )
a22
1
x1n
(bn an1 x10 an 2 x20 ann 1 xn01 )
ann
x11
xk=Mxk-1+p iteration for Jacobi method
105
A can be written as A=L+D+U (not decomposition)
0 0 a11 0
0 0 a12 a13
a11 a12 a13 0
a
a
0 a
0 0 a
a
a
0
0
0
22
23
21 22 23 21
a31 a32 a33 a31 a32 0 0
0 a33 0 0
0
Ax=b (L+D+U)x=b
i 1
n
1
k 1
k 1
x
b i a ij x j a ij x j
a ii
j 1
j i 1
k
i
Dxk+1
Lx k
Uxk
Dxk =-(L+U)xk-1+b
xk=-D-1(L+U)xk-1+D-1b
M=-D-1(L+U)
p=D-1b
Convergence - Jacobi
106
For any x0 , Jacobi converges if and only if (M ) 1
(i.e the spectral radius/largest eigenvalue of M is
less than 1) where M=-D-1(L+U)
If A is strictly diagonally dominant, then for any
choice of x0, the Jacobi methods gives a sequence
that converge to the unique solution.
If A is symmetric positive definite, then for any
choice of x0, the Gauss-Seidel methods gives a
sequence that converge to the unique solution.
Example 1 (Jacobi Iteration)
107
4 1 1 x1 7
4 8 1 x 21
2
2 1 5 x3 15
0
x 0 0
0
b Ax 0
2
26.7395
Is matrix A diagonally dominant ? YES
0
0
7
x
x
7
1
2
3
x1
1.75
4
4
0
0
21
21
4
x
x
1
1
3
2.625
x2
8
8
0
0
15
15
2
x
x
1
3.0
1
2
x3
5
5
b Ax1 10.0452
2
Example 1 continued...
108
7 x12 x31
7 2.625 3
x
1.65625
4
4
2
1
1
b
Ax
1.8061
21
4
x
x
21
4
1.75
3
2
1
3
2
x2
3.875
8
8
15 2 1.75 2.625
15 2 x11 x12
2
3.175
x3
5
5
2
1
7 3.875 3.175
1.925
4
21 4 1.65625 3.175
x23
3.85
8
15 2 1.65625 3.875
x33
2.8875
5
x13
b Ax3
2
1.0027
Matrix is diagonally dominant, Jacobi iterations are converging
Example 2
109
2 1 5 x1 15
4 8 1 x 21
2
4 1 1 x3 7
0
x 0 0
0
b Ax 0
2
26.7395
Is matrix A diagonally dominant ? NO !
Is matrix A symmetric positive definite? NO !
15 x20 5 x30
15
x
7.5
2
2
21 4 x10 x30
21
1
x2
2.625
8
8
x31 7 4 x10 x20
7.0
1
1
b Ax1 54.8546
2
Example 2 continued...
110
15 2.625 5 7
x
11.3125
2
21 4 7.5 7
1
x2
0.25
8
x31 7 4 7.5 2.625 39.625
1
1
b Ax 2
2
208.3761
The residual term is increasing at each iteration, so
the iterations are diverging.
Note that the matrix is not diagonally dominant
Now, to get the right answer what will you do ?
Compare !!!
111
Current problem
(Non-Converging)
Previously solved problem
(Converging)
2 1 5 x1 15
4 8 1 x 21
2
4 1 1 x3 7
4 1 1 x1 7
4 8 1 x 21
2
2 1 5 x3 15
Gauss-Seidel (GS) iteration
112
a11 x1 a12 x2 a1n xn b1
Use the latest a21 x1 a22 x2 a2 n xn b2
update
an1 x1 an 2 x2 ann xn bn
x10
0
x2
0
x
0
xn
1
i 1
n
1
(b1 a12 x20 a1n xn0 )
k
k
k 1
xi
a ij x j
a11
bi a ij x j
a ii
j 1
j i 1
1
1
1
0
0
x2
(b2 a21 x1 a23 x3 a2 n xn )
a22
1
x1n
(bn an1 x11 an 2 x12 ann 1 x1n 1 )
ann
x11
x(k+1)=Mx(k)+p iteration for Gauss-Seidel
113
Ax=b (L+D+U)x=b
i 1
n
1
k
k 1
x
b i a ij x j a ij x j
a ii
j 1
j i 1
k
i
Dxk+1
L x k 1
Uxk
(L+D)xk =-Uxk-1+b
xk=-(L+D)-1Uxk-1+(L+D)-1b
M=-(L+D)-1U
p= (L+D)-1b
Convergence – Gauss-Seidel
114
For any x0 , Gauss-Seidel converges if and only if
(M ) 1 (i.e the spectral radius/largest eigenvalue
of M is less than 1) where M = -(L+D)-1U
If A is strictly diagonally dominant, then for any
choice of x0, the Gauss-Seidel methods gives a
sequence that converge to the unique solution.
If A is symmetric positive definite, then for any
choice of x0, the Gauss-Seidel methods gives a
sequence that converge to the unique solution.
Comparison
115
Gauss-Seidel iteration converges more rapidly than
the Jacobi iteration since it uses the latest updates
But there are some cases that Jacobi iteration does
converge but Gauss-Seidel does not
To accelerate the Gauss-Seidel method even further,
successive over relaxation method can be used
Example (Gauss-Seidel Iteration)
116
4 1 1 x1 7
4 8 1 x 21
2
2 1 5 x3 15
0
x 0 0
0
b Ax 0
2
26.7395
Diagonally dominant matrix
7
7 x20 x30
1.75
x
4
4
21 4 x11 x30 21 4 1.75
1
3.5
x2
8
8
15 2 x11 x12 15 2 1.75 3.5
1
3.0
x3
5
5
1
1
b Ax1 3.0414
2
b Ax1 10.0452
2
Jacobi iteration
Example 1 continued...
117
1
1
7
x
x
7 3.5 3
2
2
2
3
b
Ax
0.4765
x1
1.875
2
4
4
2
1
2
21 4 1.875 3
21
4
x
x
b
Ax
1.8061
2
1
3
3
.
9375
2
x2
8
8
Jacobi iteration
2
2
15 2 1.875 3.9375
15
2
x
x
1
2
2.9625
x32
5
5
When both Jacobi and Gauss-Seidel iterations
converge, Gauss-Seidel converges faster
Successive Over Relaxation Method
118
GS iteration can also be written as follows
x
i 1
n
1
k 1
k
x
bi a ij x j a ij x j
a ii
j 1
j i
k 1
i
k
i
x ik 1 x ik ik
Correction term
i2
xi3
xi2
xi1
xi0
2
i
i1
i1
i0
Multiply with
1
i0
Faster
convergence
SOR
119
x
k 1
i
x
k
i
k
i
i 1
n
1
k 1
k
k 1
k
xi xi
bi aij x j aij x j
aii
j 1
j i
i 1
n
1
k 1
k
k 1
k
xi (1 ) xi
bi aij x j aij x j
aii
j 1
j i 1
1<<2 over relaxation (faster convergence)
0<<1 under relaxation (slower convergence)
There is an optimum value for
Find it by trial and error (usually around 1.6)
x(k) = Mx(k-1) + p iteration for SOR
120
i 1
n
1
k
k 1
k
k 1
x i (1 ) x i
b i a ij x j a ij x j
a ii
j 1
j i 1
Dxk = (1-)Dxk-1 + b - Lxk - Uxk-1
(D+ L)xk = [(1-)D - U]xk-1 + b
M = (D+ L)-1[(1-)D - U]
p = (D+ L)-1b
Convergence of Relaxation method
121
Matrix A must be strictly diagonally dominant or
symmetric and positive definite
If 0<<2, SR method converges for any initial vector
if A matrix is symmetric and positive definite
If >2, SR method diverges
If 0<<1, SUR method converges but the convergence
rate is slower than the Gauss-Seidel method.
If =1, SR method converges at the same speed as
Gauss-Seidel
Convergence of SOR method
122
If 1<<2, SOR method converges and the
convergence rate is faster (acceleration) than the
Gauss-Seidel method.
123
In some cases the optimal value of can be computed
as (i.e when A is symmetric Positive definite)
where
is the spectral radius of the Jacobi matrix M
Eigenvalue & Eigenvectors
124
Introduction
The values 10 and 3 are eigenvalue of
the vectors
and
and
their corresponding eigenvectors
Characteristic Equation Method
125
This means that is the eigenvalue of A if
Ax = x
That is,
for some non-zero vector x
This is possible if the matrix
has no
inverse
Hence
--Characteristic Equation
Steps
126
1)
2)
Solve
obtain the eigenvalues,
With each eigenvalue, we solve
to obtain the eigenvectors.
Check your Eigenvalues
The sum of the eigenvalues is equal to the trace of
the matrix
The product of the eigenvalues is equal to the
determinant of the matrix
Terms
127
The set of all the eigenvalues of A is called spectrum
of A
The largest of the absolute values of the eigenvalues
of A is called the spectral radius of A.
Examples
128
Find the eigenvalues and eigenvectors of
1)
3)
B=
,
2)
Finding the Characteristic Equation
129
Take
B=
The trace of B is 6+7 = 13
The determinant of B is 6x7 – 4x3 = 30
130
Where
131
Second order diagonal minors
Third order diagonal
minors
..
There are
diagonal minors of order k in A
Example
132
133
The Power Method
134
The largest absolute Eigenvalue
Given an initial vector v
Max eigenvalue is
eigenvector is
and the corresponding
Inverse Power Method
135
The least absolute Eigenvalue
Given an initial vector
Max eigenvalue of
Therefore Min Eig. Val. of
is
is
Gen./Shifted Inverse Power Method
The Eigenvalue closer to a given value,
136
Given an initial vector
and
Max Eig. Val of
is
Eig. Val.
of
closeer to
is found as
Inverse Power Method
137
To Use this method one must have a fair idea about
the distribution of the eigenvalues in space. OR
Their approximate locations
To know these approximate locations we use the
Gerschgorin’s Circles
Gerschgorin’s Circles or Discs
138
Given any Matrix
Row Discs
Column Discs
Examples
139
Draw the Gershgorin Circles of the matrix
Solution
Rows
140
141
Any isolated disc contains an eigenvalue
Isolated union of r circles contain r different
eigenvalues
All eigenvalues belong to the region of the complex
plane which is the intersection of the two regions
formed respectively by the union of the row circles
and the union of the column circles
Examples
142
Draw the Gershgorin Circles of the matrix
Solution
Rows
143
Methods of Numerical Integration
144
Finding the definite integral
Split the x-interval into n sub-intervals of uniform
height
Such that
values as
with corresponding f
where j = 0,1,2,...,n
Trapezoidal Method
145
The Area of each of the sub divisions, is given as
146
Check the precision
147
Evaluate
for
using
direct integration and compare to the solution by
the trapezoidal rule with h = 1
Conclusion
The trapezoidal method is exact for polynomials of
order not exceeding 1
Simpson’ s Method
148
Even number of
subintervals
149
Check the precision
150
Evaluate
for
using direct integration and compare to the solution
by the Simpson’s rule with h = 1
Conclusion
151
The method will work when n is odd but will not give
the optimum result
The method is exact if the function is a polynomial
of order not exceeding 3.
Gaussian Quadrature (2-Point)
152
This is an extension of the trapezoidal rule
approximation
The right contains 4 unknowns,
and
Assume the integral gives exact solution for
polynomial of degree 3 (since it also has 4 unknowns)
That is
153
154
Example
155
Derive the two point Gaussian Quadrature formula
for evaluating
Solution :
Note: This is very handy and as such we change
other problems into this form.
Changing limits from
[a, b] to [-1, 1]
156
To convert any integral with limits of [a; b] into an
integral with limits [-1; 1],
Set
to convert the integral from x
coordinate to t coordinate system
That is, find the values of m and c from the system
Hence
Example
157
With 8 subintervals, approximate the integral
using;
Trapezium Rule
The Simpson’s
The Gaussian Quadrature
Interpolation
158
Given the points
Find a missing value of y at a point x within the
interval ( x0 , xn )
Examples
Direct Method
Lagrange Polynomial Method
Newton’s Divided Difference Polynomial
Direct Method
159
Given n+1 data points, the direct method fits a
polynomial of order n given as
With the n+1 points, form n+1 equations containing
the n+1 unknowns
Solve this system of equations for the values of
Then with these values use the polynomial for
predictions
Example
160
The upward velocity of a rocket is given as a function
of time in the table below
Determine the value of the velocity at
t =16seconds using the direct method
of interpolation and
i. a first order polynomial
ii. a second order polynomial.
iii. a third order polynomial.
Solution
161
i. For a first order polynomial interpolation, use
solution
162
i. For a first order polynomial interpolation, use
Which gives
OR
solution
163
ii. For second order polynomial interpolation, use
Which gives
OR
164
Solving gives
Hence
Therefore at t=16
165
iii. For third order polynomial interpolation, use
this gives
OR
166
Solving gives
Hence
Therefore at t =16
Lagrange’s Polynomial Method
167
This method also fits to a given data set a polynomial
of a particular degree.
Where fn(x) is a polynomial of degree n, and
Example
168
The upward velocity of a rocket is given as a
function of time in Table (3). Determine the value of
the velocity at t = 16 seconds using the second
order Lagrangian polynomial interpolation
169
For a second order polynomial we have
Since we want to find the velocity at t = 16 , and we
choose the three data points that well bracket t = 16.
That is
170
Therefore, for
171
At t = 16
Newton’s Divided Difference
172
Numerical Differentiation
173
Taylor's series expansion
Taylor's series expansion of a function f(x) around the
point c is given by
174
For a given step size h, find the Taylor’s series
expansion of f(x+h) and f(x-h) around the
point x given as
Forward difference formula
175
Solving the equation,
for
we get
Backward difference formula
176
Solving the equation,
for
we get
Central difference formula
177
Subtracting the second Taylor series from the first
we get
Central difference formula for
second derivative
178
Adding the two equations
Example
179
Find the first and second derivatives of f(x) = xex at
x = 1 using
1. forward difference method
2. backward difference method
3. central difference method
for different step sizes h =1/2n for n = 1, 2,...,20
Solving ODE
180
Given
Discritize x-interval
As before where
as
, n is the # of subdivisions
Single Step Method
181
Euler Method
This method approximate the first order derivative
with the forward difference method
i.e.
Example
182
Using the Euler method, and a step size of h = 0.1,
determine an approximate value of the solution of
the initial value problem
y’ - 2y = 1 + t
y(0) = 1
at time t = 0.1 and t = 0.2
183
Backward Euler Method
184
Approximates the first order derivative with the
backward order difference method
i.e.
Shifting index
Example
185
Using the Backward Euler method, and a step size
of h = 0.1, determine an approximate value of the
solution of the initial value problem
y’ - 2y = 1 + t
y(0) = 1
at time t = 0.1 and t = 0.2
186
Trapezoidal Method
187
From the error plots above, averaging Euler and
Backward Euler may bring averaging of the error
The average of the two gives
This is an implicit second order method
Example
188
Using the Trapezoidal method, and a step size of
h = 0.1, determine an approximate value of the
solution of the initial value problem
y’ - 2y = 1 + t
y(0) = 1
at time t = 0.1 and t = 0.2
189
Taylor Series Method
190
From the Taylor's series
For a 2nd order or stronger method keep the
But
term
191
Therefore
Example
Using the Taylor’s series method, and a step size of
h = 0.1, determine an approximate value of the
solution of the initial value problem
y’ - 2y = 1 + t
y(0) = 1
at time t = 0.1 and t = 0.2
192
Runge-Kutta Methods
193
2nd Order Runge-Kutta
Take the trapezium
And estimate the
i.e
Then we have
term on the right by Euler
194
Which is an explicit formula and usually written as
Example
195
Using the second order Runge-Kutta method, and a
step size of h = 0.1, determine an approximate
value of the solution of the initial value problem
y’ - 2y = 1 + t
y(0) = 1
at time t = 0.1 and t = 0.2
Fourth Order Runge-Kutta
196
The fourth order Runge-Kutta method is given by
Example
197
Using the fourth order Runge-Kutta method, and a
step size of h = 0.1, determine an approximate
value of the solution of the initial value problem
y’ - 2y = 1 + t
y(0) = 1
at time t = 0.1 and t = 0.2
Multi-Step Methods
198
These methods use information from more than the last
previous point computed.
That is
depends not only on but some other
previously computed points.
Adams-Bashford Method
199
This is a fourth order explicit method and is given
by;
usually written as;
Adams-Moulton Method
200
This is a fourth order implicit method
It is usually used as a corrector to other methods
Predictor-Corrector Method
201
These methods combines two other methods, usually an
explicit method serving as the predictor and an implicit
method as the corrector
Note:
This is how the second order Runge-Kutta method was
formed from the Euler method (Predictor) and the
trapezoidal method (corrector)
This means that the second order Runge-Kutta method
can be described as a single-step Predictor-Corrector
method
Adams-Bashford-Moulton
predictor-corrector method
202
This is a fourth order multistep method
Matlab built-in ODE functions
203
ode23
Based on an explicit Runge-Kutta (2,3) formula. A single
step method
ode45
Based on an explicit Runge-Kutta (4,5) formula. A single
step method
ode113
Variable order Adams-Bashforth-Moulton P-C solver. It is
a multi-step method
How to use them
204
With the ode in the form y’ = f(t,y), y(t0) = y0
Define the function
fun = @(t,y) f(t,y)
Define time inputs
tin = t0:h:tn
Call the function as
[t,y] = ode23(fun,tin,y0)
Matlab will display a column vector of the input t and
another column vector containing corresponding y
values
Example
205
Using the fourth order Runge-Kutta method, and a
step size of h = 0.1, determine an approximate
value of the solution of the initial value problem
y’ - 2y = 1 + t
y(0) = 1
at time t = 0.1 and t = 0.2
206
Thanks You
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )