\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 7}
\bigskip

\centerline{\textbf{Change of basis}}
\medskip

Let~$V$ be a vector space with ordered basis $\alpha=\langle
v_1,\dots,v_n\rangle$.  Recall the coordinate mapping
\begin{align*}
  \phi_{\alpha}\colon V&\xrightarrow{\sim} F^n\\
 v= a_1v_1+\dots+a_n v_n&\mapsto (a_1,\dots,a_n).
\end{align*}
In particular, we have~$\phi_{\alpha}(v_{j})=e_{j}$.  Consider the special case
where~$V=F^{n}$ so that
\[
  \phi_{\alpha}\colon F^{n}\to F^{n},
\]
and each $v_{j}$ is an element of~$F^{n}$.  Since~$\phi_{\alpha}$ is now a
mapping between tuples, is represented by the~$n\times n$ matrix~$M$ with the
property that~$\phi_{\alpha}(v)=Mv$ for all~$v\in F^{n}$.  The~$j$-th column
of~$M$ is~$\phi_{\alpha}(e_j)$ for~$j=1,\ldots,n$.
\medskip

\textbf{Proposition.} With notation as above, let~$P$ be the $n\times n$ matrix
whose~$j$-th column is~$v_{j}$ for $j=1,\ldots,n$.  Then~$M=P^{-1}$.
\begin{proof}
  If~$X$ is any matrix, then~$Xe_{j}$ is the~$j$-th column of $X$.  So in our
  case, $Pe_{j}=v_{j}$.  Since the $v_{j}$ form a basis, the columns of~$P$ are
  linearly independent.  So~$P$ has rank~$n$ and is, thus, invertible.  We have
  \[
    Pe_{j}=v_{j}
    \quad\Rightarrow\quad
    P^{-1}Pe_{j}=P^{-1}v_{j}
    \quad\Rightarrow\quad
    e_{j} = P^{-1}v_{j}.
  \]
  Therefore,~$P^{-1}v_{j}=e_{j}=\phi_{\alpha}(v_{j})$ for all~$j$.
  Since the~$v_{j}$ form a basis for~$F^{n}$, it follows that $P^{-1}v=\phi_{\alpha}(v)$ for all $v\in
  F^{n}$.  So $P^{-1}$ is the matrix representing~$\phi_{\alpha}$, which means
  that~$P^{-1}=M$.
\end{proof}

Next, consider a linear function
\[
  L_A\colon F^{n}\to F^{m} 
\]
given by the~$m\times n$ matrix~$A$, i.e., $L_A(v)=Av$ for all~$v\in F^{n}$.
Let $\alpha=\langle v_1,\dots,v_n\rangle$ and~$\beta=\langle
w_1,\ldots,w_m\rangle$ be ordered bases for~$F^{n}$ and~$F^{m}$ respectively.
What is the matrix representing~$L_A$ with respect to these new bases?  We have
the diagram
\begin{center}
  \begin{tikzcd}
    F^n\arrow[d,swap, "\phi_{\alpha}","\sim" labr]\arrow[r,"L_A"]&
    F^m\arrow[d,"\phi_{\beta}","\sim" labl]\\
    F^n\arrow[r,"{[L_A]}_{\alpha}^{\beta}"]&F^m.
  \end{tikzcd}
\end{center}
For ease of notation, let~$B:=[L_A]_{\alpha}^{\beta}$.  Our main goal today is to
give a formula for calculating $B$.  We already know how to find the matrices
representing the vertical coordinate mappings: let $P$ and~$Q$ be the matrices whose
columns are the elements of~$\alpha$ and~$\beta$, respectively, in order.  Our
diagram becomes
\begin{center}
  \begin{tikzcd}
    F^n\arrow[d,swap, "P^{-1}","\sim" labr]\arrow[r,"A"]&
    F^m\arrow[d,"Q^{-1}","\sim" labl]\\
    F^n\arrow[r,"B"]&F^m.
  \end{tikzcd}
\end{center}
Therefore, $B=Q^{-1}AP$.  We summarize our result:
\medskip

\textbf{Proposition.} Let~$A\in M_{m\times n}(F)$, and consider the linear
mapping~$L_A\colon F^{n}\to F^{m}$ determined by~$A$, i.e., $L(v)= Av$ for each~$v\in
F^{n}$.  Let $\alpha=\langle v_1,\dots,v_n\rangle$ and~$\beta=\langle w_1,\dots,
w_m\rangle$ be ordered bases for~$F^{n}$ and $F^m$, respectively.  Let~$P$ be the
$n\times n$ matrix with~$j$-th column~$v_j$ for $j=1,\ldots,n$, and let~$Q$ be
the $m\times m$ matrix with~$j$-th column~$w_j$ for~$j=1,\ldots,m$.  
Then the matrix~$B$ representing $L_A$ with respect to the bases~$\alpha$ and~$\beta$ is
\[
B=Q^{-1}AP,
\]
and we have the commutative diagram
\begin{center}
  \begin{tikzcd}
    F^n\arrow[d,swap, "P^{-1}","\sim" labr]\arrow[r,"A"]&
    F^m\arrow[d,"Q^{-1}","\sim" labl]\\
    F^n\arrow[r,"B"]&F^m.
  \end{tikzcd}
\end{center}
\medskip

\textbf{Example.}  Let~$\Q$ be the field of rational numbers, and consider the
linear function
\begin{align*}
  f\colon \Q^3&\to\Q^2\\
  (x,y,z)&\mapsto (x+3y+2z,2y+z),
\end{align*}
with corresponding matrix
\[
A = 
\left(\begin{array}{ccc}
    1&3&2\\
    0&2&1
\end{array} \right).
\]
Choose the following bases for the domain and codomain:
\begin{align*}
  \Q^3:\quad\alpha&=\langle(1,0,0),(1,1,0),(1,1,1)\rangle\\
  \Q^2:\quad\beta&=\langle(0,1),(1,1)\rangle.
\end{align*}
To find the matrix representing~$f$ with respect to these new bases, create
matrices whose columns are the basis vectors:
\[
P=
\left(\begin{array}{ccc}
    1&1&1\\
    0&1&1\\
    0&0&1
\end{array} \right)
\quad
\text{and}
\quad
Q=
\left(\begin{array}{cc}
    0&1\\
    1&1\\
\end{array} \right).
\]
Calculate the inverse of~$Q$:
\[
  \left(\begin{array}{cc|cc}
      0&1&1&0\\
      1&1&0&1
\end{array} \right)
\xrightarrow{r_1\leftrightarrow r_2}
  \left(\begin{array}{cc|cc}
      1&1&0&1\\
      0&1&1&0
\end{array} \right)
\xrightarrow{r_1\to r_1-r_2}
  \left(\begin{array}{cc|rr}
      1&0&-1&1\\
      0&1&1&0
\end{array} \right).
\]
The matrix representing~$f$ with respect to the bases~$\alpha$ and~$\beta$ is
then:
\[
  B = Q^{-1}AP =
  \left(\begin{array}{rr}
      -1 & 1 \\
      1 & 0
  \end{array}\right)
\left(\begin{array}{ccc}
    1&3&2\\
    0&2&1
\end{array} \right)
\left(\begin{array}{ccc}
    1&1&1\\
    0&1&1\\
    0&0&1
\end{array} \right)
=
  \left(\begin{array}{rrr}
      -1 & -2 & -3 \\
      1 & 4 & 6
  \end{array}\right).
\]
This agrees with the fact that
\begin{align*}
  f(1,0,0)&= (1,0)=-1(0,1)+1(1,1)\\
  f(1,1,0)&= (4,2)=-2(0,1)+4(1,1)\\
  f(1,1,1)&= (6,3)=-3(0,1)+6(1,1).
\end{align*}
\medskip

\textbf{An important special case.} The special case of the Proposition that arises most frequently in
practice is where~$m=n$ and~$\alpha=\beta$.  In other, words, we start with a
mapping~$L_A\colon F^n\to F^n$ represented by the matrix~$A$, and we choose the
same new basis $\alpha=\langle v_1,\dots,v_n\rangle$ for~$F^n$ for both the domain and
codomain.  We are then interested in the matrix representing~$L_A$ with respect to
this new basis~$\alpha$.  In that case, let~$P$ be the matrix whose columns
are~$v_1,\dots,v_n$, and we get the commutative diagram
\begin{center}
  \begin{tikzcd}
    F^n\arrow[d,swap, "P^{-1}","\sim" labr]\arrow[r,"A"]&
    F^n\arrow[d,"P^{-1}","\sim" labl]\\
    F^n\arrow[r,"B"]&F^m
  \end{tikzcd}
\end{center}
and the matrix we are looking for is
\[
  B = P^{-1}AP.
\]
We say~$B$ is formed by \emph{conjugating}~$A$.
\medskip

\textbf{Exercise.} Say~$A,B\in M_{n\times n}(F)$ are \emph{similar} and
write~$A\sim B$ if there exists an invertible matrix~$P\in M_{n\times n}(F)$
such that~$P^{-1}AP=B$.  Prove that $\sim$ is an equivalence relation.  What
does an equivalence class represent?
\medskip

\textbf{Example.} Consider the real matrix
\[
  A = 
  \left(\begin{array}{ccc}
      0 & 1 & 1 \\
      1 & 0 & 1 \\
      1 & 1 & 0
  \end{array}\right)
\]
What matrix represents the linear function~$L_A\colon F^{3}\to F^{3}$ with
respect to the ordered basis~$\alpha=\langle (1,1,1),(1,0,-1),(0,1,-1)\rangle$?
\smallskip

\textsc{Solution.} Use the vectors of~$\alpha$ as columns to define the matrix
\[
  P=
  \left(\begin{array}{rrr}
  1 & 1 & 0 \\
1 & 0 & 1 \\
1 & -1 & -1 
  \end{array}\right).
\]
Compute the inverse of~$P$ using our algorithm (omitted):
\[
  P^{-1} =
  \left(\begin{array}{rrr}
\frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\[5pt]
\frac{2}{3} & -\frac{1}{3} & -\frac{1}{3} \\[5pt]
-\frac{1}{3} & \frac{2}{3} & -\frac{1}{3}
\end{array}\right)
=\frac{1}{3}
\left(\begin{array}{rrr}
1 & 1 & 1 \\
2 & -1 & -1 \\
-1 & 2 & -1
\end{array}\right).
\]
Then the matrix representing~$L_A$ with respect to the ordered basis~$\alpha$ is
\[
  B = P^{-1}AP = 
  \left(\begin{array}{rrr}
2 & 0 & 0 \\
0 & -1 & 0 \\
0 & 0 & -1
\end{array}\right).
\]

Notice that the matrix representing~$L_A$ in the example becomes the much
simpler diagonal matrix after a change of basis.  We can then apply an important
trick to compute~$A^k$ for all integers~$k$.  First note that
\[
  A^{2}=
\left(\begin{array}{rrr}
2 & 1 & 1 \\
1 & 2 & 1 \\
1 & 1 & 2
\end{array}\right),\quad
A^{3}=
\left(\begin{array}{rrr}
2 & 3 & 3 \\
3 & 2 & 3 \\
3 & 3 & 2
\end{array}\right),\quad
A^{4}=
\left(\begin{array}{rrr}
6 & 5 & 5 \\
5 & 6 & 5 \\
5 & 5 & 6
\end{array}\right),\quad
A^{5}=
\left(\begin{array}{rrr}
10 & 11 & 11 \\
11 & 10 & 11 \\
11 & 11 & 10
\end{array}\right).
\]
What happens in general?  Here is the trick that can be applied here:
\begin{align*}
  B^{k}&=(P^{-1}AP)^{k}\\
 &= \underbrace{(P^{-1}AP)(P^{-1}AP)(P^{-1}AP)\cdots(P^{-1}AP)(P^{-1}AP)}_{\text{$k$
  times}}\\[8pt]
  &=P^{-1}A(PP^{-1})A(PP^{-1})A(PP^{-1})\cdots (PP^{-1})A(PP^{-1})AP\\
  &=P^{-1}A^{k}P.
\end{align*}

Since $B^{k}=P^{-1}A^{k}P$, we can solve for~$A^{k}$ by multiply both sides of
the equality on the left by~$P$ and on the right by~$P^{-1}$ to get
\begin{align*}
  A^{k}=PB^{k}P^{-1}
  &=
  \left(\begin{array}{rrr}
  1 & 1 & 0 \\
1 & 0 & 1 \\
1 & -1 & -1 
  \end{array}\right)
  \left(\begin{array}{rrr}
2 & 0 & 0 \\
0 & -1 & 0 \\
0 & 0 & -1
\end{array}\right)^{k}
\left(
\frac{1}{3}
\left(\begin{array}{rrr}
1 & 1 & 1 \\
2 & -1 & -1 \\
-1 & 2 & -1
\end{array}\right)
\right)\\[8pt]
&=
  \left(\begin{array}{rrr}
  1 & 1 & 0 \\
1 & 0 & 1 \\
1 & -1 & -1 
  \end{array}\right)
  \left(\begin{array}{rrr}
2^{k} & 0 & 0 \\
0 & (-1)^{k} & 0 \\
0 & 0 & (-1)^{k}
\end{array}\right)
\left(
\frac{1}{3}
\left(\begin{array}{rrr}
1 & 1 & 1 \\
2 & -1 & -1 \\
-1 & 2 & -1
\end{array}\right)
\right)\\[8pt]
&=
\frac{1}{3}
\left(\begin{array}{rrr}
2^k + 2 \, (-1)^k & 2^k - (-1)^k & 2^k - (-1)^k \\
2^k - (-1)^k & 2^k + 2 \, (-1)^k & 2^k - (-1)^k \\
2^k - (-1)^k & 2^k - (-1)^k & 2^k + 2 \, (-1)^k
\end{array}\right)\\[8pt]
&=
\frac{1}{3}
\left(\begin{array}{ccc}
a & b & b \\
b & a & b \\
b & b & a
\end{array}\right)
\end{align*}
where for~$k=1,2,3,\ldots$,
\[
a = 
\begin{cases}
  2^{k}+2&\text{if~$k$ is even}\\ 
  2^{k}-2&\text{if~$k$ is odd}
\end{cases}
\quad\text{and}\quad
b = 
\begin{cases}
  2^{k}-1&\text{if~$k$ is even}\\ 
  2^{k}+1&\text{if~$k$ is odd}.
\end{cases}
\]

\textbf{Exercise.} Show that~$2^{k}\pm 2$ and~$2^{k}\pm 1$ are divisible by~$3$
for~$k=1,2,\ldots$
\end{document}
