\documentclass{amsart}[11pt]
\usepackage{graphicx}

\addtolength{\textwidth}{1.4in}                          
\oddsidemargin=0in                          
\evensidemargin=0in       

\newtheorem{example}{Example} 
\newtheorem{question}[example]{Question}
\newtheorem{definition}[example]{Definition}
\newtheorem{theorem}[example]{Theorem}
\newtheorem{notation}[example]{Notation}
\newtheorem{fact}[example]{Fact}

\begin{document}

\title{Math 242, Lecture 14}
\maketitle

\subsection{ The dot product}  

Recall vectors, which are rows or columns of numbers, and the dot product. 
 

\begin{definition}
The dot product of a row vector $ \begin{bmatrix}  a_1 & a_2 & \cdots & a_n \end{bmatrix}$
and a column vector $\begin{bmatrix}   b_1  \\ b_2 \\ \cdots \\ b_n  \end{bmatrix} $
is the sum $a_1 b_1 + a_2 b_2 + \cdots a_n b_n$.  
\end{definition}

Note that the dot product of two vectors is not another vector but a number.  
Dot products can supply us with alternate notation for linear equations.  

\begin{example}
$$\begin{bmatrix}  3 & 2\end{bmatrix} \cdot \begin{bmatrix} x \\ y 
\end{bmatrix} = 5 $$
is an alternate notation for the equation $3x + 2y = 5$.   
\end{example}

Any collection of related data   (that is any series of numbers)  
can (and rightfully should) be collected in a vector.     The dot
product is then useful in describing linear relationships in that data.  

\begin{example}
Let $V$ denote the number of vampires in Sunnydale and $S$ be
the number of vampire slayers.     We may collect these data
in the vector$\begin{bmatrix} V \\ S \end{bmatrix}$.     Let $W$
be the number of vampires next year,   which is 1.2 times the
number of vampires this year minus 26 times the number of slayers.  
Then we have 
$$ W = \begin{bmatrix} 
1.2 & -26  
\end{bmatrix} \begin{bmatrix} V \\ S \end{bmatrix}.$$
\end{example}

 

\section{ Matrix multiplication}  

The multiplication of matrices often throws people for
a loop since it seems unnatural.     It builds on the dot
product of vectors, which is a helpful starting point.  

\begin{definition}
The product $M \cdot N$ of two matrices is the matrix
whose entry in the $i$th row and $j$th column
is the dot product of the $i$th row of $M$ and the $j$th column
of $N$,   when this is defined. 
\end{definition}

 

\begin{example}
(Try to) perform the following matrix multiplications:
$$
\begin{bmatrix}  1 & 2 \\  3 & 4 \end{bmatrix}  \begin{bmatrix}  -1 &  0 \\  \frac{1}{2} & -2 \end{bmatrix}  
\;\;\; \begin{bmatrix}  1  & 2 & 3\\ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix}   -1 \\ 0 \\  1   \end{bmatrix}  
\;\;\; \begin{bmatrix}  1  & 2 & 3\\ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix}  5 & -2 \\ 1 & 3 \end{bmatrix}  
$$
\end{example}

So, the matrices $M$ and $N$ can only be multiplied if the number of columns of
$M$ equals the number of rows of $N$.    So in the second example, while the
two matrices given can be multiplied, they could not be if their order is reversed.  
Reversing order of matrices is a problem even when the multiplication is still
defined.     Compare our first example with the product
$  \begin{bmatrix}  -1 &  0 \\  \frac{1}{2} & -2 \end{bmatrix}   
\begin{bmatrix}  1 & 2 \\  3 & 4 \end{bmatrix}$.  \\

{\em Matrix multiplication is not commutative!  In general $M \cdot N$ is not equal to $N \cdot M$,
even when both are defined!}

You should be asking at this point:   why should I multiply matrices like this?  
Why can't I say $\begin{bmatrix}  1 & 2 \\ 3 & 4 \end{bmatrix} \times 
\begin{bmatrix}  5 & 6\\  7& 8 \end{bmatrix} = \begin{bmatrix}  5 & 12\\  21& 32 \end{bmatrix}$?  
At least that would be commutative...  

The answer is that you could, but you would not find it as useful as the matrix multiplication
defined using the dot product.     Experience with many kinds of problems ranging from
geometry and computer graphics to iterative processes and political science has shown
that the matrix multiplication just defined is a remarkably expedient.   

\begin{example}
The system of equations 
\begin{eqnarray*}
2x + 3y = 5 \\
x - 2y = 3  
\end{eqnarray*}

can be written in matrix-vector notation as
$$
\begin{bmatrix}  2 & 3 \\ 1  & -2  \end{bmatrix}
\begin{bmatrix}  x \\ y  \end{bmatrix} =
\begin{bmatrix}  5 \\ 3  \end{bmatrix}  
$$
\end{example}

Because matrix multiplication {\em is} associative, some applications
can be developed cleanly.  

\begin{example}
Suppose that the number of vampires and slayers in Sunnydale changes
from one year to the next according to 
$$\begin{bmatrix}   V_{new} \\  S_{new}  \end{bmatrix}
= \begin{bmatrix}   1.2 & -26 \\  \frac{1}{100} & 1 \end{bmatrix}
\begin{bmatrix}   V_{o} \\  S_{o}  \end{bmatrix}.  
$$
(Interpret this equation.)  
Then after ten year you would expect 
$$ \begin{bmatrix}   1.2 & -26 \\  \frac{1}{100} & 1 \end{bmatrix} 
\begin{bmatrix}   1.2 & -26 \\  \frac{1}{100} & 1 \end{bmatrix}   \cdots 
\begin{bmatrix}   1.2 & -26 \\  \frac{1}{100} & 1 \end{bmatrix} 
\begin{bmatrix}   V_{o} \\  S_{o}  \end{bmatrix}. $$
vampires and slayers to be on the prowl.
Because matrix multiplication is associative, this can be written
and computed more succinctly as
$$ \begin{bmatrix}   1.2 & -26 \\  \frac{1}{100} & 1 \end{bmatrix}^{10} 
\begin{bmatrix}   V_{o} \\  S_{o}  \end{bmatrix}. $$  
\end{example}

This example is a taste of population modeling using matrices.  
For a more complete story, take Math 342.  



\section{ Solving systems of equations using inverses of matrices}  

Matrices are collections of numbers which behave in some
ways just like numbers themselves.   We can add, subtract and
multiply them, and there is a zero matrix.     The similarities only
go so far, though - only square matrices can both be 
added and multiplied, the multiplication is complicated and it depends
on the order in which the matrices appear!  

Our next step will be to learn how to ``divide'' matrices,     which will be
essential in solving matrix equations.    Remember that for numbers
to solve the equation $3x + 2 = 8$ we first need to subtract to get
$3x = 6$ and then we divide both sides by $3$   - the key step! -   to 
get $x = 2$.  

\subsection{ Identity matrices}  

Division by $x$ is just multiplication by $\frac{1}{x}$, so first we must
understand what ``1'' is for matrices.     Your first guess might
be the matrix $\begin{bmatrix}  1 & 1 \\ 1 & 1 \end{bmatrix}$.  
But how would we know this is right?    The key fact about $1$
is that $1 \cdot y = y$ for any $y$.     We can check
whether $\begin{bmatrix}  1 & 1 \\ 1 & 1 \end{bmatrix}$ satisfies
this key fact:   $\begin{bmatrix}  1 & 1 \\ 1 & 1 \end{bmatrix}
\begin{bmatrix}  1 & 2\\  3&  4\end{bmatrix} = 
\begin{bmatrix}  4 & 6\\ 4 & 6 \end{bmatrix}$.     So it doesn't!  
Fortunately, there is a matrix which satisfies this key property.  

\begin{definition}
The $n$ by $n$ identity matrix is the square matrix with $1$'s for the $1,1$,
$2,2, \ldots, n,n$ entries, and $0$'s everywhere else.    For example,
the $3$ by $3$ identity matrix is 
$\begin{bmatrix}  1 & 0 & 0 \\  0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$.  
Identity matrices are often denoted by the letter $I$ (which then does
not specify the size of the matrix).  
\end{definition}

\begin{theorem}
For any identity matrix $I$ and square matrix $M$ of the same size,
$I M = M I = M$.  
\end{theorem}

\begin{example}
We verify this theorem for the $2 \times 2$ identity matrix.  
\end{example}

We have already seen the identity matrix when we first looked at solving
systems of equations using matrix notation.    In fact, linear equations
expressed in terms of the identity matrix couldn't be any easier!  

\begin{example}
Translate the matrix equation $\begin{bmatrix}  1 &  0 \\ 0  &1  \end{bmatrix}
\begin{bmatrix}  x \\ y  \end{bmatrix} = \begin{bmatrix}  3 \\ 5  \end{bmatrix}$.  
\end{example} 

\subsection{ Inverses of matrices}  

\begin{definition}
The inverse of a square matrix $M$ is one which we call $M^{-1}$   (as opposed to
$\frac{1}{M}$)   where $M M^{-1} = I = M^{-1} M$.  
\end{definition}

\begin{theorem}
The inverse of the $2 \times 2$ matrix $\begin{bmatrix}  a & b \\ c & d \end{bmatrix}$ is
$\begin{bmatrix}  \frac{d}{ad-bc} & \frac{-b}{ad-bc}\\  \frac{-c}{ad - bc} & \frac{a}{ad-bc} \end{bmatrix}$.  
\end{theorem}

Note that the number $ad - bc$ which appears everywhere in this formula has its own
special name; it is the {\em determinant} of the matrix.    If it is zero, then an inverse
does not exist.   

\begin{example}
Verify this theorem for the matrices $\begin{bmatrix}  1 & 2 \\ 3 &  4\end{bmatrix}$  
and $\begin{bmatrix}  5 &7 \\  2& 3 \end{bmatrix}$.  
\end{example}

There are formulae for inverting larger matrices, but they are complicated!  
Fortunately, we do not have to invert matrices by hand.     Many graphing calculators,
including the TI-83, have a function to invert a matrix.  See the manual, linked
to from the class page, to learn how.    

\subsection{ Using inverses to solve linear systems}  

Let $M$ be a square matrix, $X$ be a column vector of variables and $C$ be a column
vector of constants (of compatible sizes).    To solve the equation
$MX = C$ we first find $M^{-1}$ (if it exists) and then multiplying both sides
by $M^{-1}$ we get $M^{-1} M X = M^{-1} C$  , or $I X = M^{-1} C$  
or $X = M^{-1} C$.  

So the steps to solve $MX = C$ are:
\begin{enumerate}
\item Find $M^{-1}$.  
\item Compute the product $M^{-1} C$.  
\item (For thoroughness) check that your answer works.  
\end{enumerate}

\begin{example}
Use matrix algebra to solve the system of equations $5x + 7y = 3$, $2x + 3y = -1$.  
\end{example}

One great advantage to matrix methods is in solving related systems.  

\begin{example}
Solve the matrix equation $\begin{bmatrix}  3 & 2\\  \frac{1}{2} & \frac{1}{2} \end{bmatrix}
\begin{bmatrix}  x \\ y  \end{bmatrix} = \begin{bmatrix}  5 \\  6  \end{bmatrix}$.  
What if we replace $\begin{bmatrix}  5 \\  6  \end{bmatrix}$ by 
$\begin{bmatrix}  1 \\  2 \end{bmatrix}$?    By $\begin{bmatrix}  -1  \\  \pi  \end{bmatrix}$?  
\end{example}

With these techniques (and calculators in hand) we can move on to swiftly solving
problems with more variables.   

\begin{example}
The average yield on A-bonds is 6\%, on B-bonds is 7\% and on C-bonds is 10\%.
Because of a hedging scheme,  you must invest twice as much money in $A$ bonds
as $C$ bonds.  Find the amounts to invest for the following desired outcomes:  
\begin{itemize}
\item \$25K invested with an annual return of \$1.8K.  
\item \$30K invested with an annual return of \$2.2K.  
\item \$40K invested with an annual return of \$2.9 K.  
\end{itemize}
\end{example}

\end{document}
 