1 _2_ by mazharciit

VIEWS: 39 PAGES: 13

Discrete Structure Notes

More Info
									                                LECTURE # 41

                                       MATRIX

An m  n matrix A over a set S is a rectangular array of elements of S
arranged into m rows and n columns:

                 a11         a12        a1 j            a1n 
                a            a22        a2 j            a2 n 
                 21                                            
                                                         
              A                                               
                 ai1         ai 2             aij       ain      ith row of A
                                                         
                                                               
                am1
                             am 2  amj                  amn 
                                         
                              jth column of A
Briefly, it is written as:
                   A = (aij)mn
                                      EXAMPLE

                             4  2 0 6
                         A  2  3 1 9
                                        
                             0
                                 7 5  1
                                         
A is a matrix having 3 rows and 4 columns. We call it a 3  4 matrix, or
matrix of size 3  4 or matrix of order 3  4 .
Note that
                   a13 = 0,          a23 = 1,         a32 = 7


                                                                                1
                         SQUARE MATRIX

A matrix for which the number of rows and columns are equal is called a
square matrix. A square matrix A with n rows and n columns (size n  n)
has the form:
                a11     a12       a1i        a1n 
               a        a22  a2i             a2 n 
                21                                  
                                              
             A                                     
                ai1     ai 2      aii        ain 
                                              
                                                    
               an1
                        an 2  ani            ann 

The main diagonal of A consists of all the entries
                                a11, a22, a33, …, aii,…, ann


                   TRANSPOSE OF A MATRIX

The transpose of a matrix A of size m  n, is the matrix At of size n  m,
obtained by writing the rows of A, in order, as columns. Thus if



     a11 a12  a1n                            a11     a21  am1 
    a    a22  a2 n                          a        a22  am 2 
A   21             ,                   At   12                 
                                                          
                                                                 
     am1 am 2  amn                          a1n      a2 n  amn 

                                                                      2
                                 EXAMPLE
Find transpose of the following matrix

                                 4  2 0 6
                             A  2  3 1 9
                                            
                                 0
                                     7 5  1
                                             

Then its transpose is obtained by changing rows of A into columns. Thus

                                 4    2 0
                                 2  3 7 
                           At             
                                 0    1 5
                                           
                                 6    9  1

Note that the order of A is 3 x 4 where as order of At is 4 x 3. In fact if A has
order m x n then At will have order n x m.
                         SYMMETRIC MATRIX

A square matrix A = (aij) of size n  n is called symmetric if, and only if,
At = A i.e., for all i, j = 1, 2, …, n,              aij = aji
EXAMPLE                                                4 2 0
                       1 3 7
                     A                          B  2  3 1
                        5 2 9
          Let                  ,           and               
                                                    0 1 5
                                                             
                       1 5                            4 2 0
    Then          At   3 2  ,
                                        and    B t  2  3 1
                                                              
                       7 9 
                                                     0 1 5
                                                              

Note that Bt = B, so that B is a symmetric matrix. But A is not equal to At
hence A is not symmetric.
                                                                         3
                    MATRIX MULTIPLICATION


  Suppose A and B are two matrices such that the number of columns of A is
  equal to the number of rows of B, say A is an m  p matrix and B is a p  n
  matrix.
  Then the product of A and B, written AB, is the m  n matrix whose ijth
  entry is obtained by multiplying the elements of the ith row of A by the
  corresponding elements of the jth column of B and then adding;

 a11 a12  a1 p                         c11  c1 j  c1n 
                  b  b1 j  b1n  
               11
                  b  b  b                             
                                                            
 ai1 ai 2  aip    21    2j    2n 
                                         ci1  cij  cin 
                                                      
                                                   
ami am 2  amp   b p1  bpj  bpn  
                                     c  c  c 
                                        m1     mj     mn 


  where
                                                        p
          cij  ai1b1 j  ai 2b2 j    aip b pj   aik bkj
                                                       k 1


  REMARK
                   If the number of columns of A is not equal to the number
  of rows of B, then the product AB is not defined.




                                                                       4
                              EXAMPLE

Find the product AB and BA of the matrices

              1 3                          2 0  4
            A               and         B        
              2 1                         3  2 6 
SOLUTION
Size of A is 2  2 and of B is 2  3, the product AB is defined as a 2  3
matrix. But BA is not defined, because
                 no. of columns of B = 3  2 = no. of rows of A.

             1 3        2 0  4
        AB  
              2  1
                    
                          3  2 6 
                                  
              (1)(2)  (3)(3)   (1)(0)  (3)(6)  (1)(4)  (3)(6) 
                                                                  
             (2)(2)  (1)(3) (2)(0)  (1)(2) (2)(4)  ( 2)(6) 
             11 6 14 
                           
              1 2 14
                             EXAMPLE

Find AAt and AtA, where
                          1 2 0
                        A       
                          3  1 4
SOLUTION
At is obtained from A by rewriting the rows of A as columns:


                                                                       5
                              1 3 
                         At  2  1
                                   
                              0 4 
                                   
 Now
                       1 3 
  t  1 2 0
AA                   2 - 1  1  4  0 3  2  0   5 1 
     3  1 4
             
                             3  2  0 9  1  16 1 26
                       0 4  
                            
                                                             
       and


                      1 3 
                                  1 2 0
               At A  2  1
                                3  1 4
                      0 4              
                             
                       1 9  2  3 0  12
                      23
                             4 1 0  4 
                      0  12
                             0  4 0  16
                                          
                       10  1 12 
                        1 5  4
                                  
                       12  4 16 
                                  

 Which are the required matrices you can note that AAt is not equal to the
 AtA. Which shows that the operation of Matrix multiplication is not
 commutative in General.


                                                                      6
              ADJACENCY MATRIX OF A GRAPH

Let G be a graph with ordered vertices v1, v2,.., vn. The adjacency matrix of
G is the matrix A = (aij) over the set of non-negative integers such that
                 aij = the number of edges connecting vi and vj
                            for all i, j = 1, 2, …, n
                                EXAMPLE

A graph with it’s adjacency matrix is shown.
                            v1                          v2



                                         e3
                           e1                   e4               e5

                                v4


                                                        v3
                                e2

                                               Adjacency Matrix

   Note that the nonzero entries                     v1 v2 v3 v4
   along the main diagonal of A
   indicate the presence of loops               v1 0        0    1   1
   and entries larger than 1                    v2 0        0    2   0
   correspond to parallel edges.              A                      
                                                v3 1        2    0   0
   Also note A is a symmetric                                         
   matrix.                                      v4 1        0    0   1

                                                                           7
                               EXERCISE

Find a graph that have the following adjacency matrix.

                              0 2 0
                               2 1 0
                                    
                              0 0 1 
                                    
SOLUTION
Let the three vertices of the graph be named v1, v2 and v3. We label the
adjacency matrix across the top and down the left side with these vertices
and draw the graph accordingly.


             v1    v2    v3                      v2
                                                                    v1
          v1 0 2 0
          v2  2 1 0 
                                                       v3
          v3 0 0 1 
                    

                         DIRECTED GRAPH

A directed graph or digraph, consists of two finite sets: a set V(G) of
vertices and a set D(G) of directed edges,
where each edge is associated with an ordered pair of vertices called its end
points.
If edge e is associated with the pair (v, w) of vertices, then e is said to be the
directed edge from v to w and is represented by drawing an arrow from v to
w.

                                                                          8
                                   EXAMPLE
                                                        v2

                                   e1                    e4

                                                  e3
                                       v1
                                            e2
                          v4                e5           v3
                                             e6
In the above figure we have a directed graph note that there is an edge from
v2 to v3 but no edge from v3 to v2.

        ADJACENCY MATRIX OF A DIRECTED GRAPH

Let G be a graph with ordered vertices v1, v2, …, vn.
The adjacency matrix of G is the matrix A = (aij) over the set of non-
negative integers such that
      aij = the number of arrows from vi to vj
for all i, j = 1, 2, …, n.
                                   EXAMPLE
A directed graph with its adjacency matrix is shown
                                  v2
                                                              v1 v2 v3 v4
              e1                   e4                    v1 1   0   1   0
                                                         v2 0   0   1   0
               v1
                             e3                        A                
                    e2                                   v3 1   0   0   1
                                                                         
      v4            e5             v3                    v4 0   0   1   0   9
                     e6
                             EXERCISE

Find directed graph that has the adjacency matrix
                            1    0 1 2
                            0    0 1 0
                                      
                            0    2 1 1
                                      
                            0    1 1 0
SOLUTION
The 4  4 adjacency matrix shows that the graph has 4 vertices say v1, v2, v3
and v4 labeled across the top and down the left side of the matrix.
                             v1 v2 v3 v4
                          v1 1   0   1   2
                          v2 0   0   1   0
                        A                
                          v3 0   2   1   1
                                          
                          v4 0   1   1   0

                                          A corresponding directed graph is

Since we know that in the matrix we
have the value corresponding to v1v4 is                              v2
                                                       v1
2. It means that we will have two
directed edges from v1 to v4.
Similarly you can see that the entry in
the v3v2 has the entry 2 thus we have
two directed arrows from v3 to v2.
                                                  v4                      v3
Following the same procedure we will
get the graph given in the front.


                                                                     10
                               THEOREM

If G is a graph with vertices v1, v2, …,vm and A is the adjacency matrix of
G, then for each positive integer n,
the ijth entry of An = the number of walks of length n from vi to vj
for all integers i,j = 1, 2, …, n
                                EXERCISE

                                   1 1 2 
                    Let        A  1 0 1 
                                         
                                   2 1 0
                                         
be the adjacency matrix of a graph G with vertices v1, v2, and v3. Find
(a)   the number of walks of length 2 from v2 to v3
(b)   the number of walks of length 3 from v1 to v3
Draw graph G and find the walks by visual inspection for (a)

SOLUTION
(a)   Since we have to find out the number of walks of length 2 from v 2 to
      v3 which will be the 23rd element of A2 (By using the above Theorem)
      So first we will calculate A2.

                      1 1 2  1 1 2  6 3 3 
            A2  AA  1 0 1 1 0 1  3 2 2
                                            
                       2 1 0   2 1 0  3 2 5 
                                            

Hence, number of walks of length 2 from v2 to v3
= the entry at (2,3) of A2 = 2
                                                                       11
(b)          Similarly we can find out the walks of length 3 from v1 to v3.

                          1 1 2 6 3 3 15 9 15
               A3  AA2  1 0 1 3 2 2   9 5 8 
                                               
                          2 1 0 3 2 5 15 8 8 
                                               

  Hence, number of walks of length 3 from v1 to v3
  = the entry at (1,3) of A3 = 15
  Hence there are 15 walks of length 3 from v1 to v3.

  Walks from v2 to v3 by visual inspection of graph
             1 1 2 
         A  1 0 1 
                                           e1              e2        v2
                                               v1
             2 1 0
                   
                                                                e3
                                                                      e5
  Two Walks of length 2 from v2 to v3 are             e4
                                                                     v3
  (i)     v2 e2 v1 e3 v3
  (ii)    v2 e2 v1 e4 v3


              INCIDENCE MATRIX OF A SIMPLE GRAPH

  Let G be a graph with vertices v1, v2, …, vn and edges e1, e2, …, em. The
  incidence matrix of G is the matrix M = (mij) of size n  m defined by

                  1 if the vertex vi is incident on the edge e j
            mij  
                  0                  otherwise

                                                                           12
                            EXAMPLE
A graph with its incidence matrix is shown.
                                              INCIDENCE MATRIX
           v1                  v2
                                                     e1 e2 e3 e4

                          e4
                                                v1 1    0   1   0   0
                                                v2  0               1
          e1
                                    e5                   0   0   1
                     e3                       M                     
                                                v3 0    0   1   1   1
           v4                                                        
                                                v4 1    1   0   0   0
           e2                  v3




REMARK
   In the incidence matrix
1.   Multiple edges are represented by columns with identical entries
     (e4 & e5)
2.   Loops are represented using a column with exactly one entry equal to
     1, corresponding to the vertex that is incident with this loop and other
     zeros (e2).




                                                                          13

								
To top