<<

Matrix Analysis February 17-19, 2014

Outline Introduction to Analysis • Why matrices, basic definitions/terms • Matrix Larry Caretto • Inverse of a Matrix Mechanical 309 of • Simultaneous linear : matrix from and solution Engineering Systems – Matrix and its role in determining type February 17–19, 2014 of solutions (unique, infinite, none) • Eigenvalues and eigenvectors

2

Why Matrices Matrix Example • Simplified notation for general statements about mathematical or engineering systems • Simple linkage of two springs with

• Have multiple components that are spring constant k and displacements uk interrelated at individual points – Elements in a machine structure • Individual loads, Pk, related to individual – Springs, masses and dampers in a displacements, uk, by matrix vibrating system shown below. • Matrix notation provides general 푃1 푘1 −푘1 0 푢1 푢 relationships among components P= 푃2 = −푘1 푘1 + 푘2 −푘2 2 = 푲푼 푃 0 −푘 푘 푢3 3 3 2 2 4

Matrix Basics Row and Column Matrices

a a a   a • Matrices with only one row or only one  11 12 13 1m  • Array of a a a   a  column are called row or column matrices 21 22 23 2m numbers with   (sometimes called row or column vectors) a31 a32 a33   a3m  n rows and m A    – The row number 1 is usually      columns   dropped in row matrices as is c11  c1         c  c    • Components the column number 1 in  21   2  an1 an2 an3   anm column matrices       are a(row)(column) c  c31  c3       r  r r r   r     • Size of matrix (n x m) or (n by m) is  11 12 13 1m            number of rows and columns  r1 r2 r3   rm  cn1  cn 

5 6

ME 309 – Numerical Analysis of Engineering Systems 1 February 17-19, 2014

More Matrix Basics • Two matrices are equal (e.g., A = B) a1 0 0   0  • The diagonal matrix – If both A and B have the same size (rows  0 a 0   0  A is a square and columns)  2   0 0 a3   0  matrix with nonzero – If each component of A is the same as the A         components only corresponding component of B (aij = bij for   on the principal all i and j)          diagonal • A has the same number  0 0 0   an  of rows and columns • Components of A are 1 i  j • A diagonal matrix, D, has all zeros aidij, where dij is the dij   except for the principal diagonal Kroenecker delta 0 i  j

7 8

Matrix Operations Null (0) and Unit (I) Matrices • Can add or subtract matrices if they are • For any matrix, A, A + 0 = 0 + A = A; the same size IA = AI = A and 0 A = A 0 = 0 – C = A  B only valid if A, B, and C have • The unit (or identity) matrix is a square the same size (rows and columns) matrix; the null matrix, which need not – Components of C, cij = aij  bij be square, is sometimes written 0(nxm) • Multiplication by a : C = xA 0 0 0   0 1 0 0   0     – C and A have the same size (rows and 0 0 0   0 0 1 0   0 0 0 0 0 0 0 1   0 columns) 0    I              – Components of C, cij = xaij               – For scalar , C = A/x, cij = aij/x 0 0 0   0 0 0 0   1

9 10

Transpose of a Matrix Preview • of A denoted as AT • Not an intuitive operation. Look at two • Reverse rows and columns; for B = AT coordinate transformations as example y  a x  a x z  b y  b y – bij = aji 1 11 1 12 2 1 11 1 12 2 – If A is (n x m), B = AT is (m by n) y2  a21x1  a22x2 z2  b21y1  b22y2 • In MATLAB the apostrophe is used to construct the transpose: B = A’ • Substitute equations for y in terms of x  3 14  into equations for z1 and z2  3 12  6 T   A  A  12  2 z1  b11[a11x1  a12x2 ]  b12[a21x1  a22x2 ] 14  2 0       6 0    z2  b21[a11x1  a12x2 ]  b22[a21x1  a22x2 ]

11 12

ME 309 – Numerical Analysis of Engineering Systems 2 Matrix Analysis February 17-19, 2014

Matrix Multiplication Preview II Matrix Multiplication Preview III • Rearrange last set of equations to get • Coefficients as matrix components direct transformation from x to z a a  b b  c c  A  11 12 B  11 12 C  11 12 z  [b a  b a ]x  [b a  b a ]x  c x  c x       1 11 11 12 21 1 11 12 12 22 2 11 1 12 2 a21 a22 b21 b22 c21 c22 z2  [b21a11  b22a21]x1  [b21a12  b22a22]x2  c21x1  c22x2 c c  b a  b a b a  b a  C  11 12  11 11 12 21 11 12 12 22 c11  [b11a11  b12a21] c12  [b11a12  b12a22]     c21 c22 b21a11  b22a21 b21a12  b22a22 c21  [b21a11  b22a21] c22  [b21a12  b22a22] 2 C = AB if cij  bik akj (i  1,2; j  1,2) k1 • Generalize this to any matrix size

13 14

Multiplying Matrices General Matrix Multiplication • For general matrix multiplication, C = AB • For matrix multiplication, C = AB – A has n rows and p columns p – A has n rows and p columns p cij   aikbkj cij   aikbkj – B has p rows and m columns k 1 – B has p rows and m columns k 1 – C has n rows and m columns (i 1,n; j 1,m) – C has n rows and m columns (i 1,n; j 1,m) – A is left; B is right; C is – A is left; B is right; C is product (AB) is • For C = AB, we get c by adding prod- ij ij • Example 3 4 product of row i ucts of terms in row i of A (left matrix) 3 0  6 A  B  1 2 of A times by terms in column j of B (right matrix) 4  2 0      6 1 column j of B • c = a b + a b + a b + a b + …   ij i1 1j i2 2j i3 3j i4 4j 3(3)  0(1)  6(6) 3(4)  0(2)  6(1)  27 6  • In general, AB ≠ BA AB       4(3)  2(1)  0(6) 4(4)  2(2)  0(1)  10 12

15 16

Matrix Multiplication Exercise Matrix Multiplication Exercise II • Consider the following matrices • What is the size of C = AB? 1 2 3 0 2  2 0   A  0 1 4 B  1 3 1 0     1 1 0   2 1  3 1 • Can you find AB, BA or both? • We can find AB, because A has three • C = AB has three rows (like A) and four columns and B has three rows columns (like B) • We cannot find BA because B has four • What is c ? columns and A has three rows 11 • Next chart starts the process of finding all • c11 = (1)(0) + (2)(1) + (3)(2) = 8 components of AB 17 18

ME 309 – Numerical Analysis of Engineering Systems 3 Matrix Analysis February 17-19, 2014

Matrix Multiplication Exercise III Matrix Multiplication Exercise IV

• Find c11, c12, c13, and c14 in C = AB • Find c21, c22, c23, and c24 in C = AB 1 2 3 0 2  2 0   A  0 1 4 B  1 3 1 0     1 1 0   2 1  3 1

• c11 = (1)(0) + (2)(1) + (3)(2) = 8 • c21 = (0)(0) + (-1)(1) + (4)(2) = 7

• c12 = (1)(2) + (2)(3) + (3)(1) = 11 • c22 = (0)(2) + (-1)(3) + (4)(1) = 1

• c13 = (1)(-2) + (28)(111) + 9(3)(3-3) = -9 • c23 = (0)(-2) + (-1)(1) + (4)(-3) = -13 8 11  9 3 C    • c14 = (1)(0) + (2)(0) + (3)(1) = 3 • c24 = (0)(0C) + 7(-11)(0) 13+ (44)(1) = 4         19   20

Matrix Multiplication Exercise V Matrix Multiplication Results

• Find c31, c32, c33, and c34 in C = AB • Solution for matrix product C = AB

• c31 = (1)(0) + (1)(1) + (0)(2) = 1

• c32 = (1)(2) + (1)(3) + (0)(1) = 5 • c = (1)(-2) + (1)(1) + (0)(-3) = -1 33 8 11  9 3 • c34 = (1)(0C) + (71)(01) + (130)(14) = 0   1 5 1 0 21 22

MATLAB/Excel Matrices Determinants • Have seen term-by-term operations on • Looks like a matrix but isn’t a matrix arrays, A+B, A-B, A.*B, A./B and A.^n • A square array of numbers with a rule • Matrix operations are given by following: for computing a single value for the array A+B, A-B, A*B, A/B, A\B and A^n Example at 1 3 1 9 a11 a12 a13 a11 a12 a13 • MATLAB 푨 = 푨. ^ퟐ = 2 4 4 16 right shows Deta a a   a a a calculation of  21 22 23 21 22 23 1 3 1 3 7 15 a a a  a a a • A^2: 푨ퟐ = = Det(A), the  31 32 33 31 32 33 2 4 2 4 10 22 of a a a  a a a  a a a • Excel has mmult array to  11 22 33 21 32 13 31 12 23 3 x 3 matrix A  a a a  a a a  a a a multiply two arrays 11 32 23 21 12 33 31 22 13 23 24

ME 309 – Numerical Analysis of Engineering Systems 4 Matrix Analysis February 17-19, 2014

More Determinants General Rule for Determinants • Useful in obtaining algebraic • Any size determinant can be evaluated expressions for matrix operations, but by any of the following equations not useful for numerical computation n n n n i j i j – Equation for 2 by 2 determinant Det A  (1) aijMij (1) aijMij  aijAij aijAij i1 j1 i1 j1 a11 a12 a11 a12 Det A  Det    a11a22  a21a12 a21 a22 a21 a22 • Can pick any row or any column • Choose row or column with most zeros to 2 • An n x n determinant has n Minors, Mij, simplify calculations obtained by deleting row i and column j • Can apply equation recursively; evaluate a 5 i+j • Cofactors, Aij = (-1) Mij used in general x 5 determinant as a sum of 4 x 4 deter- expressions for determinants 25 minants then get 4 x 4’s in terms of 3 x 3’s26

Determinant Behavior Determinant Behavior II • A determinant is zero if any row or any • If one row (or one column) of a column contains all zeros. determinant is replaced by a linear • If one row or one column of a combination of that row (or column) with determinant is multiplied by a constant, another row (or column), the value of k, the value of the determinant is the determinant is not changed. multiplied by the same constant. • If two rows (or two columns) of a – Note the implication for matrices: if a matrix determinant are linearly dependent the is multiplied by a constant, k, then each value of the determinant is zero. matrix element is multiplied by k. If A is an n x n matrix, Det(kA) = knDet(A).

27 28

Determinant Behavior III Inverse of a Matrix • The determinant of the product of two • For a square matrix, A, an inverse matrix, matrices, A and B is the product of the A-1 may exist such that AA-1 = A-1A = I determinants of the individual matrices: • For the algebraic equation ax = b, x = a-1b Det(AB) = Det(A) Det(B). • For the matrix equation Ax = b, x = A-1b -1 • The determinant of transposed matrix is the • Just as x = a b is not valid if a = 0, x = A-1b is not valid if A-1 does not exist same as the determinant of the original – A-1 does not exist if DetA = 0 T matrix: Det(A ) = Det(A). • The inverse is an important concept in • MATLAB: det(A) gives Det(A) analysis of linear systems, but is not used • Excel: mdeterm; video for all Excel matrix in computational work – http://www.youtube.com/watch?v=gY81Jg7jyc4 29 30

ME 309 – Numerical Analysis of Engineering Systems 5 Matrix Analysis February 17-19, 2014

Formula for Inverse of a Matrix Inverse of 2 x 2 Matrix

-1 • Find the components of B = A , bij, from determinant of A and its cofactors A M 1 ji i j ji M a M a If B  A , bij   (1) b  (1)11 11  22 b  (1)12 21   12 Det(A) Det(A) 11 Det(A) Det(A) 12 Det(A) Det(A)

21 M12 a21 22 M 22 a11 • Use to get algebraic equations for b21  (1)   b22  (1)  components of inverse matrix Det(A) Det(A) Det(A) Det(A) • Matrix computations, if necessary, obtain a a  1  a  a  A  11 12 A1  22 12 components by alternative numerical a a  a a  a a  a a   21 22 11 22 21 12  21 11 

31 32

Inverse of 3 x 3 Matrix MATLAB/Excel Inverse Apply B  A1, • MATLAB: use B = inv(A) to get B = A-1 a a a 1  11 12 13 • MATLAB can use C=B/A to get C = A-1B i j M ji a a a   b  (1)  21 22 23 • Excel function minverse computes inverse ij Det(A) a31 a32 a33 – Select empty cell area same size as matrix – Enter formula =minverse() (a a  a a ) (a a  a a ) (a a  a a ) 22 33 32 23 32 13 33 12 12 23 22 13 – Press control+shift+enter (a a  a a ) (a a  a a ) (a a  a a )  31 23 33 21 11 33 31 13 21 13 11 23  (a21a32  a31a22) (a31a12  a11a32) (a11a22  a21a12) – Original matrix in cells A1:B2  a11a22a33  a21a32a13  a31a12a23    – Array formula =minverse(A1:B2) in cells C1:D2  a11a32a23  a21a12a33  a31a22a13 – Array formula =mmult(A1:B2,C1:D2) in cells E1:F2 33 34

Simultaneous Equation Basics Simultaneous Equations • A set of simultaneous linear algebraic • The second column is an equivalent set equations may have of equations that is a – A single (unique) solution – No solution of the equations in the first column x 1 – An infinite number of solutions 3x1  5x2 13 1 x  2 • A linear combination of any two x2  2 2 equations can replace one of the 3x  5x 13 x1  a (any a) 1 2 3x1  5x2 13 equations and not change the solution 13  3a 6x1 10x2  26 0  0 x2  6x 11x  28 5 Eqn I 3x1  5x2 13 1 2 (Eqn II) – 3x  5x 13 3x  5x 13 1 2 1 2 No solution Eqn II  23x1  5x2 13 2 * (Eqn I) 6x1 11x2  28 6x1 10x2  25 0  1 x2  2 35 36

ME 309 – Numerical Analysis of Engineering Systems 6 Matrix Analysis February 17-19, 2014

Getting to a Matrix Form Standard Form • Example of 3 equations (3 unknowns) 3x + 7y – 3z = 8 a11x1 + a12x2 + a13x3 +...+ a1N-1xN-1 + a1NxN = b1 2x – 4y + z = -3 a21x1 + a22x2 + a23x3 +...+ a2N-1xN-1 + a2NxN = b2 8x + 6y – 2z = 14 a31x1 + a32x2 + a33x3 +...+ a3N-1xN-1 + a3NxN = b3 • How can we develop a general notation ...... for N equations in N unknowns? aN-1,1x1 + aN-1,2x2 + ...... + aN-1,NxN = bN-1 a x + a x + a x +...... + a x = b – Call variables x1, x2, x3 etc. N1 1 N2 2 N3 3 NN N N – Call right hand side b1, b2, b3, etc. • Usual subscripts on a are arow,column – Call top row coefficients a11, a12, a13, etc. • Row is equation and x column is unknown ∙ Coefficient of xj in equation i is aij • N can be any number 37 38

Compact Standard Forms Example in Standard Form

N • Previous example of 3 equations (N = 3) • Ax = b aij x j  bi i 1,, N j1 3x + 7y – 3z = 8 2x – 4y + z = -3 • Equations defined by data: N, aij, and bi • is same as matrix 8x + 6y – 2z = 14 multiplication formula • In standard form:

• aij coefficients are a matrix, A – x is x1, y is x2, and z is x3 • Right-hand side, b, and unknowns, x, – a11 = 3, a12 = 7, a13 = -3, b1, = 8

are column vectors – a21 = 2, a22 = -4, a23 = 1, b2, = -3

– a31 = 8, a32 = 6, a33 = -2, b3, = 14

39 40

Example in Standard Form Example in Standard Form • Multiply A and x as shown below • Previous 3x + 7y – 3z = 8 3 7 −3 x1 3x1 + 7x2 − 3x3 8 example of N 2x – 4y + z = -3 2 −4 1 x2 = 2x1 − 4x2 + 1x3 = −3 = 3 equations 8x + 6y – 2z = 14 8 6 −2 x3 8x1 + 6x2 − 2x3 4 • Final equal for two (3x1) matrices

3 7  3x1   8 gives original form of three simultaneous      equations • As Ax = b 2  4 1 x   3   2    3x + 7y – 3z = 8 2x – 4y + z = -3 8 6  2x3  14  8x + 6y – 2z = 14

41 42

ME 309 – Numerical Analysis of Engineering Systems 7 Matrix Analysis February 17-19, 2014

Solve Ax = b in MATLAB/Excel Solving Ax = b • MATLAB could use x = inv(A) * b • Know A (all the a ) and b (all b ) – Preferred approach is x = b\A which is ij i faster and more accurate for solving Ax=b • Want x (all the unknowns xi) • Excel: Select column for x solution then a11 a12 a13   a1n   x1  b1  a a a   a  x  b  enter array formula:  21 22 23 2n   2   2  – mmult(minverse(), ) a31 a32 a33   a3n  x3  b3         Array formula        in f2:f4 is:       =mmult(a2:c4,              Array formula in e2:e4 is: e2:e4)-d2:d4       =mmult(minverse(a2:c4),d2:d4) an1 an2 an3   ann xn  bn  43 44

General System for Ax = b n equations and m unknowns? • How can this be? We expect m = n (n x m) (m x 1) (n x 1) • First we have to see if the n equations

 x1  are really independent equations a11 a12 a13   a1m    b1  x2 • Systems for m > n have an infinite a a a   a    b   21 22 23 2m   2   x3  number of solutions a31 a32 a33   a3m    b3          • Systems for n > m can be solved in a              least squares sense                  – Provide solution that has least error in    2 an1 an2 an3   anm  bn  푛 푚       solution: minimize 푖=1 푏푖 − 푗=1 퐴푖푗푥푗 xm  45 46

Gauss Elimination Upper Triangular Form (UTF) • Practical tool for obtaining solutions • Convert original set of equations to UTF • Analytical tool for determining linear          x     dependence or independence 11 12 13 1n1 1n 1 1  0         x     • Basic idea is to manipulate the  22 23 2n1 2n   2   2  equations (or data) to make them easier  0 0 33   3n1 3n   x3   3        to solve without changing the results              • Systematically create zeros in lower left             part of the equations (or data)        0 0 0    n1n1  n1n  xn1  n1         0 0 0   0  nn  xn  n  47 48

ME 309 – Numerical Analysis of Engineering Systems 8 Matrix Analysis February 17-19, 2014

Gauss Elimination III Gauss Elimination

• Upper triangular form on previous slide • How do we get the upper triangular form? is easily solved by back substitution • Work on • xn = n/nn a a a   a b  • xn-1= (n-1 – n-1 nxn)/n-1 n-1, et cetera 11 12 13 1m 1 a a a   a b  • General equation for back substitution  21 22 23 2m 2 

n a31 a32 a33   a3m b3     x [A,b]    i  ij j       ji1   x  i  n,n 1,n  2,,1 i          ii Convention: If lower index is   greater than upper index in S an1 an2 an3   anm bn  operator, do not execute sum 49 50

Gauss Elimination Algorithm II General Gauss Elimination • Use each row from row 1 to row n-1 as • Repeatedly replace rows by linear the “pivot” row combination of two rows that produces a – Diagonal element on pivot row is apivot,pivot zero in a desired row/column combination – For each row (row r) below the pivot row

• First step: make all of column 1 below row • Multiply that row by arow,pivot/apivot,pivot • Subtract result from row r to make a = 0 1 zero (sets all ar1 = 0 except a11) row,pivot • Second step: make all of column 2 below • Operation requires subtraction for each column of A right of pivot column and for b row 2 zero (sets all a = 0 for r > 2) r2 – Repeat for each row below pivot row • Continue this kind of step for all rows • Repeat for rows 1 to n-1 as pivot rows except the last row – Row being subtracted is called “pivot row” • Replace existing array with results of new operations 51 52

General Gauss Elimination II Gauss Pseudocode • Operations with row 2 as pivot row For pivot 1to n 1 • Replace RowR by {RowR – (aR2/a22)Row2} For row  pivot 1to n  a a a   a b    11 12 13 1m 1  For column  pivot 1to n        0 a22 a23   a2m b2  a      row, pivot   a a a a  arow,column  arow,column  a pivot,column   0 a  32 a a  32 a   a  32 a 32    a   32 22 33 23 3m 2m b3  b2   pivot, pivot   a a a a   22 22 22 22     a a a a     42 42 42 42  0 a42  a22 a43  a23  a4m  a2m b4  b2    arow, pivot  a22 a22 a22 a  22  brow  brow  bpivot            a pivot, pivot   a a a a      0 a  n2 a a  n2 a   a  n2 a b  n2 b     n2 22 n3 23 nm 2m n a 2  a22 a22 a22 22  Operations on brow are the same arow, pivot 53 54 arow,column  arow,column  a pivot,column as operations would be on arow,n+1 a pivot, pivot

ME 309 – Numerical Analysis of Engineering Systems 9 Matrix Analysis February 17-19, 2014

Solution Details More Details 2x  4x  26x  34 (i) • Solve the set 1 2 3 • Result from 2x1  4x2  26x3  34 first set of of equations  3x1  2x2  9x3  13 (ii) 0x1  4x2  30x3  38 operations on the right 0x1 17x2  99x3  133 7x1  3x2  8x3  14 (iii) • Subtract –3/2 times (i) from equation (ii)   17    • Subtract x2 17   (4)  x3 99  and 7/2 times (i) from (iii) 17/(-4) times    4     17     17    3   3   3   3  (ii) from (iii)  (30)  133  (38)           4      4   3 2x1  2  (4)x2  9  (26)x3  13 (34)  2   2   2   2          2x  4x  26x  34 • Final upper- 1 2 3   7     7     7     7   0x1  4x2  30x3  38 7  2x1  3 (4)x2  8 (26)x3  14  (34) triangular form   2     2     2     2   57 57 0x1  0x2  x3   Unnecessary operations 55 2 2 56

Back Substitution Do we have a solution to Ax = b? • Final upper- • Answer to question based on the rank triangular form which is defined as the number of linearly independent rows or columns • Use Gauss elimination to determine rank • We see that x = 1 and back substitution 3 – Use Gauss elimination to convert matrix to gives x2 and x1 as follows upper-triangular form 2x1  4x2  26x3  34  4x2  30x3  38 – In this form, rank is number of rows with  34  4x2  26x3  38  30(x3 )  38  30(1) x  non-zero coefficients x   1 2  4  4 2 – This is sometimes called row-echelon form  34  4(2)  26(1) x2  2 x   0 1 2 • MATLAB has function rank(matrix)

57 58

What is a row-echelon form? What is the rank of each matrix? • Apply Gauss elimination to get – All zeros below row one in column one 6 0 2 0 0 0 1 6 6 0 2 0 0 0 – All zeros below row two in column two     0 1 7 8 6 2 8 4 0 1 7 8 6 2 – Keep this up until you get to the final row or 0 0 2 0 3 5 8 0 0 0 3 4 0 0 until there are no more rows with nonzeros     • Count number of rows that are not all 0 0 0 4 1 0 7 3 0 0 0 9 1 2 zeros; this is the rank 0 0 0 0 6 0 3 5 0 0 0 0 0 0     • This is way to determine linear 0 0 0 0 0 0 2 1 0 0 0 0 0 0 independence of a set of vectors 6 4

59 60

ME 309 – Numerical Analysis of Engineering Systems 10 Matrix Analysis February 17-19, 2014

Finding Rank Solutions to Ax = b • For a system of n unknowns • What is rank of matrix,  1  12  A?  6 72  • If rank A = rank [A b] = n there is a A    unique solution • What is maximum pos-  13  156  sible value for rank? 2   • If rank A = rank [A b] < n there are an  7 84  infinite number of solutions • Lower right matrix is 1  12 result of applying Gauss • If rank A  rank [A b] there are no 0 0  elimination to A   solutions • What is its rank? 0 0    • Rank A = 1 0 0  61 62

Three Examples First Example Rank Original Equations Triangularized Set Solutions x1  4x2  26x3  2 x1  4x2  26x3  2 x1  0 1  4  26 1  4  26 2  2x  9x  5 2x  9x  5 x  7 Original     2 3 2 3 2 A  0 2 9  A b  0 2 9  5      7x1  3x2  8x3  13 50.5x3  50.5 x3  1 7 3 8  7 3 8 13

x1  4x2  26x3  2 x1  4x2  26x3  2 x1  8 8 Row- 1  4  26 1  4  26 2  2x  9x  5 2x  9x  5 x  2.5  4.5 echelon     2 3 2 3 2 A  0 2 9  A b  0 2 9  5  form      2x1 10x2  61x3  9 0  0 x3   0 0 50.5 0 0 50.5 50.5

x1  4x2  26x3  2 x  4x  26x  2 1 2 3 No Here we see that rank A = rank [A b] = 2x2  9x3  5 2x  9x  5 2 3 solution number of unknowns = 3 so we have a  2x1 10x2  61x3  8 0 1 unique solution 63 64

Second Example Rank Third Example Rank

 1  4  26  1  4  26 2  Original  1  4  26  1  4  26 2    A   0 2 9  A b  0 2 9  5 A   0 2 9  A b   0 2 9  5 Original          2 10 61  8  2 10 61     2 10 61   2 10 61  9 Row- 1  4  26 1  4  26 2  Row- 1  4  26 1  4  26 2      echelon A  0 2 9  A b  0 2 9  5 A  0 2 9  A b  0 2 9  5   echelon       0 0 0  form   0 0 0 1  form 0 0 0  0 0 0 0  rank A = rank [A b] = 2 which is less Here, rank A = 2  rank [A b] = 3; than the number of unknowns (3) so we therefore we have no solutions have an infinite number of solutions 65 66

ME 309 – Numerical Analysis of Engineering Systems 11 Matrix Analysis February 17-19, 2014

Homogenous Equations Homogenous Equation Example

• If b = 0, i.e., each bi = 0, we a11 = -1 A matrix automatically have rank A = rank[A b] Equations  x1  4x2  3x3  0 1  4 3    so we have a solution  4x 11x  6x  0 A   4 11  6 1 2 3   • If this rank equals the number of x1 8x2  5x3  0  1 8 5  unknowns, we have a unique solution, x = 0 Original [A b] matrix Row-echelon form 1  4 3 0 • If this rank is less than the number of 1  4 3 0 [A b]   4 11  6 0   unknowns we have an infinite number of   [A b]   0 27 18 0  1 8 5 0  0 0 0 0 solutions   Rank A = rank [A b] = 2 < unknowns = 3 so 67 there are infinite solutions 68

Homogenous Equation Example II Rank and Determinants

Equations a11 = +1 A matrix • Determinant rank, like matrix rank, is the number of linearly independent x1  4x2  3x3  0  1  4 3     4x1 11x2  6x3  0 rows or columns. A   4 11  6 x 8x  5x  0 1 2 3  1 8 5  • Two equivalent statements: a Original [A b] matrix Row-echelon form determinant is zero if  1  4 3 0  1  4 3 0 – its rows are linearly dependent   [A b]   4 11  6 0 [A b]   0  5 6 0 – the size of a determinant is larger than      1 8 5 0 its rank    0 0 2.8 0 Rank A = rank [A b] = unknowns = 3 so

there is a unique solution (x = 0) 69 70

Practical Determinant Evaluation Upper Triangular Determinant • Use Gauss elimination and find the product of the elements on the diagonal a11 a12 a13 a14 a15 a22 a23 a24 a25 – A determinant does not change if one row 0 a a a a 22 23 24 25 0 a a a is replaced by a linear combination of that 0 0 a a a  (1)11a 33 34 35 row with another row 33 34 35 11 0 0 a a 0 0 0 a a 44 45 – Gauss elimination converts a determinant 44 45 0 0 0 a into upper-triangular form without changing 55 0 0 0 0 a55 its value a a a – The determinant of an upper-triangular 33 34 35 a a  a (1)22 a 0 a a  a a (1)33 a 44 45 array is the product of the components on 11 22 44 45 11 22 33 0 a55 the principal diagonal 0 0 a55 5 71  a11a22a33a44a55  akk 72 k1

ME 309 – Numerical Analysis of Engineering Systems 12 Matrix Analysis February 17-19, 2014

Determinant Sign Homogenous Infinite Solutions • Gauss elimination uses row swapping to a = –1 A matrix reduce round-off error Example 11  x1  4x2  3x3  0 1  4 3  • If two rows in a determinant are swap-    4x1 11x2  6x3  0 A   4 11  6 ped, the determinant sign changes   x1 8x2  5x3  0  1 8 5  ퟏ ퟐ   푫풆풕 = ퟏ ퟒ − ퟑ ퟐ = −ퟐ ퟑ ퟒ ퟑ ퟒ Row-echelon form ~ 푫풆풕 = ퟑ ퟐ − ퟏ ퟒ = ퟐ Det A  Det A  (1)(11)(5)  ퟏ ퟐ 1  4 3 ~ (4)(8)(3)  (1)(4)(6) • In Gauss elimination keep a count of the A   0 27 18    (1)(11)(3)  (4)(4)(5)  (1)(8)(6)  0 0 0 row swaps, nSwaps; find determinant    55  96  24  3380  48  0 from diagonalized array by the formula 푁 Det A = 0 => solution of x  0 may exist 푛푆푤푎푝푠 −1 훼푘푘 73 74 푘=1

Homogenous Infinite Solutions Cramer’s Rule

Example a11 = +1 A matrix  1  4 3  • You may like to use this for small x1  4x2  3x3  0 A   4 11  6 systems of equations  4x1 11x2  6x3  0    1 8 5  x1  8x2  5x3  0   Det A  (1)(11)(5)  b1 a12 a13 a11 b1 a13 a11 a12 b1

Row-echelon form (4)(8)(3)  (1)(4)(6) b2 a22 a23 a21 b2 a23 a21 a22 b2 1  4 3   (1)(11)(3)  (4)(4)(5)  (1)(8)(6) b a a a b a a a b ~ x  3 32 33 x  31 3 33 x  31 32 3 A  0  5 6  1 2 3    55  96  24  3380  48 14 a11 a12 a13 a11 a12 a13 a11 a12 a13   0 0  2.8 a21 a22 a23 a21 a22 a23 a21 a22 a23 ~ Det A  (1)(5)(2.8) 14 Det A  0 and b = 0 a31 a32 a33 a31 a32 a33 a31 a32 a33 means x = 0

75 76

Rank and Inverses Rank and Inverses II • Finding A-1 for an n x n matrix requires • Recall the general result for the elements, the solution of Ax = b n times, where b b , of B = A-1 is one column of the unit matrix ij • b = A /Det(A), where A is the cofactor of a • We cannot solve this equation unless ij ji ij ij • We see that b is not defined if Det A = 0 rank A = n ij • A-1 does not exist if Det A = 0 • An n x n square matrix A will not have • Det A = 0 for an n x n determinant shows an inverse unless its rank equals its size that Rank A < n • An alternative statement is that A will • Det A  0 and rank A = n: two equivalent not have an inverse if Det(A) = 0 conditions for A(n x n) to have an inverse

77 78

ME 309 – Numerical Analysis of Engineering Systems 13 Matrix Analysis February 17-19, 2014

Why Eigenvalues/Eigenvectors Eigenvalues and Eigenvectors • In electrical and mechanical networks, • Basic definition (A square): Ax = lx provides fundamental frequencies • x is eigenvector, l is eigenvalue • Shows coordinate transformations • Basic idea is that eigenvector is special appropriate for physical problems vector of matrix A; multiplication of x by • Provides way to express network A produces x multiplied by a constant problem as diagonal matrix • Ax = lx => Ax – lx = [A – Il]x = 0 • Transformations based on eigenvectors • Homogenous equations; requires Det [A used in some solutions of Ax = b – Il] = 0 for solution other than x = 0

79 80

Det[A – Il] = 0 Two-by-two Matrix Eigenvalues

a  l a a   a  11 12 13 1n  • Quadratic a11  l a12  a a  l a   a    21 22 23 2n  equation with a21 a22  l  a31 a32 a33  l   a3n  two roots for Det[A  Il]  Det    0      eigenvalues   (a11  l)(a22  l)  a21a12           l2  (a  a )l  a a  a a  0  an1 an2 an3   ann  l 11 22 11 22 21 12 • Eigenvalue solutions • Det[A – Il] = 0 produces an nth order equation that has n roots for l. May (a  a )  (a  a )2  4(a a  a a ) l  11 22 11 22 11 22 21 12 have duplicate roots for eigenvalues. 2 81 Det A 82

Two-by-two Matrix Eigenvalues Sum and Product

2 • Write ( a 11  a 22 )  4 Det A as • The results on the previous slide apply • Add the two solutions to get to all matrices • The sum of the eigenvalues is the sum (a  a )  (a  a )  11 22 11 22 of the diagonal elements of the matrix, l1  l2    a11  a22 2 2 called the of the matrix • Multiply the two solutions to get • The product of the eigenvalues is the 2  (a  a )   (a  a )   (a  a )2   11 22  11 22  11 22   determinant of the matrix l1l2       2  2  4 n n n (a  a )2  (a  a )2  4Det A l  a  Trace A l  Det A  11 22 11 22  Det A  i  ii  i 4 i1 i1 i1 83 84

ME 309 – Numerical Analysis of Engineering Systems 14 Matrix Analysis February 17-19, 2014

Two-by-two Matrix Eigenvectors Two-by-two Eigenvectors II

T • Two eigenvectors: x(1) = [x(1)1 x(1)2] and • Eigenvector equations are homogen- T T x(2) = [x(2)1 x(2)2] (x(j) = [x(j)1 x(j)2] ) eous, so eigenvectors are determined only within a multiplicative constant • Substitute each eigenvalue solution, l , j (a  l )x  a x  0 into (A – Il)x = 0 to find all x(j) components • Pick x(j)1 =  11 j ( j)1 12 ( j)2 (arbitrary) a x  (a  l )x  0 (a11  l j )x( j)1  a12x( j)2  0 21 ( j)1 22 j ( j)2

a21x( j)1  (a22  l j )x( j)2  0 (l j  a11) a21 x( j)1   x( j)2     Notation: yi is component i of vector y; z(k) a12 (l j  a22) is one of a vector set with components z(k)i 85 86

How Many Eigenvalues? Diagonalize a Matrix • An n x n matrix has k  n distinct • For an n x n matrix it is possible to eigenvalues create a matrix, X, where each column • Algebraic multiplicity of an eigenvalue, is one eigenvector • One can then show that X-1AX = L, Ml, is the number of roots of Det[A – Il] = 0 that have the same root, l where L is a diagonal matrix whose components are the eigenvalues • Geometric multiplicity, ml, of eigenvalue is number of linearly independent – Next assignment uses MATLAB to do this 풙 ퟏ ퟏ 풙 ퟐ ퟏ ⋯ 풙 푵 ퟏ 흀ퟏ ퟎ ⋯ ퟎ eigenvectors for this l 풙 풙 ⋯ 풙 ퟎ 흀 ⋯ ퟎ ퟏ ퟐ ퟐ ퟐ 푵 ퟐ L = ퟐ X = ⋮ ⋮ ⋱ ⋮ ⋮ ⋮ ⋱ ⋮ 풙 ퟏ 푵 풙 ퟐ 푵 ⋮ 풙 푵 푵 ퟎ ퟎ ⋮ 흀푵

87 88

Supplemental Materials Coordinate transformations • Items not planned for in-class coverage • Recall previous equations

– Matrix equations for coordinate transforms y1  a11x1  a12x2 z1  b11y1  b12y2 – Derivation of 3x3 determinant formula from y2  a21x1  a22x2 z2  b21y1  b22y2 general determinant formula • Define matrices so that y = Ax and z = By – Example of inverse calculation for 4x4 matrix (with many zeros) a a  b b  A  11 12 B  11 12 – Example of eigenvalue and eigenvector a a  b b  calculations  21 22  21 22 x   y  z  • 2 x 2 array x  1 y  1 z  1 • 3 x 3 array       x2  y2  z2 

89 90

ME 309 – Numerical Analysis of Engineering Systems 15 Matrix Analysis February 17-19, 2014

Coordinate transformations II Coordinate Transformations III • Show that matrix definitions give • From matrix equations y = Ax and z = transformation results By, we have z = BAx = Cx with C = BA y  a x  a x z  b y  b y 1 11 1 12 2 1 11 1 12 2 a11 a12 b11 b12 c11 c12 A    B    C    y2  a21x1  a22x2 z2  b21y1  b22y2 a21 a22 b21 b22 c21 c22  y  a a x  a x  a x  c c  b a  b a b a  b a  y  1  Ax  11 12 1  11 1 12 2 C  11 12  11 11 12 21 11 12 12 22        c c  b a  b a b a  b a  y2  a21 a22x2  a21x1  a22x2   21 22  21 11 22 21 21 12 22 22

z1  b11 b12 y1  b11y1  b12y2  z1  c11 c12x1  c11x1  c12x2  z     By        z     Cx        z2  b21 b22y2  b21y1  b22y2  z2  c21 c22x2  c21x1  c22x2  91 92

Example of General Rule Example of General Rule II • Get determinant of a 3 x 3 matrix by • Get determinant of a 3 x 3 matrix expansion along last row a31M 31  a32M 32  a33M 33 

a12 a13 a11 a13 a11 a12 a11 a12 a13 a31  a32  a33  a21 a22 a23  a31A31  a32A32  a33A33 a22 a23 a21 a23 a21 a22

a31 a32 a33  a31(a12a23  a22a13)  a32(a11a23

33 a11 a12 22 a11 a13  a a )  a (a a  a a ) A  (1) M  A  (1) M  21 13 33 11 22 12 21 33 33 a a 22 22 a a 21 22 31 33  a31a12a23  a31a22a13  a32a11a23 a a a a A  (1)32 M   11 13 A  (1)31 M  12 13 32 32 31 31  a a a  a a a  a a a a21 a23 a22 a23 32 21 13 33 11 22 33 12 21 93 94

Example Problem Example Problem Det A

• Find A-1 for A at right • Det A = (-1)3+1a M + (-1)3+2a M + 1 0 2 1 31 31 32 32 (-1)3+3a M + (-1)3+4a M • Have the following 2 1 0 0 33 33 34 34 1 0 2 1 formula for B = A-1 A    2 1 0 0 1 0 0 0 0 2 1 A    M 31 1 0 0 0 i j ji   Det A  (1) (1) 1 0 0  0  0  0   bij  (1) 0 2 3 1 0 2 3 1 Det(A)   2 3 1   0 2 1 • General determinant formula: SaijAij  (0)(0)(1)  (1)(3)(1)  (2)(2)(0) Det A  1 0 0 1 • Take sum over third row to simplify  (2)(0)(1)  (1)(2)(1)  (0)(3)(0) calculation of Det A 2 3 1 95 96

ME 309 – Numerical Analysis of Engineering Systems 16 Matrix Analysis February 17-19, 2014

Example Problem III Example Problem Solution • Apply: b = (-1)i+jM /Det A ij ji 1 0 2 1  0 0 1 0  • Det A = 1 so b = (-1)i+jM    0 1  2 0  ij ji 2 1 0 0 1   A    A  – Examples shown below 1 0 0 0 1  2 5 1    0 2 1   3 4 11  2 0 2 3 1   b  (1)12 M   0 0 0  0 12 21 Remove Remove -1 -1 for M • We can show that AA = A A = I 2 3 1 21 for M34 -1 • (AA )11 = 1∙0 + 0∙0 + 2∙(-1) + 1∙3 = 1 1 0 2 -1  3  8  0 • (A A)43 = 3∙2 + 4∙0 + (-11)∙0 + (-2)∙3 = 0 b  (1)43 M   2 1 0   11 43 34  0  0  0 • Only 14 left to check 0 2 3 97 98

Two-by-two Example Two-by-two Example Continued

• Find eigenvalues and 1 5 • Find x components for l = 2 A  (1) 1 eigenvectors of A   • Solve [A – I]x = 0 for x components 0 2 l (1) 1 l 5 (1 2)x(1)1  5x(1)2  x(1)1  5x(1)2  0 Det[A  Il]   0 0x  (2  2)x  0x  0x  0 0 2  l (1)1 (1)2 (1)1 (1)2 • One equation in two unknowns Det[A  Il]  (1 l)(2  l)  (0)(5)  0 • Pick x(1)2 =  then x(1)1 = 5 from first equation • Solutions are l1 = 2 and l2 = 1 T 99 • Eigenvector x(1) is [5 ] 100

Two-by-two Example Concluded Check Two-by-two Example 1 5 5 (1)(5)  (5)() • Next find x(2) components for l2 = 1      Ax (1)        • Same as approach for finding x(1)1 0 2   (0)(5)  (2)() 10  5 (11)x(2)1  5x(2)2  0x(2)1  5x(2)2  0     2   l1x(1)  2     0x(2)1  (2 1)x(2)2  0x(2)1 1x(2)2  0 1 5  (1)( )  (5)(0)  • Both equations give x(2)2 = 0 Ax   (2) 0 20 (0)( )  (2)(0) • Pick x(2)1 =  (x(2)1 cannot be determined)      T • x(2) = [ 0]        1   l2x(2) 101 0 0 102

ME 309 – Numerical Analysis of Engineering Systems 17 Matrix Analysis February 17-19, 2014

Eigenvector Factors Multiple Eigenvalue Example

• 2 x 2 example showed Ax = l x (j) j (j)  2 2  6 2  l 2  6  regardless of choice of  and  A   2 1  3     A  Il   2 1 l 3  • This is general result    2 1 1    2 1 1 l • We can pick one eigenvector component; typical choices are to make Det(A  Il)  (2  l)(1 l)(1 l)  (2)(1)(6) eigenvector simple or a unit vector  (2)(2)(3)  (2)(1 l)(6)  (2)(2)(1 l)  5   (2  l)(1)(3)  l3  2l2  l  2 12 12 12 5 5  26   1 x(1)    x(1)    x(1)  x(2)    x(2)    3 2    1  1  0 0 12l  4  4l  6  3l  l  2l  20l  24  0  26 103 104

Multiple Eigenvalue Example II Multiple Eigenvalue Example III

2  (2) 2  6 x(k)1  0   Det(A Il)  (l  2)(l  2)(l 6)  0  2 1 (2) 3  x  0   (k)2         • Solutions are l = 6, –2, –2   2 1 1 (2)x(k)3  0 • l = –2 has algebraic multiplicity of 2 4 2  6 x  0   (k)1   • Apply Gauss      • Find eigenvector(s) from (A – Ilk)x(k) = 0 2 1 3 x  0   (k)2    elimination to   these equations  2 1 3  x(k)3 0 2  lk 2  6 x(k)1  0           • Look at 2 1 lk 3 x(k)2  0 4 2  6x  0      lk = –2 (k )1 • Pick x(k)3          2 1 1 lk  x(k)3 0 0 0 0 x  0 and x        (k )2    (k)2 105      106 0 0 0 x(k )3  0

Multiple Eigenvalue Example IV Continue Example for l3 = 6 2  6 2  6 x  0 • Pick x(k)2 and (3)1 4 2  6x(k )1  0     x then (A  Il )x   2 1 6 3  x  0  0 0 0 0  x  0 (k)3 3 (3)   (3)2      (k )2    6x(k)3  2x(k)2   2 1 1 6x  0      x    (3)3    0 0 0 x(k )3  0 (k)1 4  4 2  6 x  0   (3)1   • Apply Gauss • Pick x = 2 and x = 0 => x = 3      (k)3 (k)2 (k)1 2  7 3 x  0 elimination to • Pick x = 0 and x = 2 => x = -1   (3)2    (k)3 (k)2 (k)1      these equations  2 1 5x(3)3  0 • Two linearly 3 1 independent     x  0 x  2  4 2  6x(3)1  0 • Pick x 1   2     (3)3 eigenvectors  0  6  6 x  0 =1 => for l = -2 2  0    (3)2    107      x(3)2 =108-1  0 0 0 x(3)3  0

ME 309 – Numerical Analysis of Engineering Systems 18 Matrix Analysis February 17-19, 2014

Example Results Eigenvector Linear Dependence

 4 2  6x  0 6x(3)1  2x(3)1 • Can we have  x +  x +  x = 0 (3)1 x  1 (1) 2 (2) 3 (3)      (3)1  4 without  =  =  = 0? 0  6  6 x(3)2   0 1 2 3     6(1)  2(1)  0 0 0 x  0   2 3 1  2 0   (3)3     4  x  x  x   0   2   1  0  0 1 1 1 2 3 3 1   2   3     • Eigenvalues l1 = -2, l2 = -2, l3 = 6 have 2  0   1  0 eigenvectors shown below         3 1  2 3 1  2  0         1    • Homogenous equations x  0 x   2  x  1 0 2 1   0 1   2   3     2    have 1 = 2 = 3 = 0 if 2  0   1  2 0 1 3  0 matrix has full rank 109 110

Linear Dependence II Quiz Three Solutions 1. Results of MATLAB commands • Matrix has full rank it its determinant is 1 not zero 2 >> A = [ 1; 2; 3; 4] 퐴 = 3 3 1  2 (3)(2)(1)  (0)(0)(2)  4 Det0 2 1  (2)(1)(1)  (2)(2)(2)  5 6   >> B = [5 6; 7 8; 9 10] 퐵 = 7 8   2 0 1  (0)(1)(1)  (3)(0)(1) 15 9 10 >> C = [A B] Error: A and B must have the • Since determinant is not zero, the only same number of rows solution is 1 = 2 = 3 = 0, so 2 6 eigenvectors are linearly independent >> D = [A(2:4,1) B(:,2)] 퐷 = 3 8

111 4 10 112

Quiz Three Solutions II Quiz Three Solutions III 2. Write MATLAB Commands 4. Results of (a) G = [E; [F F]] and (b) H = [F; E’]? 3 5 −6 10 4 7 퐸 = E = [3 5 -6 10; 12 7 -9 4] 12 7 −9 4 3 5 −6 10 −2 9 4 7 12 7 −9 4 6 0 퐹 = −2 9 F = [4 7; -2 9; 6 0] 푮 = 4 7 4 7 푯 = 3 12 6 0 −2 9 −2 9 5 7 3. Results of series of two commands 6 0 6 0 −6 −9 10 4 >> t = 2:6 (log(2))1, (log(3))2, (log(4))3, 5. G array after the command G(2:4,2:3) = F? >> x = log(t) .^ (t – 1) (log(5))4, (log(6))5 3 5 −6 10 >> t = 0:pi/4:pi cos(0)/e0, cos(p/4)/ep/4, cos(p/2)/ep/2, 12 4 7 4 >> y = cos(t) ./ exp(t) cos(3p/4)/e3p/4,cos(p)/ep 퐺 = 4 −2 9 7 −2 6 0 9 >> t = 0:2:10 z = 0 + 2 + 4 + 6 + 8 + 10 = 30 6 0 6 0 >> z = sum(t) 113 114

ME 309 – Numerical Analysis of Engineering Systems 19 Matrix Analysis February 17-19, 2014

First Programming Assignment Comments on Assignment • Number of students: 20 • Range of methods considered • Maximum possible score: 40 • Cell formulas are simplest and quickest • Mean: 31.7 • Use user defined functions (UDF) when • Median: 34 you have repeated calculations and you • Standard deviation: 6.94 want to avoid errors in reentering formulas • Grade distribution: • Range names better identify variables 18 21 23 24 25 26 26 – not so important for simple calculations, 30 32 32 36 36 37 but useful for more complex workbooks 37 37 37 38 39 39 40 115 116

Comments on Assignment II Second Quiz • Array function and macro require a lot of • Number of students: 22 coding which is justified only if • Maximum possible score: 25 calculation is repeated by several users • Mean: 15.9 – With array function multiple tables can be placed on worksheet, each driven by • Median: 16.5 separate input cells • Standard deviation: 6.63 • Difficult to specify exact number of cells by • Grade distribution: selection 3 6 7 10 11 11 11 – Macro requires recoding to use other 11 12 13 15 18 20 21 21 inputs or place results in other locations • Uses exact specification of number of cells 21 22 22 23 23 24 25 117 118

Comments on Second Quiz Second Program • Confusion over transpose • Number of students: 20 – MATLAB A‘ denotes transpose (usually AT) • Maximum possible score: 40 1 4 1 2 3 • Mean: 26.5 – For 퐴 = , 퐴푇 = 2 5 4 5 6 • Median: 27.5 3 6 • Expression cos(t).^(t-1) is same as • Standard deviation: 8.8 (cos(t)).^(t-1) NOT cos[(t).^(t-1) • Grade distribution: • Sum (x), where x is a 1D array gives the 10 10 12 19 19 24 24 a sum of all elements in (For a 2D array 24 27 27 28 30 31 it gives sum of each column 32 34 34 34 35 38 38 119 120

ME 309 – Numerical Analysis of Engineering Systems 20 Matrix Analysis February 17-19, 2014

Second Program Comments MATLAB vs. Excel/VBA • Do not generate or do not copy output • We have focused on use of MATLAB or large arrays from command window • Differences between scripts and – This is similar to entering data on the Excel functions spreadsheet – Functions receive values through • Less focus on MATLAB programming argument list, just as functions do in other – This is comparable to VBA languages like VBA • Many students prefer Excel because of – Variables in scripts, that are not set in the familiarity script, use the current value of the variable in the workspace • Excel/VBA more readily available, especially in small companies 121 122

Quiz Three Solutions Quiz Three Solutions II • Initial guesses show that x = 3 and x = 3 − 1.2615 + - 푥 = 1.2615 − −0.01133 = 1.2661 1 because f(3) > 0 and f(1) < 0 푛푒푤 4.2858 − −0.01133 푥 − 푥 + − 1.2615−1.2661 푥푛푒푤 = 푥− − 푓 푥− relErr = = 0.00362 > 0.001: 퐜퐨퐧퐭퐢퐧퐮퐞 푓 푥+ − 푓 푥− 1.2661 3 − 1 = 1 − −0.5403 = 1.2239 4.2858 − −0.5403 • f(xnew) < 0 so xnew replaces x- • f(xnew) < 0 so xnew replaces x- 3 − 1.2661 푥 = 1.2661 − −0.01130 = 1.2666 3 − 1.2239 푛푒푤 4.2858 − −0.01130 푥 = 1.2239 − −0.09269 = 1.2615 푛푒푤 4.2858 − −0.09269 1.2666−1.2661 1.2615−1.2239 relErr = = 0.000416 < .001: 퐟퐢퐧퐢퐬퐡퐞퐝 relErr = = 0.0298 > 0.001: 퐜퐨퐧퐭퐢퐧퐮퐞 1.2666 1.2615

• f(xnew) < 0 so xnew replaces x- x = 1.2666 123 124

Review Last Lecture Review Last Lecture II

• Discussion of matrices: a(row)(column) – Use MATLAB commands det(A) and inv(A) – Row, column, diagonal, square, unit(I), null(0) for determinant and inverse – A = B, A ± B, xA, A/x (scalar x), AT – Use Excel formulas mmult(A, B) for matrix multiplication, mdeterm(A) for determinant, – Matrix multiplication: P = LR and minverse(A) for inverse 푞 • Columns in L = rows in R = q 푝푖푗 = 푘=1 푙푖푘푟푘푗 • minverse and mmult are array formulas • P rows = L rows; P columns = R columns – Simultaneous linear equations in general • Multiply row of L by column of R 푁 matrix form, Ax = b 푗=1 푎푖푗푥푗 = 푏푖 – Determinants: single number for rectangular • Variables x1, x2, x3, … array; formula depends on array size • Coefficients aij multiplies xj in equation i -1 -1 -1 – Inverse, A : AA = A A = I • Right hand side bi in equation i 125 126

ME 309 – Numerical Analysis of Engineering Systems 21 Matrix Analysis February 17-19, 2014

Review Last Lecture III Review Last Lecture IV – Linear dependence: if one equation in a – Solution of a system of linear algebraic system of equations is a linear combination of equations, Ax = b, with n unknowns depends one or more other equations, the system is of rank of A and [A b] said to be linearly dependent • Unique solution: rank(A) = rank([A b]) = n • A system that is not linearly dependent is linearly • Infinite solutions: rank(A) = rank([A b]) < n independent • No solutions: rank(A)  rank([A b]) • In matrix form an equation is a row – Gaussian elimination: process to get matrix – Matrix rank = number of linearly independent for system of equations in upper triangular rows = number of linearly independent form for simple back substitution columns • Also used to determine rank – MATLAB formula rank(A) for matrix rank • Will review in detail later

127 128

ME 309 – Numerical Analysis of Engineering Systems 22