Professional Documents
Culture Documents
Gaussian Elimination
Two steps
1. Forward Elimination
2. Back Substitution
1
9/20/2021
Forward Elimination
The goal of forward elimination is to transform the
coefficient matrix into an upper triangular matrix
25 5 1 x1 106.8
64 8 1 x 177.2
2
144 12 1 x3 279.2
25 5 1 x1 106.8
0 4.8 1.56 x 96.21
2
0 0 0.7 x3 0.735
Forward Elimination
A set of n equations and n unknowns
a11 x1 a12 x2 a13 x3 ... a1n xn b1
a21 x1 a22 x2 a23 x3 ... a2 n xn b2
. .
. .
. .
an1 x1 an 2 x2 an 3 x3 ... ann xn bn
2
9/20/2021
Forward Elimination
Step 1
For Equation 2, divide Equation 1 by a11 and
multiply by a21 .
a21
a ( a11 x1 a12 x2 a13 x3 ... a1n xn b1 )
11
a21 a a
a21 x1 a12 x2 ... 21 a1n xn 21 b1
a11 a11 a11
Forward Elimination
Subtract the result from Equation 2.
a21 x1 a22 x2 a23 x3 ... a2 n xn b2
a21 a21 a21
− a x
21 1 a x
12 2 ... a x
1n n b1
a 11 a 11 a11
_________________________________________________
a a a
a22 21 a12 x2 ... a2 n 21 a1n xn b2 21 b1
a11 a11 a11
or
'
a22 x2 ... a2' n xn b2'
3
9/20/2021
Forward Elimination
Repeat this procedure for the remaining
equations to reduce the set of equations as
a11 x1 a12 x2 a13 x3 ... a1n xn b1
'
a22 x2 a23
'
x3 ... a2' n xn b2'
'
a32 x2 a33
'
x3 ... a3' n xn b3'
. . .
. . .
. . .
End of Step 1
Forward Elimination
Step 2
Repeat the same procedure for the 3rd term of
Equation 3.
a11 x1 a12 x2 a13 x3 ... a1n xn b1
'
a22 x2 a23
'
x3 ... a2' n xn b2'
"
a33 x3 ... a3" n xn b3"
. .
. .
. .
4
9/20/2021
Forward Elimination
At the end of (n-1) Forward Elimination steps, the
system of equations will look like
a11 x1 a12 x 2 a13 x3 ... a1n x n b1
'
a22 x2 a23
'
x3 ... a2' n xn b2'
"
a33 x3 ... a3" n xn b3"
. .
. .
. .
n 1 n 1
ann xn bn
0 0 0 (n 1 )
0 ann xn bn(n-1 )
5
9/20/2021
Back Substitution
Solve each equation starting from the last equation
25 5 1 x1 106.8
0 4.8 1.56 x 96.21
2
0 0 0.7 x3 0.735
n 1 n 1
ann xn bn
6
9/20/2021
Back Substitution
Start with the last equation because it has only one unknown
bn( n 1)
x n ( n 1)
a nn
Back Substitution
bn( n 1)
x n ( n 1)
a nn
7
9/20/2021
THE END
8
9/20/2021
Example 1
The upward velocity of a rocket is given at three
different times
v t a1t 2 a 2 t a 3 , 5 t 12.
Find the velocity at t=6 seconds .
Example 1 Cont.
Assume
v t a 1 t 2 a 2 t a 3 , 5 t 12.
t 12 t1 1 a1 v1
2 a v
t2 t2 1 2 2
t 32 t3 1 a 3 v 3
9
9/20/2021
Example 1 Cont.
25 5 1 a 1 106 .8 25 5 1 106 .8
64 8 1 a 177 .2 64 8 1 177 .2
2
144 12 1 a 3 279 .2 144 12 1 279 .2
1. Forward Elimination
2. Back Substitution
Forward Elimination
10
9/20/2021
. 64 8 1 177.2
Subtract the result from 64 12.8 2.56 273.408
Equation 2
0 4.8 1.56 96.208
25 5 1 106.8
Substitute new equation for 0 4.8 1.56 96.208
Equation 2
144 12 1 279.2
11
9/20/2021
25 5 1 106.8
Substitute new equation for 0 4.8 1.56 96.208
Equation 3
0 0 0.7 0.76
12
9/20/2021
Back Substitution
Back Substitution
25 5 1 106.8 25 5 1 a1 106.8
0 4.8 1.56 96.2 0 4.8 1.56 a 96.208
2
0 0 0.7 0.7 0 0 0.7 a3 0.76
Solving for a3
0.7 a3 0.76
0.76
a3
0. 7
a3 1.08571
13
9/20/2021
Solving for a2
4.8a2 1.56a3 96.208
96.208 1.56a3
a2
4.8
96.208 1.56 1.08571
a2
4.8
a2 19.6905
Solving for a1
25a1 5a2 a3 106.8
106.8 5a2 a3
a1
25
106.8 5 19.6905 1.08571
25
0.290472
14
9/20/2021
a1 0.290472
a 19.6905
2
a3 1.08571
Example 1 Cont.
Solution a1 0.290472
a 19.6905
The solution vector is
2
a3 1.08571
The polynomial that passes through the three data points is then:
v t a1t 2 a2t a3
0.290472 t 2 19.6905t 1.08571, 5 t 12
129.686 m/s.
15
9/20/2021
THE END
16
9/20/2021
0 10 7 x1 3
6 2 3 x2 11
5 1 5 x3 9
12 10 7 x1 15
6 5 3 x2 14
5 1 5 x3 9
17
9/20/2021
Exact Solution
x1 1
x 1
2
x3 1
18
9/20/2021
19
9/20/2021
Avoiding Pitfalls
Increase the number of significant digits
• Decreases round-off error
• Does not avoid division by zero
Avoiding Pitfalls
20
9/20/2021
THE END
21
9/20/2021
Avoiding Pitfalls
Increase the number of significant digits
• Decreases round-off error
• Does not avoid division by zero
22
9/20/2021
Avoiding Pitfalls
Gaussian Elimination with Partial Pivoting
• Avoids division by zero
• Reduces round off error
23
9/20/2021
0 a'n 2 an' 3 an' 4 '
ann xn bn'
6 14 5.1 3.7 6 x1 5
0 7 6 1 2 x 2 6
0 4 12 1 11 x3 8
0 9 23 6 8 x4 9
0 17 12 11 43 x5 3
24
9/20/2021
6 14 5.1 3.7 6 x1 5
0 17 12 11 43 x 3
2
0 4 12 1 11 x3 8
0 9 23 6 8 x4 9
0 7 6 1 2 x5 6
Switched Rows
Gaussian Elimination
with Partial Pivoting
A method to solve simultaneous linear
equations of the form [A][X]=[C]
Two steps
1. Forward Elimination
2. Back Substitution
25
9/20/2021
Forward Elimination
Same as naïve Gauss elimination method
except that we switch rows before each
of the (n-1) steps of forward elimination.
0 a'n 2 an' 3 an' 4 '
ann xn bn'
26
9/20/2021
0 0 0 (n 1 )
0 ann xn bn(n-1 )
n 1 n 1
ann xn bn
27
9/20/2021
Back Substitution
bn( n 1)
x n ( n 1)
a nn
n
bii 1 aiji 1 x j
j i 1
xi i 1 for i n 1,...,1
a ii
THE END
28
9/20/2021
Example 2
Solve the following set of equations
by Gaussian elimination with partial
pivoting
25 5 1 a 1 106 .8
64 8 1 a 177 .2
2
144 12 1 a 3 279 .2
29
9/20/2021
Example 2 Cont.
25 5 1 a 1 106 .8 25 5 1 106 . 8
64 1 a 177 .2
8 2 64 8 1 177 . 2
144 12 1 a 3 279 .2 144 12 1 279 . 2
1. Forward Elimination
2. Back Substitution
Forward Elimination
30
9/20/2021
31
9/20/2021
32
9/20/2021
.
0 2.667 0.5556 53.10
Subtract the result from 0 2.667 0.7556 53.33
Equation 3
0 0 0.2 0.23
144 12 1 279.2
Substitute new equation for 0 2.917 0.8264 58.33
Equation 3
0 0 0.2 0.23
33
9/20/2021
Back Substitution
Back Substitution
144 12 1 279.2 144 12 1 a1 279.2
0 2.917 0.8264 58.33 0 2.917 0.8264 a 58.33
2
0 0 0.2 0.23 0 0 0.2 a3 0.23
Solving for a3
0.2a3 0.23
0.23
a3
0. 2
1.15
34
9/20/2021
Solving for a2
2.917a2 0.8264a3 58.33
58.33 0.8264a3
a2
2.917
58.33 0.8264 1.15
2.917
19.67
Solving for a1
144a1 12a2 a3 279.2
279.2 12a2 a3
a1
144
279.2 12 19.67 1.15
144
0.2917
35
9/20/2021
25 5 1 a 1 106 .8
64 8 1 a 177 .2
2
144 12 1 a 3 279 .2
a1 0.2917
a 19.67
2
a 3 1.15
36
9/20/2021
37
9/20/2021
10 7 0 x1 7
0 2.5 5 x 2 2.5
0 0 6.002 x3 6.002
38
9/20/2021
10 7
6.002
0 x1 7 x3 1
0 2.5 5 x 2 2.5 6.002
0 0 6.002 x3 6.002 2.5 5 x3
x2 1
2.5
7 7 x 2 0 x3
x1 0
10
x1 0 x1 0
X calculated x2 1 X exact x 2 1
x3 1 x3 1
39
9/20/2021
THE END
40
9/20/2021
Theorem of Determinants
If a multiple of one row of [A]nxn is added or
subtracted to another row of [A]nxn to result in
[B]nxn then det(A)=det(B)
Theorem of Determinants
The determinant of an upper triangular matrix
[A]nxn is given by
41
9/20/2021
Forward Elimination of a
Square Matrix
Using forward elimination to transform [A]nxn to an
upper triangular matrix, [U]nxn.
A n n U n n
det A det U
Example
Using naïve Gaussian elimination find the
determinant of the following square
matrix.
25 5 1
64 8 1
144 12 1
42
9/20/2021
Forward Elimination
43
9/20/2021
25 5 1
Substitute new equation for 0 4.8 1.56
Equation 3
0 16.8 4.76
44
9/20/2021
25 5 1 25 5 1
64 8 1 0 4.8 1.56
144 12 1 0 0 0.7
.
det A u11 u 22 u 33
25 4 . 8 0 . 7
84 . 00
Summary
-Forward Elimination
-Back Substitution
-Pitfalls
-Improvements
-Partial Pivoting
-Determinant of a Matrix
45