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

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

Recall from last time that given a linear mapping $f\colon
V\to W$ and ordered bases $\mathcal{B}=\langle v_{1},\ldots,v_{n}\rangle$ and 
$\mathcal{D}=\langle w_{1},\ldots,w_{m}\rangle$ for~$V$ and~$W$, respectively,
we have a 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}
where
\[
  L := \phi_{\mathcal{D}}\circ f\circ \phi_{\mathcal{B}}^{-1}.
\]
The matrix representing~$L$ is denoted $[f]_{\mathcal{B}}^{\mathcal{D}}$ and its
calculation is displayed in the following diagram:
\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}
We compute $[f]_{\mathcal{B}}^{\mathcal{D}}$ by finding each of its columns: 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$.

Commutativity of the diagram says that for each $v\in V$
\[
  [f]_{\mathcal{B}}^{\mathcal{D}}(\phi_{\mathcal{B}}(v)) =
  \phi_{\mathcal{D}}(f(v)).
\]
Recall our notation for the coordinates of a vector with respect to a ordered basis, we
can rewrite that above as
\[
  [f]_{\mathcal{B}}^{\mathcal{D}}[v]_{\mathcal{B}}=[f(v)]_{\mathcal{D}}.
\]

\textbf{Example.}  Consider the linear function
\begin{align*}
  f\colon \R[x]_{\leq2}&\to \R[x]\leq3\\
  p&\mapsto xp+2p'.
\end{align*}
Choose ordered bases~$\mathcal{B}=\langle 1,x,x^{2}\rangle$ and $\mathcal{D}=\langle
1,x,x^{2},x^{3}\rangle$ for the domain and codomain, respectively.  Find the
matrix representing~$f$ with respect to these bases, and use the matrix to
computer~$f(3+2x+x^{2})$.
\smallskip

\emph{Solution.} Compute the images of the basis vectors in $\mathcal{B}$:
\begin{align*}
  f(1)&=x\cdot 1+2(1)' = x\\
  f(x)&=x\cdot x+2(x)' = x^{2}+2\\
  f(x^{2})&=x\cdot x^{2}+2(x^{2})' = x^{3}+4x.
\end{align*}
Next, find the coordinates of each of these with respect to~$\mathcal{D}$:
\begin{align*}
  [x]_{\mathcal{D}}=(0,1,0,0)\\
  [x^{2}+2]_{\mathcal{D}}=(2,0,1,0)\\
  [x^{3}+4]_{\mathcal{D}}=(0,4,0,1).
\end{align*}
Therefore,
\[
  [f]_{\mathcal{B}}^{\mathcal{D}}
  =
  \left(\begin{array}{ccc}
      0 & 2 & 0 \\
      1 & 0 & 4 \\
      0 & 1 & 0 \\
      0 & 0 & 1
  \end{array}\right).
\]
Here is a helpful way to think about this matrix:
\begin{center}
\begin{tikzpicture}
  \node at (-1.7,0.1)
  {$\displaystyle\left(\begin{array}{c@{\hskip 0.8cm}c@{\hskip 0.8cm}c}
      0&2&0\\
      1&0&4\\
      0&1&0\\
      0&0&1
\end{array} \right)$.};
\node at (-2.8,1.5) {$f(1)$};
\node at (-1.8,1.5) {$f(x)$};
\node at (-0.7,1.5) {$f(x^2)$};
\node at (-3.6,0.85) {$1$};
\node at (-3.6,0.33) {$x$};
\node at (-3.6,-0.1) {$x^2$};
\node at (-3.6,-0.62) {$x^3$};
\end{tikzpicture}
\end{center}
The columns are labeled by the images of the basis vectors of the
domain, and the rows are labeled by basis vectors of codomain.

To find $f(3+2x+x^{2})$, we first do the calculation using coordinates:
\begin{align*}
  [f(3+2x+x^{2})]_{\mathcal{D}} 
  &= [f]_{\mathcal{B}}^{\mathcal{D}}[3+2x+x^{2}]_{\mathcal{B}}\\[5pt]
  &=
  \left(\begin{array}{ccc}
      0 & 2 & 0 \\
      1 & 0 & 4 \\
      0 & 1 & 0 \\
      0 & 0 & 1
  \end{array}\right)
  \left(\begin{array}{c}
      3 \\
      2 \\
      1
  \end{array}\right)\\[8pt]
  &=
  \left(\begin{array}{c}
      4 \\
      7 \\
      2 \\
      1
  \end{array}\right).
\end{align*}
It follows that
\[
  f(3+2x+x^{2})= 4+7x+2x^2+x^3.
\]
Check using the definition of $f$:
\begin{align*}
  f(3+2x+x^{2})&=x(3+2x+x^{2})+2(3+2x+x^{2})'\\
	       &=(3x+2x^{2}+x^{3})+2(2+2x) \\
	       &=4+7x+2x^2+x^3.
\end{align*}

We would next like to prove that the rank of a linear function is equal to
the rank of any matrix representative of that function.  Recall that the
rank of a linear function is the dimension of its image, and the rank of a
matrix is the dimension of its column space (which we saw is equal to the
dimension of its row space---it is the number of pivot columns in the
reduced row echelon form of the matrix).
\medskip

\textbf{Proposition.} Let~$V$ and~$W$ be finite-dimensional vector spaces
with ordered bases~$\mathcal{B}$ and~$\mathcal{D}$, respectively.
Let~$f\colon V\to W$ be a linear transformation.  Then
\[
  \rk(f)=\rk([f]_{\mathcal{B}}^{\mathcal{D}}).
\]
\begin{proof}
  We first consider the special case of a linear mapping~$L_A\colon F^{n}\to
  F^{m}$ where~$A\in M_{m\times n}$.  Thus,~$L_A(x)=Ax$.  We saw last time
  that the image of $L_A$ is the span of the column of~$A$, i.e., the column
  space of~$A$.  Thus, the result holds in this case:
  \[
    \rk(L_A):=\dim(\im(L_A))=\dim(\mathrm{colspace}(A))=\rk(A).
  \]
  Now consider the general case.  We have the 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_A"]&F^m
    \end{tikzcd}
  \end{center}
  where, in this case, $A=[f]_{\mathcal{B}}^{\mathcal{D}}$.
  Since $\phi_{\mathcal{B}}$ and~$\phi_{\mathcal{D}}$ are isomorphism and
  the diagram commutes,
  \[
    \rk(L_A):=\dim(\im(L_A))=\dim(\im(L_A\circ\phi_{\mathcal{B}}))=\dim(\im(\phi_{\mathcal{D}}\circ
    f))=\dim(\im(f))=:\rk(f).
  \]
  We have seen that~$\rk(L_A)=\rk(A)$.  So the result follows, in general.
\end{proof}

\textbf{Corollary.} With notation as above, let~$A =
[f]_{\mathcal{B}}^{\mathcal{D}}\in M_{m\times n}(F)$.
\begin{enumerate}[itemsep=0pt]
  \item $f$ is surjective if and only if~$\rk(A)=m=\dim(W)$.
  \item $f$ is injective if and only if~$\rk(A)=n=\dim(V)$.
  \item $f$ is an isomorphism if and only if~$\rk(A)=m=n$.
\end{enumerate}
\begin{proof}\ 
  \begin{enumerate}[itemsep=0pt]
    \item The function~$f$ being surjective means that~$\im(f)=W$, which is
      equivalent to saying that~$\dim(\im(f))=\dim(W)$, or that~$\rk(f)=m$,
      and we have just seen that~$\rk(f)=\rk(A)$.
    \item We know that~$f$ is injective if and only if~$\dim(\ker(f))=0$.
      By the rank-nullity theorem,
      \[
	n=\dim V = \dim(\im(f))+\dim(\ker(f))=\rk(f)+\dim(\ker(f)).
      \]
      From the Proposition, we have~$\rk(f)=\rk(A)$.  Therefore,
      $\dim(\ker{f})=0$ if and only if~$\rk(A)=n$.
    \item This part follows from the previous two.
  \end{enumerate}
\end{proof}
\bigskip

\textbf{Composition of linear functions.}
Consider the linear functions
\begin{align*}
  f\colon \R^{4}&\to \R^{2}\\
  (x,y,z,w)&\mapsto (2x-z+3w,x-y+4z)
\end{align*}
and
\begin{align*}
  g\colon \R^{2}&\to \R^{3}\\
  (s,t)&\mapsto (5s-t,2t,-3s).
\end{align*}
Let's compute the composition $g\circ f\colon\R^{4}\to\R^{3}$:
\begin{align*}
  (g\circ f)(x,y,z,w)&=g(\underbrace{2x-z+3w}_{s},\underbrace{x-y+4z}_{t})\\[5pt]
  &=(5(2x-z+3w)-(x-y+4z),2(x-y+4z),-3(2x-z+3w))\\
  &=(9x+y-9z+15w,2x-2y+8z,-6x+3z-9w).
\end{align*}
The matrices associated with $f$ and~$g$ (with respect to the standard bases)
are, respectively,
\[
 \left(\begin{array}{rrrr}
 2 & 0 & -1 & 3 \\
1 & -1 & 4 & 0
 \end{array}\right),
 \quad
\left(\begin{array}{rr}
5 & -1 \\
0 & 2 \\
-3 & 0
\end{array}\right),
\quad
\left(\begin{array}{rrrr}
9 & 1 & -9 & 15 \\
2 & -2 & 8 & 0 \\
-6 & 0 & 3 & -9
\end{array}\right).
\]
What is the relation among these matrices?  We will take up this question next
time.
\end{document}
