Chapter 8 Linear Algebraic Equations and Matrices.
-
date post
20-Dec-2015 -
Category
Documents
-
view
261 -
download
13
Transcript of Chapter 8 Linear Algebraic Equations and Matrices.
Chapter 8Chapter 8
Linear Algebraic Equations Linear Algebraic Equations and Matricesand Matrices
Three individuals connected by bungee cords
Free-body diagramsFree-body diagrams
Newton’s Newton’s second lawsecond law
0xxkgm
0xxkxxkgm
0xkxxkgm
2333
1222332
111221
)(
)()(
)(
gmxkxk
gmxkxkkxk
gmxkxkk
33323
23323212
122121
)(
)(
Rearrange the equations
[K] {x} = {b}
Newton’s second law – equation of motionNewton’s second law – equation of motion
Kirchhoff’s current and voltage rules
Mass-spring system
(similar to bungee jumpers)
Resistor circuits
Solved single equations previously
Now consider more than one variable and more than one equation
0xf
0x,...,x,xf
0x,...,x,xf0x,...,x,xf
n21n
n212
n211
Linear Algebraic EquationsLinear Algebraic Equations
Linear equations and constant coefficients
aij and bi are constants
nnnn22n11n
2nn2222121
1nn1212111
bxa...xaxa
bxa...xaxabxa...xaxa
Linear SystemsLinear Systems
nnnn22n11n
2nn2222121
1nn1212111
RFa...FaFa
RFa...FaFa
RFa...FaFa
Forces on a TrussForces on a TrussMost obvious example in Civil Engineeringtrusses: force balance at joints
F1
F2F3
R
}{}]{[][]][[ bxA or bxA
n
2
1
n
2
1
nn2n1n
n22221
n11211
b
b
b
x
x
x
aaa
aaa
aaa
Mathematical backgroundMathematical background
It is convenient to write system of equations in matrix-vector form
mn4m3m2m1m
n444434241
n334333231
n224232221
n114131211
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
A
Matrix NotationsMatrix Notations
Column 4
Row 3
(second index)
(first index)
Scalars, Vectors, MatricesScalars, Vectors, Matrices
MATLAB treat variables as “matrices”
Matrix (m n) - a set of numbers arranged in rows (m) and columns (n)
Scalar : 1 1 matrixRow Vector : 1 n matrix ( [b] or b )Column Vector : m 1 matrix ( [c] or {c} )
227150
592342
5231
D
217
32
025
bbc
21732025bb 275a
T
..
..][
.
.
.
][}{][
...][.][
Square matrix, m = nParticularly important when solving simultaneous
equations in engineering applications
aii – principle or main diagonal
44434241
34333231
24232221
14131211
aaaa
aaaa
aaaa
aaaa
A][
Square MatrixSquare Matrix
Transpose
In MATLAB, transpose is A
Trace is sum of diagonal elementsIn MATLAB, trace(A)
44434241
34333231
24232221
14131211
aaaa
aaaa
aaaa
aaaa
A][
44342414
43332313
42322212
41312111
T
aaaa
aaaa
aaaa
aaaa
A][
Matrix OperationsMatrix Operations
Matrix TransposeMatrix Transpose
4231234
2
1
3
324yx
639
426
8412
213
3
2
4
yx
2
1
3
y' ;
3
2
4
x
213y ;324x
)())(())((*
*
43016
31254
02381
15822
64125
B
jigd
ihfc
gfeb
dcba
A
][
][
• symmetric matrices
Special MatricesSpecial Matrices
aij = aji
[A]T = [A]
44
33
22
11
a
a
a
a
A][
• Diagonal matrix • Identity matrix
1
1
1
1
I ][
Special MatricesSpecial Matrices
[A][I] = [I][A] = [A]
Banded matrix – all elements are zero, with the exception of a band centered on the main diagonal
Special MatricesSpecial Matrices
4443
343332
232221
1211
aa
aaa
aaa
aa
A][Tridiagonal – three
non-zero bands
• lower triangular
44434241
333231
2221
11
aaaa
aaa
aa
a
A][
• upper triangular
44
3433
242322
14131211
a
aa
aaa
aaaa
A][
Special MatricesSpecial Matrices
Matrix Operation RulesMatrix 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 SubtractionAddition 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 ScalarMultiplication of Matrix by a Scalar
6132
0725
3124
4231
aaaa
aaaa
aaaa
aaaa
A
44434241
34333231
24232221
14131211
][
3051510
0351025
1551020
2010155
gagagaga
gagagaga
gagagaga
gagagaga
gAAgB
44434241
34333231
24232221
14131211
][][][
g = 5
Visual depiction of how the rows and columns line up in matrix multiplication
Matrix MultiplicationMatrix Multiplication
Matrix MultiplicationsMatrix Multiplications
Recall how matrix multiplication works
lficleibldia
kfhckehbkdha
jfgcjegbjdga
fed
cba
li
kh
jg
flekdjfiehdg
clbkajcibhag
li
kh
jg
fed
cba
[A]*[B] [B]*[A]
Matrix multiplication can be performed only if the inner dimensions are equal
Matrix MultiplicationMatrix Multiplication
Interior dimensions have to be equal
For a vector
We will be using square matrices
kikjji CBA
ijji bxA
nnnn bxA
Matrix MultiplicationMatrix Multiplication
MATLABMATLAB
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 MultiplicationMatrix 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 InverseMatrix 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
1000
0100
0010
0001
aaaa
aaaa
aaaa
aaaa
A
44434241
34333231
24232221
14131211
44434241
34333231
24232221
14131211
aaaa
aaaa
aaaa
aaaa
A
AugmentationAugmentation
Whatever you do to left-hand-side, do to the right-hand side (useful when solving system of equations)
444434241
334333231
224232221
114131211
baaaa
baaaa
baaaa
baaaa
bA
Augmented MatrixAugmented Matrix
4444343242141
3434333232131
2424323222121
1414313212111
bxaxaxaxa
bxaxaxaxa
bxaxaxaxa
b xaxaxaxa
MATLAB Matrix ManipulationsMATLAB 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
>> A'
ans =
1 2 3 -1
5 5 4 3
3 6 -2 2
-4 -1 5 6
Create a matrix
Matrix transpose
MATLAB Matrix ManipulationsMATLAB Matrix Manipulations
>> x = [5 1 -2 3];
>> y = [2 -1 4 2];
>> z = [3 -2 1 -5];
>> B = [x; y; x; z]
B =
5 1 -2 3
2 -1 4 2
5 1 -2 3
3 -2 1 -5
>> C = A + B
C =
6 6 1 -1
4 4 10 1
8 5 -4 8
2 1 3 1
>> C = C – B ( = A)C =
1 5 3 -4
2 5 6 -1
3 4 -2 5
-1 3 2 6
Matrix Concatenation
Addition and Subtraction
MATLAB Matrix ManipulationsMATLAB Matrix Manipulations
A =
1 5 3 -4
2 5 6 -1
3 4 -2 5
-1 3 2 6
B =
5 1 -2 3
2 -1 4 2
5 1 -2 3
3 -2 1 -5
>> A*B
ans =
18 7 8 42
47 5 3 39
28 -13 19 -14
29 -14 16 -21
>> A.*B
ans =
5 5 -6 -12
4 -5 24 -2
15 4 4 15
-3 -6 2 -30
Matrix multiplication and element-by-element operation
A*B A*B A.*B A.*B
MATLAB Matrix ManipulationsMATLAB Matrix Manipulations
>> D = [2 4 3 1; 3 -5 1 2; 1 -1 3 2]
D =
2 4 3 1
3 -5 1 2
1 -1 3 2
>> A*D
??? Error using ==> *
Inner matrix dimensions must agree.
>> D*A
ans =
18 45 26 9
-6 0 -19 10
6 18 -5 24
A =
1 5 3 -4
2 5 6 -1
3 4 -2 5
-1 3 2 6
Inner dimension must agree
A*D D*A
MATLAB Matrix ManipulationsMATLAB 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
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
Matrix Inverse
MATLAB Matrix ManipulationsMATLAB 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 = 4m = 8
Matrix Augmentation
Bungee JumpersBungee Jumpers
gm
gm
gm
x
x
x
kk0
kkkk
0kkk
0xxkgm
0xxkxxkgm
0xkxxkgm
3
2
1
3
2
1
33
3322
221
2333
1222332
111221
)(
)(
)(
)()(
)(
[K] {x} = {b}
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
>> 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]*gmg = 588.6000 686.7000 784.8000
>> x=K\mgx = 41.2020 55.9170 71.6130
>> xi = [20; 40; 60]; >> xf = xi + xxf = 61.2020 95.9170 131.6130
>> x = inv(K)*mgx = 41.2020 55.9170 71.6130
k1 = 50
k2 = 100 stiffer cord
k3 = 50
Final positions of bungee jumpers
1
4
2 3
5
F14
F23F12
F24
F45
H1
F35
F25
V3V1
TRUSSTRUSS
W = 100 kg
Statics: Force BalanceStatics: Force Balance
0FFFF
0FFF
0FFFF
0FFF
0FFF
0FVF
0FFFFF
100FFF
0FFHF
0FVF
4535255x
35255y
4524144x
24144y
35233x
3533y
252423122x
25242y
141211x
1411y
coscos
sinsin
coscos
sinsin
cos
sin
coscos
sinsin
sin
sin
,
,
,
,
,
,
,
,
,
,
Node 1
Node 2
Node 3
Node 4
Node 5
Exampe: Forces in a Simple TrussExampe: Forces in a Simple Truss
0
0
0
0
0
0
0
100
0
0
F
F
F
F
F
F
F
V
H
V
1coscos0000000
0sinsin0000000
100cos0cos0000
000sin0sin0000
0cos00100000
0sin00000100
00coscos101000
00sinsin000000
00000cos1010
00000sin0001
45
35
25
24
23
14
12
3
1
1
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
Define Matrices A and b in script file
[A]{ f } = {b} { f } = [A]1 {b}