Appendix 3.
Grossly Oversimplified Matrix Math Course

(c) 2017 by Barton Paul Levenson



A "matrix" is a square or rectangular array of numbers. These are enormously useful in science and math, especially statistics.

Here are some matrices:



│  2  3  5 │
│ -7  0  1 │
│  4  8 -3 │

│ 1 0 1 3 │
│ 6 8 5 7 │

│ 13.456  168.999 │
│ -2.375   47.234 │

│ 7 8 │
│ 3 1 │
│ 2 4 │
│ 0 1 │


A matrix with just one element is a "scalar"--a regular number. A matrix with just one row or one column of numbers is a "vector." A "square matrix" has the name number of rows and columns. Square matrices have special properties.

Rows are like this, left to right:



1 3 9 6 2


Columns are like this, up and down:



3
2
1
7


If two matrices are the same size and shape--that is, if they have the same number of rows and columns--you can add or subtract them by adding or subtracting the corresponding numbers in each location:



│ 3 0 │ + │ 7 2 │ = │ 10  2 │
│ 9 4 │   │ 1 6 │   │ 10 10 │

│ 3 1 │ - │ 5 7 │ = │ -2 -6 │
│ 4 6 │   │ 2 3 │   │  2  3 │


To multiply matrices, the number of rows in the left-hand matrix must match the number of columns in the right-hand one. Thus a 2 by 4 matrix



│ 3 7 5 0 │
│ 9 4 1 6 │


can be multiplied by a 4 by 3 matrix,


│ 1 2 3 │
│ 1 6 4 │
│ 7 0 2 │
│ 3 4 1 │


but not by a 3 by 4 matrix. That inner number always has to be the same:

  1. 1 by 4 times 4 by 3, or
  2. 2 by 5 times 5 by 8, or
  3. 2 by 3 times 3 by 1. And so on.

The answer matrix, on the far right of the equation, then has the number of rows from the first matrix, and the number of columns from the second. So A (1 x 4) times B (4 x 3) gives a C with 1 row and 3 columns. The common middle term, 4, drops out.

To do this, you multiply an entire row in A by an entire column in B to get one number in C.

How do you multiply a row by a column? You multiply the first number in your A row times the first in your B column, then add the second number in A's row times the second in B's column, and so on to the last number in A's row times the last in B's column. The answer is one number. Then go on to the next row and column. Here's a full example, A x B = C:



   A           B                                  C                           
│ 1 2 │   │ 7  8  9 │   │ {1 x 7 + 2 x 0}  {1 x 8 + 2 x -1}  {1 x 9 + 2 x 0} │
│ 2 3 │ x │ 0 -1  0 │ = │ {2 x 7 + 3 x 0}  {2 x 8 + 3 x -1}  {2 x 9 + 3 x 0} │
│ 5 6 │                 │ {5 x 7 + 6 x 0}  {5 x 8 + 6 x -1}  {5 x 9 + 6 x 0} │

                                                  C                           
                                  │ { 7 + 0}  {16 - 2}  { 9 + 0} │            
                      =           │ {14 + 0}  {16 - 3}  {18 + 0} │            
                                  │ {35 + 0}  {40 - 6}  {45 + 0} │            

                                                 C                            
                                            │  7 14  9 │                      
                      =                     │ 14 13 18 │                      
                                            │ 35 34 45 │                      


Note the sizes again. A (3 x 2) times B (2 x 3) = C (3 x 3).

To use matrices in statistics, we need two more concepts: Transposes and Inverses.

To get the transpose of a matrix, you rotate it along the diagonal line from upper left to lower right--change the rows for columns and the columns for rows. We abbreviate the transpose of a matrix A as A'. Here are some examples:



   A         A'                     
│ 2 3 │   │ 2 5 │                    
│ 5 7 │   │ 3 7 │                    

   Q            Q'                   
│ 1  0 │   │ 1  2  9 │               
│ 2  4 │   │ 0  4 -3 │               
│ 9 -3 │                             

      Z                   Z'         
│  3.6 17.8 │   │  3.6 7.2 1.0 -4.5 │
│  7.2  3.2 │   │ 17.8 3.2 6.6  0.4 │
│  1.0  6.6 │                        
│ -4.5  0.4 │                        


The inverse of matrix A, written A-1, is another matrix. When you multiply A times A-1, you get an "identity matrix" I as the answer. Inverses only exist for square matrices, and not for all of them.

An identity matrix has all 1s on the "main diagonal"--the elements from the upper left corner to the lower right--and 0s everywhere else. Here are two examples:



│ 1 0 │
│ 0 1 │

│ 1 0 0 │
│ 0 1 0 │
│ 0 0 1 │


Here's an example of a matrix and its inverse multiplying together to yield an identity matrix.



   A                      A-1                     I   
│ 2 3 │  x  │  0.636363636 -0.272727273 │  =  │ 1 0 │
│ 1 7 │     │ -0.090909091  0.181818182 │     │ 0 1 │






Page created:04/12/2017
Last modified:  04/13/2017
Author:BPL