Chapter 16 Numerical Linear Algebra
16.1 Sets of Linear Equations
MATLAB was developed to handle problems involving matrices and vectors in an
efficient way.
One of the most basic problems of this type involves the solution of a
system of linear equations.
The builtin matrix algebra functions of MATLAB facilitate
the process of establishing whether a solution exists and finding it when it does.
For
example, the 4
×
3 system below
4
7
5
1
2
3
4
0
3
0
x
y
z
x
y
z
x
y
z
x
y
z
+
+
=

+
+
=
+
+
=


=
is a system of equations which can be represented as
Ax
=
b
where
1
4
7
5
1
1
1
1
,
=
,
=
2
3
4
0
1
1
3
0
x
A
x
y
b
z
=


To check if a unique solution exists, the
MATLAB function '
rank
' can be used
with the coefficient matrix
A
and the augmented matrix (
Ab
).
If the ranks of both
matrices are equal to the number of unknown variables, in this case 3, a unique solution
exists.
If the ranks are equal and less than 3, an infinite number of solutions exist, i.e.
the system is underconstrained.
Finally if the rank of
A
is one less than the rank of (
Ab
),
the equations are inconsistent, i.e the system is overconstrained and there is no solution.
Example 16.1.1
A=[1,4,7; 1,1,1; 2,3,4; 1 1 3];
b=[5;1;0;0];
rA=rank(A) % Check rank of A
rAb=rank([A b]) % Check rank of (Ab)
rA =
2
rAb =
3
Since the ranks are unequal, the system of equations are inconsistent and no
solution exists.
Suppose the
A
(4,3) element were +3 instead of 3.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Example 16.1.2
A=[1,4,7; 1,1,1; 2,3,4; 1 1 3];
b=[5;1;0;0];
rA=rank(A) % Check rank of A
rAb=rank([A b]) % Check rank of (Ab)
rA =
3
rAb =
3
In this case, the ranks are both equal to the number of unknowns so there is a
unique solution to the system.
The solution can be determined by transforming the
augmented matrix into an echelon form using the '
rref
' function, which stands for row
reduced echelon form, a Gauss elimination type of solution.
Example 16.1.3
format rat
rref([A b])
ans =
1
0
0
13/6
0
1
0
1/3
0
0
1
5/6
0
0
0
0
From the echelon form of (
Ab
)
the solution is given by
x
= 13/6,
y
= 1/3,
z
=5/6
When the coefficient matrix
A
is square (same number of equations as unknowns)
the MATLAB function '
det
' will also reveal whether there is a unique solution.
A
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 klee
 Linear Algebra, Linear Equations, unique solution

Click to edit the document details