\documentclass[11pt]{article}

\usepackage{systeme}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
%\usepackage{palatino}
\usepackage{setdeck}

\usepackage{xcolor}

%\usepackage[textheight=8.5in, margin=1.6in]{geometry}
\usepackage[total={6in,8in}]{geometry}

\usepackage{tikz}
\usetikzlibrary{cd}
\tikzset{
      labr/.style={anchor=north, rotate=90, inner sep=.7mm}
    }
\tikzset{
      labl/.style={anchor=south, rotate=90, inner sep=.7mm}
    }

%\usepackage{pgfplots}
%\tikzstyle{ball} = [circle,shading=ball, ball color=black,
%    minimum size=1mm,inner sep=1.3pt]
%\usetikzlibrary{arrows.meta}
%\tikzset{>={Latex[length=2mm,width=1.5mm]}}

%\usepackage{graphicx}

\usepackage{needspace}  % <-- to prevent bad pagebreak over environment titles
% Use:  \Needspace{3\baselineskip} before opening an environment

\usepackage[shortlabels]{enumitem}
\setlist[enumerate]{leftmargin=*,label=(\alph*)}

%\usepackage[colorlinks=true,citecolor=black,linkcolor=black,urlcolor=blue]{hyperref}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\sn}{\mathfrak{S}}
\newcommand{\ve}{\varepsilon}
\newcommand{\ips}[2]{\langle{#1}, {#2}\rangle}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\Span}{\mathrm{Span}}
\DeclareMathOperator{\rk}{\mathrm{rank}}
\DeclareMathOperator{\rspace}{\mathrm{rowspace}}
\DeclareMathOperator{\cspace}{\mathrm{colspace}}
\DeclareMathOperator{\trace}{\mathrm{tr}}
\DeclareMathOperator{\im}{\mathrm{im}}
\DeclareMathOperator{\Sym}{\mathrm{Sym}}
\DeclareMathOperator{\Hom}{\mathrm{Hom}}
\DeclareMathOperator{\diag}{\mathrm{diag}}
\DeclareMathOperator{\glb}{\mathrm{glb}}
\DeclareMathOperator{\lub}{\mathrm{lub}}

\parskip = 0.05in
\parindent = 0.0in

%\pagestyle{empty}

\begin{document}
\centerline{Math 201 lecture for Friday, Week 6}
\bigskip

\centerline{\textbf{Linear transformations and matrices III}}
\medskip

The goal today is to formally define the algebraic structure for matrices
(linear structure and multiplication).  Multiplication of matrices corresponds
with composition of their corresponding linear transformations.   
\bigskip

\textbf{Composition of linear functions.}
\smallskip

\textbf{Proposition.} Let~$f\colon V\to W$ and~$g\colon W\to U$ be linear
functions.  Their the composition~$g\circ f\colon V\to U$ is a linear function.
\begin{proof}
  Let~$u,v\in V$ and~$\lambda\in F$.  Then, since~$f$ and~$g$ are linear,
  \begin{align*}
    (g\circ f)(u+\lambda v)&:=g(f(u+\lambda v))\\
    &=g\left(f(u)+\lambda f(v)\right)\\
    &=g(f(u))+\lambda g(f(v))\\
    &=(g\circ f)(u)+\lambda (g\circ f)(v).
  \end{align*}
\end{proof}

Let~$f\colon V\to W$ and $g\colon W\to U$ be a linear functions.  We are
interested in a matrices representing the composition
\[
  g\circ f\colon V\xrightarrow{f} W\xrightarrow{g}U.
\]
Fix ordered bases
$\mathcal{B}=\langle v_{1},\ldots,v_{n}\rangle$ for~$V$,
$\mathcal{C}=\langle w_{1},\ldots,w_{\ell}\rangle$ for~$W$, and
$\mathcal{D}=\langle u_{1},\ldots,u_{m}\rangle$ for~$U$.
Let
\[
  P :=[g]_{\mathcal{C}}^{\mathcal{D}}\quad\text{and}\quad
  Q=[f]_{\mathcal{B}}^{\mathcal{C}}.
\]
Thus, $P\in M_{m\times \ell}(F)$ and~$Q\in M_{\ell\times n}$.
The relevant commutative diagram is
\begin{center}
  \begin{tikzcd}
    V\arrow[d,swap, "\phi_{\mathcal{B}}","\sim" labr]\arrow[r,"f"]
    & W\arrow[d,"\phi_{\mathcal{C}}","\sim" labl]\arrow[r,"g"]
    & U\arrow[d,"\phi_{\mathcal{D}}","\sim" labl]\\
    F^n\arrow[r,"Q"]&F^{\ell}\arrow[r,"P"]& F^{m}
  \end{tikzcd}
\end{center}
Let's compute~$[g\circ f]_{\mathcal{B}}^{\mathcal{D}}$.  To find its $j$-th
column, we find the coordinates of~$(g\circ f)(v_j)$ with respect to the
ordered basis~$\mathcal{D}$:
\begin{align*}
  (g\circ f)(v_{j})
  &=g(f(v_{j}))\\
 &=g\left(\sum_{k=1}^{\ell} Q_{kj}w_{k}\right)&&\text{(~$j$-th column of~$Q$)}\\
  &=\sum_{k=1}^{\ell} Q_{kj}g(w_{k})\\
  &=\sum_{k=1}^{\ell} Q_{kj}\left(\sum_{i=1}^{m} P_{ik}u_i\right)&&\text{(~$k$-th column of~$P$)}\\
  &=\sum_{i=1}^{m} \left(\sum_{k=1}^{\ell} P_{ik}Q_{kj}\right)u_{i}.
\end{align*}
So the $j$ column of $[g\circ f]_{\mathcal{B}}^{\mathcal{D}}$ is given by the
coefficients of the~$u_i$ in the above some.  That means that the $(i,j)$-th
entry of the matrix $[g\circ f]_{\mathcal{B}}^{\mathcal{D}}$, i.e., the entry in
its~$i$-row and~$j$-th column is
\[
  \left([g\circ f]_{\mathcal{B}}^{\mathcal{D}}\right)_{ij}=
\sum_{k=1}^{m} P_{ik}Q_{kj}.
\]

\textbf{Definition.} (Multiplication of matrices) Let~$P\in M_{m\times \ell}(F)$ and~$Q\in M_{\ell\times n}(F)$,
then the product~$PQ\in M_{m\times n}(F)$ is defined by
\[
  (PQ)_{ij}=\sum_{k=1}^{\ell} P_{ik}Q_{kj}.
\]

\textbf{Note:} The formula says that the $(i,j)$-th entry of the product~$PQ$ is
the dot product of the $i$-th row of~$P$ with the $j$-th column of~$Q$.  That's
what one thinks about when performing the calculation of~$PQ$ in practice.
\medskip

\textbf{Example.}  Here is an example of the product of two matrices.  For
instance, to find the $(2,3)$-entry of the product, we take the dot product of
the second row of the first matrix with the third column of the second:
\begin{center}
  \begin{tikzpicture}
    \node at (0,0) {$
	\left(\begin{array}{rr}
	    5 & -1 \\
	    0 & 2 \\
	    -3 & 0
	\end{array}\right)
	\left(\begin{array}{rrrr}
	    2 & 0 & -1 & 3 \\
	    1 & -1 & 4 & 0
	\end{array}\right)
	=
	\left(\begin{array}{rrrr}
	    9 & 1 & -9 & 15 \\
	    2 & -2 & 8 & 0 \\
	    -6 & 0 & 3 & -9
	\end{array}\right).
      $};
    \fill[blue!20,opacity=0.4] (-4.6,0.25) rectangle (-3.2,-0.2);
    \fill[blue!20,opacity=0.4] (-1,0.5) rectangle (-0.3,-0.5);
    \fill[blue!20,opacity=0.4] (3.35,0.3) rectangle (3.8,-0.2);
  \end{tikzpicture}
\end{center}
Recall the relevance of this computation: the first two matrices encode linear
functions~$g$ and~$f$, and their product is a matrix encoding the
composition~$g\circ f$.
\medskip

\textbf{Proposition.}
Let~$f\colon V\to W$ and $g\colon W\to U$ be a linear functions, and 
fix ordered bases
$\mathcal{B}=\langle v_{1},\ldots,v_{n}\rangle$ for~$V$,
$\mathcal{C}=\langle w_{1},\ldots,w_{\ell}\rangle$ for~$W$, and
$\mathcal{D}=\langle u_{1},\ldots,u_{m}\rangle$ for~$U$.
Then we have
\[
  [g\circ f]_{\mathcal{B}}^{\mathcal{D}} =
  [g]_{\mathcal{C}}^{\mathcal{D}}[f]_{\mathcal{B}}^{\mathcal{C}}.
\]
\begin{proof}
  The proof is exactly the motivation we just gave for the definition of the matrix
  product.
\end{proof}

We summarize some basic properties of matrix algebra.
\medskip

\textbf{Proposition.} Let~$A$ be an~$m\times n$ matrix,~$B$ an~$n\times r$ matrix,
both over a field~$F$, and~$\lambda\in F$. 
\begin{enumerate}
  \item $\lambda(AB)=(\lambda A)B=A(\lambda B)$.
  \item\label{item2:06fri} $A(BC)=(AB)C$ for all~$r\times s$ matrices~$C$.
  \item $A(B+C)=AB+AC$ for all~$n\times r$ matrices~$C$.
  \item $(C+D)A = CA+DA$ for all~$r\times m$ matrices~$C$ and~$D$.
\end{enumerate}

\begin{proof}
  We will just prove part~\ref{item2:06fri}, associativity of multiplication.  So
  let~$C$ be an~$r\times s$ matrix.  We have
  \begin{align*}
    (A(BC))_{ij}
    &=\sum_{k=1}^{n}A_{ik}(BC)_{kj}\\[4pt]
    &=\sum_{k=1}^{n}\left(A_{ik}\left(\sum_{\ell=1}^{r}B_{k\ell}C_{\ell j}\right)\right)\\[10pt]
    &=\sum_{k=1}^{n}\sum_{\ell=1}^{r}A_{ik}(B_{k\ell}C_{\ell j})\\[4pt]
    &=\sum_{\ell=1}^{r}\sum_{k=1}^{n}A_{ik}(B_{k\ell}C_{\ell j})\\[4pt]
    &=\sum_{\ell=1}^{r}\sum_{k=1}^{n}(A_{ik}B_{k\ell})C_{\ell j}\\[4pt]
    &=\sum_{\ell=1}^{r}\left(\sum_{k=1}^{n}A_{ik}B_{k\ell}\right)C_{\ell j}\\[4pt]
    &=\sum_{\ell=1}^{r}(AB)_{i\ell}C_{\ell j}\\[4pt]
    &=((AB)C)_{ij}.
  \end{align*}
\end{proof}

\textbf{Warning.}  Matrix multiplication is not commutative, in general.  First of
all, if the dimensions aren't right, multiplication for both~$AB$ and~$BA$ might
not make sense. For instance, if
\[
A = 
  \left(\begin{array}{rr}
      1&0\\
      3&-1\\
  \end{array} \right)
  \quad\text{and}\quad
  B=
  \left(\begin{array}{ccc}
      1&0&2\\
      3&1&4
  \end{array} \right),
\]
then~$AB$ is defined, but not~$BA$.

However, even if~$AB$ and~$BA$ are both defined, it is usually not the case
that~$AB=BA$.  Try just about any example with~$2\times2$ matrices to see this.
\medskip

\textbf{Definition.}  Let~$V$ and~$W$ be vector spaces over a field~$F$.
The set of linear transformations (homomorphisms) from~$V$ to~$W$ is denoted
$\mathcal{L}(V,W)$ or~$\Hom(V,W)$.  It forms a vector space with operations
defined as follows: for $f,g\in\Hom(V,W)$ and~$\lambda\in F$, 
\[
  (f+ g)(v)=f(v)+g(v)\quad\text{and}\quad (\lambda f)(v)=\lambda f(v)
\]
for all~$v\in V$.
\medskip

\textbf{Proposition.} Let~$V$ and~$W$ be vectors spaces over~$F$ of dimension~$n$ and
$m$, respectively.  Then there is an isomorphism of vector spaces
\[
  \Hom(V,W)\to M_{m\times n}(F).
\]
\begin{proof}[Sketch of proof.]
 Choose ordered bases~$\mathcal{B}$ and~$\mathcal{D}$ for~$V$ and~$W$,
 respectively.  Then an isomorphism is given by
\begin{align*}
  \Hom(V,W) &\to M_{m\times n}(F)\\
  f &\mapsto [f]_{\mathcal{B}}^{\mathcal{D}}. 
\end{align*}
This isomorphism will change to a different isomorphism if different bases are
chosen.
\end{proof}
\end{document}
