Transcript Chapter 3
Chapter 8
Linear Algebraic Equations
and Matrices
Three individuals connected by bungee cords
Free-body diagrams
Newton’s
second law
m1 g k 2 ( x 2 x 1 ) k1 x 1 0
m2 g k3 ( x 3 x 2 ) k2 ( x 2 x1 ) 0
m g k ( x x ) 0
3
3
2
3
Rearrange the equations
[K] {x} = {b}
( k 1 k 2 ) x 1
k2 x1
k2 x 2
( k2 k3 ) x 2
k3 x 2
m1 g
k3 x 3
k3 x 3
m2 g
m3 g
Newton’s second law – equation of motion
Mass-spring
system
(similar to
bungee jumpers)
Kirchhoff’s current and voltage rules
Resistor
circuits
Linear Algebraic Equations
Solved single equations previously
f x 0
Now consider more than one variable and more
than one equation
f 1 x1 , x 2 ,...,xn 0
f 2 x1 , x 2 ,...,xn 0
f n x1 , x 2 ,...,xn 0
Linear Systems
Linear equations and constant coefficients
a11 x1 a12 x 2 ... a1n xn b1
a 21 x1 a 22 x 2 ... a 2 n xn b2
an1 x1 an 2 x 2 ... ann xn bn
aij and bi are constants
Forces on a Truss
Most obvious example in Civil Engineering
trusses: force balance at joints
a11 F1 a12 F2 ... a1 n Fn R1
a 21 F1 a 22 F2 ... a 2 n Fn R2
a n 1 F1 a n 2 F2 ... a nn Fn Rn
R
F1
F2
F3
Mathematical background
It is convenient to write system of equations
in matrix-vector form
[ A][ x] [b]
a11
a
21
a n 1
a12
a 22
an 2
or
[ A]{ x} {b}
a1 n x1 b1
a 2 n x 2 b2
a nn x n bn
Matrix Notations
Column 4 (second index)
a11
a
21
a31
A
a41
am 1
a12
a13
a14
a22
a23
a24
a32
a42
a33
a43
a34
a44
am 2
am 3
am 4
a1 n
a2 n
a3 n
a4 n
amn
Row 3
(first index)
Scalars, Vectors, Matrices
MATLAB treat variables as “matrices”
Matrix (m n) - a set of numbers arranged in
rows (m) and columns (n)
Scalar : 1 1 matrix
Row Vector : 1 n matrix ( [b] or b )
Column Vector : m 1 matrix ( [c] or {c} )
[a] 5.27
[b] b 5.02 2.3 7.21
5.02
[c ] { b} [b]T 2.3
7.21
1
3 2
5
[ D] 2
4 3.2 9.5
0.5 1 7.2 2
Square Matrix
Square matrix, m = n
Particularly important when solving simultaneous
equations in engineering applications
a11
a
21
[ A]
a31
a41
a12
a13
a22
a32
a23
a33
a42
a43
aii – principle or main diagonal
a14
a24
a34
a44
Matrix Operations
Transpose
a11
a
[ A] 21
a31
a41
a12
a13
a22
a32
a23
a33
a42
a43
a14
a24
a34
a44
a11
a
[ A]T 12
a13
a14
a21
a31
a22
a23
a32
a33
a24
a34
In MATLAB, transpose is A
Trace is sum of diagonal elements
In MATLAB, trace(A)
a41
a42
a43
a44
Matrix Transpose
x 4
2 3 ;
y 3 1 2
4
3
x 2 ;
y' 1
3
2
4 8
4
12
x * y 2 3 1 2 6 2
4
3
9
3 6
3
x * y 4 2 3 1 ( 4 )(3 ) ( 2 )(1) 3( 2 ) 4
2
Special Matrices
• symmetric matrices
a
b
[ A]
c
d
b
e
f
g
c
f
h
i
2 1
5
2 2
8
[ B] 1
8
3
2
4 5
6
1
0
d
g
i
j
4
6
5
1
2
0
1
3
3 4
aij = aji
T
[A] = [A]
Special Matrices
• Diagonal matrix
a11
[ A]
a22
a33
a44
• Identity matrix
1
1
[I ]
1
1
[A][I] = [I][A] = [A]
Special Matrices
Banded matrix – all elements are
zero, with the exception of a band
centered on the main diagonal
a11
a
21
[ A]
a12
a22
a32
a23
a33
a43
a34
a44
Tridiagonal – three
non-zero bands
Special Matrices
a11
a
21
[ A]
a31
a41
• upper triangular
a11
[ A]
• lower triangular
a22
a32
a33
a42
a43
a12
a13
a22
a23
a33
a44
a14
a24
a34
a44
Matrix Operation Rules
Matrix identity
[A] = [B] if and only if aij = bij for all i and j
Matrix Addition and Subtraction
[C] = [A] + [B] Cij = Aij + Bij
[C] = [A] [B] Cij = Aij Bij
Addition and Subtraction
Commutative
[A] + [B] = [B] + [A]
[A] [B] = [B] + [A]
Associative
( [A] + [B] ) + [C] = [A] + ( [B] + [C] )
( [A] + [B] ) [C] = [A] + ( [B] [C] )
( [A] [B] ) + [C] = [A] + ([B] + [C] )
Multiplication of Matrix by a Scalar
a11
a
[ A] 21
a31
a41
a12
a13
a22
a32
a23
a33
a42
a43
a14 1
a24 4
a34 5
a44 2
ga11
ga
[ B] g[ A] [ A] g 21
ga 31
g=5
ga 41
ga12
ga13
ga 22
ga 32
ga 23
ga 33
ga 42
ga 43
3 2
2
2
3
4
1 3
7
0
1
6
ga 14 5
ga 24 20
ga 34 25
ga 44 10
15 10
10
10
15
20
5 15
35
0
5
30
Matrix Multiplication
Visual depiction of how the rows and columns line up
in matrix multiplication
Matrix Multiplications
Recall how matrix multiplication works
a b
d e
g j
c
ag bh ci aj bk cl
h
k
f
dg eh fi dj ek fl
i l
g j
h k a b
d e
i l
ga jd gb je gc jf
c
ha
kd
hb
ke
hc
kf
f
ia ld
ib le ic lf
[A]*[B] [B]*[A]
Matrix Multiplication
Matrix multiplication can be performed only if the
inner dimensions are equal
Matrix Multiplication
Interior dimensions have to be equal
Ai j B jk Cik
For a vector
Ai j x j bi
We will be using square matrices
Ann xn bn
MATLAB
In Fortran, the matrix multiplication have to be done by Do
Loops
In MATLAB, it is automatic
A*B = C
Note no period ‘.’ (not element-by-element operation)
For vectors
A*x = b
Matrix Multiplication
Associative
( [A] [B] ) [C] = [A] ( [B] [C] )
Distributive
[A] ( [B] + [C] ) = [A] [B] + [A] [C]
([A] + [B] ) [C] = [A] [C] + [B] [C]
Not generally commutative
[A] [B] [B] [A]
Matrix Inverse
Matrix division is undefined
However, there is a matrix inverse for
non-singular square matrices
[A]1 [A] = [A] [A]1 = [I]
Multiplication of a matrix by the inverse
is analogous to division
Augmentation
a11
a
A 21
a 31
a 41
a11
a 21
A
a 31
a 41
a12
a13
a 22
a 23
a 32
a 33
a 42
a 43
a12
a 22
a 32
a 42
a13
a 23
a 33
a 43
a14
a 24
a 34
a 44
a14
a 24
a 34
a 44
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
Whatever you do to left-hand-side, do to the righthand side (useful when solving system of equations)
Augmented Matrix
a 11 x 1
a 21 x 1
a 31 x 1
a 41 x 1
a 12 x 2
a 22 x 2
a 32 x 2
a 42 x 2
a 11
a
A b 21
a 31
a 41
a 13 x 3
a 23 x 3
a 33 x 3
a 43 x 3
a 14 x 4
a 24 x 4
a 34 x 4
a 44 x 4
a 12
a 22
a 13
a 23
a 14
a 24
a 32
a 33
a 34
a 42
a 43
a 44
b1
b2
b3
b4
b1
b2
b3
b4
MATLAB Matrix Manipulations
>> A = [1 5 3 -4; 2 5 6 -1; 3 4 -2 5; -1 3 2 6]
A =
1
5
3
-4
2
5
6
-1
3
4
-2
5
-1
3
2
6
1
2
3
-1
5
5
4
3
3
6
-2
2
-4
-1
5
6
Create a matrix
>> A'
ans =
Matrix transpose
MATLAB Matrix Manipulations
Matrix Concatenation
>> C = A + B
C =
>> x = [5 1 -2 3];
>> y = [2 -1 4 2];
>> z = [3 -2 1 -5];
>> B = [x; y; x; z]
B =
6
6
1
-1
4
4
10
1
8
5
-4
8
2
1
3
1
( = A)
5
1
-2
3
>> C = C – B
2
-1
4
2
C =
5
1
-2
3
1
5
3
-4
3
-2
1
-5
2
5
6
-1
3
4
-2
5
-1
3
2
6
Addition and Subtraction
MATLAB Matrix Manipulations
Matrix multiplication and element-by-element operation
>> A*B
A =
ans =
1
5
3
-4
2
5
6
-1
18
7
8
42
3
4
-2
5
47
5
3
39
-1
3
2
6
28
-13
19
-14
29
-14
16
-21
B =
5
1
-2
3
>> A.*B
2
-1
4
2
ans =
5
1
-2
3
5
5
-6
-12
3
-2
1
-5
4
-5
24
-2
15
4
4
15
-3
-6
2
-30
A*B A.*B
MATLAB Matrix Manipulations
>> D = [2 4 3 1; 3 -5 1 2; 1 -1 3 2]
A =
1
5
3
-4
2
5
6
-1
2
4
3
1
3
4
-2
5
3
-5
1
2
-1
3
2
6
1
-1
3
2
D =
>> A*D
??? Error using ==> *
Inner dimension
must agree
A*D D*A
Inner matrix dimensions must agree.
>> D*A
ans =
18
45
26
9
-6
0
-19
10
6
18
-5
24
MATLAB Matrix Manipulations
>> A = [1 5 3 -4; 2 5 6 -1; 3 4 -2 5; -1 3 2 6]
>> format short; AI = inv(A)
AI =
-0.2324
0.2520
0.1606
-0.2467
0.2428
-0.1397
0.0457
0.1005
-0.1436
0.2063
-0.0862
0.0104
-0.1123
0.0431
0.0326
0.0718
>> A*AI
Matrix Inverse
ans =
1.0000
0
0
-0.0000
-0.0000
1.0000
0
0.0000
0.0000
0
1.0000
-0.0000
0.0000
0
0.0000
1.0000
MATLAB Matrix Manipulations
>> A = [1 5 3 -4; 2 5 6 -1; 3 4 -2 5; -1 3 2 6]
>> I = eye(4)
I =
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
>> Aug = [A I]
Aug =
1
5
3
-4
1
0
0
0
2
5
6
-1
0
1
0
0
3
4
-2
5
0
0
1
0
-1
3
2
6
0
0
0
1
>> [n, m] = size(Aug)
n =
4
m =
Matrix Augmentation
8
Bungee Jumpers
Jumper
Mass (kg) Spring constant (N/m) Unstretched cord length (m)
Top (1)
60
50
20
Middle (2)
70
100
20
Bottom (3)
80
50
20
m1 g k 2 ( x 2 x 1 ) k1 x 1 0
m2 g k3 ( x 3 x 2 ) k2 ( x 2 x1 ) 0
m g k ( x x ) 0
3
3
2
3
[K] {x} = {b}
k2
0 x1
( k1 k 2 )
k2 ( k2 k3 ) k3 x 2
0
k3
k 3 x 3
m1 g
m g
2
m 3 g
k1 = 50
k2 = 100
stiffer cord
k3 = 50
>> k1 = 50; k2 = 100; k3 = 50;
>> K=[k1+k2 -k2 0;-k2 k2+k3 -k3;0 -k3 k3]
K =
150 -100
0
-100
150
-50
0
-50
50
>> format short
>> g = 9.81; mg = [60; 70; 80]*g
mg =
588.6000
686.7000
784.8000
>> x=K\mg
x =
41.2020
55.9170
71.6130
>> x = inv(K)*mg
x =
41.2020
55.9170
71.6130
>> xi = [20; 40; 60];
>> xf = xi + x
xf =
61.2020
95.9170
Final positions of bungee jumpers
131.6130
TRUSS
4
5
F45
F14
H1
F24
1
V1
F35
F25
F12
2
F23
W = 100 kg
3
V3
Statics: Force Balance
Node 1
Node 2
Node 3
Node 4
Node 5
F y , 1
F x , 1
F y , 2
F x , 2
V1 F14 sin 0
F y , 3
F x , 3
F y , 4
F x , 4
F y , 5
F x , 5
V 3 F35 sin 0
H 1 F12 F14 sin 0
F24 sin F25 sin 100
F12 F23 F24 cos F25 cos 0
F23 F35 cos 0
F14 sin F24 sin 0
F14 cos F24 cos F45 0
F25 sin F35 sin 0
F25 cos F35 cos F45 0
Exampe: Forces in a Simple Truss
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0 1
sin
cos
0
0
0
0
0
1
0
0
0
0
sin
cos
sin
cos
0
0
0
0 1
0
sin
0 sin
0
0
0
0 1
0 0
0 0
0
0
0
0 0
0 0
0 0
0 cos
0
0
0
0
0
0
0
cos
0
0 sin
0
cos
0 V1 0
0 H 1 0
0 V 3 100
0 F12 0
sin
0 F14 0
cos
0 F23 0
0
0 F24 0
0
1 F25 0
sin
0 F35 0
cos 1 F45 0
0
0
0
0
Define Matrices A and b in script file
function [A, b]=Truss(alpha, beta, gamma, delta)
A = zeros(10,10);
A(1,1) = 1; A(1,5) = sin(alpha);
A(2,2) = 1; A(2,4) = 1; A(2,5) = cos(alpha);
A(3,7) = sin(beta); A(3,8) = sin(gamma);
A(4,4) = -1; A(4,6) = 1; A(4,7) = -cos(beta);
A(4,8) = cos(gamma);
A(5,3)= 1; A(5,9) = sin(gamma);
A(6,6) = -1; A(6,9) = -cos(delta);
A(7,5) = -sin(alpha); A(7,7)=-sin(beta);
A(8,5) = -cos(alpha); A(8,7) = cos(beta); A(8,10)=1;
A(9,8) = -sin(gamma); A(9,9) = -sin(delta);
A(10,8) = -cos(gamma); A(10,9) = cos(delta); A(10,10) = -1;
b = zeros(10,1); b(3,1)=100;
f = A\b
[A]{ f } = {b} { f } = [A]1 {b}