Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Chapter one Mathematics II Matrices and determinates *Definition: An m×n matrix is a rectangular array of numbers (m rows and n columns) enclosed in brackets. The numbers are called the elements of the matrix. Examples: 1. A 2×3 matrix has 2 rows and 3 columns: [ 2. Here’s a 3 × 3 square matrix: 1 2 5 6 7 [3 4 2 5 3 3 ] 7 −1 −2] 0 3. Column vectors are matrices with only one column: 1 [ 5] 8 4. Row vectors are matrices which only have one row: [3 A general real matrix A −1 7] Rmxn with m × n elements is of the form: a11 a21 [ ⋮ am1 a12 a22 ⋮ am2 … a1n … a2n ⋱ ⋮ ] … amn Each element has two properties: 1. location: The first index represents the row (i) and The second index represents the column (j), e.g. (a21 is the element in row 2, column 1 of the matrix A) 2. Value: which represents the amount of the element. 1 Mathematics II Chapter one Matrices and determinates *Special matrices 1. The unit matrix I is a square matrix whose only non-zero elements are on the diagonal and are equal to one, e.g. 𝐼=[ 1 0 0 ], 1 1 [0 0 0 1 0 0 0] , 1 1 [0 0 0 0 1 0 0 0 0 0 0] ⋱ 0 0 1 2. Zero matrix 0 : All elements of the zero matrix are equal to zero, e.g. [ 0 0 0 ], 0 0 [0 0 0 0 0 0 0] , 0 0 [0 ⋮ 0 0 0 ⋮ 0 ⋯ ⋯ ⋱ ⋯ 0 0] ⋮ 0 3. A diagonal matrix only has non-zero elements on the main diagonal. These non-zero elements can have any value, e.g. 𝑑 𝐷 = [ 11 0 0 ], 𝑑22 𝑑11 [ 0 0 0 𝑑22 0 0 0 ], 𝑑33 𝑑11 0 0 𝑑22 [ ⋮ ⋮ 0 0 ⋯ 0 ⋯ 0 ] ⋱ ⋮ ⋯ 𝑑𝑛𝑛 4. Upper triangular matrix: all the elements under the main diagonal are zero and the others can have any value, e.g. 𝑈=[ 2 0 −1 ], 5 1 [0 0 3 −5 0 7 −1] , 2 2 [0 0 0 5 9 0 0 1 7 1 0 −3 6] 4 −2 5. Lower triangular matrix: all the elements above the main diagonal are zero and the others can have any value, e.g. L=[ 2 1 0 ], −3 1 [2 7 0 −4 3 0 0] , 5 3 [2 0 4 0 −5 9 −6 0 0 2 1 0 0] 0 7 2 Mathematics II Chapter one Matrices and determinates *Matrix algebra 1. Matrix equality. Two matrices are equal if they have the same size and if their corresponding elements are identical , i.e. A=B if and only if: aij = bij , for i = 1,….., m ; j = 1,……, n Examples: 1 1. If A = [ 5 −2 7 3 2 ],B=[ −9 3 4 5 4 ] then A ≠ B 2 ( same size but the corresponding elements are not equal) 1 0 1 2. If A = [3 −5] , B = [ 0 9 6 ( different size) 1 3. If A = [ −3 2 1 ],B=[ 7 −3 3 −5 9 ] then A ≠ B 6 −2 ] then A ≠ B 7 ( same size but a12 ≠ b12 ) 1 Ex: A = [ −4 0 a ] , B=[ 2 c b ] , given that A = B, find a, b, c, and d? d Sol. A=B a=1 b=0 c = -4 d=2 3 Mathematics II Chapter one Matrices and determinates 2. Matrix addition. Two matrices can only be added if they have the same size. The result is another matrix of the same size. We add matrices by adding their corresponding elements, i.e. cij = aij + Ex: if A = [ 1 5 2 6 C=A+B bij for i = 1,….., m ; j = 1,……, n 3 10 ],B=[ 7 5 1 16 23 ] find: 3 1. C = A + B ? 2. D = B – A ? Sol. 1 + 10 C=A+B=[ 5+5 2+1 6 + 16 3 + 23 11 ]=[ 7+3 10 10 − 1 D=B–A=[ 5−5 1−2 16 − 6 23 − 3 9 ]=[ 3−7 0 3 22 −1 10 26 ] 10 20 ] −4 3. Multiplication of a matrix by a scalar. A matrix is multiplied by a scalar ( a number) by multiplying each element of the matrix by that scalar. The result is a matrix of the same size. A=αB bij = α aij for i = 1,….., m ; j = 1,……, n 3 Ex: If A = [4 3 5 2 −4 −2 4 ] find 3A? 3 Sol. 3×3 3A = [3 × 4 3×3 3×5 3×2 3 × −4 3 × −2 9 3 × 4 ] = [12 3×3 9 15 6 −12 −6 12 ] 9 4 Mathematics II Chapter one Matrices and determinates 4. Matrix – Matrix multiplication. The product of an m × n matrix A and an n × p matrix B produces an m × p matrix C, i.e. This implies that the number of columns of the first matrix must be equal to the number of rows in the second matrix. Here are some examples: 1 A= [ 3 5 0 −2 ], 7 2 B = [4 4 2×3 1 2 3 2 C = [ 5 −7 6 −2 ] , −9 0 −1 7 3×4 −1 5 −3 3 9] 6 3×3 2 1 6] D = [5 9 −2 3 7 4×2 We can form : AB : the result is a 2 × 3 matrix AC : the result is a 2 × 4 matrix BC : the result is a 3 × 4 matrix CD : the result is a 3 × 2 matrix But, It is not possible to form: BA or AD The product matrix of two matrices is obtained by taking dot products of the rows of the left matrix with the columns of the right matrix. 5 Mathematics II Chapter one 1 Ex: Find AB if A = [ 3 2 4 ] ,B = [ 4 2 3 1 Matrices and determinates 2 ]? 1 Sol. 3 2 2) ( ) ( 1 2) ( ) 1 1 ] AB = [ (3 (3 4) (3) (3 4) (2) 1 1 (1 × 4 + 2 × 2) (1 × 3 + 2 × 1) (1 × 2 + 2 × 1) = [ ] (3 × 4 + 4 × 2) (3 × 3 + 4 × 1) (3 × 2 + 4 × 1) (1 =[ 4 2) ( ) 2 4 4) ( ) 2 8 20 5 13 (1 4 ] 10 For practical computation Falk’s scheme could be used to evaluate AB in tabular form as follows: 4 3 2 2 1 1 1 2 (1×4 + 2×2) (1×3 + 2×1) (1×2 + 2×1) 3 4 (3×4 + 4×2) (3×3 + 4×1) (3×2 + 4×1) 8 AB = [ 20 5 13 4 ] 10 Properties of matrices multiplication. 1. Matrix multiplication is not commutative (AB ≠ BA) 2 2 1 2 ] ,B = [ ] 4 1 3 1 1×2+2×3 1×2+2×1 8 AB = [ ] = [ 4×2+1×3 4×2+1×1 11 Proof: A = [ BA = [ 2×1+2×4 3×1+1×4 2×2+2×1 10 ]= [ 3×2+1×1 7 4 ] 9 6 ] 7 6 Mathematics II Chapter one Matrices and determinates 2. AB = 0 does not imply A = 0, B = 0 or BA = 0. 1 1 ] ,B = 2 2 1 × (−1) + 1 × 1 AB = [ 2 × (−1) + 2 × 1 Proof: A = [ BA = [ −1 1 1 1 ] .[ −1 2 1 −1 1 ] −1 = [ [ −1 1 ] 1 −1 1 × 1 + 1 × (−1) 0 ]= [ 2 × 1 + 2 × (−1) 0 (−1) × 1 + 1 × 2 1 ]= [ 1 × 1 + (−1) × 2 2 0 ] 0 (−1) × 1 + 1 × 2 ] 1 × 1 + (−1) × 2 3. AB = AC does not necessarily imply B = C 1 2 1 ] , B= [ ] , C= 2 2 2 1×2+1×2 1 2 1 ] .[ ]= [ 2×2+2×2 2 2 2 Proof: A = [ 1 AB = [ 2 AC = [ 1 2 1 2 1 3 ] .[ 2 1 1×3+1×1 0 ]= [ 2×3+2×1 3 3 0 ] 1 3 1×1+1×2 4 ] = [ 2×1+2×2 8 [ 1×0+1×3 4 ] = [ 2×0+2×3 8 3 ] 6 3 ] 6 But, other properties are similar to numbers 4. A(B + C) = AB + AC distributive law 3 1 1 2 1 ] , B= [ ] , C= [ 2 2 2 2 1 5 1 B+C= [ ] 3 5 8 6 1 1 5 1 A(B+C) = [ ] .[ ]= [ ] 2 2 3 5 16 12 4 3 4 3 AB = [ ] , AC = [ ] 8 6 8 6 4 3 4 3 8 6 AB + AC = [ ]+ [ ]= [ ] 8 6 8 6 16 12 Proof: A = [ 0 ] 3 ∴ A(B + C) = AB + AC O.K. 5. A(BC) = (AB)C associative law 7 Mathematics II Chapter one Matrices and determinates *Transpose of a matrix. The transpose of a matrix is obtained by interchanging its rows and columns aTij = aji for i = 1,….., m ; j = 1,……, n The transpose is denoted by a superscript T and the general matrix becomes: a11 a21 a12 aa22 AT = [ ⋮ ⋮ a1n a2n 1 Ex: Find AT if A = [ 5 2 6 ⋯ am1 ⋯ am2 ⋱ ⋮ ] … anm 3 ]? 7 Sol. 1 A = [2 3 T 5 6] 7 Hint: If AT = A then A is a symmetric matrix, e.g. 3 A=[ 2 −1 2 7 0 −1 3 T 0] , A = [2 8 −1 2 7 0 −1 0] 8 Properties of matrices transpose: 1. (AT)T = A for any matrix A. 2. (A + B)T = AT + BT. for matrices A and B with compatible dimensions. 3. (A.B)T = BT. AT . for matrices A and B with compatible dimensions. 4. If AAT = ATA = I then A is orthogonal matrix. 8 Mathematics II Chapter one Matrices and determinates *Determinant of a matrix 1. The determinant of a 2 × 2 matrix a11 A = [a 21 ˗ + a11 is written det. A or |A| = |a 21 Ex: Find det. A if A = [ 1 4 a12 a22 ] a12 a22 | = 𝑎11 . 𝑎22 − 𝑎12 . 𝑎21 2 ]? −7 Sol. |A| = | 1 4 2 | = 1 × (−7) − 2 × 4 = −15 −7 2.The determinant of a 3 × 3 matrix is written as: a11 |A| = |a21 a31 a12 a22 a32 a13 a a23 | = a11 . | 22 a32 a33 a23 a21 | − a . | 12 a a33 31 a23 a21 | + a . | 13 a a33 31 a22 a32 | |A| = 𝑎11 (𝑎22 𝑎33 − 𝑎23 𝑎32 ) − 𝑎12 (𝑎21 𝑎33 − 𝑎23 𝑎31 ) + 𝑎13 (𝑎21 𝑎32 − 𝑎22 𝑎31 ). 3 Ex: Find det. A if A = [2 1 3 Sol. |A| = |2 1 = 3| 1 0 −5 1 0 −5 1 0 3 −1] ? 4 3 −1| 4 −1 2 | − (−5) | 4 1 2 −1 | + 3| 4 1 1 | 0 = 3(4) + 5(9) + 3(-1) = 54 9 Mathematics II Chapter one Matrices and determinates There is another method and to compute the determinant of a 3×3 matrix. It is named Sarrus' rule or Sarrus' scheme. Consider a 3×3 matrix : a11 [a21 a31 a12 a22 a32 a13 a23 ] a33 then its determinant can be computed by the following scheme: = a11 a22 a33 + a12 a23 a31 + a13 a21 a32 − a13 a22 a31 − a11 a23 a32 − a12 a21 a33 + 3 |A| = |2 1 + + −5 1 0 3 3 −1| 2 4 1 - - −5 1 0 = 3×1×4 + (-5)×(-1)×(1) + 3×2×0 - 3×1×1 - 3×(-1)×0 – (-5)×2×4 = 12 + 5 + 0 – 3 – 0 – (-40) = 54 Properties of determinate. 1. if det. A = 0 the matrix A is called a singular matrix. 2. det. A = det. AT 3. det. (AB) = det. A det. B 10 Mathematics II Chapter one Matrices and determinates *Cofactors. The cofactor cij is defined as the coefficient of aij in the determinant A. It is given by the formula: 𝑐𝑖𝑗 = (−1)𝑖+𝑗 |𝑚𝑖𝑗 | where mij is the minor matrix of order (n −1)×(n −1) formed by deleting the column and row containing aij, e.g. c11 a11 = (−1)1+1 |m11 | = (1) |a21 a31 c23 a11 = (−1)2+3 |m23 | = (−1) |a21 a31 a12 a22 a32 a13 a a23 | = | 22 a32 a33 a12 a22 a32 a13 a a23 | = | 11 a31 a33 a23 a33 | = a22 a33 − a23 a32 a12 a32 | = a11 a32 − a12 a31 2 1 4 Ex1: Find the cofactors matrix of A = [5 2 3] ? 8 7 3 Sol. 5 3 𝑐12 = (−1)1+2 | | = (−1)[5 × 3 − 3 × 8] = (-1).(-9) = 9 8 3 𝑐22 = (−1)2+2 | 2 8 4 | = (−1)[2 × 3 − 4 × 8] = (1). (−26) = −26 , etc... 3 Ex2: Find the cofactors matrix of A = [ −2 7 3 ]? 11 Sol. 𝑐11 = (−1)1+1 |11| = (1). (11) = 11 𝑐21 = (−1)2+1 |3| = (-1).(3) = -3 , etc... 11 Chapter one Mathematics II Matrices and determinates *The matrix inverse The inverse a−1 of a scalar (number) a is defined by a a−1 = 1. For square matrices we use a similar definition: the inverse A−1 of a n × n matrix A fulfils the relation: AA−1 = I (unit matrix) The matrix inverse can be computed as follows: 1. Find the determinant det. A. 2. Find the cofactors of all elements in A and form a new matrix C of cofactors, where each element is replaced by its cofactor. 3. The inverse of A is now given as: −1 A CT = |A| Note: the inverse A−1 exists if (and only if) det. A ≠ 0. 1 −1 2 Ex: Find the inverse of A = [−3 1 2 ]? 3 −2 −1 Sol. + + + 1 |A| = |−3 3 −1 1 −2 - - 2 1 −1 2 | −3 1 −1 3 −2 = 1×1×(-1) + (-1) ×2×3 + 2×(-3) ×(-2) - 2×1×3 - 1×2×(-2) - (-1) ×(-3) ×(-1) =6 Since the determinant is nonzero an inverse exists. 1 2 |=3 −2 −1 −3 2 = (−1)1+2 | | = 3 , etc. 3 −1 c11 = (−1)1+1 | c12 12 Mathematics II Chapter one Matrices and determinates Cofactors matrix will be: 3 C = [−5 −4 3 C = [3 3 T 3 −7 −8 3 −1 ] −2 −5 −7 −1 −4 −8] −2 Finally, the inverse of A is: −1 A −1 Check AA 1 3 = [3 6 3 1 2 −5 −7 −1 −4 −8] = [ 12 1 −2 2 −5 6 −7 6 −1 6 −2 3 −4 3 −1 3 ] = I (unit matrix) −1 AA 1 = [−3 3 −1 1 −2 1 2 2 2 ] [ 12 −1 1 2 −5 6 −7 6 −1 6 −2 3 −4 3 −1 3 1 ] = [0 0 0 1 0 0 0] o. k 1 13 *Solution of Ax = B. Mathematics II Chapter one Matrices and determinates Given: a11 x1 + a12 x2 + … … … + a1n xn = b1 a21 x1 + a22 x2 + … … … + a2n xn = b2 ⋮ ⋮ ⋱ ⋮ ⋮ an1 x1 + an2 x2 + … … … + ann xn = bn In matrices: a11 a21 [ ⋮ an1 a12 a22 ⋮ an2 ⋯ a1n x1 b1 ⋯ a2n x2 b2 ] { } = [ ] ⋱ ⋮ ⋮ ⋮ ⋯ ann xn bn There are many methods: 1. By inversion of coefficients matrix. Ax = B → x = A−1 B Ex: solve the following system of equations: x + 3y = 5 -x + 2y = 2 Sol. 1 3 x 5 [ ] {y} = [ ] −1 2 2 |𝐴| = 1 × 2 − 3 × (−1) = 5 𝑐11 = (−1)1+1 |2| = 2 , 𝑐12 = 1 , 𝑐21 = −3 , 𝑐22 = 1 C= [ −1 A 2 −3 1 2 ] , CT = [ 1 1 CT = = |A| 2 𝑥 {𝑦} = [51 5 1 5 −3 5 1 5 2 [ 1 −3 ] 1 2 −3 ] = [51 1 5 −3 5 1 5 ] 4 5 ] . [ ] = [57 ] 2 5 14 Ex: solve the following system of equations: Mathematics II Chapter one Matrices and determinates 8x1 + 2x2 + 3x3 = 30 x1 − 9x2 + 2x3 = 1 2x1 + 3x2 + 6x3 = 31 Sol. 8 [1 2 c11 c13 3 x1 30 2] . {x 2 } = [ 1 ] 6 x3 31 −9 2 1 = (−1)1+1 . | | = −60 , c12 = (−1)1+2 | 3 6 2 1 −9 2 3 = (−1)4 | | = 21 , c21 = (−1)3 | |= 2 3 3 6 2 −9 3 −60 −2 C = [ −3 42 31 −13 + + + 8 |A| = |1 2 −1 A 2 −9 3 x1 2 {x2 } = [ 421 x3 −21 421 −3 42 −20 −3 , etc. 31 −13] −74 3 8 2 2| 1 −9 = (−432) + (8) + (9)— 54 − (48) − (12) = −421 6 2 3 1 −60 = [ −2 −421 21 60 421 21 −60 T −20] , C = [ −2 −74 21 - - - 2 | = −2 6 3 421 −42 421 20 421 −3 42 −20 −31 421 13 421 74 421 31 −13] −74 30 2 ] . [ 1 ] = [ 1] 31 4 15 2. Cramer's rule. Chapter one Mathematics II Matrices and determinates This method based on replacing the column(s) of variables by the column vector of results, then the value of each variable can be found by dividing the determinate of the new matrix to the determinate of the matrix of coefficients. x1 = x2 = xn = b1 b | 2 ⋮ bn a12 … a1n a22 … a2n | ⋮ ⋱ ⋮ an2 … ann |A| a11 a | 21 ⋮ an1 b1 … a1n b2 … a2n | ⋮ ⋱ ⋮ bn … ann |A| a11 a21 | ⋮ an1 a12 a22 ⋮ an2 |A| … b1 … b2 | ⋱ ⋮ … bn Ex: solve the following system of equations: -x + 4y = 1 3x + 12y = 1 16 Ex: solve the following system of equations: Mathematics II Chapter one Matrices and determinates 4.7x1 + 1.3x2 – 1.6x3 = 1.3 x1 – 4.1x2 + 1.1x3 = 4.6 2.1x1 + 1.4x2 + 6.2x3 = 5.2 Sol. 4.7 [1 2.1 1.3 −4.1 1.4 1.3 |4.6 𝑥1 = 5.2 4.7 |1 2.1 −1.6 x1 1.3 1.1 ] . {x2 } = [4.6] x3 6.2 5.2 1.3 −4.1 1.4 1.3 −4.1 1.4 −1.6 1.1 | 6.2 = −109.104 = 0.738 −1.6 −147.785 1.1 | 6.2 4.7 1.3 −1.6 | 1 4.6 1.1 | 109.239 𝑥2 = 2.1 5.2 6.2 = = −0.739 −147.785 −147.785 4.7 1.3 1.3 | 1 −4.1 4.6| −111.661 𝑥3 = 2.1 1.4 5.2 = = 0.756 −147.785 −147.785 Check using eq.1 4.7(0.738) + 1.3(-0.739) – 1.6(0.756) = 1.2983 ≈ 1.3 o.k. 17 3. Gauss elimination. Mathematics II Chapter one Matrices and determinates The solution using this method has three stages. In the first stage the equations are written in matrix form. In the second stage the matrix equations are replaced by a system of equations having the same solution but which are in triangular form. In the final stage the new system is solved by back-substitution. Ex: Use Gaussian elimination to solve the system of linear equations: x1 + 5x2 = 7 −2x1 − 7x2 = −5 Sol. x1 7 1 5 ] . {x } = [ ] −5 2 −2 −7 Row(2) + 2*Row(1) 7 1 5 x1 [ ] . {x } = [ ] 9 2 0 3 [ 3x2 = 9 → x2 = 3 x1 + 5x2 = 7 → x1 = 7 − 5 × 3 = −8 Ex: Use Gaussian elimination to solve the system of linear equations: 2x1 + x2 − x3 + 2x4 = 5 4x1 + 5x2 − 3x3 + 6x4 = 9 −2x1 + 5x2 − 2x3 + 6x4 = 4 4x1 + 11x2 − 4x3 + 8x4 = 2 Sol. 2 1 [ 4 5 −2 5 4 11 −1 −3 −2 −4 x1 2 5 x 6] . { 2 } = [ 9] x3 6 4 x4 8 2 18 Mathematics II Chapter one x1 2 5 2] . {x2 } = [−1] x3 8 9 x4 4 −8 2 R1 R2 − 2R1 [0 R3 + R1 0 R4 − 2R1 0 1 3 6 9 −1 −1 −3 −2 2 R1 R2 [0 R3 − 2R2 0 R4 − 3R2 0 1 3 0 0 x1 −1 2 5 −1 2 ] . {x2 } = [−1] x3 −1 4 11 x4 1 −2 −5 R1 2 R2 [0 R3 0 R4 + R3 0 1 3 0 0 −1 −1 −1 0 Matrices and determinates x1 2 5 2] . {x2 } = [−1] x3 4 11 x4 2 6 2x4 = 6 x4 = 3 −x3 + 4x4 = 11 −x3 + 4(3) = 11 x3 = 1 3x2 − x3 + 2x4 = −1 3x2 − 1 + 2(3) = −1 x2 = −2 2x1 + x2 − x3 + 2x4 = 5 2𝑥1 + (−2) − 1 + 2(3) = 5 𝑥1 = 1 Check using Eq. 2 4x1 + 5x2 − 3x3 + 6x4 = 9 4(1) + 5(-2) – 3(1) + 6(3) = 9 o.k. 19