SlideShare a Scribd company logo
1 of 12
Download to read offline
Relations, Functions, and Matrices




                    Mathematical
                    Structures for
                  Computer Science
                               Chapter 4




    Section 4.6 © 2006 W.H. Freeman & Co.
     Copyright                               
   MSCS Slides
                                                         Matrices   Relations, Functions and Matrices
Monday, March 29, 2010
Matrix

        ●     Data about many kinds of problems can often be
              represented using a rectangular arrangement of values;
              such an arrangement is called a matrix.


        ●     A is a matrix with two rows and three columns.
        ●     The dimensions of the matrix are the number of rows
              and columns; here A is a 2 × 3 matrix.
        ●     Elements of a matrix A are denoted by aij, where i is
              the row number of the element in the matrix and j is
              the column number.
        ●     In the example matrix A, a23 = 8 because 8 is the
              element in row 2, column 3, of A.
    Section 4.6                         Matrices                      2
Monday, March 29, 2010
Example: Matrix

        ●   The constraints of many problems are represented by
            the system of linear equations, e.g.:
        	

 	

 	

      	

     x + y = 70
        	

 	

 	

      	

     24x + 14y = 1180
        	

 The solution is x = 20, y = 50 (you can easily check
            that this is a solution).




        ●     The matrix A is the matrix of coefficients for this
              system of linear equations.

    Section 4.6                          Matrices                  3
Monday, March 29, 2010
Matrix
        ●     If X = Y, then x = 3, y = 6, z = 2, and w = 0.




        ●     We will often be interested in square matrices, in which the
              number of rows equals the number of columns.
        ●     If A is an n × n square matrix, then the elements a11, a22, ... ,
              ann form the main diagonal of the matrix.
        ●     If the corresponding elements match when we think of
              folding the matrix along the main diagonal, then the matrix
              is symmetric about the main diagonal.
        ●     In a symmetric matrix, aij = aji.
    Section 4.6                              Matrices                        4
Monday, March 29, 2010
Matrix Operations

        ●     Scalar multiplication calls for multiplying each entry
              of a matrix by a fixed single number called a scalar.
              The result is a matrix with the same dimensions as the
              original matrix.
        ●     The result of multiplying matrix A:



        	

 by the scalar r = 3 is:




    Section 4.6                         Matrices                   5
Monday, March 29, 2010
Matrix Operations

        ●     Addition of two matrices A and B is defined only
              when A and B have the same dimensions; then it is
              simply a matter of adding the corresponding elements.
        ●     Formally, if A and B are both n × m matrices, then C
              = A + B is an n × m matrix with entries cij = aij + bij:




    Section 4.6                          Matrices                    6
Monday, March 29, 2010
Matrix Operations
        ●     Subtraction of matrices is defined by
        	

   	

   	

    	

     A − B = A + (− l)B
        ●     In a zero matrix, all entries are 0. If we add an n × m zero
              matrix, denoted by 0, to any n × m matrix A, the result is matrix
              A. We can symbolize this by the matrix equation:
        	

   	

   	

    	

     0+A=A
        ●     If A and B are n × m matrices and r and s are scalars, the
              following matrix equations are true:
        	

   	

   	

    	

      A+B=B+A
        	

   	

   	

    	

     (A + B) + C = A + (B + C)
        	

   	

   	

    	

     r(A + B) = rA + rB
        	

   	

   	

    	

     (r + s)A = rA + sA
        	

   	

   	

    	

     r(sA) = (rs)A
        ! !         !      !       rA = Ar
    Section 4.6                               Matrices                            7
Monday, March 29, 2010
Matrix Operations

        ●     Matrix multiplication is computed as A times B and
              denoted as A ⋅ B.
        ●     Condition required for matrix multiplication: the
              number of columns in A must equal the number of
              rows in B. Thus we can compute A ⋅ B if A is an n × m
              matrix and B is an m × p matrix. The result is an n × p
              matrix.
        ●     An entry in row i, column j of A ⋅ B is obtained by
              multiplying elements in row i of A by the
              corresponding elements in column j of B and adding
              the results. Formally, A ⋅ B = C, where


    Section 4.6                          Matrices                   8
Monday, March 29, 2010
Example: Matrix Multiplication

        ●     To find A ⋅ B = C for the following matrices:




        ●     Similarly, doing the same for the other row, C is:


    Section 4.6                          Matrices                  9
Monday, March 29, 2010
Matrix Multiplication

        ●     Compute A ⋅ B and B ⋅ A for the following matrices:




        ●     Note that even if A and B have dimensions so that
              both A ⋅ B and B ⋅ A are defined, A ⋅ B need not equal
              B ⋅ A.




    Section 4.6                         Matrices                      10
Monday, March 29, 2010
Matrix Multiplication

        ●     Where A, B, and C are matrices of appropriate
              dimensions and r and s are scalars, the following
              matrix equations are true (the notation A (B ⋅ C) is
              shorthand for A ⋅ (B ⋅ C)):
        	

   	

 	

     	

    A (B ⋅ C) = (A ⋅ B) C
        	

   	

 	

     	

    A (B + C) = A ⋅ B + A ⋅ C
        	

   	

 	

     	

    (A + B) C = A ⋅ C + B ⋅ C
        	

   	

 	

     	

    rA ⋅ sB = (rs)(A ⋅ B)
        ●     The n × n matrix with 1s along the main diagonal and
              0s elsewhere is called the identity matrix, denoted by
              I. If we multiply I times any nn matrix A, we get A as
              the result. The equation is:
        	

   	

 	

     	

    I⋅A=A⋅I=A
    Section 4.6                          Matrices                  11
Monday, March 29, 2010
Matrix Multiplication Algorithm
        ALGORITHM MatrixMultiplication
        //computes n × p matrix A ⋅ B for n × m matrix A, m × p matrix B
        //stores result in C
        for i = 1 to n do
        	

 for j = 1 to p do
        	

 	

  C[i, j] = 0
        	

 	

  for k =1 to m do
        	

 	

  	

      C[i, j] = C[i, j] + A[i, k] * B[k, j]
        	

 	

  end for
        	

 end for
        end for
        write out product matrix C
        ● If A and B are both n × n matrices, then there are Θ(n3)

            multiplications and Θ(n3) additions required. Overall complexity
            is Θ(n3)
    Section 4.6                            Matrices                        12
Monday, March 29, 2010

More Related Content

What's hot

Calculus and Numerical Method =_=
Calculus and Numerical Method =_=Calculus and Numerical Method =_=
Calculus and Numerical Method =_=Fazirah Zyra
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - MathematicsDrishti Bhalla
 
Add Math(F5) Graph Of Function Ii 2.1
Add Math(F5) Graph Of Function Ii 2.1Add Math(F5) Graph Of Function Ii 2.1
Add Math(F5) Graph Of Function Ii 2.1roszelan
 
Lecture 07 graphing linear equations
Lecture 07 graphing linear equationsLecture 07 graphing linear equations
Lecture 07 graphing linear equationsHazel Joy Chong
 
Matrix and its operation (addition, subtraction, multiplication)
Matrix and its operation (addition, subtraction, multiplication)Matrix and its operation (addition, subtraction, multiplication)
Matrix and its operation (addition, subtraction, multiplication)NirnayMukharjee
 
Intro to Algebra II
Intro to Algebra IIIntro to Algebra II
Intro to Algebra IIteamxxlp
 
Class 8 Cbse Maths Syllabus 2011-12
Class 8 Cbse Maths Syllabus 2011-12Class 8 Cbse Maths Syllabus 2011-12
Class 8 Cbse Maths Syllabus 2011-12Sunaina Rawat
 
Xmss ict lesson sec 2 qe wksheet
Xmss  ict lesson sec 2 qe wksheetXmss  ict lesson sec 2 qe wksheet
Xmss ict lesson sec 2 qe wksheetbryan
 
Properties of a Triangular Matrix
Properties of a Triangular MatrixProperties of a Triangular Matrix
Properties of a Triangular MatrixChristopher Gratton
 
Lecture 4 chapter 1 review section 2-1
Lecture 4   chapter 1 review section 2-1Lecture 4   chapter 1 review section 2-1
Lecture 4 chapter 1 review section 2-1njit-ronbrown
 

What's hot (20)

7 5
7 57 5
7 5
 
Matrices
MatricesMatrices
Matrices
 
M a t r i k s
M a t r i k sM a t r i k s
M a t r i k s
 
Calculus and Numerical Method =_=
Calculus and Numerical Method =_=Calculus and Numerical Method =_=
Calculus and Numerical Method =_=
 
Determinants - Mathematics
Determinants - MathematicsDeterminants - Mathematics
Determinants - Mathematics
 
Add Math(F5) Graph Of Function Ii 2.1
Add Math(F5) Graph Of Function Ii 2.1Add Math(F5) Graph Of Function Ii 2.1
Add Math(F5) Graph Of Function Ii 2.1
 
Matrizes
MatrizesMatrizes
Matrizes
 
MATEMATIK SEM 3 TRANSFORMASI
MATEMATIK SEM 3 TRANSFORMASIMATEMATIK SEM 3 TRANSFORMASI
MATEMATIK SEM 3 TRANSFORMASI
 
Matrices and determinants-1
Matrices and determinants-1Matrices and determinants-1
Matrices and determinants-1
 
Lecture 07 graphing linear equations
Lecture 07 graphing linear equationsLecture 07 graphing linear equations
Lecture 07 graphing linear equations
 
Unit 1
Unit 1Unit 1
Unit 1
 
Matrix and its operation (addition, subtraction, multiplication)
Matrix and its operation (addition, subtraction, multiplication)Matrix and its operation (addition, subtraction, multiplication)
Matrix and its operation (addition, subtraction, multiplication)
 
Intro to Algebra II
Intro to Algebra IIIntro to Algebra II
Intro to Algebra II
 
Class 8 Cbse Maths Syllabus 2011-12
Class 8 Cbse Maths Syllabus 2011-12Class 8 Cbse Maths Syllabus 2011-12
Class 8 Cbse Maths Syllabus 2011-12
 
Image compression
Image compressionImage compression
Image compression
 
Xmss ict lesson sec 2 qe wksheet
Xmss  ict lesson sec 2 qe wksheetXmss  ict lesson sec 2 qe wksheet
Xmss ict lesson sec 2 qe wksheet
 
tutorial6
tutorial6tutorial6
tutorial6
 
Properties of a Triangular Matrix
Properties of a Triangular MatrixProperties of a Triangular Matrix
Properties of a Triangular Matrix
 
Per5_matrix multiplication
Per5_matrix multiplicationPer5_matrix multiplication
Per5_matrix multiplication
 
Lecture 4 chapter 1 review section 2-1
Lecture 4   chapter 1 review section 2-1Lecture 4   chapter 1 review section 2-1
Lecture 4 chapter 1 review section 2-1
 

Viewers also liked

Applications of matrices in real life
Applications of matrices in real lifeApplications of matrices in real life
Applications of matrices in real lifeSuhaibFaiz
 
Appilation of matrices in real life
Appilation of matrices in real lifeAppilation of matrices in real life
Appilation of matrices in real lifeStudent
 
Applications of Matrices
Applications of MatricesApplications of Matrices
Applications of Matricessanthosh kumar
 
Linear Algebra and Matrix
Linear Algebra and MatrixLinear Algebra and Matrix
Linear Algebra and Matrixitutor
 
Application of algebra
Application of algebraApplication of algebra
Application of algebraAbhinav Somani
 
presentation on matrix
 presentation on matrix presentation on matrix
presentation on matrixNikhi Jain
 
Matrices And Application Of Matrices
Matrices And Application Of MatricesMatrices And Application Of Matrices
Matrices And Application Of Matricesmailrenuka
 

Viewers also liked (7)

Applications of matrices in real life
Applications of matrices in real lifeApplications of matrices in real life
Applications of matrices in real life
 
Appilation of matrices in real life
Appilation of matrices in real lifeAppilation of matrices in real life
Appilation of matrices in real life
 
Applications of Matrices
Applications of MatricesApplications of Matrices
Applications of Matrices
 
Linear Algebra and Matrix
Linear Algebra and MatrixLinear Algebra and Matrix
Linear Algebra and Matrix
 
Application of algebra
Application of algebraApplication of algebra
Application of algebra
 
presentation on matrix
 presentation on matrix presentation on matrix
presentation on matrix
 
Matrices And Application Of Matrices
Matrices And Application Of MatricesMatrices And Application Of Matrices
Matrices And Application Of Matrices
 

Similar to CPSC 125 Ch 4 Sec 6

Matrices y determinants
Matrices y determinantsMatrices y determinants
Matrices y determinantsJeannie
 
Linear Algebra for beginner and advance students
Linear Algebra for beginner and advance studentsLinear Algebra for beginner and advance students
Linear Algebra for beginner and advance studentsShamshadAli58
 
Matrix and Determinants
Matrix and DeterminantsMatrix and Determinants
Matrix and DeterminantsAarjavPinara
 
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.pptALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.pptssuser2e348b
 
Matrices & determinants
Matrices & determinantsMatrices & determinants
Matrices & determinantsindu thakur
 
MATRICES
MATRICESMATRICES
MATRICESdaferro
 
Matrices and determinats
Matrices and determinatsMatrices and determinats
Matrices and determinatsdaferro
 
Section 7.5 version 2 AM new ppt for every
Section 7.5 version 2 AM new ppt for everySection 7.5 version 2 AM new ppt for every
Section 7.5 version 2 AM new ppt for everyjaved75
 
MATRIX-ARTIHMETIC.pdf1234567898765432123
MATRIX-ARTIHMETIC.pdf1234567898765432123MATRIX-ARTIHMETIC.pdf1234567898765432123
MATRIX-ARTIHMETIC.pdf1234567898765432123ElaMaeSilmaro
 
Engg maths k notes(4)
Engg maths k notes(4)Engg maths k notes(4)
Engg maths k notes(4)Ranjay Kumar
 
matrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdfmatrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdfShafaqMehmood2
 
Rosalina Apriana - Math Compulsory Grade XI - Matriks
Rosalina Apriana - Math Compulsory Grade XI - MatriksRosalina Apriana - Math Compulsory Grade XI - Matriks
Rosalina Apriana - Math Compulsory Grade XI - MatriksRosalinaApriana
 
Matematika kelas XI semester 2 - Matriks fun mathematics
Matematika kelas XI semester 2 - Matriks fun mathematicsMatematika kelas XI semester 2 - Matriks fun mathematics
Matematika kelas XI semester 2 - Matriks fun mathematicsRosalinaApriana
 
Basic concepts. Systems of equations
Basic concepts. Systems of equationsBasic concepts. Systems of equations
Basic concepts. Systems of equationsjorgeduardooo
 

Similar to CPSC 125 Ch 4 Sec 6 (20)

Matrices y determinants
Matrices y determinantsMatrices y determinants
Matrices y determinants
 
Matrices 1.pdf
Matrices 1.pdfMatrices 1.pdf
Matrices 1.pdf
 
LinearAlgebra.ppt
LinearAlgebra.pptLinearAlgebra.ppt
LinearAlgebra.ppt
 
LinearAlgebra.ppt
LinearAlgebra.pptLinearAlgebra.ppt
LinearAlgebra.ppt
 
Linear Algebra for beginner and advance students
Linear Algebra for beginner and advance studentsLinear Algebra for beginner and advance students
Linear Algebra for beginner and advance students
 
Matrix and Determinants
Matrix and DeterminantsMatrix and Determinants
Matrix and Determinants
 
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.pptALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
 
Matrices & determinants
Matrices & determinantsMatrices & determinants
Matrices & determinants
 
MATRICES
MATRICESMATRICES
MATRICES
 
Matrices and determinats
Matrices and determinatsMatrices and determinats
Matrices and determinats
 
7 4
7 47 4
7 4
 
Matrices & Determinants.pdf
Matrices & Determinants.pdfMatrices & Determinants.pdf
Matrices & Determinants.pdf
 
Section 7.5 version 2 AM new ppt for every
Section 7.5 version 2 AM new ppt for everySection 7.5 version 2 AM new ppt for every
Section 7.5 version 2 AM new ppt for every
 
MATRIX-ARTIHMETIC.pdf1234567898765432123
MATRIX-ARTIHMETIC.pdf1234567898765432123MATRIX-ARTIHMETIC.pdf1234567898765432123
MATRIX-ARTIHMETIC.pdf1234567898765432123
 
Ma3bfet par 10.5 31 julie 2014
Ma3bfet par 10.5 31 julie 2014Ma3bfet par 10.5 31 julie 2014
Ma3bfet par 10.5 31 julie 2014
 
Engg maths k notes(4)
Engg maths k notes(4)Engg maths k notes(4)
Engg maths k notes(4)
 
matrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdfmatrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdf
 
Rosalina Apriana - Math Compulsory Grade XI - Matriks
Rosalina Apriana - Math Compulsory Grade XI - MatriksRosalina Apriana - Math Compulsory Grade XI - Matriks
Rosalina Apriana - Math Compulsory Grade XI - Matriks
 
Matematika kelas XI semester 2 - Matriks fun mathematics
Matematika kelas XI semester 2 - Matriks fun mathematicsMatematika kelas XI semester 2 - Matriks fun mathematics
Matematika kelas XI semester 2 - Matriks fun mathematics
 
Basic concepts. Systems of equations
Basic concepts. Systems of equationsBasic concepts. Systems of equations
Basic concepts. Systems of equations
 

CPSC 125 Ch 4 Sec 6

  • 1. Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Section 4.6 © 2006 W.H. Freeman & Co. Copyright MSCS Slides Matrices Relations, Functions and Matrices Monday, March 29, 2010
  • 2. Matrix ● Data about many kinds of problems can often be represented using a rectangular arrangement of values; such an arrangement is called a matrix. ● A is a matrix with two rows and three columns. ● The dimensions of the matrix are the number of rows and columns; here A is a 2 × 3 matrix. ● Elements of a matrix A are denoted by aij, where i is the row number of the element in the matrix and j is the column number. ● In the example matrix A, a23 = 8 because 8 is the element in row 2, column 3, of A. Section 4.6 Matrices 2 Monday, March 29, 2010
  • 3. Example: Matrix ● The constraints of many problems are represented by the system of linear equations, e.g.: x + y = 70 24x + 14y = 1180 The solution is x = 20, y = 50 (you can easily check that this is a solution). ● The matrix A is the matrix of coefficients for this system of linear equations. Section 4.6 Matrices 3 Monday, March 29, 2010
  • 4. Matrix ● If X = Y, then x = 3, y = 6, z = 2, and w = 0. ● We will often be interested in square matrices, in which the number of rows equals the number of columns. ● If A is an n × n square matrix, then the elements a11, a22, ... , ann form the main diagonal of the matrix. ● If the corresponding elements match when we think of folding the matrix along the main diagonal, then the matrix is symmetric about the main diagonal. ● In a symmetric matrix, aij = aji. Section 4.6 Matrices 4 Monday, March 29, 2010
  • 5. Matrix Operations ● Scalar multiplication calls for multiplying each entry of a matrix by a fixed single number called a scalar. The result is a matrix with the same dimensions as the original matrix. ● The result of multiplying matrix A: by the scalar r = 3 is: Section 4.6 Matrices 5 Monday, March 29, 2010
  • 6. Matrix Operations ● Addition of two matrices A and B is defined only when A and B have the same dimensions; then it is simply a matter of adding the corresponding elements. ● Formally, if A and B are both n × m matrices, then C = A + B is an n × m matrix with entries cij = aij + bij: Section 4.6 Matrices 6 Monday, March 29, 2010
  • 7. Matrix Operations ● Subtraction of matrices is defined by A − B = A + (− l)B ● In a zero matrix, all entries are 0. If we add an n × m zero matrix, denoted by 0, to any n × m matrix A, the result is matrix A. We can symbolize this by the matrix equation: 0+A=A ● If A and B are n × m matrices and r and s are scalars, the following matrix equations are true: A+B=B+A (A + B) + C = A + (B + C) r(A + B) = rA + rB (r + s)A = rA + sA r(sA) = (rs)A ! ! ! ! rA = Ar Section 4.6 Matrices 7 Monday, March 29, 2010
  • 8. Matrix Operations ● Matrix multiplication is computed as A times B and denoted as A ⋅ B. ● Condition required for matrix multiplication: the number of columns in A must equal the number of rows in B. Thus we can compute A ⋅ B if A is an n × m matrix and B is an m × p matrix. The result is an n × p matrix. ● An entry in row i, column j of A ⋅ B is obtained by multiplying elements in row i of A by the corresponding elements in column j of B and adding the results. Formally, A ⋅ B = C, where Section 4.6 Matrices 8 Monday, March 29, 2010
  • 9. Example: Matrix Multiplication ● To find A ⋅ B = C for the following matrices: ● Similarly, doing the same for the other row, C is: Section 4.6 Matrices 9 Monday, March 29, 2010
  • 10. Matrix Multiplication ● Compute A ⋅ B and B ⋅ A for the following matrices: ● Note that even if A and B have dimensions so that both A ⋅ B and B ⋅ A are defined, A ⋅ B need not equal B ⋅ A. Section 4.6 Matrices 10 Monday, March 29, 2010
  • 11. Matrix Multiplication ● Where A, B, and C are matrices of appropriate dimensions and r and s are scalars, the following matrix equations are true (the notation A (B ⋅ C) is shorthand for A ⋅ (B ⋅ C)): A (B ⋅ C) = (A ⋅ B) C A (B + C) = A ⋅ B + A ⋅ C (A + B) C = A ⋅ C + B ⋅ C rA ⋅ sB = (rs)(A ⋅ B) ● The n × n matrix with 1s along the main diagonal and 0s elsewhere is called the identity matrix, denoted by I. If we multiply I times any nn matrix A, we get A as the result. The equation is: I⋅A=A⋅I=A Section 4.6 Matrices 11 Monday, March 29, 2010
  • 12. Matrix Multiplication Algorithm ALGORITHM MatrixMultiplication //computes n × p matrix A ⋅ B for n × m matrix A, m × p matrix B //stores result in C for i = 1 to n do for j = 1 to p do C[i, j] = 0 for k =1 to m do C[i, j] = C[i, j] + A[i, k] * B[k, j] end for end for end for write out product matrix C ● If A and B are both n × n matrices, then there are Θ(n3) multiplications and Θ(n3) additions required. Overall complexity is Θ(n3) Section 4.6 Matrices 12 Monday, March 29, 2010