ES 240: Scientific and Engineering Computation. Chapter 8
Chapter 8: Linear Algebraic Equations and Matrices
Uchechukwu Ofoegbu
Temple University
ES 240: Scientific and Engineering Computation. Chapter 8
OverviewOverview
Matrix:– rectangular array of elements represented by a single
symbol (e.g. [A]).
Element– An individual entry of a matrix
– example: a23 – arow column
ES 240: Scientific and Engineering Computation. Chapter 8
Overview (cont)Overview (cont)
A horizontal set of elements is called a row and a vertical set of elements is called a column.
The first subscript of an element indicates the row while the second indicates the column.
The size of a matrix is given as m rows by n columns, or simply m by n (or m x n).
1 x n matrices are row vectors.
m x 1 matrices are column vectors.
ES 240: Scientific and Engineering Computation. Chapter 8
Special MatricesSpecial Matrices
Matrices where m=n are called square matrices. There are a number of special forms of square matrices:
Symmetric
A 5 1 2
1 3 7
2 7 8
Diagonal
A a11
a22
a33
Identity
A 1
1
1
Upper Triangular
A a11 a12 a13
a22 a23
a33
Lower Triangular
A a11
a21 a22
a31 a32 a33
Banded
A
a11 a12
a21 a22 a23
a32 a33 a34
a43 a44
ES 240: Scientific and Engineering Computation. Chapter 8
Matrix OperationsMatrix Operations
Equal Matrices– Two matrices are considered equal if and only if every element in the first
matrix is equal to every corresponding element in the second. – Both matrices must be the same size.
Matrix addition and subtraction– performed by adding or subtracting the corresponding elements. – Matrices must be the same size.
ES 240: Scientific and Engineering Computation. Chapter 8
Example Addition & SubtractionExample Addition & Subtraction
2 1 3 1 4 7
4 0 5 8 3 2
1 3 10
12 3 3
1 82 1 3
4 34 0 5
7 2
2 1 3 1 4 7
4 0 5 8 3 2
3 5 4
4 3 7
is not defined.
ES 240: Scientific and Engineering Computation. Chapter 8
Matrix MultiplicationMatrix Multiplication
Scalar matrix multiplication is performed by multiplying each element by the same scalar.
If A is a row matrix and B is a column matrix, then we can form the product AB provided that the two matrices have the same length.
The product AB is a 1x1 matrix obtained by multiplying corresponding entries of A and B and then forming the sum.
1
21 2 1 1 2 2n n n
n
b
ba a a a b a b a b
b
ES 240: Scientific and Engineering Computation. Chapter 8
Example Multiplying Row to ColumnExample Multiplying Row to Column
3
2 1 3 2
5
2 3 1 2 3 5 7
3
4 0 2 1 2
5
is not defined.
ES 240: Scientific and Engineering Computation. Chapter 8
Matrix MultiplicationMatrix Multiplication
If A is an mxn matrix and B is an nxq matrix, then we can form the product AB.
The product AB is an mxq matrix whose entries are obtained by multiplying the rows of A by the columns of B.
The entry in the ith row and jth column of the product AB is formed by multiplying the ith row of A and jth column of B.
c ij aikbkj
k1
n
ES 240: Scientific and Engineering Computation. Chapter 8
Example Matrix MultiplicationExample Matrix Multiplication
7 12 -5
-19 0 2
3 2 02 1 3
2 1 23 0 2
5 3 1
is not defined.
3 2 02 1 3
2 1 23 0 2
5 3 1
Matlab command: A*B Matlab command: A*B – no dot multiplication– no dot multiplication
ES 240: Scientific and Engineering Computation. Chapter 8
Matrix Inverse and TransposeMatrix Inverse and Transpose
The inverse of a square matrix A, denoted by A-1, is a square matrix with the property
A-1A = AA-1 = I,where I is an identity matrix of the same size. – Matlab command: inv(A), A^-1
The transpose of a matrix involves transforming its rows into columns and its columns into rows.
– (aij)T=aji– Matlab command: a’ or transpose(a)
ES 240: Scientific and Engineering Computation. Chapter 8
Example Example
Verify that is the inverse of 4 111 11
3 211 11
2 1.
3 4
4 1 2 1 1 011 113 3 4 0 1211 11
4 12 1 1 011 1133 4 0 1211 11
checks
checks
ES 240: Scientific and Engineering Computation. Chapter 8
Representing Linear AlgebraRepresenting Linear Algebra
Matrices provide a concise notation for representing and solving simultaneous linear equations:
a11x1 a12x2 a13x3 b1
a21x1 a22x2 a23x3 b2
a31x1 a32x2 a33x3 b3
a11 a12 a13
a21 a22 a23
a31 a32 a33
x1
x2
x3
b1
b2
b3
[A]{x} {b}
ES 240: Scientific and Engineering Computation. Chapter 8
Solving a Matrix EquationSolving a Matrix Equation
Solving a Matrix Equation – If the matrix A has an inverse, then the solution of the matrix equation
AX = B is given by X = A-1B.
ES 240: Scientific and Engineering Computation. Chapter 8
Example Solving a Matrix EquationExample Solving a Matrix Equation
Use a matrix equation to solve 2 4 2
3 7 7.
x y
x y
The matrix form of the equation is
2 4 2.
3 7 7
x
y
1 7 22 4 2 2 72
3 7 7 3 7 412
x
y
ES 240: Scientific and Engineering Computation. Chapter 8
Solving With MATLABSolving With MATLAB
MATLAB provides two direct ways to solve systems of linear algebraic equations [A]{x}={b}:– Left-divisionx = A\b
– Matrix inversionx = inv(A)*b
Disadvantages of the matrix inverse method:– less efficient than left-division – only works for square, non-singular systems.
ES 240: Scientific and Engineering Computation. Chapter 8
LabLab
Ex 8.9 (see pgs 193/194)