E Example l CSE 541 – Numerical Methods • Suppose we have three masses all connected by Linear Systems y springs. i • Each spring has the same constant k. constant k. • Simple force balance gives us accelerations in terms of displacements. di l S Simple Force Equation l F E Simple Force Equation S l F E • If we attach the masses and then let go, physically we • Recall from elementary know that it will oscillate physics that F=ma or physics, that F ma , or • Crucial question is what is the steady state Crucial question is what is the steady state – i.e., no acceleration ma=F ). − + = 3 kx 2 kx 0 m g 1 2 1 2 d d ( ( ) ) = − + − m x 2 k x x m g kx − + − = 2 kx 3 kx kx m g 1 1 2 1 1 1 2 1 2 3 2 dt − + = 0 kx kx m g 2 d d 2 3 3 ( ( ) ) = − + − − m x k k ( ( x x ) ) m g 2 2 k k x x • How do we solve such a linear system of equations? 2 2 3 2 2 2 1 2 dt • Occurs in many circumstances: mass balances, circuit d 2 design, stress-strain, weather forecasting, light = − − m m x x m m g g k k ( ( x x x x ) ) propagation, etc. i 3 3 3 3 2 2 dt
S Systems of Equations f E S Systems of Equations f E • Three different things can happen: • This simple example produces 3 equations in three unknowns: – Planes intersect at a single point. – A unique solution to the system of equations. • Geometrically this represents 3 planes in space. S Systems of Equations f E S Systems of Equations f E • Planes do not intersect at all: (At least two • Planes intersect at an infinite number of are parallel). points (plane or line). parallel planes
S Systems of Equations f E S Systems of Equations f E • How do we know whether a unique solution • In general, we may have n equations in n exists? unknowns unknowns. • How do we find such a solution? • Can we find a solution? • Can we program an algorithm to efficiently C l ith t ffi i tl find a solution? • Is it well behaved? Accuracy? Convergence? Stability? Wh What is a Matrix? M ? M Matrix Definitions D f • A matrix is a set of elements, organized into • n x m Array of Scalars ( n Rows and m Columns) rows and columns rows and columns – n : row dimension of a matrix, m : column dimension , – m = n � square matrix of dimension n rows – Element { } { } = = a ij , i 1 , , n , j j 1 , , m K K ⎡ ⎡ ⎤ ⎤ a b b ij ⎡ ⎡ ⎤ ⎤ a a ... a [ ] 11 12 1 n ⎢ ⎥ = a A [ ] a a ... a ⎢ ⎢ ⎥ ⎥ ⎢ ⎥ ij = = 21 22 2 n columns A a ⎢ ⎢ ⎥ ⎥ ij j mxn mxn c d ⎣ ⎦ ⎢ ⎥ a a ... a ⎣ ⎦ m 1 m 2 mn
M Matrix Definitions D f Basic Matrix Operations B M O • Column Matrices and Row Matrices • Addition (just add each element) – Column matrix ( n x 1 matrix): ( ) – Each matrix must be the same size! – Each matrix must be the same size! [ ] ⎡ b ⎤ = + = + a b C A B 1 ⎢ ⎥ ij ij b + + ⎡ ⎡ ⎤ ⎤ ⎡ ⎡ ⎤ ⎤ ⎡ ⎡ ⎤ ⎤ a b e f f a e b f f [ ] [ ] ⎢ ⎢ ⎥ ⎥ = = 2 b b + = b b ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ i + + M c d g h c g d h ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎢ ⎥ b ⎣ ⎣ ⎦ ⎦ • Properties of Matrix-Matrix Addition • Properties of Matrix-Matrix Addition n n – Row matrix (1 x n matrix): + = + – Commutative: A B B A a = [ a i ] = [a 1 a 2 … a n ] ( ( ) ) ( ( ) ) + + + + = = + + + + – Associative: Associative: A A B B C C A A B B C C B Basic Matrix Operations M O B Basic Matrix Operations M O • Subtraction • Scalar-Matrix Multiplication [ [ ] ] α α = = α α a a A A − − ⎡ ⎡ a b ⎤ ⎤ ⎡ ⎡ e f ⎤ ⎤ ⎡ ⎡ a e b f ⎤ ⎤ ij − = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ − − c d g h c g d h ⎣ ⎣ ⎦ ⎦ ⎣ ⎣ ⎦ ⎦ ⎣ ⎣ ⎦ ⎦ • Properties of Scalar-Matrix Multiplication ( ( ) ) ( ( ) A ) α α β β = αβ αβ A A A αβ = βα A A
B Basic Matrix Operations M O Matrix Multiplication M M l l Matrices A and B have these dimensions: • Matrix-Matrix Multiplication – A : n x l matrix, B : l x m � C : n x m matrix – A : n x l matrix B : l x m � C : n x m matrix [ ] = = c C AB ij [n x m] and [p x q] [n x m] and [p x q] l ∑ = c a b ij ik kj = k 1 – example l + + ⎡ a b ⎤ ⎡ e f ⎤ ⎡ ae bg af bh ⎤ = ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ + + + + c c d d g g h h ce ce dg dg cf cf dh dh ⎣ ⎣ ⎦ ⎦ ⎣ ⎣ ⎦ ⎦ ⎣ ⎣ ⎦ ⎦ Matrix Multiplication M M l l M Matrix Multiplication M l l The resulting matrix will have the dimensions: Matrices A and B can be multiplied if: [ [n x m] and [p x q] ] d [ ] [ [n x m] and [p x q] ] d [ ] m = p n x q
Computation: A x B = C Computation: A x B = C ⎡ ⎡ ⎤ ⎤ 2 3 2 3 A = a 11 a 12 ⎡ ⎤ ⎥ and B = 1 1 1 ⎡ ⎤ [2 x 2] ⎢ A = ⎢ ⎥ 1 1 ⎣ ⎣ ⎦ ⎦ a 21 a 22 ⎢ ⎢ ⎥ ⎥ ⎣ ⎣ ⎦ ⎦ 1 0 2 1 0 2 ⎢ ⎥ ⎣ ⎦ 1 0 B = b 11 b 12 b 13 ⎡ ⎤ [2 x 3] [3 x 2] [2 x 3] ⎢ ⎢ ⎥ ⎥ ⎣ ⎣ ⎦ ⎦ b b 21 b 22 b 23 b b A and B can be multiplied + + + + = + = + = ⎡ ⎡ a b a b a b a b a b a b ⎤ ⎤ ⎡ 2 * 1 3 * 1 5 2 * 1 3 * 0 2 2 * 1 3 * 2 8 ⎤ ⎡ 5 2 8 ⎤ 11 11 12 21 11 12 12 22 11 13 12 23 = ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ C ⎢ ⎥ = + = + = + = = C 1 * 1 1 * 1 2 1 * 1 1 * 0 1 1 * 1 1 * 2 3 2 1 3 ⎢ ⎥ ⎢ ⎥ + + + a b a b a b a b a b a b ⎣ ⎦ 21 11 22 21 21 12 22 22 21 13 22 23 ⎢ + = + = + = ⎥ ⎢ ⎥ 1 * 1 0 * 1 1 1 * 1 0 * 0 1 1 * 1 0 * 2 1 1 1 1 ⎣ ⎦ ⎣ ⎦ [2 x 3] [2 x 3] [3 x 3] Computation: A x B = C Computation: A x B = C M t i M lti li Matrix Multiplication ti ⎡ ⎡ 2 3 2 3 ⎤ ⎤ • Is AB = BA? Maybe, but maybe not! and B = 1 1 1 ⎡ ⎤ ⎢ ⎥ A = 1 1 ⎡ ⎤ ⎡ ⎤ ⎡ + ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ + ⎤ ⎢ ⎢ ⎥ ⎥ a b e f ae bg ... e f a b ea fc ... ⎣ ⎣ ⎦ ⎦ 1 0 2 1 0 2 = = = = ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ c d g h ... ... g h c d ... ... ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ 1 0 [3 x 2] [2 x 3] Result is 3 x 3 • Heads up: multiplication is NOT commutative! ⎡ + = + = + = ⎤ ⎡ ⎤ 2 * 1 3 * 1 5 2 * 1 3 * 0 2 2 * 1 3 * 2 8 5 2 8 ⎢ ⎢ ⎥ ⎥ ⎢ ⎢ ⎥ ⎥ = + = + = + = = C 1 * 1 1 * 1 2 1 * 1 1 * 0 1 1 * 1 1 * 2 3 2 1 3 ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ + = + = + = 1 * 1 0 * 1 1 1 * 1 0 * 0 1 1 * 1 0 * 2 1 1 1 1 ⎣ ⎦ ⎣ ⎦ [3 x 3]
M Matrix Multiplication M l l The Identity Matrix Th Id M • Properties of Matrix-Matrix Multiplication • Identity Matrix, I, is a Square Matrix: ( ( ) ) ( ( ) C ) ⎡ ⎤ 1 0 0 = = A A BC BC AB AB C = [ ] ⎧ ⎧ 1 1 if if i i j j ⎢ ⎢ ⎥ ⎥ = = = a , a I 0 1 0 ⎨ I ≠ ⎢ ⎥ AB BA ij ij 0 otherwise ⎩ ⎢ ⎥ 0 0 1 ⎣ ⎣ ⎦ ⎦ • Properties of the Identity matrix: – AI = A IA = A – Multiplying a matrix with the Identity matrix does not change the initial matrix. Vector Operations V t O ti Matrix Transpose M T ⎡ a ⎤ • Vector: 1 x N matrix • Transpose : interchanging the rows and columns of ⎢ ⎢ ⎥ ⎥ • Interpretation: a line in r r a matrix. = b v N dimensional space [ ] ⎢ ⎥ = T a A • Dot Product, Cross ji ⎢ ⎢ ⎥ ⎥ ⎣ c ⎣ ⎦ ⎦ Product, and Magnitude • Properties of the Transpose defined on vectors only • ( A T ) T = A ( ) y • ( A + B ) T = A T + B T v • ( AB ) T = B T A T x
Recommend
More recommend