Gauss Elimination Matlab
Gauss Elimination Matlab
Chapter 9
Gauss Elimination
Chapter Objectives
Knowing how to solve small sets of linear equations with the
graphical method and Cramers rule.
Understanding how to implement forward elimination and
back substitution as in Gauss elimination.
Understanding the concepts of singularity and ill-condition.
Understanding how partial pivoting is implemented and how
it differs from complete pivoting.
Recognizing how the banded structure of a tridiagonal
system can be exploited to obtain extremely efficient
solutions.
Graphical Method
For small sets of simultaneous equations,
graphing them and determining the location
of the intercept provides a solution.
Determinants
The determinant D=|A| of a matrix is formed from the
coefficients of [A].
Determinants for small matrices are:
11
22
a11
3 3
a11
a21
a12
a21 a22
a31 a32
a11 a11
a12
a11a22 a12a21
a22
a13
a22 a23
a21 a23
a21 a22
a23 a11
a12
a13
a32 a33
a31 a33
a31 a32
a33
Cramers Rule
Cramers Rule states that each unknown in a
system of linear algebraic equations may be
expressed as a fraction of two determinants
with denominator D and with the numerator
obtained from D by replacing the column of
coefficients of the unknown in question by
the constants b1, b2, , bn.
1 1.9
0.5 1.9
0.5 1
1 1.9 0.3
0.52
1
0.0022
0.3 0.5
0.1 0.5
0.1 0.4
0.3 0.5
0.67 1.9
0.5 1.9
0.5 0.67
D2 0.5 0.67 1.9 0.3
0.01
1
0.0649
0.44 0.5
0.1 0.5
0.1 0.44
0.1 0.44 0.5
Divide
0.3 0.01
x2
D2 0.0649
29.5
D 0.0022
Forward elimination
Starting with the first row, add or
subtract multiples of that row to
eliminate the first coefficient from the
second row and beyond.
Continue this process with the second
row to remove the second coefficient
from the third row and beyond.
Stop when an upper triangular matrix
remains.
Back substitution
Starting with the last row, solve for the
unknown, then substitute that value
into the next highest row.
Because of the upper-triangular nature
of the matrix, each row will contain
only one more unknown.
Pivoting
Problems arise with nave Gauss elimination if a
coefficient along the diagonal is 0 (problem:
division by 0) or close to 0 (problem: round-off
error)
One way to combat these issues is to determine
the coefficient with the largest absolute value in the
column below the pivot element. The rows can
then be switched so that the largest element is the
pivot element. This is called partial pivoting.
If the rows to the right of the pivot element are also
checked and columns switched, this is called
complete pivoting.
Tridiagonal Systems
A tridiagonal system is a banded system with a
bandwidth of 3:
f1
e2
g1
f2
e3
g2
f3
g3
en1
f n1
en
x r
x 1 r1
2 2
x 3 r3
gn1x n1 rn1
f n
x n rn
method
as Gauss elimination, but with much less
effort because most of the matrix elements are
already 0.