A tutorial on the addition and multiplication of matrices.

## Definition of a Matrix

An m x n ( "m by n" ) matrix is a rectangular array of numbers arranged in m rows (horizontal lines) and n columns (vertical lines).

Examples:

A matrix with 3 rows and 2 columns : a 3 x 2 matrix (read "a 3 by 2 matrix")

  [2     3]

[-4    5]

[6    -8]



A matrix with 3 rows and 3 columns : a 3 x 3 matrix

  [2     3    -4]

[4     5     6]

[6     0     8]



In general an m x n matrix A has the form

       [a 11     a 12    ...    a 1n]

[a 21     a 22    ...    a 2n]

[.                         ]

A  =   [.                         ]

[.                         ]

[a m1     a m2     ...   a mn]



Another denotation for matrix A is A = [a ij] for 1<= i <= m and 1<= j<= n.

The order of a matrix having m rows and n columns is m x n.

If the number of rows of a matrix is equal to its number of columns, it is a square matrix and its main diagonal entries are : a 11, a 22, a 33 . . .

Only matrices of the same order (same number of rows and same number of columns) may be added by adding corresponding elements.

Example:

1.
  [2    -3]   [7     3]   [2 + 7       -3 + 3]   [9    0]

[4     5] + [-2    7] = [4 + (-2)    5  + 7] = [2   12]

[6     0]   [1    -5]   [6 + 1     0 + (-5)]   [7   -5]



2.
  [2    -3]   [7     3      5]

[4     5] + [-2    7     -9]

[6     0]   [1    -5      0]


The addition above is undefined since the two matrices do not have the same number of columns.

## Scalar Multiplication of a Matrix

To multiply matrix A of order m x n by a scalar k, we multiply each element of matrix A by k to obtain another matrix of the same order.

Example:

1.
      [2    -3     7]

A =   [4     5    -3]

[6     0    -1]



Matrix - 2 A is given by
          [-2*2    -2*-3     -2*7]   [-4    6     -14]

- 2 A =   [-2*4     -2*5    -2*-3] = [-8   -10      6]

[-2*6     -2*0    -2*-1]   [-12    0      2]



## Multiplication of two Matrices.

If A = [a ij] is a matrix of order m x n and B = [b ij] a matrix of order n x p, then the product C = AB of the two matrices is a matrix of order m x p matrix defined.

C = [c
ij] where c ij is given by

c
ij = a i1b 1j + a i2b 2j + a i3b 3j + . . . + a inb nj

Note that a multiplication of two matrices AB is defined only if the number of columns of matrix A is equal to the number of rows of matrix B.

Example: Find the product AB where A and B are matrices given by

1.
      [2    -3]          [1    0]

A =   [4     5]  ,  B =  [-2   1]

[6     0]



Solution

The product AB is defined since A is a 3 x 2 matrix and has
2 columns and B is a 2 x 2 matrix and has 2 rows. To find elements of the product C = AB, multiply each row of A by each column of B.

         [2    -3][1    0]

C = AB = [4     5][-2   1]

[6     0]


  [(2)(1) + (-3)(-2)   (2)(0)+(-3)(1)]    [8  -3]

= [(4)(1) + (5)(-2)     (4)(0)+(5)(1)] =  [-6  5]

[(6)(1) + (0)(-2)     (6)(0)+(0)(1)]    [6   0]


You may want to explore more the multiplication of matrices using an applet.

Exercises

1 . What are the number of rows, the number of columns and the order of each matrix below? Which of these matrices is a square matrix?

a)  [2    3]   b)  [-2   0    5]   c) [0    0    4]

[-2   5]                          [4    -2   6]

[0    9]                          [-1    2   9]



2 . Find matrices

a) A + B

b) C
2

c) A + BC

d) A + CB

if possible. Matrices A, B and C are given by

       [2    3]         [-2   4]             [2    1]

A =    [-2   5]    B =  [3    1]         C = [0   -1]

[0    9]         [0   -8]



1.

a) Matrix below has 3 rows and 2 colums hence its order is 3 x 2. Since the number of rows and the number of columns are not equal the matrix is not square.

       [2    3]

[-2   5]

[0    9]


b) Matrix below has 1 row and 3 columns, its order is 1 x 3. It is not a square matrix since the number of rows and the number of columns are different.
   [-2   0    5]


c) Matrix below has 3 rows and 3 columns, its order is 3 x 3 and it is a square matrix since the number of rows and the number of columns are equal.
   [0    0    4]

[4    -2   6]

[-1    2   9]



2.
           [0    7]

A + B =    [1    6]

[0    1]


b)
C 2= C C =  [2   1] [2   1] = [4   1]

[0  -1] [0  -1]   [0   1]


c)
            [2    3]   [-2   4][2    1]

A + BC =    [-2   5] + [3    1][0   -1]

[0    9]   [0   -8]


We calculate the product BC first and then add.
            [2    3]   [-4   -6]      [-2   -3]

A + BC =    [-2   5] + [6     2] =    [4     7]

[0    9]   [0     8]      [0    17]


d)
            [2    3]   [2   1][-2   4]

A + CB =    [-2   5] + [0  -1][3    1]  = undefined

[0    9]          [0   -8]


The product CB is undefined since the number of columns of C is 2 and the number of rows of B is 3. They are not equal.

Exercises

1. What is the order of each matrix.



A =  [1 ]




B =  [1   2    4]

[2  -1    0]


2. Add matrices A and B given below.



B =  [1   0    4    -8]

[2  -1    4     3]





A =  [-1   2    4    -8]

[4  -1     2     2]


3. Multiply matrices A and B given below.

     [0    0    4]          [1   -1    2]

A =  [4    -2   6]      B = [0    2   -1]

[-1    2   9]          [2    2    3]



1. order of matrix A is 1 X 1 , the order of matrix B is 2 X 3

2.



A + B =  [0   2    8    -16]

[6  -2    6      5]



3.
        [8   8   12]

A . B = [16  4   28]

[17  23  23]



More pages and references related to matrices.