CS100: Discrete structures

Slides:



Advertisements
Similar presentations
Matrix.
Advertisements

CSNB143 – Discrete Structure
Chapter Matrices Matrix Arithmetic
Mathematics. Matrices and Determinants-1 Session.
CALCULUS – II Matrix Multiplication by Dr. Eman Saad & Dr. Shorouk Ossama.
Matrices MSU CSE 260.
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
MATRICES. Matrices A matrix is a rectangular array of objects (usually numbers) arranged in m horizontal rows and n vertical columns. A matrix with m.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
3.8 Matrices.
ECON 1150 Matrix Operations Special Matrices
Lecture 7 Matrices CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Chapter 4 – Matrix CSNB 143 Discrete Mathematical Structures.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
Prepared by Deluar Jahan Moloy Lecturer Northern University Bangladesh
Chapter 6 Systems of Linear Equations and Matrices Sections 6.3 – 6.5.
Meeting 18 Matrix Operations. Matrix If A is an m x n matrix - that is, a matrix with m rows and n columns – then the scalar entry in the i th row and.
CSCI 171 Presentation 9 Matrix Theory. Matrix – Rectangular array –i th row, j th column, i,j element –Square matrix, diagonal –Diagonal matrix –Equality.
Matrices Section 2.6. Section Summary Definition of a Matrix Matrix Arithmetic Transposes and Powers of Arithmetic Zero-One matrices.
Matrices: Basic Operations and Their Properties
Chapter 2 … part1 Matrices Linear Algebra S 1. Ch2_2 2.1 Addition, Scalar Multiplication, and Multiplication of Matrices Definition A matrix is a rectangular.
CSNB143 – Discrete Structure Topic 3 – Matrices. Learning Outcomes Students should understand all matrices operations. Students should be able to differentiate.
Matrices and Determinants
Af2. The Queen Mother says “ Please be quite and let Patrick give the lecture. Thank you.”
Linear Algebra Chapter 2 Matrices.
Section 2.4. Section Summary  Sequences. o Examples: Geometric Progression, Arithmetic Progression  Recurrence Relations o Example: Fibonacci Sequence.
Matrix Algebra Definitions Operations Matrix algebra is a means of making calculations upon arrays of numbers (or data). Most data sets are matrix-type.
CS 285- Discrete Mathematics Lecture 11. Section 3.8 Matrices Introduction Matrix Arithmetic Transposes and Power of Matrices Zero – One Matrices Boolean.
A very brief introduction to Matrix (Section 2.7) Definitions Some properties Basic matrix operations Zero-One (Boolean) matrices.
2.1 Matrix Operations 2. Matrix Algebra. j -th column i -th row Diagonal entries Diagonal matrix : a square matrix whose nondiagonal entries are zero.
Linear Algebra by Dr. Shorouk Ossama.
Matrices Introduction.
MTH108 Business Math I Lecture 20.
2. Matrix Methods
CSE15 Discrete Mathematics 03/01/17
CSE 504 Discrete Mathematics & Foundations of Computer Science
CSNB 143 Discrete Mathematical Structures
3.8 Matrices L Al-zaid Math1101.
Sections 2.4 and 2.5 Matrix Operations
4.5 Matrices.
Matrix Algebra MATRIX OPERATIONS © 2012 Pearson Education, Inc.
Properties and Applications of Matrices
Boyce/DiPrima 10th ed, Ch 7.2: Review of Matrices Elementary Differential Equations and Boundary Value Problems, 10th edition, by William E. Boyce and.
nhaa/imk/sem /eqt101/rk12/32
MATRICES.
1.4 Inverses; Rules of Matrix Arithmetic
Discrete Structures – CNS2300
Applied Discrete Mathematics Week 5: Mathematical Reasoning
1.5 Matricies.
MATHEMATICS Matrix Algebra
5 Systems of Linear Equations and Matrices
4.6 Matrices.
MATHEMATICS Matrix Multiplication
Matrix Algebra MATRIX OPERATIONS © 2012 Pearson Education, Inc.
L6 matrix operations.
L5 matrix.
Sequences and Summations
7.3 Matrices.
2. Matrix Algebra 2.1 Matrix Operations.
Section 2.4 Matrices.
Matrices Introduction.
Matrices and Matrix Operations
Properties of Relations
3.5 Perform Basic Matrix Operations
Multiplication of Matrices
Matrix Addition, C = A + B Add corresponding elements of each matrix to form elements of result matrix. Given elements of A as ai,j and elements of B as.
Matrix Algebra MATRIX OPERATIONS © 2012 Pearson Education, Inc.
3.8 Matrices L Al-zaid Math1101.
Applied Discrete Mathematics Week 4: Functions
Matrices and Determinants
Presentation transcript:

CS100: Discrete structures Computer Science Department Lecture 5 - Matrices

Matrices Introduction DEFINITION 1: A matrix is a rectangular array of numbers. A matrix with m rows and n columns is called an m x n matrix. The plural of matrix is matrices. A matrix with the same number of rows as columns is called square. Two matrices are equals if they have the same number of rows and the same number of columns and the corresponding entries in every position are equal. Example: The matrix is a 3 x 2 matrix. 18-Jan-19 Computer Science Department

Matrices DEFINITION 2: 18-Jan-19 Computer Science Department

Example 1 Then A is 2 x 3 with a12 = 3 and a23 = 2, B is 2 x 2 with b21 = 4, C is 1 x 4, D is 3 x 1, and E is 3 x 3 ? ? ? ? ? ? ? ? 18-Jan-19 Computer Science Department

Exercise 3×4 Let What size is A ? What is the third column of A ? What is the second row of A ? What is the element of A in the (3,2)th position ? 3×4 A(3,2)=1 18-Jan-19 Computer Science Department

Diagonal Matrix Example : A square matrix A = [aij ] for which every entry off the main diagonal is zero, that is, aij = 0 for i ≠ j, is called a diagonal matrix Example : 18-Jan-19 Computer Science Department

Identity Matrix The n x n diagonal matrix all of whose diagonal elements are 1, is called the identity matrix of order n. Multiplying a matrix by an appropriately sized identity matrix does not change this matrix. In other words, when A is an m x n matrix, we have AIn= ImA = A Powers of square matrices can be defined. When A is an n x n matrix, we have A0 = In , Ar = AAAA…A (r times) 18-Jan-19 Computer Science Department

Example of Matrix applications Matrices are used in many applications in computer science, and we shall see them in our study of relations and graphs. At this point, we present the following simple application showing how matrices can be used to display data in a tabular form 18-Jan-19 Computer Science Department

Cont’d The following matrix gives the airline distance between the cities indicated 18-Jan-19 Computer Science Department

Equal Matrices if aij = bij , DEFINITION 2: Two m x n matrices A = [aij ] and B = [bij] are said to be equal if aij = bij , 1 ≤ i ≤ m , 1 ≤ j ≤ n; that is, if corresponding elements are the same. Notice how easy it is to state the definition using generic elements aij , bij Two matrices are equal if they have the same dimension or order and the corresponding elements are identical. 18-Jan-19 Computer Science Department

Then A = B if and only if X=-3, y=0, and z=6 Cont’d Then A = B if and only if X=-3, y=0, and z=6 18-Jan-19 Computer Science Department

Matrices Matrix Arithmetic DEFINITION 3: Let A = [aij] and B = [bij] be m x n matrices. The sum of A and B, denoted by A + B, is the m x n matrix that has aij + bij as its (i,j)th element. In other words, A + B = [aij + bij]. The sum of two matrices of the same size is obtained by adding elements in the corresponding positions. Matrices of different sizes can’t be added. 18-Jan-19 Computer Science Department

Example 1 Example 2 18-Jan-19 Computer Science Department

Zero Matrix A matrix all of whose entries are zero is called a zero matrix and is denoted by 0 Each of the following is Zero matrix 18-Jan-19 Computer Science Department

Properties of Matrix Addition A + B = B + A (A + B) + C = A + (B + C) A + 0 = 0 + A = A 18-Jan-19 Computer Science Department

Matrices Production DEFINITION 4: Let A be an m x k matrix and B be a k x n matrix. The product of A and B, denoted by AB, is the m x n matrix with its (i,j)th entry equal to the sum of the products of the corresponding elements from the ith row of A and the ith column of B. In other words, if AB = [cij], then cij = ai1b1j + ai2b2j + … + aikbkj. 18-Jan-19 Computer Science Department

Matrices Production The product of the two matrices is not defined when the number of columns in the first matrix and the number of rows in the second matrix is not the same. 18-Jan-19 Computer Science Department

Matrices Production 18-Jan-19 Computer Science Department

AB= 18-Jan-19 Computer Science Department

Matrices Production Example: Find AB if it is defined. Let A 4X3= and B3X2 = Find AB if it is defined. AB4X2 = 18-Jan-19 Computer Science Department

Exercise Consider the matrices A= ,B= ,C= Find the following: 2A= 4A + B = A+0= 18-Jan-19 Computer Science Department

Matrices Production No Solution: Example: Let A 2x2 = and B 2x2= DEFINITION 5: If A and B are two matrices, it is not necessarily true that AB and BA are the same. E.g. if A is 2 x 3 and B is 3 x 4, then AB is defined and is 2 x 4, but BA is not defined. Even when A and B are both n x n matrices, AB and BA are not necessarily equal. Example: Let A 2x2 = and B 2x2= Does AB = BA? Solution: AB = and BA = No 18-Jan-19 Computer Science Department

Properties of Multiplication If A = m x p matrix, and B is a p x n matrix, then AB can be computed and is an m x n matrix. As for BA, we have four different possibilities: BA may not be defined; we may have n ≠ m For Example : A=4x5 , B=5x6 BA may be defined if n = m, and then BA is p x p, while AB is m x m and p ≠ m. Thus AB and BA are not equal For Example : A=4x5 , B=5x4 AB and BA may both the same size, but not equal as matrices AB ≠ BA For Example : A=4x4 , B=4x4 AB = BA 18-Jan-19 Computer Science Department

Basic Properties of Multiplication The basic properties of matrix multiplication are given by the following theorem: A(BC) = (AB)C A(B + C)= AB + AC (A + B)C = AC + BC 18-Jan-19 Computer Science Department

Transpose Matrices Example: The transpose of the matrix is the matrix DEFINITION 6: Let A = [aij] be an m x n matrix. The transpose of A, denoted by At, is the n x m matrix obtained by interchanging the rows and columns of A. In other words, if At = [bij], then bij = aji, for i = 1,2,…,n and j = 1,2,…,m. Example: The transpose of the matrix is the matrix 18-Jan-19 Computer Science Department

Properties for Transpose If A and B are matrices, then 𝐴 𝑇 𝑇 =𝐴 (𝐴+𝐵) 𝑇 = 𝐴 𝑇 + 𝐵 𝑇 (𝐴𝐵) 𝑇 = 𝐵 𝑇 𝐴 𝑇 18-Jan-19 Computer Science Department

Exercises Consider the matrices : A= ,B= ,C= Find the following: 𝐶 𝑇 (𝐴+𝐵) 𝑇 =𝐴 𝑇 + 𝐵 𝑇 1 2 5 3 −4 −2 −1 1 4 0 3 2 2 −2 3 + 6 4 3 8 −2 1 5 7 2 = 5 5 7 8 1 3 7 5 5 18-Jan-19 Computer Science Department

Symmetric Matrices Example: The matrix is symmetric. Example DEFINITION 7: A square matrix A is called symmetric if A = At. Thus A = [aij] is symmetric if aij = aji for all i and j with 1 ≤ i ≤ n and 1 ≤ j ≤ n. Example: The matrix is symmetric. Example 18-Jan-19 Computer Science Department

The Transpose of a Symmetric Matrix 18-Jan-19 Computer Science Department

Boolean Matrix Operation A Boolean matrix is an m x n matrix whose entries are either zero or one. Example: 1 0 1 0 0 1 1 1 0 18-Jan-19 Computer Science Department

Boolean Matrix Operations (join) Let A = [aij] and B = [bij] be m x n Boolean matrices. We define A v B = C = [ Cij], the join of A and B, by 1 if aij =1 or bij = 1 Cij = 0 if aij and bij are both 0 18-Jan-19 Computer Science Department

Example Find the join of A and B: A = B = A v B = 1 0 1 0 1 0 0 1 0 1 1 0 1v0 0v1 1v0 0v1 1v1 0v0 = 1 1 1 1 1 0 18-Jan-19 Computer Science Department

Boolean Matrix Operations (Meet) We define A ^ B = C = [ Cij], the meet of A and B, by 1 if aij and bij are both 1 Cij = 0 if aij = 0 or bij = 0 Meet & Join are the same as the addition procedure each element with the corresponding element in the other matrix Matrices have the same size 18-Jan-19 Computer Science Department

Example Find the meet of A and B: A = B = A ^ B = 1 0 1 0 1 0 0 1 0 1 1 0 1^0 0^1 1^0 0^1 1^1 0^0 = 0 0 0 0 1 0 18-Jan-19 Computer Science Department

Boolean PRODUCT The Boolean product of A and B, denoted , 𝑨 ⊙𝑩 is the m x n Boolean matrix defined by C𝑖𝑗= 1 , if aik = 1 and bkj = 1 for some k,1 ≤ k ≤ p 0,𝑂𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 Procedure: Select row i of A and column j of B, and arrange them side by side. Compare corresponding entries. If even a single pair of corresponding entries consists of two 1’s, then Cij = 1, otherwise Cij = 0 18-Jan-19 Computer Science Department

Example Find the Boolean product of A and B: A 3x2= B 2x3 = 𝑨 ⊙𝑩3x3= 1 0 0 1 1 0 1 1 0 0 1 1 (1 ^ 1) v (0 ^ 0) (1 ^ 1) v (0 ^ 1) (1 ^ 0) v (0 ^ 1) (0 ^ 1) v (1 ^ 0) (0 ^ 1) v (1 ^ 1) (0 ^ 0) v (1 ^ 1) (1 ^ 1) v (0 ^ 0) (1 ^ 1) v (0 ^ 1) (1 ^ 0) v (0 ^ 1) = 1 1 0 0 1 1 1 1 0 18-Jan-19 Computer Science Department

Boolean Operations Properties If A, B, and C are Boolean Matrices with the same sizes, then A v B = B v A A ^ B = B ^ A (A v B) v C = A v (B v C) (A ^ B) ^ C = A ^ (B ^ C) 18-Jan-19 Computer Science Department

Exercises Find meet and join for A and B: Solution : Meet of A and B = join of A and B = 18-Jan-19 Computer Science Department

Exercises Find 𝑨 ⊙𝑩 Solution: 𝑨 ⊙𝑩 = 18-Jan-19 Computer Science Department

Any Question Refer to chapter 3 of the book for further reading 18-Jan-19 Computer Science Department