0% found this document useful (0 votes)
88 views23 pages

Computations in Mechanical Engineering: Matrices

The document discusses matrices including definitions, operations, and properties. Matrices can represent linear algebra concepts and are used in mechanical engineering computations. Common matrix operations like addition, multiplication, and transpose are examined.

Uploaded by

Tanaka Okada
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views23 pages

Computations in Mechanical Engineering: Matrices

The document discusses matrices including definitions, operations, and properties. Matrices can represent linear algebra concepts and are used in mechanical engineering computations. Common matrix operations like addition, multiplication, and transpose are examined.

Uploaded by

Tanaka Okada
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

WIDENER UNIVERSITY School of Engineering

Third Edition
Tradition & Excellence Since 1821 Mechanical Engineering

TOPIC

ME 354

03 Computations in
Mechanical Engineering

Matrices

© Tulong Zhu, All rights reserved.


That’s THE MATRIX

What is a MATRIX ?

is
Matrix

The

03 - 2
Matrices: Definition
Definition • A matrix is a rectangular array of elements written as

 a11 a12  a1n  • A matrix with m rows and n


a  a2 n 
 21 a22  columns
A
      • aij is the element of the
a  amn  matrix A.
 m1 am 2

 An m n matrix
 A matrix of size m n
 A matrix of order m n
 Sometimes A is denoted as A = [aij] or (aij)

Equivalent • Two matrices A = [aij] and B = [bij] are equal if


Matrices  They are of the same size, and
 The corresponding elements are equal, i.e.,
aij = bij

03 - 3
Matrices Operations: Addition & Scalar Multiplication
Addition • Two matrices of the same size can be added by performing
element-by-element addition, i.e.,
 a11 a12  a1n   b11 b12  b1n 
a  a2 n  b  b2n 
 21 a22 
b22
A B   21 
           
a  amn  b
 m1 am 2  m1 bm 2  bmn 

 a11  b11 a12  b12  a1n  b1n 


a b a22  b22  a2n  b2n 
C AB   21 21 
     
a  b  amn  bmn 
 m1 m1 am 2  bm 2

Scalar  ka11 ka12  ka1n 


Multipl.  ka  ka2n 
21 ka22
• kA   
     
ka  kamn 
 m1 kam 2
03 - 4
Matrices Operations: Matrix Multiplication
Matrix • If A is m  n and B is n  p , the C = AB is m  p
Multiplica-
tion  a11 a12  a1n   b11 b12  b1 p 
a  a2 n  b  b2 p 
 21 a22   21 b22 
A B
           
a b  bnp 
 m1 am 2  amn   n1 bn 2
 b1 j 
 c11 c12  c1 p  b 
cij  [ai1 ai 2  ain ] 
2j
c  c2 p 
 21 c22    
C b 
     
c  nj 
 m1 cm 2  cmp   ai1b1 j  ai 2b2 j    ain bnj

Notes  Unless m = p, BA is not defined.


 AB  BA even if both AB and BA are defined.
03 - 5
Matrices Operations: Transpose
Transpose • If A is m  n , the transpose AT, (A’) is n  m, given by

 a11 a12  a1n   a11 a21  am1 


a  a2 n  a  am 2 
 21 a22 
a22
A AT  A   12 
           
a  amn  a  amn 
 m1 am 2  1n a2 n

Notes  A T T
A

 ( AB )T  BT AT

Row and • A row vector, x = [x1, x2, …, , xn ]can be considered as a matrix


Column of size 1  n.
Vectors
 y1 
y 
• A column vector, y   
2
  
y 
 m
03 - 6
can be considered as a matrix of size m  1.
Matrices Operations: Properties
Properties • In the following properties, all operations are assumed to be
definable.

• A+B=B+A

• (A + B) + C = A + (B + C)

• A(B + C) = AB + AC

• (A + B)C = AC + BC

• k(A + B) = kA + kB

• A(BC) = (AB)C

• (AB)T = BTAT

• AB  BA for most matrices.

03 - 7
Matrix Operations: MATLAB© Commands
Types Operation Command Math Form
Basic Addition (subs) AB AB
Operations Scalar Multipl. k*A kA
Transpose A’ AT or A’
Multiplication A*B AB
Matrix Single Element A(i,j) aij
Index
Row A(i,:) [ai1, ai2, …, ain]
Column A(:,j) [a1j, a2j, …, amj]T
Sub-matrix A(i:j,k:l) A sub-matrix of A from rows i to
j and from columns k to l
Define Empty matrix [] Empty matrix
Special Matrix of 1s ones(m,n) m  n matrix of ones
Matrices
Matrix of 0s zeros(m,n) m  n matrix of zeros
Matrix of random rand(m,n) m  n matrix of random
numbers numbers
03 - 8
MATLAB© Element-by-Element Operations
Operation Command Math Form
Multiplication A.*B  a11b11  a1nb1n 
    
 
am1bm1  amnbmn 
Power A.^k  a11k
 a1kn 
 
    
a k  k 
amn
 m1 
Function f(A)  f (a11 )  f (a1n ) 
    
 
 f (am1 )  f (amn )
Add Scalar A+k  a11  k  a1n  k 
    
 
am1  k  amn  k 

See Ex03_01.m for matrix operations.


03 - 9
Square and Symmetric Matrices
Square • A square matrix has the same numbers of rows and columns.
Matrices  a11 a12  a1n 
a a22  a2n  • aii : diagonal elements
A 21 
      • aij (i  j ) off-diagonal elements
a 
 n1 an 2  ann 
Symmetric • A square matrix A with elements aij = aji is called a symmetric
Matrix matrix.
 a11 a12  a1n 
a a22  a2 n 
A   12 
     
a  ann 
 1n a2 n

Fact  A = AT for a symmetric matrix A.


An  xx  xy  xz 
Example  
 The stress matrix σ   xy  yy  yz 
  xz  yz  zz 
 
03 - 10
Square Matrices: Diagonal and Identity Matrices
Diagonal • A special symmetric matrix in which all the OFF-DIAGONAL
Matrices elements are zero.
d11 0  0 
 0 d  0 
D 22 
     
 0 0  d nn 

Identity • A special diagonal matrix with all diagonal elements being 1.


Matrix I
1 0  0
0 1  0
I 
   
0 0  1

 >> eye(n)

Note  For any square matrix Q, QI = IQ = Q

03 - 11
Determinants
Definition • The determinant of a square matrix A (n  n) is a number, denoted
as det(A) or |A|.
How to • The determinant can be computed using the Laplace expansion.
Compute? To do that, the minor and the cofactor need to be defined.
Minor  The minor of the element aij designated Mij is the n–1  n –1
submatrix of A by deleting row i and column j. For example
 a11 a12  a1n  a21 a23  a3n 
a a22  a2n  a a33  a3n 
A 21  M12   31 
           
a   a  
 n1 a n2 a nn   n1 a n3 a nn 
Cofactor  The cofactor of aij, designated Aij is value (–1)i+j det(Mij).
Laplace Exp • The determinant of A can be determined using all elements and
their cofactors of a row OR a column as follows:

 
n n
k j
Expand by
 detA    akj Akj    1 akj det M kj 
Row k j 1 j 1
n n
ik
 detA    aik Aik    1 aik detM ik 
Expand by
Column k 
03 - 12 i 1 i 1
Determinants of Order 2 and 3: Expand by 1st Row
a a 
• A 2nd order matrix A   11 12 
a21 a22 

A   111 a11a22   11 2 a12 a21  a11a22  a12 a21

 b11 b12 b13 


• A 3rd order matrix B  b21 b22 b23 

b31 b32 b33 

11 b22 b23 21 b12 b13 31 b12 b13


B   1 b11   1 b21   1 b31
b32 b33 b32 b33 b22 b23

B  b11 b22b33  b32b23   b21 b12b33  b32b13   b31 b12b23  b22b13 

B  b11b22b33  b12b23b31  b13b21b32  b31b22b13  b32b23b11  b33b21b12


– – –
b11 b12 b13 b11 b12
b21 b22 b23 b21 b22 This scheme is applied
to matrix of any order

b31 b32 b33 b31 b32
03 - 13 + + +
Determinants: Properties and MATLAB©
Properties • If A has a row or column of zeros, det(A) = 0
• If any two rows (or columns) of A are interchanged, the sign of
det(A) is changed.
• If all elements of a row ( or column) of A are multiplied by the
same number k, then the determinant becomes k det(A), e.g.,
ka11 ka12  ka1n a11 a12  a1n
a21 a22  a2 n a21 a22  a2 n
k
       
am1 am 2  amn am1 am 2  amn

 det(kA) = kn det(A) ( A is or order n)


• The determinant of a diagonal matrix is the product of the
diagonal elements.
• det(AT) = det(A)
• det(AB) = det(A) det(B)

03 - 14
• >> det(A) 
Square Matrices: Inverse
Reciprocal • For a number a  0, aa–1 = a–1a = 1, a–1 is the inverse of a.
Inverse • Inverse of a square matrix A, designated A–1 is such that
Matrix AA–1 =A–1A = I
 The inverse A–1 may not exist.
 If the inverse A–1 exists, A is said to be invertible or
nonsingular. Otherwise, A is noninvertible or more
commonly singular.
 If A is invertible, then det(A)  0, vice versa.
 Only a square matrix can have an inverse.
 I–1 = I
 (AB)–1 = B–1 A–1
How? • Using cofactors. 
• Solve for each element in A–1 from AA–1 = I 
• Using elementary row operations. 
• >>inv(A), >>rref(A) 
03 - 15
• …
Inverse Matrix: Using cofactors
Cofactors • Recall the cofactor Aij
 The minor of the element aij designated Mij is the n–1  n –1
submatrix of A by deleting row i and column j. For example
 a11 a12  a1n  a21 a23  a3n 
a  a2 n  a a33  a3n 
 21 a22 
A M12   31 
           
a  ann  a 
 n1 an 2  n1 an3  ann 
 Aij = (–1)i+j det(Mij).

Inverse T
 A11 A12  A1n 
Matrix A A22  A2n 
1 adjA    21 
1
• A  adjA 
 detA   
A
   
 n1 An 2  Ann 

 For A to be invertible, det(A) must not be zero.


03 - 16
Inverse Matrix: Elementary Row Operations
Elementary • Interchange two rows (Ri  Rj).
Row • Multiply a row by some nonzero constant (kRi).
Operations • Add a multiple of a row to another row(kRj + Ri).
Inverse • Form the augmented matrix that has A on the left and the
Matrix from identity matrix (same size as A), I, on the right, [A | I ].
Elem. Row
Operations • Perform elementary row operations on the augmented matrix
until the left part (at A) becomes an identity matrix, or a row of
zeros appears on the left part.
 If the procedure produces a row of zeros, then the matrix A
is singular (noninvertible).

 If it produces an identity matrix, then the matrix on the right


of the augmented matrix is the inverse, A–1, i.e., the original
augmented matrix [A | I ] becomes [I | A–1 ]
• MATLAB has commands to do this procedure:
>>rref[A eye(n)] [more accurate than >>inv(A)]
>>rrefmovie[A eye(n)] (step by step display)
03 - 17
Inverse from Ele. Row Operations: An Example
3  1 0  3  1 0 1 0 0
A  1 1 2 The augmented matrix 1 1 2 0 1 0 R1  R2
   
0 2 4 0 2 4 0 0 1

1 1 2 0 1 0 1 1 2 0 1 0
3 –3R1 + R2 0  4  6 1  3 0 R2  R3
1 0 1 0 0  
 
0 2 4 0 0 1 0 2 4 0 0 1

1 1 2 0 1 0 1 1 2 0 1 0  –R + R
0 2 0 1 2 0 0 1 / 2  2 1
4 0 0 1 1/2 R2   4R2 + R3
 
0  4  6 1  3 0 0  4  6 1  3 0 
1 0 0 0 1  1 / 2 1 0 0 0 1  1 / 2
0 1 2 0 0 1 / 2  1/2 R3 0 1 2 0 0 1 / 2  –R3 + R2
   
0 0 2 1  3 2  0 0 1 1 / 2  3 / 2 1 

1 0 0 0 1  1/ 2   0 1  1/ 2 
0 1 0  1 3  3 / 2  A 1    1 3  3 / 2 See Ex03_02.m.
   
0 0 1 1 / 2  3 / 2 1  1 / 2  3 / 2 1 
03 - 18
Square Matrices: Orthogonal Matrices
Orthogonal • An orthogonal matrix Q is an n  n matrix that is invertible and
Matrices Q–1 = QT or QTQ = QQT = I

Example cos  sin  


 The vector transformation matrix Q   is an
orthogonal matrix.  sin  cos 

T  cos sin   cos  sin  


Q Q
 sin  cos   sin  cos 
 cos2   sin 2   sin  cos  sin  cos 
 
 sin  cos  sin  cos cos   sin 
2 2

1 0 
  I
0 1 
Similarly, QQT = I

Theorem • The n  n matrix Q is orthogonal if and only if the columns (and


rows) of Q forms an orthonormal system.
03 - 19
Square Matrices: Triangular Matrices
Triangular • Lower Triangular Matrix • Upper Triangular Matrix
Matrices
 a11 0  0  a11 a12  a1n 
a  0   0 a  a2 n 
 21 a22 
A A 22 
           
a  ann   0 
 n1 an 2  0  a nn 

 The diagonal matrix and the identity matrix are special


triangular matrices. They are both lower and upper triangular
matrices.

Properties • Det(A) = |A| = a11a22…ann


• The inverse of an upper (lower) triangular matrix is up (lower)
triangular.
• The product of two upper (lower) triangular matrices is upper
(lower) triangular.

• The eigenvalues of a triangular matrix are the diagonal elements.


03 - 20
LU Factorization (Decomposition)
LU • Any nonsingular square matrix A may be decomposed into the
Factoriza- product of two triangular matrices as,
tion
A = LU

1 0  0
l 1  0
• A unit lower triangular
L   21  matrix with all diagonal
     elements equal to 1
l  1
 n1 ln 2

u11 u12  u1n 


 0 u  u2n 
U 22  • An upper triangular
      matrix.
 0 0  unn 

03 - 21
LU Factorization: Equations
Manual  a11 a12  a1n   1 0  0 u11 u12  u1n 
a a22  a2n   l21 1  0  0 u22  u2n
A   21   
                
a  ann   ln1
 n1 an 2 ln2  1  0 0  unn

How to Get • (1st row of L)  (All columns of U)  1st row of U, u1j = a1j
lij and uij?
• (2nd row of L)  (All columns of U)  2nd rows of L and U:
l21  a21 / u11, u2 j  a2 j  l21u1 j

• (ith row of L)  (All columns of U)  ith rows of L and U:


j 1 i 1
lij  (aij   lik ukj ) / u jj , uij  aij   lik ukj
k 1 k 1

 When calculating lij, ujj is divided. This will generate


computational error if |ujj| is very small.
 To reduce the error, the LU factorization with pivoting
(exchanging rows and/or columns in A) should be used
(MATLAB uses row exchange!!).
03 - 22
LU Factorization: MATLAB©
>>[L,U,P]=lu(A)
• Provides the L, U and P (permutation) matrices. The
permutation matrix is basically an identity matrix with rows
and columns reordered. P reveals the information about how
rows in A are changed before the factorization is performed.
 The process from the identity matrix I to P is the same as
the process of exchanging rows in A, e.g.,
1 0 0 
P  0 0 1 
Shows that the 2nd and 3rd rows are
  exchanged
0 1 0

• The actual factorization in MATLAB (and it should be the way


factorization is performed to reduce errors) is
PA = LU, not A = LU

See Ex03_03.m

03 - 23

You might also like