You are on page 1of 18

GNE 333 - Engineering Analysis 1

Part 3 – Matrix Algebra

Matrix Operations

Dr. Yves Mansour


yves.mansour@lau.edu.lb

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 1
Objectives
 Understanding matrix notation.
 Being able to identify the following types of matrices: identity, diagonal,
symmetric, triangular, and tridiagonal.
 Knowing how to perform matrix multiplication and being able to assess
when it is feasible.
 Knowing how to represent a system of linear algebraic equations in matrix
form.
 Knowing how to solve linear algebraic equations with left division and
matrix inversion in MATLAB.

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 2
You’ve Got a Problem
Suppose that three jumpers are connected by bungee cords
and that you are asked to compute the displacement of
each of the jumpers as they reach equilibrium.
If we assume that each cord behaves as a linear spring
having a spring constant kj (N/m), free-body diagrams can
be developed for each jumper.
Newton’s 2nd law:

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 3
You’ve Got a Problem (cont.)
Because we are interested in the equilibrium (steady-state)
solution, the second derivatives can be set to zero.

The problem reduces to solving a system of 3 simultaneous


equations for the 3 unknown displacements.
In matrix form notation: [ 𝐴 ] [ 𝑥 ] =[ 𝑏]

[ ][ ] [ ]
𝑘1 +𝑘2 −𝑘2 0 𝑥1 𝑚1 𝑔
−𝑘2 𝑘2 +𝑘3 − 𝑘3 𝑥 2 = 𝑚2 𝑔
0 −𝑘3 𝑘3 𝑥3 𝑚3 𝑔

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Linear Systems - Direct Methods 4
Matrix Notation
A matrix consists of a rectangular
array of elements represented by a
single symbol.
designates an individual element of
the matrix.
A matrix with m rows and n columns
and is said to have a dimension of .
It is referred to as an m by n matrix.

A matrix with 1 row (m = 1) is called row vector:

[]
[ 𝑏 ] =[ 𝑏1 𝑏2 … 𝑏 𝑛 ]= ⌊ 𝑏 ⌋ 𝑐1
𝑐2
A matrix with 1 column (n = 1) is called column vector: [ 𝑐 ] = ⋮ = {𝑐}

𝑐𝑚
03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 5
Matrix Notation (cont.)
Matrices where m = n are called square matrices. [A] is for
example a 3×3 matrix.
The diagonal consisting of elements , , and is termed
the principal or main diagonal of the matrix.

[ ]
5 1 2
A symmetric matrix is one where the rows equal the [ 𝐴𝑠 ]= 1 3 7
columns, i.e., for all i’s and j’s, as in [As]. 2 7 8

[ ]
𝑎11 0 0
A diagonal matrix is a square matrix where all elements off
[ 𝐴𝑑 ]= 0 𝑎 22 0
the main diagonal are equal to zero, as in [Ad].
0 0 𝑎 33

[ ]
An identity matrix is a diagonal matrix where all elements 1 0 0
on the main diagonal are equal to 1, as in [I]. [ 𝐼 ]= 0 1 0
0 0 1

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 6
Matrix Notation (cont.)

[ ]
𝑢11 𝑢1 2 𝑢1 3
An upper triangular matrix is one where all the
[ 𝑈 ]= 0 𝑢 22 𝑢23
elements below the main diagonal are zero, as in [U]. 0 0 𝑢33

[ ]
𝑙11 0 0
An lower triangular matrix is one where all the
[ 𝐿 ] = 𝑙2 1 𝑙 22 0
elements above the main diagonal are zero, as in [L].
𝑙3 1 𝑙3 2 𝑙33

[ ]
𝑎 11 𝑎1 2 0 0
A banded matrix has all elements equal to zero, with
the exception of a band centered on the main diagonal, [ 𝐴 ] = 𝑎2 1 𝑎 22 𝑎2 3 0
0 𝑎3 2 𝑎 33 𝑎3 4
as in [A]. [A] is also called tridiagonal matrix. 0 0 𝑎4 3 𝑎 44

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 7
Matrix Operating Rules
To add two matrices, they must have same size.
+

Addition is commutative and associative :

The multiplication of a matrix [A] by a scalar g is obtained by multiplying every element


of [A] by g. For example, for a 3×3 matrix:

[ ] [ ]
𝑎 11 𝑎 12 𝑎1 3 𝑔 . 𝑎 11 𝑔 . 𝑎 12 𝑔 . 𝑎 13
[ 𝐴 ] = 𝑎 21 𝑎 22 𝑎 2 3 → [ 𝐷 ] =𝑔 . [ 𝐴 ] = 𝑔 . 𝑎 21 𝑔 . 𝑎 22 𝑔 . 𝑎 23
𝑎 31 𝑎 32 𝑎3 3 𝑔 . 𝑎 31 𝑔 . 𝑎 32 𝑔 . 𝑎 33
03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 8
Matrix Operating Rules (cont.)
The product of two matrices is represented as

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 9
Matrix Operating Rules (cont.)
If the dimensions of the matrices are suitable, matrix multiplication is associative
and distributive.

However, multiplication is not commutative, unless [A] and [B] are symmetric.

That is, the order of matrix multiplication is important.


Identity matrix [I] is the neutral element in multiplication:

If [A] is a square matrix, [A]×[I] = [I]×[A] = [A]


03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 10
Matrix Operating Rules (cont.)
The transpose of a square matrix involves transforming its rows into columns and
its columns into rows.
For example, for a 3×3 matrix [A], its transpose is designated [A]T

The element of the transpose is equal to the element of the original matrix.
The transpose allows a column vector to be written as a row, and vice versa.

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 11
Matrix Operating Rules (cont.)
A permutation matrix (also called a transposition matrix) is an identity matrix
with rows and columns interchanged.
For example:

Left multiplication:

Right multiplication:

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 12
Inverse of a Matrix
Matrix division is not a defined operation.
However, if a matrix [A] is square and nonsingular, there is another matrix [A]−1,
called the inverse of [A], for which:

For a 2×2 matrix: [ 𝐴 ] = [ 𝑎 11


𝑎 21
𝑎 12
𝑎 22 ]
[ 𝐴] =
−1 1
[
𝑎 22
𝑎 11 𝑎 22 − 𝑎 21 𝑎 12 −𝑎 2 1
− 𝑎12
𝑎11
=
]
1 𝑎22
det ⁡( 𝐴) − 𝑎21 [ − 𝑎 12
𝑎 11 ]
Determinant of a 2×2 matrix:det ( 𝐴 ) =𝑎 11 𝑎 22 − 𝑎21 𝑎12
If det(A) = 0, [A] is said to be singular and does not exist.

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 13
Inverse of a Matrix (cont.)

[ ]
𝑎11 𝑎 12 𝑎 13
For a 3×3 matrix: [ 𝐴 ]= 𝑎21 𝑎 22 𝑎2 3
𝑎3 1 𝑎3 2 𝑎3 3

Det ( 𝐴 ) = 𝑎11
|𝑎22
𝑎32
𝑎23
𝑎33 |
− 𝑎12
𝑎 21
𝑎 31 | 𝑎 23
𝑎 33 |
+ 𝑎13
𝑎 21
𝑎 31 | 𝑎2 2
𝑎 32 |

[ ]
| | | | | |
𝑇
𝑎 22 𝑎 23 𝑎 21 𝑎 23 𝑎 21 𝑎 22

𝑎 32 𝑎 33 𝑎 31 𝑎 33 𝑎 31 𝑎 32

𝐴 −1=
1
Det ( 𝐴)
𝑎
¿ − 12
𝑎32 | 𝑎13
𝑎33 | | 𝑎 11
𝑎 31
𝑎13
𝑎 33 | | −
𝑎 11
𝑎 31
𝑎 12
𝑎 32 |
¿
|𝑎12
𝑎22
𝑎13
𝑎23 | | −
𝑎 11
𝑎 21
𝑎 13
𝑎 23 | | 𝑎 11
𝑎 21
𝑎 12
𝑎 22 | cofactor matrix
03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 14
Example 8.1
MATLAB Matrix Manipulations
Problem statement. The following example illustrates how a variety of matrix manipulations
are implemented with MATLAB. Do also the calculations by hand.
>> A = [1 5 6; 7 4 2; -3 6 >> A*B >> P = [0 0 1; 0 1 0; 1 0
7] >> A.*B 0]
>> A’ >> D = [1 4 3; 5 8 >> PA = P*A
>> x = [8 6 9]; 1]; >> AP = A*P
>> y = [-5 8 1]; >> A*D
>> z = [4 8 2]; >> D*A
>> B = [x; y; z] >> AI = inv(A)
>> C = A + B >> A*AI
>> A = C − B >> I = eye(3)
03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 15
Representing Linear Algebraic Equations in Matrix Form
Matrices provide a concise notation for representing simultaneous linear equations.
For example, a 3 × 3 set of linear equations,

can be expressed in matrix form as

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 16
Resolution of Linear Algebraic Equations in Matrix Form
A formal way to obtain a solution of is to multiply each side of the equation by the
inverse of [A].
[ 𝐴]
−1
[ 𝐴 ] { 𝑥 }=[ 𝐴] −1 { 𝑏 } → [ 𝐼 ] { 𝑥 }={ 𝑥 }=[ 𝐴 ]−1 { 𝑏 }
If , is singular and solution cannot be determined.
In this case, there is a linear combination between the rows of the linear system.
If is said ill-conditioned (close to singular).
MATLAB provides two direct ways to solve systems of linear algebraic equations.
The most efficient way is to employ the backslash, or “left-division,” operator as in:

The 2nd is to use matrix inversion (but it is less efficient then backslash – CPU time wise):

03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 17
Example 8.2
Solving the Bungee Jumper problem with
Problem
MATLABstatement. Use MATLAB to solve the bungee
jumper problem described at the beginning of this chapter.
Also find the solution by hand calculation.
The parameters for the problem are

See “Example_8_2.m”
03/27/2024 GNE 333 - Engineering Analysis 1 – Part 3 – Matrix Algebra – Matrix Operations 18

You might also like