MPBzI3 Lecture7 PDF
MPBzI3 Lecture7 PDF
MPBzI3 Lecture7 PDF
MECE 390-A1
Numerical Methods of Mechanical Engineering
In this course, we denote components of a row vector, column vector and tensor respectively as
𝑏1 𝑎11 𝑎12 𝑎1𝑛
𝑎21 𝑎22 ⋯ 𝑎2𝑛
𝑏
𝒂 = [𝑎𝑖 ] = 𝑎1 , 𝑎2 , … 𝑎𝑛 , 𝒃 = [𝑏𝑖 ] = 2 and 𝒂 = [𝑎𝑖𝑗 ] = ⋮ ⋮ ⋱ ⋮
⋮
𝑏𝑛 𝑎𝑛1 𝑎𝑛2 ⋯ 𝑎𝑛𝑛
Matrix operations
a. Addition: 𝑨 = 𝑩 + 𝑪, 𝑨 + 𝑩 = 𝑩 + 𝑨: commutative, 𝑨 + 𝑩 + 𝑪 = 𝑨 + 𝑩 + 𝑪 : Associative.
b. Scalar multiplication: 𝑘𝑨 = 𝑩 ⇒ 𝑘𝐴𝑖𝑗 = 𝐵𝑖𝑗 (multiplying a scalar 𝑘 on each component of a
matrix i.e. 𝑘𝐴12 = 𝐵12 etc…
c. Matrix multiplication 𝑨 = 𝑩𝑪 ⇒ 𝑎𝑖𝑗 = 𝑏𝑖𝑘 𝑐𝑘𝑗 (summation over 𝑘 for 𝑘 = 1,2, … 𝑛).
Many complex engineering problems can be expressed as set of equations with many
variables. Solving all equations simultaneously is equivalent to finding the roots of all equations
with respect to all variables.
To study the numerical solution of systems of linear equations, let us define more precisely our
matrix notation. Given a system of 𝒏 equation and 𝒏 unknowns:
Examples of matrixes
Cramer’s Rule
𝑎11 𝑎12 𝑥1 𝑏1 𝑎11 𝑥1 + 𝑎12 𝑥2 = 𝑏1
Consider the 2 × 2 systems of equations 𝑎 𝑎22 𝑥2 = ⇒
21 𝑏2 𝑎21 𝑥1 + 𝑎22 𝑥2 = 𝑏2
𝑏2 −𝑎21 𝑥1
Eliminating 𝑥1 from latter equations shows that 𝑥2 = .
𝑎22
Thus 𝑑𝑒𝑡𝐴 𝑥1 = 𝑑𝑒𝑡𝐴1 , where 𝐴1 is obtained from 𝐴 by replacing the first column with the vector 𝒃.
𝑏 𝑎12 𝑎 𝑏1
i.e. 𝐴1 = 1 . Similarly, 𝑑𝑒𝑡𝐴 𝑥2 = 𝑑𝑒𝑡𝐴2 where 𝐴2 = 11 .
𝑏2 𝑎22 𝑎21 𝑏2
Note: in the above, the solution (𝑥𝑘 ) exist only if 𝑑𝑒𝑡𝐴 ≠ 0. For 𝑑𝑒𝑡𝐴 = 0 ⇒ Singularity (no solution!!)
Determinant may be evaluated in matlab using either the built in function ‘det’ or a personally
designed code (see, for example, Lecture7_determinant.m).
Example 1. Find solutions of the following linear equations using Cramer’s Rule
2𝑥1 + 𝑥2 = 1
2𝑥1 + 3𝑥2 = 2
2 1 1 𝑏 𝑎12 1 1
Ans. 𝐴 = ,𝑏= ⇒ 𝑑𝑒𝑡𝐴 = 2 × 3 − 2 × 1 = 4, Also we find that A1 = 1 = and
2 3 2 𝑏2 𝑎22 2 3
2 1
𝐴2 = . Thus 𝑑𝑒𝑡𝐴1 = 1 × 3 − 2 × 1 = 1 and 𝑑𝑒𝑡𝐴2 = 2 × 2 − 2 × 1 = 2. Consequently, we obtain
2 2
𝑑𝑒𝑡𝐴1 1 𝑑𝑒𝑡𝐴2 2
𝑥1 = = = 0.25 and 𝑥2 = = = 0.5
𝑑𝑒𝑡𝐴 4 𝑑𝑒𝑡𝐴 4
Example 2. Find solutions of the following linear equations using Cramer’s Rule (show 𝑥1 ONLY)
2𝑥1 − 𝑥2 + 𝑥3 = 4
4𝑥1 + 3𝑥2 − 𝑥3 = 2
3𝑥1 + 2𝑥2 − 2𝑥3 = 15
2 −1 1
Ans. 𝑑𝑒𝑡𝐴 = 4 3 −1 = 2 3 × −2 − −1 × 2 − −1 4 × −2 − −1 × 3 + 1 4 × 2 − 3 × 3
3 2 −2
= 2 −4 + −5 + −1 = −14
4 −1 1
𝑑𝑒𝑡𝐴1
To find 𝑥1 we require to compute: 𝑥1 = , where 𝐴1 = 2 3 −1
𝑑𝑒𝑡𝐴
15 2 −2
Thus we find 𝑑𝑒𝑡𝐴1 = −46
46
𝑥1 = − = 3.2857
−14
And similarly for others
Try matlab code: Lecture7_cramer.m
where 𝑀𝑖𝑘 is the minor. i.e. the determinant of the (n-1) by (n-1) submatrix of 𝐴 obtained by
deleting the 𝑖 𝑡ℎ row and the 𝑖 𝑡ℎ column.