\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 Monday, Week 6}
\bigskip

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

Our next goal is to encode linear functions by matrices.  We first treat the
special case of linear functions of the form $F^n\to F^m$.  Next, we consider
linear functions~$V\to W$ between general finite-dimensional vector spaces.  If $\dim V=n$
and $\dim W=m$ we saw last time that a choices of bases give isomorphisms
$V\simeq F^{n}$ and~$W\simeq F^m$, which reduces the problem to the special case.
\medskip

\textsc{Matrices for linear functions $F^n\to F^m$.}
The \emph{dot product} of vectors $(a_1,\ldots,a_n)$ and $(b_1,\ldots,b_n)$
in~$F^n$ is defined by
\[
  (a_1,\ldots,a_n)\cdot (b_1,\ldots,b_n):=\sum_{i=1}^{n} a_i b_i=a_1b_1+\cdots+a_nb_n.
\]
From now on we make adopt the convention of identifying vectors
$(a_1,\ldots,a_n)\in F^n$ with $n\times 1$ matrices, also called \emph{column
vectors}:
\[
  \left(\begin{array}{c}
  a_1 \\
\vdots \\
a_n
  \end{array}\right).
\]
If $A\in M_{m\times n}(F)$ and $x=(x_1,\ldots,x_n)\in F^{n}$, we define~$Ax\in
F^m$ to be the element of $F^m$ whose $i$-th component~$(Ax)_i$ is the dot
product of the $i$-th row of~$A$ with~$x$:
\begin{align*}
  Ax &=
  \left(\begin{array}{cccc}
  a_{11} & a_{12} & \dots & a_{1n} \\
a_{21} & a_{22} & \dots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots\\
a_{m1} & a_{m2} & \dots & a_{mn}
  \end{array}\right)	
  \left(\begin{array}{c}
  x_1 \\
x_{2} \\
\vdots \\
x_{n}
  \end{array}\right)
  :=
  \left(\begin{array}{c}
  a_{11}x_{1}+a_{12}x_{2}+\dots+a_{1n}x_{n} \\
  a_{21}x_{1}+a_{22}x_{2}+\dots+a_{2n}x_{n} \\
 \vdots\\
  a_{m1}x_{1}+a_{m2}x_{2}+\dots+a_{mn}x_{n} 
  \end{array}\right)\\[8pt]
  &=(a_{11}x_{1}+a_{12}x_{2}+\dots+a_{1n}x_{n},
  a_{21}x_{1}+a_{22}x_{2}+\dots+a_{2n}x_{n},\ldots,
  a_{m1}x_{1}+a_{m2}x_{2}+\dots+a_{mn}x_{n}).
\end{align*}
The latter equals sign is just making the identification of column vectors with
elements of~$F^{m}$.
Equivalently,
\[
  Ax := 
  x_1
  \left(\begin{array}{c}
      a_{11} \\
      a_{21}\\
      \vdots \\
      a_{m1}
  \end{array}\right)
  +
  x_2
  \left(\begin{array}{c}
      a_{12} \\
      a_{22}\\
      \vdots \\
      a_{m2}
  \end{array}\right)
  +
  \cdots
  +
  x_n
  \left(\begin{array}{c}
      a_{1n} \\
      a_{2n}\\
      \vdots \\
      a_{mn}
  \end{array}\right).
\]
We could similarly, convert the above notation into a statement about a linear
combination of $m$-tuples in $F^{m}$ instead of using column vectors.
\medskip

\textbf{Definition.} Let~$A\in M_{m\times n}(F)$.  The linear
associated with~$A$ is
\begin{align*}
  L_A\colon F^{n}&\to F^{m}\\
  x&\mapsto Ax.
\end{align*}

\textbf{Exercise.} The reader should perform the routine check that~$L_A$ is
a linear function: $L_A(x+\lambda y)=L_A(x)+\lambda L_{A}(y)$.
\medskip

\textbf{Examples.}
\begin{enumerate}[(1)]
  \item The matrix
    \[
      A = 
      \left(\begin{array}{rrr}
	  2 & -5 & 4 \\
	  3 & 0 & 2
      \end{array}\right)
    \]
   has corresponding linear mapping
   \begin{align*}
     L_{A}\colon F^{3}&\to F^{2}\\
     (x,y,z) &\mapsto 
     \left(\begin{array}{c}
	 2x-5y+4z \\
	 3x+2z
     \end{array}\right).
   \end{align*}		
   Recall that we are identifying
   To save space, we could we will write this as
   \begin{align*}
     L_{A}\colon F^{3}&\to F^{2}\\
     (x,y,z) &\mapsto 
     (2x-5y+4z,3x+2z).
   \end{align*}		
 \item Note that if you were given the linear function~$L_A$, you could easily
   recover the matrix: just read off the coefficients of each component
   of~$L_A(x)$ to find the rows of~$A$.  (We will see another way of
   recovering~$A$ below.) For example, find the matrix corresponding to the linear function~$\phi\colon F^{3}\to
   F^{2}$ defined by~$\phi(u,v)=(4u-3v,6u+2v,3v)$.  
   \medskip

   \emph{Solution.} Reading off the coefficients of each component of~$\phi$
   gives our matrix.  Defining
   \[
     A :=
     \left(\begin{array}{rr}
	 4 & -3 \\
	 6 & 2 \\
	 0& 3
     \end{array}\right),
   \]
   it is easy to check that~$\phi=L_A$.
 \item Here are some important special cases of this correspondence between
   linear functions and matrices:
   \begin{align*}
     L_A(x) =(2x,5x,7x)&\qquad\leftrightsquigarrow\qquad 
     A = \left(\begin{array}{c}
     2 \\ 5\\ 7
     \end{array}\right)\\[8pt]
     L_B(w,x,y,z) =w+2x-4y+z&\qquad\leftrightsquigarrow\qquad 
     B = \left(\begin{array}{cccc}
	 1&2&-4&1
     \end{array}\right)\\[8pt]
     L_C(t) =8t&\qquad\leftrightsquigarrow\qquad 
     C = \left(\begin{array}{c}
	 8
     \end{array}\right).
   \end{align*}
\end{enumerate}
We have formally defined the linear mapping~$L_A$ associated with a matrix~$A$, and from the
examples above, it may be clear how to go in the other direction to find the
matrix of a given linear function.  Here is the formal definition:
\medskip

\textbf{Definition.} The matrix associated with the linear function~$L\colon
F^{n}\to F^{m}$ is the element~$A\in M_{m\times n}(F)$ whose~$j$-th column
is~$L(e_j)$ where~$e_j$ is the $j$-th standard basis vector for~$F^{n}$.
\medskip

\textbf{Examples.}  Consider the first two examples given above.
\begin{enumerate}[(1)]
  \item Consider the linear function~$L\colon F^{3}\to F^{2}$ given
    by~$L(x,y,z)=(2x-5y+4z,3x+2z)$.  Evaluate~$L$ at the three standard basis
    vectors for~$F^{3}$:
    \begin{align*}
      L(e_1)&=L(1,0,0)=(2,3)\\
      L(e_2)&=L(0,1,0)=(-5,0)\\
      L(e_3)&=L(0,0,1)=(4,2).
    \end{align*}
    Use these three vectors to form a matrix:
    \[
      A=
      \left(\begin{array}{rrr}
	  2 & -5 & 4 \\
	  3 & 0 & 2
      \end{array}\right).
    \]
    Thus,~$L=L_A$.
  \item Consider the linear function~$\phi\colon F^{3}\to F^{2}$ given
    by~$\phi(u,v)=(4u-3v,6u+2v,3v)$.  Then,
    \[
      \phi(1,0)=(4,6,0)\quad\text{and}\quad\phi(0,1)=(-3,2,3).
    \]
    Place these vectors as columns to get the matrix
    \[
      \left(\begin{array}{rr}
	  4 & -3 \\
	  6 & 2 \\
	  0 & 3
      \end{array}\right).
    \]
\end{enumerate}
We have, thus, created a bijective correspondence between linear
function~$F^{n}\to F^{m}$ and matrices in~$M_{m\times n}(F)$.
\medskip

\textsc{Matrices for linear functions~$V\to W$.}

Let~$V$ and~$W$ be vector spaces with ordered bases~$\mathcal{B}=\langle
v_{1},\ldots,v_{n}\rangle$ and~$\mathcal{D}=\langle w_{1},\ldots,w_{m}\rangle$,
respectively.  Taking coordinates with respect to these bases yields
isomorphisms $\phi_{\mathcal{B}}: V\to F^{n}$ and~$\phi_{\mathcal{D}}\colon W\to
F^{m}$. For instance, if~$v\in V$, we write~$v=\sum_{i=1}^{n} a_i v_i$, and
then~$\phi_{\mathcal{B}}(v):=(a_{1},\ldots,a_{n})$.  Now suppose we have a
linear function~$f\colon V\to W$.  So up to now we have three mappings we are
considering:
\begin{center}
  \begin{tikzcd}
    V\arrow[d,swap, "\phi_{\mathcal{B}}","\sim" labr]\arrow[r,"f"]&
    W\arrow[d,"\phi_{\mathcal{D}}","\sim" labl]\\
    F^n&F^m
  \end{tikzcd}
\end{center}
We now describe how to use this diagram to create a linear function~$L\colon F^n\to F^m$.
Since~$\phi_{\mathcal{B}}$ is an isomorphism, we can invert it and then define
$L$ by starting at~$F^n$, applying $\phi_{\mathcal{B}}^{-1}$ to go up the left-hand
side of the diagram arriving at~$V$, then applying~$f$ to go to~$W$, and finally
using~$\phi_{\mathcal{D}}$ to go from~$W$ to~$F^m$.  More succinctly, define:
\[
  L := \phi_{\mathcal{D}}\circ f\circ \phi_{\mathcal{B}}^{-1}.
\]
In sum, we have the following important \emph{commutative diagram}:
\begin{center}
  \begin{tikzcd}
    V\arrow[d,swap, "\phi_{\mathcal{B}}","\sim" labr]\arrow[r,"f"]&
    W\arrow[d,"\phi_{\mathcal{D}}","\sim" labl]\\
    F^n\arrow[r,"L"]&F^m
  \end{tikzcd}
\end{center}
Saying the diagram is \emph{commutative} means the no matter which path we take
from~$V$ to~$F^m$, we arrive at the same place, i.e.,
\[
  L\circ\phi_{\mathcal{B}}=\phi_{\mathcal{D}}\circ f.
\]

Now~$L$ is a mapping between tuples and, thus, has a matrix, as discussed at the
beginning of this lecture.  To keep track of all of the input data, we use the
following, necessarily complicated, notation for this matrix:
\[
  [f]_{\mathcal{B}}^{\mathcal{D}}:= \text{ matrix corresponding to~$L$}.
\]

\textbf{How do we compute this matrix?}  The algorithm for
computing~$[f]_{\alpha}^{\beta}$ is summarized in the diagram below:
\begin{center}
\begin{tikzpicture}
  \node at (0,0) {
\begin{tikzcd}
  V\arrow[d,swap, "\phi_{\mathcal{B}}","\sim" labr]\arrow[r,"f"]&
  W\arrow[d,"\phi_{\mathcal{D}}","\sim" labl]\\
  F^n\arrow[r,"{[f]}_{\mathcal{B}}^{\mathcal{D}}"]&F^m.
\end{tikzcd}
};
\node[red] (vj) at (-1.9,1.2) {$v_j$};
\node[red] (fvj) at (1.9,1.2) {$f(v_j)$};
\node[red] (ej) at (-1.9,-1.4) {$e_j$};
\node[red] (fej) at (2.7,-1.4) {$j$-th col.~of $[f]_{\mathcal{B}}^{\mathcal{D}}$};
\node (dummy-left) at (1.0,-1.5) {};
\node (dummy-top) at (2.1,-1.0) {};
\draw[->,red] (vj) to[bend left=10] (fvj);
\draw[->,red,dashed] (vj) to[bend right=10] (ej);
\draw[->,red,dashed] (ej) to[bend right=10] (dummy-left);
\draw[->,red] (fvj) to[bend left=10] (dummy-top);
\node[red] at (4.1,0) {take coords.~wrt.~$\mathcal{D}$};
\end{tikzpicture}
\end{center}
In words: since~$[f]_{\mathcal{B}}^{\mathcal{D}}$ is a matrix,
its~$j$-th column is given by~$[f]_{\mathcal{B}}^{\mathcal{D}}(e_j)$.  By definition,
\[
  [f]_{\mathcal{B}}^{\mathcal{D}}(e_j)=\phi_{\mathcal{D}}\circ f\circ\phi^{-1}_{\mathcal{B}}(e_j)
  =\phi_{\mathcal{D}}\left(f\left(\phi^{-1}_{\mathcal{B}}(e_j)\right)\right).
\]
We have~$\phi_{\mathcal{B}}(v_j)=e_j$.  Hence,~$\phi^{-1}_{\mathcal{B}}(e_j)=v_j\in V$.
So,
\[
  [f]_{\mathcal{B}}^{\mathcal{D}}(e_j)
  =\phi_{\mathcal{D}}\left(f\left(\phi^{-1}_{\mathcal{B}}(e_j)\right)\right)
  =\phi_{\mathcal{D}}\left( f(v_j) \right).
\]
\emph{So here is the algorithm for computing~$[f]_{\mathcal{B}}^{\mathcal{D}}$}: 

\begin{quote}
  To find the $j$-th column of $[f]_{\mathcal{B}}^{\mathcal{D}}$ compute the coordinates of~$f(v_j)$ with respect
  to~$\mathcal{D}=\langle w_{1},\ldots,w_{m}\rangle$ for each $v_j\in\mathcal{B}=\langle v_1,\ldots,v_{n}\rangle$.
\end{quote}
\medskip

\textbf{Example.} Consider linear function~$f\colon \R^{2}\to \R^{2}$ given by
the matrix
\[
  A = 
  \left(\begin{array}{rr}
      1 & 4 \\
      2 & 3
  \end{array}\right).
\]
Thus, $f(x,y)=(x+4y,2x+3y$.  Using the notation above, we are
letting~$V=W=\R^{2}$.  Take the same ordered basis for both~$V$ and~$W$ given by
\[
  \mathcal{B}=\mathcal{D}=\langle (1,1),(-2,1)\rangle.
\]
Find the matrix representing~$f$ with respect to this choice of bases for domain
and codomain.
\medskip

\emph{Solution.}
To conform with our earlier notation, we take~$v_1=(1,1)$ and~$v_2=(-2,1)$.
First apply~$f$ to each of the basis vectors for~$V$:
\begin{align*}
  f(v_1) &= (5,5)\\
  f(v_2) &= (2,-1).	
\end{align*}
Next, take the coordinates of these vectors with respect to the
basis~$\mathcal{B}$ for~$W$:
\begin{align*}
  (5,5) &= 5v_1+0\cdot v_2\\
  (2,-1)&=0\cdot v_1-v_2.
\end{align*}
Hence,
\begin{align*}
  \phi_{\mathcal{B}}(v_1) &= (5,0)\\
  \phi_{\mathcal{B}}(v_2) &= (0,-1).
\end{align*}
These are the columns for our matrix:
\[
  [f]_{\mathcal{B}}^{\mathcal{B}}
  =
  \left(\begin{array}{rr}
      5 & 0 \\
      0 & -1
  \end{array}\right).
\]
We arrive at the commutative diagram:
\begin{center}
  \begin{tikzcd}
    \R^2\arrow[d,swap, "\phi_{\mathcal{B}}","\sim"
    labr]\arrow[r,"f"]&
    \R^2\arrow[d,"\phi_{\mathcal{B}}","\sim" labl]\\
    \R^2\arrow[r,"L"]&\R^2
  \end{tikzcd}
\end{center}
Where $L$ is the linear function corresponding
to~$[f]_{\mathcal{B}}^{\mathcal{B}}$, i.e.,
\[
  L(x,y) = (5x,-y).
\]

\textbf{Example.}  Consider the linear mapping
\begin{align*}
  f\colon \R[x]_{\leq2}&\to \R[x]_{\leq3}\\
  p&\mapsto xp.
\end{align*}
Thus, $f$ consists of multiplying a polynomial by~$x$.  Choose
bases $\mathcal{B}=\langle 1,x,x^{2}\rangle$ for the domain
and~$\mathcal{D}=\langle 1,x,x^{2},x^{3}\rangle$ for the codomain.  Thus,
$\phi_{\mathcal{B}}(a+bx+cx^{2})=(a,b,c)$
and~$\phi_{\mathcal{D}}(a+bx+cx^{2}+dx^{3})=(a,b,c,d)$.  To
find~$[f]_{\mathcal{B}}^{\mathcal{D}}$, compute the images of the elements
in~$\mathcal{B}$ and express them as linear combinations of elements
of~$\mathcal{D}$:
\begin{align*}
  f(1)&=x = 0\cdot1+1\cdot x+0\cdot x^{2}+0\cdot x^{3}\\
  f(x)&=x^{2}= 0\cdot1+0\cdot x+1\cdot x^{2}+0\cdot x^{3}\\
  f(x^{2})&=x^{3}=0\cdot1+0\cdot x+0\cdot x^{2}+1\cdot x^{3}.
\end{align*}
Therefore,
\begin{align*}
  [f(1)]_{\mathcal{D}}&=(0,1,0,0)\\
  [f(x)]_{\mathcal{D}}&=(0,0,1,0)\\
  [f(x^{2})]_{\mathcal{D}}&=(0,0,0,1).
\end{align*}
These vectors are the columns for our matrix:
\[
  [f]_{\mathcal{B}}^{\mathcal{D}}=
  \left(\begin{array}{ccc}
  0 & 0 & 0 \\
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
  \end{array}\right).
\]
\end{document}
