\documentclass[t]{paulslides}
\usepackage{pgf,tikz}
\usepackage{enumerate}
\usetikzlibrary{arrows}
\usepackage{amsthm}

\definecolor{UniBlue}{RGB}{83,121,170}
\setbeamercolor{block title}{use=structure,fg=white,bg=blue!75!black}
\setbeamercolor{block body}{use=structure,fg=black,bg=blue!10!white}

\title{MA162: Finite mathematics}
\subtitle{Algebra of Matrices}
\author{Paul Koester}
\institute{University of Kentucky}
\date{April 7, 2014}

\begin{document}

\maketitle

\begin{frame}[t]{Last Time}
\begin{itemize}
  \item A few days ago, we introduced the idea of a matrix, basically as a bookkeeping device for dealing with lots of variables \vfill
  \item Matrices are much more than short-hand notations.  They have a very rich algebraic structure, which partly mimics real number 
            algebra, but is also quite different.
\end{itemize}
\end{frame}

\begin{frame}[t]{The Matrix}
\begin{itemize}
  \item A matrix is a rectangular array of numbers.
  \item The \emph{size}, or \emph{dimension}, of a matrix is the number of rows and number of columns.
  \item A \(4 \times 3\) matrix: 
  {\tiny 
    \[ \left[\begin{array}{ccc}
      1  &  -2  &  2  \\
      3  &   0  &  1  \\
      0  &   7  &  2  \\
      4  &   1  &  6  \\
    \end{array}\right] \]
  }
  First number refers to number of rows, second refers to number of columns.
  \item A \emph{square matrix} has the same number of rows and columns:
  {\tiny 
    \[ \left[\begin{array}{ccc}
      2  &   1  &  7  \\
      9  &   6  &  3  \\
      4  &   0  &  2  \\
    \end{array}\right] \]
  }
  A \(3 \times 3 \) square matrix.
\end{itemize}
\end{frame}

\begin{frame}[t]{Vectors versus Matrices}
\begin{itemize}
  \item A vector is matrix which has either one row or one column.  
  \item A length 4 column vector is a \(4 \times 1\) matrix:
  {\tiny 
    \[ \left[\begin{array}{c}
      1 \\
      3 \\
      0 \\
      4 \\
    \end{array}\right] \]
  }
  \item A length 5 row vector is a \( 1 \times 5 \) matrix:
  {\tiny 
    \[ \left[\begin{array}{ccccc}
      1 & 2 & 7 & 3 & 2\\
    \end{array}\right] \]
  }
  \item The transpose interchanges rows and columns:  
  {\tiny 
    \[ \left[\begin{array}{ccc}
      2  &   1  &  7  \\
      9  &   6  &  3  \\
    \end{array}\right]^T 
    = 
    \left[\begin{array}{ccc}
      2  &   9  \\
      1  &   6  \\
      7  &   3  \\
    \end{array}\right]
     \]
  }
  The transpose of an \( n \times m\) matrix is an \(m \times n\) matrix.
  
\end{itemize}
\end{frame}


\begin{frame}[t]{Addition of Matrices}
\begin{itemize}
  \item Matrices can be added by adding corresponding entries:
  {\tiny 
    \[ 
      \left[\begin{array}{ccc}
      5  &   4  &  1  \\
      4  &   2  &  -2  \\
      \end{array}\right] 
     + 
      \left[\begin{array}{ccc}
      -1  &   2  &  0  \\
       3  &  -1  &  3  \\
      \end{array}\right] 
     =
      \left[\begin{array}{ccc}
      5-1  &  4+2  &  1+0  \\
      4+3  &  2-1  & -2+3  \\
      \end{array}\right]
     =
      \left[\begin{array}{ccc}
      4  &  6  &  1  \\
      7  &  1  &  1  \\
      \end{array}\right]
    \]
  }
  \item Can any two matrices be added?  NO!  Can only add matrices which have the same size.
  {\tiny 
    \[ 
      \left[\begin{array}{ccc}
      1  &   2  &  3  \\
      \end{array}\right] 
     + 
      \left[\begin{array}{cc}
       1  &   2  \\
       2  &  -1  \\
      \end{array}\right] 
     =
      \left[\begin{array}{ccc}
      1 + 1  & 2 + 2  &  3 + ??  \\
      ??+ 2  & ?? -1  &  ?? + ?? \\
      \end{array}\right]
    \]
  }
  This sum doesn't make sense.
  \item Similarly, we subtract matrices entry by entry:
  {\tiny 
    \[ 
      \left[\begin{array}{cc}
      5  &   4  \\
      9  &   6  \\
      \end{array}\right] 
     - 
      \left[\begin{array}{cc}
      2  &   3  \\
      2  &  -8  \\
      \end{array}\right] 
     =
      \left[\begin{array}{ccc}
      5-2  &  4-3     \\
      9-2  &  6-(-8)  \\
      \end{array}\right]
     =
      \left[\begin{array}{ccc}
      3  &   1  \\
      7  &  14  \\
      \end{array}\right]
    \]
  }

\end{itemize}
\end{frame}

\begin{frame}[t]{Scalar Multiplication}
\begin{itemize}
  \item Given a real number \(c\) and a matrix \(A\), the \emph{scalar product} of \(c\) and \(A\), denoted \(cA\), is obtained by multiplying \(c\) against
        each entry of \(A\).
  \item If \(c = 3\) and    
    {\small \[ 
      A = \left[\begin{array}{cc}
          1  &   2  \\
          1  &   3  \\
          1  &  -5  \\
      \end{array}\right] 
    \]} 
    then 
    {\small \[ 
      cA = 3\left[\begin{array}{cc}
          1  &   2  \\
          1  &   3  \\
          1  &  -5  \\
      \end{array}\right] 
    = 
      \left[\begin{array}{cc}
          3\cdot 1  &   3\cdot 2  \\
          3\cdot 1  &   3\cdot 3  \\
          3\cdot 1  &  3\cdot (-5)  \\
      \end{array}\right] 
    =
      \left[\begin{array}{cc}
          3  &   6  \\
          3  &   9  \\
          3  & -15  \\
      \end{array}\right] 
    \]} 
  \item Scalar multiplication is defined for matrices of any size.
\end{itemize}
\end{frame}


\begin{frame}[t]{Familiar Laws, Unfamiliar Objects}
\begin{itemize}
  \item Matrix addition is commutative: {\tiny provided \(A\) and \(B\) have the same dimensions}
    \[  A +  B  =  B  +  A\]  \vfill
  \item Matrix addition is associative:  {\tiny provided \(A\), \(B\), and \(C\) have the same dimensions}
    \[  A +  (B + C) = (A + B) + C\]  \vfill
  \item Scalar multiplication distributes over matrix addition: {\tiny provided \(A\) and \(B\) have the same dimensions}
    \[  c(A + B) = cA + cB\]   \vfill
  \item A different kind of distributive law:  
    \[  (c + d)A = cA + dA\]    \vfill
\end{itemize}
\end{frame}

\begin{frame}[t]{Computational Example}
Suppose 
\(A =      \left[\begin{array}{cc}
          1  &   2  \\
          1  &   3  \\
          1  & -5  \\
      \end{array}\right] 
\), 
\(B =      \left[\begin{array}{ccc}
          2  &   4  &   6 \\
          3  &   4  &   8 \\
      \end{array}\right] 
\), 
and 
\(C =      \left[\begin{array}{cc}
          0  &   -2  \\
          2  &    3  \\
          1  &    0  \\
      \end{array}\right] 
\).

Compute
\[
3\cdot A - \frac{1}{2} \left(B^T + 4\cdot C\right)
\]

\end{frame}

\begin{frame}[t]{Chapter 2.4 Exercise 36}

The following table gives the number of shares of certain corporations help by Leslie and Tom in their respective 
IRA accounts at the beginning of the year:

\begin{center}
\begin{tabular}{lllll}\hline
           &  IBM   &   GE   &   Ford   &   Wal-Mart \\ \hline
  Leslie:  &  500   &	350  &   200    &   400      \\ \hline
  Tom:     &  400   &	450  &	 300    &   200      \\ \hline
\end{tabular}
\end{center}

Over the year, they added more shares to their accounts, as shown in the table:

\begin{center}
\begin{tabular}{lllll}\hline
           &  IBM   &   GE   &   Ford   &   Wal-Mart \\ \hline
  Leslie:  &  50    &	50   &   0      &   100      \\ \hline
  Tom:     &  0     &	80   &	 100    &    50      \\ \hline
\end{tabular}
\end{center}

\end{frame}

\begin{frame}
\begin{enumerate}[(a.)]
  \item
    Write a matrix A giving the holdings of Leslie and Tom at the beginning of the year and a matrix B giving the shares they have added to their portfolios.
    \vfill
  \item
    Find a matrix C giving their total holdings at the end of the year. 
    \vfill
\end{enumerate}
\end{frame}

\begin{frame}[t]{Matrix Vector Multiplication}
Leslie's and Tom's at the end of the year 
\[ \left[\begin{array}{cccc}
    550   &	400  &   200    &   500      \\ 
    400   &	530  &	 400    &   250      \\
\end{array}\right]
\]

The following vector records the current price per share of the stocks:
\[ \left[\begin{array}{c}
  \$186.11 \\
  \$25.25 \\
  \$15.42 \\
  \$74.60 \\
\end{array}\right]
\]

The value of Leslie's total holdings is
\[ 550\cdot 186.11 +  400\cdot 25.25 + 200\cdot 15.42 + 500 \cdot 74.60 =  \$152,844.50\]

The value of Tom's total holdings is
\[ 400\cdot 186.11 +  530\cdot 25.25 + 400\cdot 15.42 + 250\cdot 74.60 =  \$112,644.50\]

\end{frame}

\begin{frame}[t]{Matrix Vector Multiplication}
The calculation in the previous slide suggests a notion of multiplying a matrix and a vector
\[ \left[\begin{array}{cccc}
    550   &	400  &   200    &   500      \\ 
    400   &	530  &	 400    &   250      \\
\end{array}\right]
 \left[\begin{array}{c}
  186.11 \\
  25.25 \\
  15.42 \\
  74.60 \\
\end{array}\right]
\]
\[
  =  
  186.11 
   \left[\begin{array}{c}
    550 \\
    400 \\
  \end{array}\right]
+
  25.25 
   \left[\begin{array}{c}
    400 \\
    530 \\
  \end{array}\right]
+
  15.42 
   \left[\begin{array}{c}
    200 \\
    400 \\
  \end{array}\right]
+
  74.60 
   \left[\begin{array}{c}
    500 \\
    250 \\
  \end{array}\right]
\]
\[ = 
   \left[\begin{array}{c}
   152844.5 \\
   112644.5 \\
  \end{array}\right]
\]
In other words, the matrix-vector product consists of adding the adding the columns of the matrix together, weighted by the values in the vector.\\

In order for this definition to make sense, the number of columns in the matrix must equal the number of rows for the vector.  

\end{frame}

\begin{frame}[t]{Matrix Multiplication}
A similar process can be used to multiply two matrices:
\begin{scriptsize}
\[ 
 \left[\begin{array}{cccc}
     1  &  4  &   1  &  1\\ 
     3  &  2  &   0  &  4\\
\end{array}\right]
 \left[\begin{array}{ccc}
     1  &  2  &   3\\ 
     2  &  1  &   3\\
     3  &  0  &   0\\
     0  &  2  &   0\\
\end{array}\right]
\]
\end{scriptsize}

Just treat each column of the right factor individually
\begin{scriptsize}
\[ 
 \left[\begin{array}{cccc}
     1  &  4  &   1  &  1\\ 
     3  &  2  &   0  &  4\\
\end{array}\right]
 \left[\begin{array}{ccc}
     1 \\ 
     2  \\
     3  \\
     0  \\
\end{array}\right]
=
 \left[\begin{array}{ccc}
     1\cdot 1 + 4\cdot 2 + 1\cdot 3 + 1\cdot 0 \\ 
     3\cdot 1 + 2\cdot 2 + 0\cdot 3 + 4\cdot 0  \\
\end{array}\right]
 \left[\begin{array}{ccc}
     12 \\ 
       7  \\
\end{array}\right]
\]

\[ 
 \left[\begin{array}{cccc}
     1  &  4  &   1  &  1\\ 
     3  &  2  &   0  &  4\\
\end{array}\right]
 \left[\begin{array}{ccc}
     2 \\ 
     1  \\
     0  \\
     2  \\
\end{array}\right]
=
 \left[\begin{array}{ccc}
     1\cdot 2 + 4\cdot 1 + 1\cdot 0 + 1\cdot 2 \\ 
     3\cdot 2 + 2\cdot 1 + 0\cdot 0 + 4\cdot 2  \\
\end{array}\right]
 \left[\begin{array}{ccc}
      8 \\ 
    16  \\
\end{array}\right]
\]
\[ 
 \left[\begin{array}{cccc}
     1  &  4  &   1  &  1\\ 
     3  &  2  &   0  &  4\\
\end{array}\right]
 \left[\begin{array}{ccc}
     3 \\ 
     3  \\
     0  \\
     0  \\
\end{array}\right]
=
 \left[\begin{array}{ccc}
     1\cdot 3 + 4\cdot 3 + 1\cdot 0 + 1\cdot 0 \\ 
     3\cdot 3 + 2\cdot 3 + 0\cdot 0 + 4\cdot 0  \\
\end{array}\right]
 \left[\begin{array}{ccc}
     15 \\ 
      15 \\
\end{array}\right]
\]
\end{scriptsize}
\end{frame}

\begin{frame}[t]{Matrix Multiplication}
Now put create a \(2\times 3\) matrix by putting the columns together
\begin{scriptsize}
\[ 
 \left[\begin{array}{cccc}
     1  &  4  &   1  &  1\\ 
     3  &  2  &   0  &  4\\
\end{array}\right]
 \left[\begin{array}{ccc}
     1  &  2  &   3\\ 
     2  &  1  &   3\\
     3  &  0  &   0\\
     0  &  2  &   0\\
\end{array}\right]
=
 \left[\begin{array}{ccc}
    12  &    8  &   15  \\ 
       7 &  16  &    15 \\
\end{array}\right]
\]
\end{scriptsize}
\end{frame}

\begin{frame}[t]{Properties of Matrix Multiplication}
If \(A\) is an \(n\times m\) matrix and \(B\) is a n \(m \times p\) matrix, then the matrix product is defined, 
and the product will be an \(n \times p\) matrix.\\  \vfill

If the number of columns of the left matrix is NOT equal to the number of rows of the right matrix then the product is not defined.\\
\vfill

\textbf{Algebraic Properties:}  Assume the dimensions of these matrices are so that the products are all defined. Then 
\begin{itemize}
  \item  Associative Law:  \(A (BC) = (AB)C\)
  \item  Left Distributive Law:  \(A (B + C) = (AB) + (AC)\)
  \item  Right Distributive Law:  \((A + B)C = (AC) + (BC)\)
\end{itemize}

\end{frame}

\begin{frame}[t]{Unusual Properties}
\textbf{Non-Commutative}
Unlike real numbers, though, matrix multiplication is not commutative, meaning AB and BA are not necessarily equal.
\begin{scriptsize}
\[
 \left[\begin{array}{cc}
     1  &    2  \\ 
      0 &    1  \\
\end{array}\right]
 \left[\begin{array}{cc}
     1  &    0  \\ 
      2 &    1  \\
\end{array}\right]
 = 
 \left[\begin{array}{cc}
     5  &    2  \\ 
     2 &    1  \\
\end{array}\right]
\] 
\end{scriptsize}
But
\begin{scriptsize}
\[
\left[\begin{array}{cc}
     1  &    0  \\ 
      2 &    1  \\
\end{array}\right]
\left[\begin{array}{cc}
     1  &    2  \\ 
      0 &    1  \\
\end{array}\right]
 = 
 \left[\begin{array}{cc}
     1  &    2  \\ 
     2 &    5  \\
\end{array}\right]
 \]
 \end{scriptsize}
\vfill

\textbf{Zero Divisors and Cancellation}
For real numbers, if \(c \neq 0\) and \(ac = bc\), then \(a = b\).  \\
This does not hold for matrices:
\begin{scriptsize}
\[
\left[\begin{array}{cc}
     1  &    2  \\ 
      3 &    4  \\
\end{array}\right]
 \neq
 \left[\begin{array}{cc}
     1  &    2  \\ 
     3 &     5  \\
\end{array}\right]
\]
\end{scriptsize}
even though
\begin{scriptsize}
\[
\left[\begin{array}{cc}
     1  &    2  \\ 
      3 &    4  \\
\end{array}\right]
\left[\begin{array}{cc}
     1  &    2  \\ 
      0 &    0  \\
\end{array}\right]
 = 
 \left[\begin{array}{cc}
     1  &    2  \\ 
     3 &    6  \\
\end{array}\right]
\]
and
\[
\left[\begin{array}{cc}
     1  &    2  \\ 
      3 &    5  \\
\end{array}\right]
\left[\begin{array}{cc}
     1  &    2  \\ 
      0 &    0  \\
\end{array}\right]
 = 
 \left[\begin{array}{cc}
     1  &    2  \\ 
     3 &    6  \\
\end{array}\right]
\]
\end{scriptsize}





\end{frame}

\begin{frame}[t]{Matrix Vector Multiplication}
Previously, we solved the system of equations:
\[
 \begin{array}{ccccccc}
   x & + &  y & + &  z & = & 2  \\
   x & + & 2y & + & 3z & = & 4  \\
   x & + & 4y & + & 9z & = & 6  \\
 \end{array}
\]

Let 
\( A = 
   \left[\begin{array}{ccc}
   1 & 1 & 1 \\
   1 & 2 & 3 \\
   1 & 4 & 9 \\
  \end{array}
  \right]
\),
\(
  b =  \left[\begin{array}{c}
   2  \\
   4  \\
   6  \\
  \end{array}
  \right]
\), 
and \(
   X = \left[\begin{array}{c}
   x  \\
   y  \\
   z  \\
  \end{array}
  \right]
\)
Note that
\[
AX =    \left[\begin{array}{ccc}
   1 & 1 & 1 \\
   1 & 2 & 3 \\
   1 & 4 & 9 \\
  \end{array}
  \right]
  \left[\begin{array}{c}
   x  \\
   y  \\
   z  \\
  \end{array}
  \right]
=
  \left[\begin{array}{c}
   x  +  y +   z \\
   x + 2y + 3z  \\
   x + 4y + 9z  \\
  \end{array}
  \right]
\]
\end{frame}
\begin{frame}[t]{}

Thus, solving the above system of linear equations is equivalent to solving the matrix equation
\(  AX  = b\)



\end{frame}




\end{document}
