\documentclass[11pt]{article}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{verbatim}
\usepackage{cancel}
\usepackage[pdftex]{graphicx}
\usepackage{url}
\usepackage[table]{xcolor}
\usepackage{multicol}
\usepackage[all,arc]{xy}
\usepackage{color, colortbl}
\usepackage{mathrsfs}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
\setlength{\textwidth}{6in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}



\input{preamble.tex}

\begin{document}

\lecture{4: Spectral Graph Theory}{Weeks 7-9}

We've studied a number of different intersections of graph theory and other fields throughout this quarter; we've seen how graphs interact with physics, Dirichlet boundary problems, flows, algorithms, and algebra!  In these notes, we will turn to studying the field of \textbf{spectral graph theory}: the study of how graph theory interacts with the field of linear algebra!

To do this, um, we need some more linear algebra.  That's what these notes start off with!

\section{Eigenvalues and Eigenvectors}

\subsection{Basic Definitions and Examples}
\begin{defn}
Let $A$ be a $n \times n$ matrix with entries from some field $F$.  (In practice, in examples we will assume that $F$ is the real numbers $\mathbb{R}$ unless otherwise stated.  It is worthwhile to occasionally think about this field being $\mathbb{C}$, when you're working on problems on your own.)  We say that $\vec{v} \in F^n$ is an \textbf{eigenvector} and $\lambda \in F$ is an \textbf{eigenvalue} if
\begin{align*}
A \vec{v} = \lambda \vec{v}.
\end{align*}
We ask that $\vec{v} \neq \vec{0}$, to avoid silly trivial cases.

Finally, given any eigenvalue $\lambda$, we define the \textbf{eigenspace} $E_\lambda$ associated to $\lambda$ as the set of all of the eigenvalues associated to $\lambda$: i.e. we define
\begin{align*}
E_\lambda = \{ \vec{v} \in V ~|~ A\vec{v} = \lambda \vec{v} \}.
\end{align*}
Notice that $E_\lambda$ is a vector space for any $\lambda$ (prove this if you don't see why!)

We say that an eigenvalue $\lambda$ \textbf{occurs with multiplicity} $k$ in an $n \times n$ matrix $A$ if $dim(E_\lambda) = k$.  The idea here is that there are ``$k$ dimensions'' of eigenvectors corresponding to $\lambda$, so we want to consider it as occurring ``$k$ times.'' (as if we had $k$ distinct eigenvectors they would also take up $k$ dimensions of space as well!)
\end{defn}

\begin{exmp}
Does the matrix 
\begin{align*}
A = \begin{bmatrix}
1 & 2 \\ 2 & 1\\
\end{bmatrix}
\end{align*}
have any real or complex-valued eigenvalues or eigenvectors?  If so, find them.
\end{exmp}
\begin{proof}
We find these eigenvalues and eigenvectors via brute force (i.e. just using the definition and solving the system of linear equations.)  To do this, notice that if $(x,y) \neq (0,0)$ is an eigenvector of $A$ and $\lambda$ is a corresponding eigenvalue to $(x,y)$, then we have
\begin{align*}
\begin{bmatrix}
1 & 2 \\ 2 & 1\\
\end{bmatrix} 
\cdot \begin{bmatrix} x \\ y \end{bmatrix} = \lambda\begin{bmatrix} x \\ y \end{bmatrix}.
\end{align*}
In other words, this is the pair of linear equations
\begin{align*}
x + 2y &= \lambda x, \\
2x + y &= \lambda y.\\
\end{align*}
We want to find what values of $\lambda, x, y$ are possible solutions to this equation.  To find these solutions, notice that if we add these two equations together, we get
\begin{align*}
3x + 3y = \lambda(x+y).
\end{align*}
If $x+y$ is nonzero, we can divide through by $x+y$ to get $\lambda = 3$, which is one potential value of $\lambda.$   For this value of $\lambda$, we have
\begin{align*}
x + 2y &= 3 x, \\
2x + y &= 3 y\\
\Rightarrow 2y &= 2x, \\
2x &= 2y. \\
\end{align*}
In other words, it seems like $3$ is an eigenvalue for any eigenvector of the form $(x,x)$.  This is easily verified: simply notice that
\begin{align*}
\begin{bmatrix}
1 & 2 \\ 2 & 1\\
\end{bmatrix} \cdot \begin{bmatrix} x \\ x \end{bmatrix} = \begin{bmatrix} 3x \\ 3x \end{bmatrix} = 3\begin{bmatrix} x \\ -x \end{bmatrix},
\end{align*}
which precisely means that $3$ is an eigenvalue corresponding to vectors of the form $(x,x)$.


Otherwise, if $x+y = 0$, we can use this observation in our earlier pair of linear equations to get
\begin{align*}
y &= \lambda x,\\
x &= \lambda y.\\
\end{align*}
If one of $x, y = 0$, then $x+y = 0$ forces the other to be zero, and puts us in the trivial case where $(x,y) = (0,0)$, which we're not interested in.  Otherwise, we have both $x, y \neq 0$, and therefore that $\lambda = \frac{x}{y} = \frac{y}{x}$.  In particular, this forces $x = \lambda y$ and $\lambda = \pm 1$.

If we return to the two equations
\begin{align*}
x + 2y &= \lambda x, \\
2x + y &= \lambda y,\\
\end{align*}
we can see that $\lambda = 1$ is not possible, as it would force $x + 2y = x$, i.e.\ $y = 0$.  Therefore we must have $\lambda = -1$, and therefore $x = -y$.    In other words, it seems like $-1$ is an eigenvalue with corresponding eigenvectors $(x, -x)$.  Again, this is easily verified: simply notice that
\begin{align*}
\begin{bmatrix}
1 & 2 \\ 2 & 1\\
\end{bmatrix} \cdot \begin{bmatrix} x \\ -x \end{bmatrix} = \begin{bmatrix} -x \\ x \end{bmatrix} = -1 \begin{bmatrix} x \\ -x \end{bmatrix} 
\end{align*}
which precisely means that $-1$ is an eigenvalue corresponding to vectors of the form $(x,-x)$.
\end{proof}

In this case, we had a $2 \times 2$ matrix with $2$ distinct eigenvalues, each one of which corresponded to a one-dimensional family of eigenvectors.  This was rather nice!  It bears noting that things are often not this nice, as the following example illustrates:
\begin{exmp}
\begin{align*}
A = \begin{bmatrix}
0 & -1 \\ 1 & 0\\
\end{bmatrix}
\end{align*}
have any real or complex-valued eigenvalues or eigenvectors?  If so, find them.
\end{exmp}
\begin{proof}
We proceed using the same brute-force method as before.  If there was an eigenvector $(x,y) \neq (0,0)$ and corresponding eigenvalue $\lambda$, we would have
\begin{align*}
\begin{bmatrix}
0 & -1 \\ 1 & 0\\
\end{bmatrix} 
\cdot \begin{bmatrix} x \\ y \end{bmatrix} = \lambda\begin{bmatrix} x \\ y \end{bmatrix}.
\end{align*}
In other words, we would have a solution to the system of equations
\begin{align*}
-y &= \lambda x\\
x &= \lambda y.
\end{align*}
If one of $x, y$ are equal to zero, then the two linear equations above force the other to be zero; this puts us in the trivial case where $(x,y) = (0,0)$, which we're not interested in. Otherwise, we can solve each of the linear equations above for $\lambda$, and get
\begin{align*}
-\frac{y}{x} &= \lambda \\
\frac{x}{y} &= \lambda .
\end{align*}
In other words, we have $-\frac{y}{x} = \frac{x}{y}$.  Because both $x$ and $y$ are nonzero, this equation is equivalent to (by multiplying both sides by $xy$) 
\begin{align*}
-y^2 = x^2.
\end{align*}
This equation has no real-valued solutions, because any nonzero real number squared is positive.  If we extend our results to complex-valued solutions, we can take square roots to get $i y = \pm x$. This gives us two possible values of $\lambda:$ either $i$ with corresponding eigenvectors $(x, -ix)$, or $-i$ with corresponding eigenvectors $(x, ix)$.  We check that these are indeed eigenvalues and eigenvectors here:
\begin{align*}
\begin{bmatrix}
0 & -1 \\ 1 & 0\\
\end{bmatrix} \cdot \begin{bmatrix} x \\ -ix \end{bmatrix} = \begin{bmatrix} ix \\ x \end{bmatrix} = i\begin{bmatrix} x \\ -ix \end{bmatrix},\\
\begin{bmatrix}
0 & -1 \\ 1 & 0\\
\end{bmatrix} \cdot \begin{bmatrix} x \\ ix \end{bmatrix} = \begin{bmatrix} -ix \\ x \end{bmatrix} = -i\begin{bmatrix} x \\ ix \end{bmatrix}.\\
\end{align*}
\end{proof}

This was an example of a $2 \times 2$ matrix that has no real eigenvalues or eigenvectors, but \textbf{did} have two distinct complex-valued eigenvalues, each with corresponding one-dimensional families of eigenvectors.  You might hope here that this is always true; i.e.\ that working in the complex plane is enough to always give you lots of eigenvectors and eigenvalues!

This is not true, as the following example indicates:
\begin{exmp}
Consider the $n \times n$ matrix 
\begin{align*}
A = \begin{bmatrix}
1 & 1 & 0 &0 & \ldots & 0 & 0\\
0 & 1 & 1 & 0 & \ldots & 0& 0\\
0 & 0 &1 & 1& \ldots & 0 & 0\\
\vdots & \vdots & \vdots & \vdots & \ddots & \vdots  & \vdots \\
0 & 0 & 0 & 0 & \ldots & 1 & 1 \\
0 & 0 & 0 & 0 & \ldots &  0& 1\
\end{bmatrix},
\end{align*}
formed by filling the main diagonal and the stripe directly above the main diagonal with 1's, and filling the rest with zeroes.  Does this matrix have any real or complex-valued eigenvalues or eigenvectors?  If so, find them.
\end{exmp}
\begin{proof}
We proceed as before.  Again, let $(x_1, \ldots x_n) \neq \vec{0}$ denote a hypothetical eigenvector and $\lambda$ a corresponding eigenvalue; then we have
\begin{align*}
A = \begin{bmatrix}
1 & 1 & 0 &0 & \ldots & 0 & 0\\
0 & 1 & 1 & 0 & \ldots & 0& 0\\
0 & 0 &1 & 1& \ldots & 0 & 0\\
\vdots & \vdots & \vdots & \vdots & \ddots & \vdots  & \vdots \\
0 & 0 & 0 & 0 & \ldots & 1 & 1 \\
0 & 0 & 0 & 0 & \ldots &  0& 1\
\end{bmatrix} \cdot \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ \ldots \\ x_{n-1} \\ x_n \end{bmatrix} = \lambda \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ \ldots \\ x_{n-1} \\ x_n \end{bmatrix} .
\end{align*}

This gives the following set of $n$ linear equations:
\begin{align*}
x_1 + x_2 &= \lambda x_1, \\
x_2 + x_3 &= \lambda x_2 ,\\
&\vdots\\
x_{n-1} + x_n &= \lambda x_{n-1},\\
x_n &= \lambda x_n.
\end{align*}
There are at most two possiblities:
\begin{enumerate}
\item $\lambda = 1$.  In this case, we can use our first equation $x_1 + x_2 = x_1$ to deduce that $x_2 = 0$, the second equation $x_2 + x_3 = x_2$ to deduce that $x_3 = 0$, and in general use the $k$-th linear equation $x_k + x_{k+1} = x_k$ to deduce that $x_{k+1} = 0$.  In other words, if $\lambda = 1$, all of the entries $x_2, \ldots x_n$ are all 0.  In this case, we have only the vectors $(x_1, 0, \ldots 0)$ remaining as possible candidates.  We claim that these are indeed eigenvectors for the eigenvalue 1: this is easily checked, as
\begin{align*}
A = \begin{bmatrix}
1 & 1 & 0 &0 & \ldots & 0 & 0\\
0 & 1 & 1 & 0 & \ldots & 0& 0\\
0 & 0 &1 & 1& \ldots & 0 & 0\\
\vdots & \vdots & \vdots & \vdots & \ddots & \vdots  & \vdots \\
0 & 0 & 0 & 0 & \ldots & 1 & 1 \\
0 & 0 & 0 & 0 & \ldots &  0& 1\
\end{bmatrix} \cdot \begin{bmatrix} x_1 \\ 0\\0\\ \ldots \\0 \\0\end{bmatrix} =  \begin{bmatrix} x_1 + 0 \\0 \\ 0\\ \ldots \\0 \\ 0\end{bmatrix}  = 1  \begin{bmatrix} x_1 \\ 0\\0\\ \ldots \\0 \\0\end{bmatrix} .
\end{align*}
\item We are trying to find any value of $\lambda \neq 1$.  If this is true, then our last equation $x_n = \lambda x_n$ can only hold if $x_n = 0$.  Plugging this observation into our second-to-last equation $x_{n-1} + 0 = \lambda x_{n-1}$ tellsus that $x_{n-1}$ is also zero.  In general, using induction (where our base case was proving that $x_n = 0$, and our inductive step is saying that if $x_{k} = 0$, we have $x_{k-1}$ also equal to zero) we get that every $x_k$ must be equal to zero.  But this is the trivial case where $(x_1, \ldots x_n) = \vec{0}$, which we're not interested in if we're looking for eigenvectors.  Therefore, there are no eigenvectors corresponding to non-1 eigenvalues.
\end{enumerate}
\end{proof}
So; in this case, we found a $n \times n$ matrix with only \textbf{one} eigenvalue, corresponding only to a one-dimensional space of eigenvectors!  In other words, sometimes there are very very few eigenvectors or eigenvalues to be found.



So: eigenvalues and eigenvectors!  We have an ad-hoc method for finding them (lots of linear equations) and have seen through examples that there are sometimes very few of them for a given matrix.  We have not yet talked about \textbf{why} we care about them, though --- why look for these things?

The short answer is that \textbf{they're useful}.  Honestly?  They're probably the most useful thing in linear algebra, and arguably in mathematics as a whole.  Understanding eigenvalues and eigenvectors is fundamental to thousands of problems, ranging from the most practical of applications in physics and economics to the airiest of theoretical constructions in higher mathematics.  To give a bit of an idea for what these applications look like, we do two examples here:
\subsection{Why We Care: The Internet}


Perhaps one of the most commonly used applications of eigenvalues and eigenvectors is Google's PageRank algorithm.  Basically, before Google came along, web search engines were \textbf{atrocious}; many search results were not very-sophisticated massive keyword-bashes plus some well-meaning but dumb attempts to improve these results by hand.  Then Brin and Page came onto the scene, with the following simple idea:
\begin{center}
\textit{Important websites are the websites other important websites link to}.
\end{center}

This seems kinda circular, so let's try framing this in more of a graph-theoretic framework: Take the internet.  Think of it as a collection of webpages, which we'll think of as ``vertices,'' along with a collection of hyperlinks, which we'll think of as directed lines\footnote{A  ``series of tubes,'' if you will.} going between webpages.  Call these webpages $\{v_1,\ldots v_n\}$ for shorthand, and denote the collection of webpages linking to some $v_i$ as the set $\textrm{LinksTo}(v_i)$.

In this sense, if we have some quantity of ``importance'' $rank(v_i)$ that we're associating to each webpage $i$, we still want it to obey the entire ``important websites are the websites other important websites link to'' idea.  However, we can refine what we mean by this a little bit.  For example, suppose that we know a website is linked to by Google.  On one hand, this might seem important --- Google is an important website, after all! --- but on the other hand, this isn't actually that relevant, because Google basically links to \textbf{everything.} So we don't want to simply say something is important if it's linked to by something important --- we want to \textbf{weight} that importance by how many \textbf{other} things that important website links to!  In other words, if you're somehow important and also only link to a few things, we want to take those links very seriously --- i.e. if something is linked to by the front page of the New York Times or the Guardian, that's probably pretty important!

If we write this down with symbols and formulae, we get the following equation:
\begin{align*}
\textrm{rank}(v_i) = \sum_{v_j \in \textrm{LinksTo}(v_i)} \frac{\textrm{rank}(v_j)}{\textrm{number of links leaving}(v_j)}.
\end{align*}
In other words, to find your rank, we add up all of the ranks of the webpages that link to you, scaling each of those links by the number of other links leaving those webpages.
This is \ldots still circular.  But it looks mathier!  Also, it's more promising from a linear-algebra point of view.  Suppose that we don't think of each ranking individually, but rather take them all together as some large rank vector $\vec{r} = (\textrm{rank}(v_1) , \ldots\textrm{rank}(v_n) )$.  

As well, instead of thinking of the links one-by-one, consider the following $n \times n$ ``link-matrix'' $A$, formed by doing the following:
\begin{itemize}
\item If there is a link to $v_i$ from $v_j$, put a $\frac{1}{\textrm{number of links leaving}(v_j)}$ in the entry $(i,j)$.
\item Otherwise, put a 0.
\end{itemize}
This contains all of the information about the internet's links, in one handy $n \times n$ matrix!

Now, notice that if we multiply this matrix $A$ by our rank vector $\vec{r}$, we get
\begin{align*}
A \cdot \vec{r} = \begin{bmatrix}   \sum_{v_j \in \textrm{LinksTo}(v_1)} \frac{\textrm{rank}(v_j)}{\textrm{number of links leaving}(v_j)} \\ 
\sum_{v_j \in \textrm{LinksTo}(v_2)} \frac{\textrm{rank}(v_j)}{\textrm{number of links leaving}(v_j)} \\
\vdots \\
\sum_{v_j \in \textrm{LinksTo}(v_n)} \frac{\textrm{rank}(v_j)}{\textrm{number of links leaving}(v_j)} \\\end{bmatrix}.
\end{align*}
In other words, if we the ``mathy'' version of the importance rule we derived earlier, we have
\begin{align*}
A \cdot \vec{r} = \vec{r}.
\end{align*}
In other words, the vector $\vec{r}$ that we're looking for is an \textbf{eigenvector} for $A$, corresponding to the eigenvalue 1! The entries in this eigenvector then correspond to the ``importance'' ranks we were looking for.  In particular, the coordinate in the vector $\vec{r}$ with the highest value corresponds to the ``most important'' website, and should be the first page suggested by the search engine.

Up to tweaks and small modifications, this is precisely how search works nowadays; people come up with quick and efficient ways to find eigenvectors for subgraphs of the internet that correspond to the eigenvalue 1.  (Actually finding this eigenvector in an efficient manner is a problem people are still working on!)

\subsection{Fibonacci Numbers}

It bears noting that eigenvalues aren't only useful for applications: they have lots of theoretical and mathy uses as well!  Consider the Fibonacci sequence, defined below:

\begin{defn}
The \textbf{Fibonacci sequence} $\{f_n\}_{n=1}^\infty$ is the sequence of numbers defined recursively as follows:
\begin{itemize}
\item $f_0 = 0,$
\item $f_1 = 1$,
\item $f_{n+1} = f_{n} + f_{n-1}$.
\end{itemize}
The first sixteen Fibonacci numbers are listed here:
\begin{align*}
0,	1,	1	,2	,3	,5	,8	,13	,21	,34,	55	,89,	144	,233	,377,	610\ldots
\end{align*}
\end{defn}
Here's a question you might want to ask, at some point in time: what's $f_{1001}$?  On one hand, you could certainly calculate this directly, by just finding all of the numbers in the sequence from 1 up to 1001.  But what if you needed to calculate this \textbf{quickly}?  Could you find a \textbf{closed form}?

The answer is yes, and the solution comes through using eigenvectors and eigenvalues!

Specifically, notice the following:
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix} \cdot \begin{bmatrix} f_n \\ f_{n-1} \end{bmatrix} = \begin{bmatrix} f_n + f_{n-1} \\ f_n \end{bmatrix}  = \begin{bmatrix} f_{n+1} \\ f_n \end{bmatrix}.
\end{align*}
In other words, if we take a vector formed by two consecutive Fibonacci sequence elements, and multiply it by the matrix $\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix} $, we shift this sequence one step forward along the Fibonacci sequence!

Therefore, if we want to find $f_{1001}$, we can just calculate

\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k} \cdot \begin{bmatrix} f_1 \\ f_0 \end{bmatrix} = \begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{999} \cdot \begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix} \cdot \begin{bmatrix} f_1 \\ f_0 \end{bmatrix} =&  \begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{999} \cdot\begin{bmatrix} f_2 \\ f_1 \end{bmatrix} \\
=&  \begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{998} \cdot\begin{bmatrix} f_3 \\ f_2 \end{bmatrix} \\
\vdots & \\
=&  \begin{bmatrix} f_{1001} \\ f_{k} \end{bmatrix} .\\
\end{align*}
So: we just need to find $\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k}$!  This is not an obviously easy task: multiplying the matrix by itself a thousand times seems about as difficult as adding the Fibonacci numbers to themselves that many times.  However, with the help of eigenvalues, eigenvectors, and the concept of \textbf{orthogonality}, this actually can be made rather trivial!

First, let's find the eigenvalues and eigenvectors for this matrix.  As before, we just use brute force: we seek $(x,y) \neq (0,0)$ and $\lambda$ such that

\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix} \cdot \begin{bmatrix} x \\ y\end{bmatrix} =  \lambda\begin{bmatrix} x \\ y\end{bmatrix}.
\end{align*} 
In terms of linear equations, this is just asking for $x, y, \lambda$ such that
\begin{align*}
x + y &= \lambda x\\
x &= \lambda y.\\
\end{align*}
First, notice that if either x or y are zero, then the other is zero by the second equation, which puts us in the trivial case $(x,y) = (0,0)$, which we don't care about.

Now, note that if we substitute the second equation into the first, we get
\begin{align*}
\lambda^2 y - \lambda y - y = 0.
\end{align*}
If we divide through by $y$ (which we can do, because it is nonzero,) we get
\begin{align*}
\lambda^2 - \lambda  - 1 = 0.
\end{align*}
We can use the quadratic formula to see that this has the roots
\begin{align*}
\frac{1 \pm \sqrt{5}}{2}.
\end{align*}
These are very famous values!  In particular, the quantity
\begin{align*}
\frac{1 + \sqrt{5}}{2}
\end{align*}
is something that people have been studying for millenia --- it's the famous \href{http://en.wikipedia.org/wiki/Golden_ratio}{golden ratio}, denoted by the symbol $\varphi$.  It has tons of weird and useful properties, but the main one I want us to note here is that
\begin{align*}
\frac{1 - \sqrt{5}}{2} = \frac{(1 - \sqrt{5})(1+ \sqrt{5})}{2(1+\sqrt{5})} = \frac{1-5}{2(1+\sqrt{5})} = -\frac{2}{1+\sqrt{5}} = -\frac{1}{\varphi}.
\end{align*}
In other words, the two possible values of $\lambda$ are $\varphi, -\frac{1}{\varphi}$.

For each of these, we can solve for $x,y$: if we have $\lambda = \varphi$, then the pair of equations
\begin{align*}
x + y &= \varphi x\\
x &= \varphi y\\
\end{align*}
has solutions given by $(\varphi y, y)$.  Similarly, if we have $\lambda = -\frac{1}{\varphi}$, then the pair of equations
\begin{align*}
x + y &= -\frac{1}{\varphi} x\\
x &= -\frac{1}{\varphi} y\\
\end{align*}
has solutions given by $(-\frac{y}{\varphi} , y)$.

So: we have the eigenvectors and eigenvalues!  Now, notice the following very clever trick we can do with these eigenvalues and eigenvectors.  First, notice that we have
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} = \begin{bmatrix} \varphi^2 x & \frac{y}{\varphi^2}\\ \varphi x & -\frac{y}{\varphi}\\ \end{bmatrix}.
\end{align*}
This is not hard to see: if you think of the $\begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} $ matrix as just two columns, each of which are eigenvectors, then the right-hand-side is just a result of that eigenvector property.

Now: notice that the right-hand-side can be written
\begin{align*} \begin{bmatrix} \varphi^2 x & \frac{y}{\varphi^2}\\ \varphi x & -\frac{y}{\varphi}\\ \end{bmatrix} = \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi  & 0\\0  &  -\frac{1}{\varphi}\\ \end{bmatrix}  .
\end{align*}
As a result of this, we have
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} = \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi  & 0\\0  &  -\frac{1}{\varphi}\\ \end{bmatrix} ,
\end{align*}
which implies
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}  = \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi  & 0\\0  &  -\frac{1}{\varphi}\\ \end{bmatrix}  \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1} 
\end{align*}
And this is \textbf{fantastic!}  Why?  Well, notice that if we're calculating something like $\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k}$, we have
\scriptsize
\begin{align*}
\overbrace{\begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi  & 0\\0  &  -\frac{1}{\varphi}\\ \end{bmatrix} \cdot \cancel{\begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1} }\cdot\cancel{\begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}}\cdot \begin{bmatrix} \varphi  & 0\\0  &  -\frac{1}{\varphi}\\ \end{bmatrix} \cdot \cancel{\begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1} }\cdot \ldots \cdot \cancel{\begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}} \cdot \begin{bmatrix} \varphi  & 0\\0  &  -\frac{1}{\varphi}\\ \end{bmatrix}  \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1}}^{\textrm{k \textrm{ copies}}}.\\
= \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}\cdot \begin{bmatrix} \varphi  & 0\\0  &  -\frac{1}{\varphi}\\ \end{bmatrix}^{k} \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1}  .\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad
\end{align*}
\normalsize
And this is easy to calculate --- if we take a diagonal matrix and raise it to a large power, we just get the matrix formed by raising those diagonal entries to that power\footnote{This property emphatically does \textbf{not} hold for normal matrices.  I.e.\ \textbf{NEVER} ever write something like $\begin{bmatrix} a & b\\ c & d\\ \end{bmatrix}^3 =  \begin{bmatrix} a^3 & b^3\\ c^3 & d^3\\ \end{bmatrix}$ on a test or quiz, because it is made of lies and will result in you getting no points and a lot of red ink.}!  In other words, we get
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k} =  \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}\cdot \begin{bmatrix} \varphi^{k}  & 0\\0  &  (-\frac{1}{\varphi})^{k}\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1}  .
\end{align*}

Great!  If we can just find $ \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1} $, then this is a very easy calculation: we just have to multiply \textbf{three} matrices, instead of a thousand.  Much less work!

To find this inverse matrix, notice the following special property about these eigenvectors: if we take one eigenvector for $\varphi$ and another for $-\frac{1}{\varphi}$, those two vectors are \textbf{orthogonal}!  Specifically, recall the following definitions:

\begin{defn}
Take two vectors $(x_1, \ldots x_n), (y_1, \ldots y_n) \in \mathbb{R}^n$.  Their \textbf{dot product} is simply the sum
\begin{align*}
x_1y_1 + x_2y_2 + \ldots x_ny_n.
\end{align*}

Alternately, you can prove that the quantity above is also equal to the product
\begin{align*}
||\vec{x}|| \cdot ||\vec{y}|| \cos(\theta),
\end{align*}
where $\theta$ is the angle between $\vec{x}$ and $\vec{y}$.  
\end{defn}
\begin{defn}
Given two vectors $\vec{v}, \vec{w} \in \mathbb{R}^n$, we say that these two vectors are \textbf{orthogonal} if their dot product $\vec{v} \cdot \vec{w} = 0$.  Note that geometrically, if both of these vectors have nonzero length, this can only happen if the cosine of the angle between these two vectors is zero: i.e.\ if these two vectors meet at a right angle!
\end{defn}

With these definitions restated, it is not hard to check that an eigenvector $(\varphi x, x)$ for $\varphi$ and an eigenvector $(-\frac{y}{\varphi} , y)$ for $-\frac{1}{\varphi}$ are orthogonal: we just calculate
\begin{align*}
(\varphi x, x) \cdot (-\frac{y}{\varphi} , y) = -xy + xy = 0.
\end{align*}
Why do we care?  Well: notice that if we look at the product
\begin{align*}
\begin{bmatrix} \varphi x & x\\-\frac{y}{\varphi}  & y\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} = \begin{bmatrix} (\varphi x, x) \cdot (\varphi x, x) & (\varphi x, x) \cdot (-\frac{y}{\varphi} , y)\\(-\frac{y}{\varphi} , y) \cdot (\varphi x, x) & (-\frac{y}{\varphi} , y) \cdot (-\frac{y}{\varphi} , y) \end{bmatrix},
\end{align*}
we get that the upper-right and bottom-left entries are 0, because those vectors are orthogonal!  Therefore, we have that this product is 
\begin{align*}
\begin{bmatrix} \varphi x & x\\-\frac{y}{\varphi}  & y\\ \end{bmatrix} \cdot \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix} = \begin{bmatrix} \varphi^2 x^2 + x^2& 0\\0 & \frac{y^2}{\varphi^2} + y^2\end{bmatrix}.
\end{align*}
So, in particular, if we wanted to make this product the identity matrix, we could just pick $x, y$ such that 
\begin{align*}
x^2(1+\varphi^2) &= 1 \quad \Leftarrow \quad x = \frac{1}{\sqrt{1+\varphi^2}}\\
y^2(1+\frac{1}{\varphi^2}) &= 1 \quad \Leftarrow \quad y = \frac{1}{\sqrt{1+\frac{1}{\varphi^2}}} = \frac{\varphi}{\sqrt{1+\varphi^2}}.\\
\end{align*}

In other words: we have just calculated $ \begin{bmatrix} \varphi x & -\frac{y}{\varphi}\\x  & y\\ \end{bmatrix}^{-1} $ for free! In the case where we set $x, y$ as above, it's just the transpose of this matrix: i.e. $\begin{bmatrix} \varphi x & x\\-\frac{y}{\varphi}  & y\\ \end{bmatrix} $!

So: we've just proven the following formula:
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k} &=  \begin{bmatrix}  \frac{\varphi}{\sqrt{1+\varphi^2}} &-\frac{1}{\sqrt{1+\varphi^2}}\\\frac{1}{\sqrt{1+\varphi^2}}  & \frac{\varphi}{\sqrt{1+\varphi^2}} \\ \end{bmatrix} \cdot \begin{bmatrix} \varphi^{k}  & 0\\0  &  (-\frac{1}{\varphi})^{k}\\ \end{bmatrix} \cdot \begin{bmatrix}\frac{\varphi}{\sqrt{1+\varphi^2}}  & \frac{1}{\sqrt{1+\varphi^2}} \\-\frac{1}{\sqrt{1+\varphi^2}}   & \frac{\varphi}{\sqrt{1+\varphi^2}} \\ \end{bmatrix} \\
&=  \begin{bmatrix}  \frac{\varphi}{\sqrt{1+\varphi^2}} &-\frac{1}{\sqrt{1+\varphi^2}}\\\frac{1}{\sqrt{1+\varphi^2}}  & \frac{\varphi}{\sqrt{1+\varphi^2}} \\ \end{bmatrix}  \cdot \begin{bmatrix}\frac{\varphi^{k+1}}{\sqrt{1+\varphi^2}}  & \frac{\varphi^{k}}{\sqrt{1+\varphi^2}} \\-\frac{(-\frac{1}{\varphi})^{k}}{\sqrt{1+\varphi^2}}   & \frac{\varphi(-\frac{1}{\varphi})^{k}}{\sqrt{1+\varphi^2}} \\ \end{bmatrix} \\
&=  \begin{bmatrix}  \frac{\varphi^{k+2} + (-\frac{1}{\varphi})^{k}}{1 + \varphi^2} &\frac{\varphi^{k+1} - \varphi (-\frac{1}{\varphi})^{k}}{1 + \varphi^2}\\\frac{\varphi^{k+1} - \varphi (-\frac{1}{\varphi})^{k}}{1 + \varphi^2}  & \frac{\varphi^k + \varphi^2(-\frac{1}{\varphi})^{k}}{1 + \varphi^2} \\ \end{bmatrix}.
\end{align*}
If we multiply the numerator and denominator in each fraction by $\frac{1}{\varphi}$, we get
\begin{align*}
  \begin{bmatrix}  \frac{\varphi^{k+1} - (-\frac{1}{\varphi})^{k+1}}{\frac{1}{\varphi} + \varphi} &\frac{\varphi^{k} - (-\frac{1}{\varphi})^{k}}{\frac{1}{\varphi} + \varphi}\\\frac{\varphi^{k} -  (-\frac{1}{\varphi})^{k}}{\frac{1}{\varphi} + \varphi}  & \frac{\varphi^{k-1} -(-\frac{1}{\varphi})^{k-1}}{\frac{1}{\varphi} + \varphi} \\ \end{bmatrix}.
\end{align*}
We do this  because 
\begin{align*}
\varphi + \frac{1}{\varphi} = \frac{1 + \sqrt{5}}{2} + \frac{2}{1+ \sqrt{5}} = \frac{1 + \sqrt{5}}{2} - \frac{1 - \sqrt{5}}{2} = \sqrt{5},
\end{align*}
which allows us to simplify the above into
\begin{align*}
\frac{1}{\sqrt{5}} \begin{bmatrix}  \varphi^{k+1} - (-\frac{1}{\varphi})^{k+1} &\varphi^{k} - (-\frac{1}{\varphi})^{k} \\ \varphi^{k} - (-\frac{1}{\varphi})^{k} & \varphi^{k-1} - (-\frac{1}{\varphi})^{k-1} \end{bmatrix}.
\end{align*}

Whew! Ok.  In the end, we've finally proven the following theorem:
\begin{thm}
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k} = \frac{1}{\sqrt{5}} \begin{bmatrix}  \varphi^{k+1} - (-\frac{1}{\varphi})^{k+1} &\varphi^{k} - (-\frac{1}{\varphi})^{k} \\ \varphi^{k} - (-\frac{1}{\varphi})^{k} & \varphi^{k-1} - (-\frac{1}{\varphi})^{k-1} \end{bmatrix}.
\end{align*}

As a particular consequence, we have 
\begin{align*}
\begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k} \cdot \begin{bmatrix} f_1 \\ f_0 \end{bmatrix} &= \begin{bmatrix} 1 & 1\\ 1 & 0\\ \end{bmatrix}^{k} \cdot \begin{bmatrix} 1 \\ 0 \end{bmatrix}\\
&=  \frac{1}{\sqrt{5}} \begin{bmatrix}  \varphi^{k+1} - (-\frac{1}{\varphi})^{k+1}  \\ \varphi^{k} - (-\frac{1}{\varphi})^{k} \end{bmatrix}.
\end{align*}
In other words, we have
\begin{align*}
f_{k+1} = \frac{\varphi^{k+1} - (-\frac{1}{\varphi})^{k+1} }{\sqrt{5}}.
\end{align*}

\end{thm}
This is exactly what we wanted!  A way to calculate the Fibonacci numbers quickly, without having to calculate everything else on the way.  Success!

\section{Eigenvalues and Graphs}

So: how can we use eigenvalues to study graphs?  Moreover, \textbf{why} would we want to use eigenvalues to study graphs?  In past classes, for example, we already came up with completely reasonable ways to study graphs with linear algebra:



\begin{definition}
Given a graph $G$ with vertex set $\{1, \ldots n\}$, we define its \textbf{adjacency matrix} $A_G$ as the following $n \times n$ matrix:
\begin{align*}
A(i,j) = \left\{ \begin{array}{cc} 1, & \{i,j\} \in E(G),\\ 0, & \textrm{ otherwise}. \end{array}\right..
\end{align*}
\end{definition}

For reference, we calculate a few easy-to-find adjacency matrices:
\begin{exmp}
\begin{enumerate}
\item The graph $K_n$ has adjacency matrix with 0's on the diagonal and 1's everywhere else:
\begin{align*}
\left[ \begin{array}{ccccc}
0 & 1 & 1 & \ldots & 1 \\
1 & 0 & 1 & \ldots & 1 \\
1 & 1 & 0 & \ldots & 1 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
1 & 1 & 1 & \ldots & 0 \\
\end{array} \right]
\end{align*}
\item The empty graph $\overline{K_n}$'s adjacency matrix is identically 0:
\begin{align*}
\left[ \begin{array}{cccc}
0 & 0 & \ldots & 0 \\
0 & 0 & \ldots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \ldots & 0 \\
\end{array} \right]
\end{align*}
\item Enumerate the vertices of the cycle graph $C_n$ as $\{1, 2, \ldots n\}$ and its edges as $\{\{i,i+1\}: 1 \leq i \leq n\}$.  Then, its adjacency matrix has ones as depicted below:
\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 1 \\
1 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 1 & 0 & 1 & \ldots & 0 \\
0 & 0 & 1 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 1 & 0 \\
\end{array} \right]
\end{align*}
\end{enumerate}
\end{exmp}



So: we have these graphs, and we've turned them into matrices.  How can we use these matrices to get back information about these graphs?

One quick application that we studied in the past is \textbf{counting walks on a graph}!   We review this application here, in case you forgot / want something to use as a warmup!
\subsection{Applications of the Adjacency Matrix: Counting Paths / Walks}

Suppose we have a graph $G$ on $n$ vertices, and two nodes $i,j \in V(G).$  How do we count all of the walks\footnote{A \textbf{walk} of length $n$ from vertex $i$ to vertex $j$ is a sequence $P = (i, \{i,x_1\}, x_1, \{x_1,x_2\}, \ldots \{x_n,j\},j)$.} of length $k$ from $i$ to $j$?

Well: let's limit ourselves to just walks of length 1.  Then, there is just one walk of length 1 if there is an edge connecting $i$ and $j$, and no walks otherwise.  What about walks of length 2?  Well: any walk of length two will have to connect $i$ to some vertex $v$, and then connect $v$ to $j$: i.e. it's the sum
\begin{align*}
\sum_{v=1}^n  \textrm{isEdge}(i,v) \cdot \textrm{isEdge}(v,j).\\
\end{align*}

But wait!  We've defined these ``isEdge'' functions earlier -- specifically, we defined the adjacency matrix $A_G$ of $G$ in such a way that $a_{ij} = 1$ whenever there is an edge from $i$ to $j$, and 0 otherwise.  So, in this notation, we have that the number of walks from $i$ to $j$ is just 
\begin{align*}
\sum_{v=1}^n  a_{iv} \cdot a_{vk},
\end{align*}
which we can recognize as the dot product 
\begin{align*}
\left[\begin{array}{cccc} a_{i1} & a_{i2} & \ldots & a_{in} \end{array} \right] \cdot \left[\begin{array}{c} a_{1j} \\ a_{2j} \\ \ldots \\ a_{nj}\\ \end{array} \right].
\end{align*}

But this is just the dot product of the $i$-th row and the $j$-th row of $A_G$!  So, we've just proven the following:
\begin{proposition}
Suppose $G$ is a graph with vertex set $\{1,\ldots n\}$ with adjacency matrix $A$.  Then the $(i,j)$-th entry of $A^2$ denotes the number of walks of length $2$ from $i$ to $j$.
\end{proposition}

We can easily generalize this to walks of length $k$:

\begin{theorem}
Suppose $G$ is a graph with vertex set $\{1,\ldots n\}$ with adjacency matrix $A$.  Then the $(i,j)$-th entry of $A^k$ denotes the number of distinct walks of length $k$ from $i$ to $j$.
\end{theorem}
\begin{proof}
As discussed above, this is trivially obvious for $k=1$.

We proceed by induction on $k$.  Suppose that we know that the entries of $A^k$ correspond to the number of walks of length $k$ from $i$ to $j$.  Given $i$ and $j$, how can we find all of the walks of length $k+1$ from $i$ and $j$?  Well: any walk of length $k+1$ from $i$ to $j$ can be described as a walk from $i$ to some vertex $v$ of length $k$, and then a walk of length 1 from $v$ to $j$ itself!  So, if we just simply use the summation trick we used before, we can see that
\begin{align*}
\textrm{numberOfWalks}_{k+1}(i,j) &= \sum_{v=1}^n  \textrm{numberOfWalks}_{k}(i,v) \cdot \textrm{isEdge}(v,j)\\
&= (i,j)-\textrm{th entry of }A_G^k \cdot A_G\\
&= (i,j)-\textrm{th entry of }A_G^{k+1}.\\
\end{align*}
\end{proof}

As a quick corollary, we have the following:
\begin{corollary}
Suppose $G$ is a graph with vertex set $\{1,\ldots n\}$ with adjacency matrix $A$.  The number of distinct triangles\footnote{A \textbf{triangle} in $G$ is a triple $(v_1, v_2, v_3)$ where all of the edges $\{v_1, v_2\}, \{v_2, v_3\}, \{v_3, v_1\}$ are contained within $G$.} $(v_1, v_2, v_3)$ contained within $G$ is $tr(A^3)/6$.
\end{corollary}
\begin{proof}
A triangle with a fixed starting point and order in which to visit its vertices is precisely a closed walk of length 3.  There are three possible starting points $(v_1, v_2, v_3)$ and two possible orientations (clockwise, counterclockwise) in which to traverse any such closed walk; therefore, the number of triangles is just $1/6$-th of the number of closed walks on a graph of length 3.

But the number of closed walks on a graph of length 3 is just the sum over all $v \in V(G)$ of the closed length-3 walks starting at $v$: i.e. the sum of the diagonal entries in $A^3$, which is (by definition) $tr(A^3)$.
\end{proof}


\subsection{Adjacency Matrices and Isomorphism}

To really work with graphs, though, we need to consider them ``up to isomorphism'' -- i.e. we want to think of the Petersen graph as just anything with the same vertex-edge relations as the Petersen graph, and not care so much about the labeling of its vertices.  However, adjacency matrices care \textbf{very much} about the labeling of our vertices: i.e. for the two graphs below,
\begin{center}
\includegraphics[width=3.5in]{mc2011_spectral_GT_isospec.pdf}
\end{center}
despite the fact that they're both ``pentagons,'' their adjacency matrices are quite different:
\begin{align*}
A_{G_1} = \left[ \begin{array}{ccccc}
0 & 1 & 0 & 0 & 1\\
1 & 0 & 1 & 0 & 0\\
0 & 1 & 0 & 1 & 0\\
0 & 0 & 1 & 0 & 1\\
1 & 0 & 0 & 1 & 0\\
\end{array} \right], \qquad \qquad A_{G_2} = \left[ \begin{array}{ccccc}
0 & 1 & 1 & 0 & 0\\
1 & 0 & 0 & 1 & 0\\
1 & 0 & 0 & 0 & 1\\
0 & 1 & 0 & 0 & 1\\
0 & 0 & 1 & 1 & 0\\
\end{array} \right]
\end{align*}

This is \ldots troublesome.  If we're going to use linear algebra to study our graphs, getting different results whenever we label our graph differently is going to give us no end of trouble.  So: can we say anything about the relation between these matrices at all?  

Thankfully, there is!  To say precisely what it is, we need the following definition:

\begin{definition}
A $n \times n$ matrix $P$ whose entries are all either 0 or 1 is called a \textbf{permutation matrix} if $P$ has exactly one 1 in each of its rows and columns.  For example, the following matrix is a permutation matrix:
\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 \\
\end{array} \right]
\end{align*}
The reason we call this a permutation matrix is because multiplying a vector $\mathbf{v}$ on the left by $P$ ``permutes'' $\textbf{v}$' entries!  For example 
\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 \\
\end{array} \right] \cdot 
\left[ \begin{array}{c}
v_1 \\
v_2 \\
v_3 \\
v_4 \\
v_5 \\
v_6 \\
\end{array} \right] = \left[ \begin{array}{c}
v_2 \\
v_6 \\
v_1 \\
v_5 \\
v_4 \\
v_3 \\
\end{array} \right] 
\end{align*} 

Given a permutation $\sigma: \{1, \ldots n\} \to \{1, \ldots n\}$, we will sometimes write $P_\sigma$ to denote the permutation matrix such that $P(v_1, \ldots v_n) = (v_{\sigma(1)}, \ldots v_{\sigma(n)})$.  It bears noting that every permutation matrix $P$ can be expressed as $P_\sigma$ for some permutation $\sigma$, by just tracking where it sends a generic vector $(v_1, \ldots v_n)$.
\end{definition}

We first note the following properties of permutation matrices:
\begin{proposition}
If $P$ is a $n \times n$ permutation matrix with associated permutation $\sigma$, then $(v_1, \ldots v_n) \cdot P = (v_{\sigma^{-1}(1)}, \ldots v_{\sigma^{-1}(n)})$.
\end{proposition}
\begin{proof}
On the HW!
\end{proof}

\begin{proposition}
If $P$ is a $n \times n$ permutation matrix with associated permutation $\sigma$, then $P^{-1}$ is also a permutation matrix with associated permutation $\sigma^{-1}$ (and furthermore is equal to $P^T$.)
\end{proposition}
\begin{proof}
On the HW!
\end{proof}

Given this, we can prove the following remarkably useful fact about adjacency matrices of isomorphic graphs:


\begin{proposition}
If $G_1$ and $G_2$ are a pair of isomorphic graphs with adjacency matrices $A_1, A_2$, then $A_1$ and $A_2$ are conjugate via a permutation matrix $P$: i.e. 
\begin{align*}
A_2 = PA_1P^{-1}.
\end{align*}
\end{proposition}
\begin{proof}
Suppose that $G_1$ and $G_2$ are isomorphic graphs, both with vertex set $\{1, \ldots n\}$.  Then there is some permutation $\sigma$ of $\{1, \ldots n\}$ that realizes this isomorphism (i.e. such that $(i,j)$ is an edge in $A_1$ iff $(\sigma(i), \sigma(j))$ is an edge in $A_2$.)  

Let $P$ be the associated permutation to this map $\sigma$; then, we have that 
\begin{itemize}
\item $PA_1$ is the matrix where we've taken each column of $A_1$ and permuted its entries according to $\sigma:$ in other words, $PA_1$ is $A_1$ if we permute its rows by $\sigma.$
\item Similarly, $A_1P^{-1}$ is the matrix where we permute $A_1$'s columns by $(\sigma^{-1})^{-1} = \sigma$, by our earlier two lemmas.
\item By combining these two results, $PA_1P^{-1}$ is the matrix where we permute $A_1$'s rows by $\sigma$, and then permute the resulting matrices' columns by $\sigma$ again! 
\end{itemize}
What does this mean?  Well: we've started by taking any point $(i,j)$ in $A_1$, and have sent it to $(\sigma(i), \sigma(j))$.  But this means that we've sent the indicator function for the edge $(i,j)$ to the location $(\sigma(i), \sigma(j))$!  In other words, we've sent $A_1$ to $A_2$: i.e. we've proven $A_2 = PA_1P^{-1}$, as claimed.
\end{proof}

One remarkable consequence of this is the following corollary:
\begin{corollary}
If $G_1$ and $G_2$ are isomorphic graphs, their adjacency matrices $A_1$ and $A_2$ have the same set of eigenvalues (counting multiplicity.)
\end{corollary}
\begin{proof}
As proven above, if $G_1$ and $G_2$ are a pair of isomorphic graphs with adjacency matrices $A_1, A_2$, then $A_1$ and $A_2$ are conjugate via a permutation matrix $P$: i.e. 
\begin{align*}
A_2 = PA_1P^{-1}.
\end{align*}

So: take any eigenvector $\vec{v}$ of $A_1$, with eigenvalue $\lambda$.  Notice that 
\begin{align*}
A_2 (P\vec{v}) = PA_1P^{-1} (P\vec{v}) = P A_1 \vec{v} = P \lambda \vec{v} = \lambda (P\vec{v});
\end{align*}
in other words, $P \vec{v}$ is an eigenvector for $A_2$ with the same eigenvalue!  So we've proven that any eigenvalue of $A_1$ must be an eigenvalue of $A_2$.  

The same logic can be reversed; if we multiply $A_2$ on the left and right by $P^{-1}, P$ respectively, we get
\begin{align*}
P^{-1}A_2 P = A_1.
\end{align*}

Using the same logic as before, we can show that if $\vec{v}$ is an eigenvector for $A_2$ with eigenvalue $\lambda$, then
\begin{align*}
 A_1 = (P^{-1}\vec{v}) = P^{-1}A_2 P (P^{-1}\vec{v}) = P^{-1} A_2 \vec{v} = P^{-1}\lambda \vec{v} = \lambda(P^{-1}\vec{v}),
\end{align*}
and therefore that $P^{-1}\vec{v}$ is an eigenvector for $A_1$ with eigenvalue $\lambda$.  So, in particular, any eigenvalue of $A_2$ must be an eigenvalue of $A_1$; this completes our proof!

\end{proof}

This motivates us to make the following definition:

\begin{definition}
The \textbf{spectrum} of a graph $G$ is the set of all of $A_G$'s eigenvalues, counted with multiplicity.  For example, we say that the empty graph on 3 vertices, $\overline{K_3}$, has spectrum $\{0,0,0\}$, where by $0^3$ we mean that it has the eigenvalue 0 repeated three times.  We will sometimes denote this as $\{0^3\}$, for shorthand; it's somewhat confusing notation, but also standard/something you'll see in the literature.
\end{definition}

Great!  We have eigenvalues, and moreover have demonstrated that eigenvalues of any two graphs are isomorphic; i.e. the spectrum of a graph is an invariant under isomorphism, and is therefore something that might be useful!   However, we currently, um, don't have any tools for calculating eigenvalues.

Let's fix that.
\section{The Determinant}

There are many ways to define the determinant of a matrix.  We list several here!

\subsection{Definitions of the Determinant: Permutations}

First, recall the following definitions and theorems about permutations of $\{1, \ldots n\}$:

\begin{defn}
A \textbf{permutation} of the set $\{1, \ldots n\}$ is any ordered way to write down the symbols $\{1, \ldots n\}$.  For example, the collection of all permutations of the string $(1,2,3)$ is the set
\begin{align*}
(1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), (3,2,1).
\end{align*}
\end{defn}
\begin{thm}
Take any permutation.  We claim that it can be created by the following process:
\begin{enumerate}
\item Start with the $n$ elements $\{1,2,3,\ldots n\}$.
\item Repeatedly pick pairs of elements in the permutation we have, and swap them.
\item By carefully choosing the pairs in step 2 above, we can get to any other permutation.
\end{enumerate}
The total number of swaps used above is called the \textbf{signature} of that permutation.  For example, the permutation $(2,3,4,1)$ has signature $\textrm{sgn}((2,3,4,1)) =3$, because
\begin{align*}
(1,2,3,4) \xrightarrow{\text{switch }1,2}(2,1,3,4) \xrightarrow{\text{switch }1,3}(2,3,1,4) \xrightarrow{\text{switch }1,4} (2,3,4,1).
\end{align*}
A given permutation can have different signatures; for example, we could have written the above with five swaps, by simply taking the above set of three swaps and then switching 1 and 3 back and forth twice (as swapping two numbers twice doesn't change anything.)  However, we do have the following theorem about the signature of the permutation, which you studied in the fall quarter:
\begin{thm}
Take any permutation $\pi$.  Suppose that $\pi$ can be written as a product of $t$ transpositions in one way, and of $s$ transpositions in another way.   Then $s \equiv t \mod 2$.
\end{thm}
In particular, this means that for any permutation $\pi$, the quantity
\begin{align*}
(-1)^\textrm{sgn}(\pi)
\end{align*}
is well-defined; i.e.\ it's 1 for any permutation that can be created with an even number of swaps, and -$1$ for a permutation that can be created with an odd number of swaps.  We use this in the determinant definitions below!
\end{thm}
\begin{defn}
Let $A$ be a $n \times n$ matrix, of the form
\begin{align*}
\begin{bmatrix} a_{11} & \ldots &a_{1n}\\ \vdots & \ddots & \vdots \\ a_{n1} & \ldots & a_{nn}\\ \end{bmatrix}
\end{align*}
The \textbf{determinant} of $A$, denoted $\det(A)$, is the following object:
\begin{align*}
\det(A) = \sum_{\pi \in S_n} (-1)^{\textrm{sgn}(\pi)} \cdot a_{1, \pi(1)} \cdot a_{2, \pi(2)} \cdot \ldots \cdot a_{n, \pi(n)}.
\end{align*}

\end{defn}

For example, for $3 \times 3$ matrices, this is the sum
\begin{align*}
&(-1)^{\textrm{sgn}((1,2,3))} \cdot a_{11} a_{22} a_{33} + (-1)^{\textrm{sgn}((1,3,2))} \cdot a_{11} a_{23} a_{32} + (-1)^{\textrm{sgn}((2,1,3))} \cdot a_{12} a_{21} a_{33} \\
+& (-1)^{\textrm{sgn}((2,3,1))} \cdot a_{12} a_{23} a_{31} + (-1)^{\textrm{sgn}((3,1,2))} \cdot a_{13} a_{21} a_{32} + (-1)^{\textrm{sgn}((3,2,1))} \cdot a_{13} a_{22} a_{31},
\end{align*}
which if you calculate the signatures is just
\begin{align*}
&(-1)^{0} \cdot a_{11} a_{22} a_{33} + (-1)^{1} \cdot a_{11} a_{23} a_{32} + (-1)^{1} \cdot a_{12} a_{21} a_{33} \\
+& (-1)^{2} \cdot a_{12} a_{23} a_{31} + (-1)^{2} \cdot a_{13} a_{21} a_{32} + (-1)^{1} \cdot a_{13} a_{22} a_{31}.
\end{align*}


This is not the only definition of the determinant!  There is also a recursive definition, which we give here:
\subsection{Definitions of the Determinant: Cofactor Expansion}

\begin{defn}
Let $A$ be a $n \times n$ matrix.  Given a row $i$ and a column $j$, let $A_{ij}$ denote the $n-1 \times n-1$ matrix formed by deleting the $i$-th row and $j$-th column of $A$; we call this the \textbf{cofactor matrix} of $A$ corresponding to $(i,j)$.

We can define the \textbf{determinant} of $A$ as the following sum:
\begin{align*}
\det(A) = \sum_{i=1}^n (-1)^{i+1} a_{1i} \det(A_{1i}).
\end{align*}

For example, for a $3 \times 3$ matrix $A = \begin{bmatrix} a_{11} & a_{12} & a_{13}\\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33}\\ \end{bmatrix}$, this is just
\begin{align*}
a_{11} \cdot \det\left( \begin{bmatrix} a_{22} & a_{23} \\ a_{32} & a_{33}\\ \end{bmatrix} \right) - a_{12} \cdot \det\left( \begin{bmatrix} a_{21} & a_{23} \\ a_{31} & a_{33}\\ \end{bmatrix} \right) +  a_{13} \cdot \det\left( \begin{bmatrix} a_{21} & a_{22} \\ a_{31} & a_{32}\\ \end{bmatrix} \right).
\end{align*}
\end{defn}

Neither of these two definitions, however, is one that I particularly like.  Instead, I'm a pretty big fan of the next two definitions:

\subsection{Definitions of the Determinant: Elementary Matrices}

Much like how natural numbers can all be expressed as products of primes, matrices can be expressed as products of certain sorts of ``elementary'' matrices!  We define these matrices here:

\begin{definition}

There are three kinds of elementary matrices:
\begin{enumerate} 
\item The first type of matrix, $E_{\textrm{multiply entry k by }\lambda}$, is the matrix corresponding to the linear map that multiplies its $k$-th co\"ordinate by $\lambda$ and does not change any of the others.   Specifically, it's the matrix corresponding to the linear map
\begin{align*}
(x_1, x_2\ldots x_n) \mapsto (x_1, x_2, \ldots x_{k-1}, \lambda x_k, x_{k+1}, \ldots x_n).
\end{align*}
This corresponds to the following matrix:
\begin{align*}
E_{\textrm{multiply entry }k\textrm{ by }\lambda} = \begin{bmatrix}
1 & 0 & \ldots & 0 & 0 & 0 & \ldots  & 0\\
0 & 1 & \ldots & 0 & 0 & 0 &  \ldots  & 0\\
\vdots & \vdots & \ddots &\vdots &\vdots & \vdots & \ddots  & \vdots\\
0 & 0 & \ldots & 1 & 0 & 0 &  \ldots  & 0\\
0 & 0 & \ldots & 0 & \cellcolor{blue!15}\lambda & 0 &  \ldots  & 0\\
0 & 0 & \ldots & 0 & 0 & 1 &  \ldots  & 0\\
\vdots & \vdots & \ddots &\vdots &\vdots & \vdots & \ddots  & \vdots\\
0 & 0 & \ldots & 0 & 0 & 0 &  \ldots  & 1\\
\end{bmatrix}
\end{align*}
This matrix has 1's down its diagonal and 0's elsewhere, with an exception for the value at $(k,k)$, which is $\lambda$.  
\item The second kind of matrix, $E_{\textrm{switch entry }k\textrm{ and entry }l}$, corresponds to the linear map that swaps its $k$-th co\"ordinate with its $l$-th co\"ordinate, and does not change any of the others.  Specifically, it's the matrix corresponding to the linear map
\begin{align*}
(x_1, x_2\ldots x_n) \mapsto (x_1, x_2, \ldots x_{k-1},  x_l, x_{k+1}, \ldots x_{l-1},  x_k, x_{l+1}, \ldots x_n).
\end{align*} 
This corresponds to the following matrix:
\newcolumntype{g}{>{\columncolor{blue!15}}c}
\begin{align*}
E_{\textrm{switch entry }k\textrm{ and entry }l} = \left[\begin{array}{cccgcgcc}
1 & 0 & \ldots & 0 & \ldots & 0 & \ldots  & 0\\
0 & 1 & \ldots & 0 & \ldots & 0 &  \ldots  & 0\\
0 & 0 & \ldots & 0 & \ldots & 1 &  \ldots  & 0\\
0 & 0 & \ldots & 0 & \ldots & 0 &  \ldots  & 0\\
0 & 0 & \ldots & 1 & \ldots & 0 &  \ldots  & 0\\
\vdots & \vdots & \ddots & \vdots &\ddots & \vdots & \ddots  & \vdots\\
0 & 0 & \ldots & 0 & \ldots & 0 &  \ldots  & 1\\
\end{array}\right]
\end{align*}
You can create this matrix by starting with a matrix with 1's down its diagonal and 0's elsewhere, and switching the $k$-th and $l$-th columns.

\item Finally, the third kind of matrix, $E_{\textrm{add }\lambda\textrm{ copies of entry }k\textrm{ to entry }l}$, for $k \neq l$, corresponds to the linear map that adds $\lambda$ copies of its $k$-th co\"ordinate to its $l$-th co\"ordinate and does not change any of the others. This corresponds to the following matrix:
\begin{align*}
E_{\textrm{add }\lambda\textrm{ copies of entry }k\textrm{ to entry }l} = \begin{bmatrix}
1 & \ldots & 0 & 0 & \ldots & 0 & 0 & \ldots & 0\\
\vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \vdots  & \ddots & \vdots\\
0 & \ldots & 1 & 0 & \ldots & 0 & 0 & \ldots & 0\\
0 & \ldots & 0 & 1 & \ldots & 0 & 0 & \ldots & 0\\
\vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \vdots  & \ddots & \vdots\\
0 & \ldots & 0 & 0 & \ldots & 1 & 0 & \ldots & 0\\
0 & \ldots & \cellcolor{blue!15}\lambda & 0 & \ldots & 0 & 1 & \ldots & 0\\
\vdots & \ddots & \vdots & \vdots & \ddots & \vdots & \vdots  & \ddots & \vdots\\
0 & \ldots & 0 & 0 & \ldots & 0 & 0 & \ldots & 1\\
\end{bmatrix}
\end{align*}
This matrix has 1's down its diagonal and 0's elsewhere, with an exception for the value in row $l$, column $k$, which is $\lambda$. 
\end{enumerate}
\end{definition}

These elementary matrices do what their names suggest:
\begin{theorem}
Take any $n \times n$ matrix $A$.  Suppose that we are looking at the composition $E \circ A$, where $E$ is one of our elementary matrices. Then, we have the following three possible situations:
\begin{itemize}
\item if $E = E_{\textrm{multiply entry k by }\lambda}$, then $E\circ A$ would be the matrix $A$ with its $k$-th row multiplied by $\lambda$.
\item if $E = E_{\textrm{switch entry }k\textrm{ and entry }l}$, then $E\circ A$ would be the matrix $A$ with its $k$-th and $l$-th rows swapped, and
\item if $E = E_{\textrm{add }\lambda\textrm{ copies of entry }k\textrm{ to entry }l}$, then $E\circ A$ would be the matrix $A$ with $\lambda$ copies of its $k$-th row added to its $l$-th row.
\end{itemize}
\end{theorem}

There is a similar version of this theorem for columns:

\begin{theorem}
Take any $n \times n$ matrix $A$.  Suppose that we are looking at the composition $A \circ E$, where $E$ is one of our elementary matrices. Then, we have the following three possible situations:
\begin{itemize}
\item if $E = E_{\textrm{multiply entry k by }\lambda}$, then $A \circ E$, would be the matrix $A$ with its $k$-th column multiplied by $\lambda$.
\item if $E = E_{\textrm{switch entry }k\textrm{ and entry }l}$, then $A \circ E$, would be the matrix $A$ with its $k$-th and $l$-th columns swapped, and
\item if $E = E_{\textrm{add }\lambda\textrm{ copies of entry }k\textrm{ to entry }l}$, then $A \circ E$, would be the matrix $A$ with $\lambda$ copies of its $l$-th column added to its $k$-th column.
\end{itemize}
\end{theorem}
These theorems are not hard to check; verify them for yourself!  Instead of proving this, I want to look at the claim we made about elementary matrices above:




\begin{thm}
Let $A$ be an arbitrary $n \times n$ matrix.  Then we can write $A$ as the product of elementary matrices.
\end{thm}
\begin{proof}
So: notice by the two theorems above, multiplying by elementary matrices lets us perform the following operations on a matrix $A$:
\begin{itemize}
\item Scaling any row or column by a constant.
\item Switching any pair of rows or any pair of columns.
\item Adding any multiple of any row to any other row, or adding any multiple of any column to any other column.
\end{itemize}


So: to do this process, first do the following:
\begin{enumerate}
\item Take the collection $R$ of all of $A$'s rows.  
\item If this set is linearly independent, halt.
\item Otherwise, there is some row that shows up in this collection that is a combination of the other rows.  Get rid of that row, and return to (2).
\end{enumerate}
This creates a subset $R'$ of $A$'s rows that is linearly independent.  Furthermore, it creates a subset from which we can create \textbf{any} of $A$'s rows, even the ones we got rid of!  This is because we only got rid of rows that were linearly dependent on the earlier ones; i.e. we only got rid of rows that we can make with the rows we kept!

So: all we need to do now is make $B$ into a matrix that has all of the rows in this subset $R'$!  If we can do this, then we can just do the following:
\begin{itemize}
\item Multiply all of the other rows in $B$ by zero.
\item Now, using each all-zero row as an empty slot, create each of the rows from $A$ that we don't have by combining the rows from $R'$.  We can do this because all of the remaining rows in $A$ were linear combinations of the $R'$ rows!
\item Finally, rearrange the rows using swaps so that our matrix \textbf{is} $A$ (and not just a matrix with the same rows, but in some different order.)
\end{itemize}

This is our plan!  We execute the plan as below:
\begin{enumerate}
\item We start with $B$ equal to the $n \times n$ identity matrix.  Note that $B$'s rows span all of $\mathbb{R}^n$
\item If all of the rows in $R'$ currently occur as rows of $B$, stop!  
\item Otherwise, there is a row $\vec{a_r}$ in $R'$ that is not currently a row in $B$.
\item If the rows of $B$ span $\mathbb{R}$, then specifically there is a combination of the rows of $B$ that yields $\vec{a_r}$. 
\item Furthermore, this vector is not just a combination of rows in $R'$, because $R'$ is a linearly independent set.  Therefore, in any linear combination of $B$'s rows that creates $\vec{a_r}$, there is some row of $B$ that is not one of the $R'$ rows that's used in creating $\vec{a_r}$.
\item So: take the linear combination 
\begin{align*}
a_1 \vec{b_{r_1}} + \ldots a_n\vec{b_{r_n}} = \vec{a_r},
\end{align*}
and let $\vec{b_{r_k}}$ denote the row that occurs above that's not one of the $R'$ rows and that has $a_k \neq 0$.

\item Take $B$, and multiply it by 
\begin{align*}
\overbrace{\overbrace{\begin{bmatrix}  & \vdots & \\\ldots & a_1 & \ldots\\ & \vdots & \\\end{bmatrix}}^{\substack{\textrm{add }a_1 \textrm{ copies of }\\r_1 \textrm{ to } r_k}} \cdot
\overbrace{\begin{bmatrix}  & \vdots & \\\ldots & a_2 & \ldots\\ & \vdots & \\\end{bmatrix}}^{\substack{\textrm{add }a_2 \textrm{ copies of }\\r_2 \textrm{ to } r_k}}\cdot \ldots \cdot 
\overbrace{\begin{bmatrix}  & \vdots & \\\ldots & a_n & \ldots\\ & \vdots & \\\end{bmatrix}}^{\substack{\textrm{add }a_n \textrm{ copies of }\\r_2 \textrm{ to } r_k}}}^{\textrm{all of the values }a_i,\textrm{ with }i \neq k}
 \cdot \overbrace{\begin{bmatrix}  & \vdots & \\\ldots & a_k & \ldots\\ & \vdots & \\\end{bmatrix}}^{\substack{\textrm{multiply row } r_k\\\textrm{ by } a_k}} \cdot B
\end{align*}
This takes the $k$-th row of $B$ and fills it with the linear combination that creates $\vec{a_r}$!  So this means that the row $\vec{a_r}$ is now in $B$.

\item Also, notice that the rows of $B$ all still span $\mathbb{R}^n$! This is because
\begin{align*}
a_1 \vec{b_{r_1}} + \ldots a_n\vec{b_{r_n}} = \vec{a_r} \\
\Rightarrow \vec{b_{r_k}} = \frac{1}{a_k} \left(\underbrace{ a_1 \vec{b_{r_1}} + \ldots a_n\vec{b_{r_n}}}_{\textrm{terms that aren't } a_k\vec{b_{r_k}}} + \vec{a_r} \right).
\end{align*}
Therefore, we have that the old $k$-th row $\vec{b_{r_k}}$ is in the span of the new $B$'s rows!  As well, because none of the other rows changed, those rows are all still in the span as well.  Therefore, because the new $B$'s rows contain the old $B$'s rows in their span, they must span $\mathbb{R}^n$!
\item Go to (2), and repeat this process!
\end{enumerate}
The result of this process is a matrix $B$ that contains all of the rows in $R'$, which is what we wanted (because we can make $A$ out of this!)  So we're done.
\end{proof}

To illustrate this argument, we run another example:
\begin{exmp}
Consider the matrix
\begin{align*}
A = \begin{bmatrix} 0 & 1 &2 \\ 4 & -1 & 0\\ 2 &0 & 1\\  \end{bmatrix}
\end{align*}
Write $A$ as a product of elementary matrices.
\end{exmp}
\begin{proof}
We start, as directed in the proof, by finding a subset of $A$'s rows that is linearly independent. We can tell at the start that the collection of all rows is not linearly independent, because
\begin{align*}
1(0,1,2) + 1(4,-1,0) - 2(2,0,1)= (0,0,0).
\end{align*}
However, we also have that the pair
\begin{align*}
(0,1,2), (2,0,1)
\end{align*}
\textbf{is} linearly independent, because
\begin{align*}
\alpha(0,1,2) + \beta(2,0,1) = (0,0,0) \Rightarrow \alpha, \beta = 0,
\end{align*}
and that these two vectors contain the third in their span.

So the set $R'$ from our discussion above is just these two vectors!

Set $B$ equal to the $3 \times 3$ identity matrix.  We start by picking a vector from $R'$ -- let's choose $\vec{a_r} = (0,1,2)$.

We want to multiply $B$ by elementary matrices so that it has $(0,1,2)$ as one of its rows.  To do this, we first write $(0,1,2)$ as a combination of $B$'s rows:
\begin{align*}
0(1,0,0) + 1(0,1,0) + 2(0,0,1) = (0,1,2).
\end{align*}
We now pick a row from $B$ whose coefficient above is nonzero, and that isn't a row in $R'$.  For example, the coefficient of the second row above is 1, and the second row $(0,1,0)$ is not in $R'$: so we can pick the second row.

We now turn the second row into this $\vec{a_r} = (0,1,2)$, by using the linear combination we have for $(0,1,2)$ above:
\begin{align*}
\overbrace{\begin{bmatrix} 1&0&0\\0&1&2\\0&0&1\\\end{bmatrix}}^{\substack{\textrm{add }2 \textrm{ copies of }\\r_3 \textrm{ to } r_2}} \cdot
\overbrace{\begin{bmatrix} 1&0&0\\0&1&0\\0&0&1\\\end{bmatrix}}^{\substack{\textrm{add }0 \textrm{ copies of }\\r_1 \textrm{ to } r_2}}\cdot
\overbrace{\begin{bmatrix} 1&0&0\\0&1&0\\0&0&1\\\end{bmatrix}}^{\substack{\textrm{multiply row } r_2\\\textrm{ by } 1}}\cdot \overbrace{\begin{bmatrix} 1&0&0\\0&1&0\\0&0&1\\\end{bmatrix}}^{\textrm{the matrix }B} = \begin{bmatrix} 1&0&0\\0&1&2\\0&0&1\\\end{bmatrix} .
\end{align*}

Success!  We repeat this.  We choose another row from $R'$, specifically $\vec{a_r} = (2,0,1)$.  We write  $(2,0,1)$ as a combination of $B$'s rows:
\begin{align*}
2(1,0,0) + 0(0,1,2) + 1(0,0,1) = (2,0,1).
\end{align*}

We now pick a row from $B$ whose coefficient above is nonzero, and that isn't a row in $R'$; for example, the first row works here.

We now turn the first row into this $\vec{a_r} = (2,0,1)$, by using the linear combination we have for $(2,0,1)$ above:
\begin{align*}
\overbrace{\begin{bmatrix} 1&0&1\\0&1&0\\0&0&1\\\end{bmatrix}}^{\substack{\textrm{add }1 \textrm{ copies of }\\r_3 \textrm{ to } r_1}} \cdot
\overbrace{\begin{bmatrix} 1&0&0\\0&1&0\\0&0&1\\\end{bmatrix}}^{\substack{\textrm{add }0 \textrm{ copies of }\\r_2 \textrm{ to } r_1}}\cdot
\overbrace{\begin{bmatrix} 2&0&0\\0&1&0\\0&0&1\\\end{bmatrix}}^{\substack{\textrm{multiply row } r_1\\\textrm{ by } 2}}\cdot \overbrace{\begin{bmatrix} 1&0&0\\0&1&2\\0&0&1\\\end{bmatrix}}^{\textrm{the matrix }B} = \begin{bmatrix} 2&0&1\\0&1&2\\0&0&1\\\end{bmatrix} .
\end{align*}

We are now out of rows of $R'$!  This brings us to the second stage of our proof: multiply all of the remaining rows that aren't $R'$ rows by 0.
\begin{align*}
\overbrace{\begin{bmatrix} 1&0&0\\0&0&1\\0&1&0\\\end{bmatrix}}^{\substack{\textrm{multiply row } r_3\\\textrm{ by }0 }}\cdot \overbrace{\begin{bmatrix} 2&0&1\\0&1&2\\0&0&1\\\end{bmatrix}}^{\textrm{the matrix }B} = \begin{bmatrix} 2&0&1\\0&1&2\\0&0&0\\\end{bmatrix} .
\end{align*}
Now we are at the last stage of our proof: combine the $R'$ rows to create whatever rows in $A$ are left, in these ``blank'' all-zero rows! 

Specifically, we take the one row of $A$ that's left: $(4,-1,0)$.  As we noted before, we can write
\begin{align*}
(4,-1,0) = 2(2,0,1) - 1(0,1,2).
\end{align*}
Therefore, we have
\begin{align*}
\overbrace{\begin{bmatrix} 1&0&0\\0&1&0\\2&0&1\\\end{bmatrix}}^{\substack{\textrm{add }2 \textrm{ copies of }\\r_1 \textrm{ to } r_3}} \cdot
\overbrace{\begin{bmatrix} 1&0&0\\0&1&0\\0&-1&1\\\end{bmatrix}}^{\substack{\textrm{add }-1 \textrm{ copies of }\\r_2 \textrm{ to } r_3}}\cdot
\overbrace{ \begin{bmatrix} 2&0&1\\0&1&2\\0&0&0\\\end{bmatrix}}^{\textrm{the matrix }B} = \begin{bmatrix} 2&0&1\\0&1&2\\4&-1&0\\\end{bmatrix} .
\end{align*}
So we have a matrix with the same rows as $A$!  Finally, we just shuffle the rows of $B$ to get $A$ itself:
\begin{align*}
\overbrace{\begin{bmatrix} 1&0&0\\0&0&1\\0&1&0\\\end{bmatrix}}^{\substack{\textrm{switch rows} \\r_3\textrm{ and }r_2 }}\cdot
\overbrace{\begin{bmatrix} 0&1&0\\1&0&0\\0&0&1\\\end{bmatrix}}^{\substack{\textrm{switch rows} \\r_2\textrm{ and }r_1 }}\cdot
\overbrace{ \begin{bmatrix} 2&0&1\\0&1&2\\4&-1&0\\\end{bmatrix}}^{\textrm{the matrix }B} = \begin{bmatrix} 0 & 1 &2 \\ 4 & -1 & 0\\ 2 &0 & 1\\  \end{bmatrix} = A.
\end{align*}
\end{proof}


This is\ldots not a determinant definition yet.  We can make it one here:

\begin{defn}
Take any $n \times n$ matrix $A$.  Write $A$ as a product $E_1\cdot \ldots \cdot E_n$ of elementary matrices.  Let $k$ denote the number of ``swap'' matrices we used in writing this product, and let $\lambda_1, \ldots \lambda_m$ denote the $m$ ``scale'' elementary matrices that occur in writing this product.  Then
\begin{align*}
\det(A) = (-1)^k \prod_{i=i}^m \lambda_i. 
\end{align*} 
\end{defn}

I care about this definition mostly because it lets us make one last definition of the determinant; it's \textbf{volume!}

\subsection{Definitions of the Determinant: Volume}

To make this rigorous, we start with the following definition:
\begin{defn}
Take two vectors $(x_1, \ldots x_n), (y_1, \ldots y_n) \in \mathbb{R}^n$.  We say that these two vectors are \textbf{orthogonal} if their dot product is 0.  Alternately, we can say that two vectors are orthogonal if the angle $\theta$ between them is $\pm \pi/2$; this is a consequence of a theorem we proved in class, where we showed 
\begin{align*}
\vec{x} \cdot \vec{y} =||\vec{x}|| \cdot ||\vec{y}|| \cos(\theta).
\end{align*}
(Recall that $||\vec{x}||$ is the \textbf{length} of the vector $\vec{x}$: i.e.\ the length of $(1,2,3)$ is simply the quantity $\sqrt{1^2 + 2^2 + 3^2} = \sqrt{14}$.)
\end{defn}

Given this definition, consider the following question:
\begin{question}
Suppose that we have a collection of vectors $W = \{ \vec{w_1}, \ldots \vec{w_k}\}$, and some other vector $\vec{v}$.  Is there some way we can write $\vec{v}$ as the sum of two vectors $\vec{r} + \vec{p}$, where $\vec{r}$ is orthogonal to all of the vectors in $W$, while $\vec{p}$ is contained in the span of $W$?
\end{question}

We can visualize this with the following picture.  Here, we describe the red vector $\vec{v}$ as the sum of two gold vectors, one of which is orthogonal to $\vec{w_1}$ and $\vec{w_2}$, and the other of which is a linear combination of $\vec{w_1}$ and $\vec{w_2}$.
\begin{center}
\includegraphics[width=2in]{mathcs103_wk8_hw_proj_q.pdf}
\end{center}

We go through an answer to this in two parts.  First,  make the following definition:
\begin{defn} Let $\vec{v}, \vec{w}$ be a pair of vectors in $\mathbb{R}^n$.  The \textbf{projection} of $\vec{v}$ onto $\vec{w}$, denoted $\textrm{proj}(\vec{v} \textrm{ onto } \vec{w})$, is the following vector:
\begin{itemize}
\item Take the vector $\vec{w}$.
\item Draw a line perpindicular to the vector $\vec{w}$, that goes through the point $\vec{v}$ and intersects the line spanned by the vector $\vec{w}$. 
\item $\textrm{proj}(\vec{v} \textrm{ onto } \vec{w})$ is precisely the point at which this perpindicular line intersects $\vec{w}$.
\end{itemize}
We illustrate this below:
\begin{center}
\includegraphics[width=2.5in]{mathcs103_wk8_hw_proj.pdf}
\end{center}
In particular, it bears noting that this vector is a multiple of $\vec{w}$.
\end{defn}
A formula for this vector is the following:
\begin{align*}
\textrm{proj}(\vec{v} \textrm{ onto } \vec{w}) = \frac{\vec{v} \cdot \vec{w}}{||\vec{w}||^2} \cdot \vec{w}.
\end{align*}
To see why, simply note that the vector we want is, by looking at the above picture, something of length $\cos(\theta) \cdot ||\vec{v}||$, in the direction of $\vec{w}$.  In other words,
\begin{align*}
\textrm{proj}(\vec{v} \textrm{ onto } \vec{w}) = \cos(\theta) \cdot ||\vec{v}|| \cdot \frac{\vec{w}}{||\vec{w}||}.
\end{align*}
Now, use the angle form of the dot product to see that because $\vec{w} \cdot \vec{v} = ||\vec{w}|| ||\vec{v}|| \cos(\theta)$, we have
\begin{align*}
\textrm{proj}(\vec{v} \textrm{ onto } \vec{w}) = \frac{\vec{v} \cdot \vec{w}}{||\vec{v}||||\vec{w}||}   ||\vec{v}|| \frac{\vec{w}}{||\vec{w}||}. 
\end{align*}
Canceling the $||\vec{v}||$'s gives us the desired formula.

Using this, you can define the ``orthogonal part'' of $\vec{v}$ over $\vec{w}$ in a similar fashion:
\begin{defn}
 Let $\vec{v}, \vec{w}$ be a pair of vectors in $\mathbb{R}^n$.  The \textbf{orthogonal part} of $\vec{v}$ over $\vec{w}$, denoted $\textrm{orth}(\vec{v} \textrm{ onto } \vec{w})$, is the following vector:
\begin{align*}
\textrm{orth}(\vec{v} \textrm{ onto } \vec{w})  = \vec{v} - \textrm{proj}(\vec{v} \textrm{ onto } \vec{w})
\end{align*}
\end{defn}

It bears noting that this vector lives up to its name, and is in fact orthogonal to $\vec{w}$.  This is not hard to see: just take the dot product of $\vec{w}$ with it!  This yields
\begin{align*}
\vec{w} \cdot (\vec{v} - \textrm{proj}(\vec{v} \textrm{ onto } \vec{w})) &= \vec{w}\cdot \vec{v} - \vec{w} \cdot \textrm{proj}(\vec{v} \textrm{ onto } \vec{w})\\
&=\vec{w}\cdot \vec{v} -  \vec{w} \cdot(\frac{\vec{v} \cdot \vec{w}}{||\vec{w}||^2} \cdot \vec{w})\\
&= \vec{w} \cdot \vec{v} - \frac{\vec{v} \cdot\vec{w}}{||\vec{w}||^2} (\vec{w} \cdot \vec{w})\\
&= \vec{w} \cdot \vec{v} - \frac{\vec{v} \cdot\vec{w}}{||\vec{w}||^2} (w_1^2 + \ldots w_n^2)\\
&= \vec{w} \cdot \vec{v} - \frac{\vec{v} \cdot\vec{w}}{||\vec{w}||^2} (||\vec{w}||^2)\\
&= 0.\\
\end{align*}

Therefore, in the case where $\{ \vec{w_1}, \ldots \vec{w_n}\}$ is a set containing just one vector $\vec{w}$, we've answered our problem!  We can write 
\begin{align*}
\vec{v} = \textrm{proj}(\vec{v} \textrm{ onto } \vec{w})  + \textrm{orth}(\vec{v} \textrm{ onto } \vec{w}), 
\end{align*}
where $\textrm{proj}$ is a multiple of $\vec{w}$ and $\textrm{orth}$ is orthogonal to $\vec{w}$!



The rough idea for why we care about orthogonality now is because it's the easiest way to understand the idea of \textbf{n-dimensional volume}! Specifically: suppose you have a parallelogram spanned by the two vectors $\vec{v}, \vec{w}$.
\begin{center}
\includegraphics[width=2in]{mathcs103_wk8_hw_par_2d.pdf}
\end{center}

What's the area of this parallelogram?  Well, it's the length of the \textbf{base} times the \textbf{height}, if you remember your high-school geometry!  But what are these two quantities?  Well: the \textbf{base} has length just given by the length of $\vec{w}$.  The \textbf{height}, however, is precisely the kind of thing we've been calculating in this set!  Specifically: suppose that we can write $\vec{v}$ as the sum $\vec{p} + \vec{r}$, where $\vec{p}$ is some multiple of $\vec{v}$ and $\vec{r}$ is orthogonal to $\vec{w}$.  Then the length of $\vec{r}$ is precisely the \textbf{height}!

\begin{center}
\includegraphics[width=2in]{mathcs103_wk8_hw_par_2d2.pdf}
\end{center}
Therefore, to find the area here, we just need to multiply the length of $\vec{r}$ and the length of $\vec{w}$ together.

For three dimensions, the picture is similar.  Suppose you want to find the volume of a parallelepiped --- i.e. the three-dimensional analogue of a parallelogram -- spanned by the three vectors $\vec{v}, \vec{w_1}, \vec{w_2}$.
\begin{center}
\includegraphics[width=3in]{mathcs103_wk8_hw_par_3d.pdf}
\end{center}

What's the volume of this parallelotope?  Well, this is not much harder to understand than the two-dimensional case: it's just the \textbf{area} of the parallelogram spanned by the two vectors $\vec{w_1}, \vec{w_2}$ times the \textbf{height}!  In other words, suppose that we can write $\vec{v} = \vec{r} + \vec{p}$, for some vector $\vec{p}$ in the span of $\vec{w_1}, \vec{w_2}$ and some vector $\vec{r}$ orthogonal to $\vec{w_1}, \vec{w_2}$.  Then the length of this vector $\vec{r}$ is, again, precisely the \textbf{height}!

\begin{center}
\includegraphics[width=3in]{mathcs103_wk8_hw_par_3d2.pdf}
\end{center}

This process generalizes to $n$ dimensions: to find the volume of a $n$-dimensional parallelotope spanned by $n$ vectors $\vec{w_1}, \ldots \vec{w_n}$, we just start with $\vec{w_1}$, and repeatedly for each $\vec{w_2}, \vec{w_n}$, find the ``height'' of each $\vec{w_i}$ over the set $\vec{w_1},\ldots \vec{w_{i-1}}$ by doing this ``write $\vec{w_i}$ as a projection $\vec{p}$ onto $\{\vec{w_1},\ldots \vec{w_{i-1}}\}$, plus an orthogonal bit $\vec{r}$, whose length is the height'' trick.  By taking the product of all of these heights, we get what we would expect to be the $n$-dimensional volume of the parallelotope!   (In fact, it's kinda confusing just what $n$-dimensional volume even \textbf{means}, so if you want you can take this as the \textbf{definition} of volume for these kinds of objects in $n$-dimensional space.)


This gives us one last way to define the determinant:
\begin{defn}
Let $[0,1]^n$ denote the set $\{(x_1, \ldots x_n) ~|~ x_i \in [0,1]\}$.  Look at the set $A([0,1]^n)$, defined as $\{A\vec{x} ~|~ \vec{x} \in [0,1]^n\}$; geometrically, if you draw this out, you'll see that it's a parallelotope spanned by the columns of $A$!

We define the ``positive'' determinant of $A$ as the volume of this parallelotope: i.e.

\begin{align*}
|\det(A)| = \textrm{vol}(A([0,1]^n)). 
\end{align*}
The determinant (i.e. where we don't have absolute values) is just this quantity times $(-1)^k$, where $k$ is the number of swaps needed to write $A$ with a product of elementary matrices.
\end{defn}



\subsection{Properties of the Determinant}

The determinant satisfies many many properties!  We list some here:
\begin{enumerate}
\item All of these definitions are equivalent; i.e. they all describe the same object.
\item For any two $n \times n$ matrices $A, B$, $\det(AB) = \det(A) \det(B)$.
\item For any matrix $A$, if $A^T$ denotes the \textbf{transpose} of $A$ (i.e. $A^T(i,j) = A(j,i)$), then $\det(A^T) = \det(A)$.
\item For any matrix $A$, the determinant is zero if and only if the rows of $A$ are linearly dependent if and only if the columns of $A$ are linearly dependent.
\item For any matrix $A$, $\lambda$ is an eigenvalue of $A$ if and only if $A - \lambda I$ has determinant 0.  (Notice that $\det(A - \lambda I)$ is actually a polynomial in $\lambda$, if we think of all of the entries in $A$ as constants: we call this the \textbf{characteristic polynomial} of $A$.)
\item For any matrix $A$, the determinant is unchanged if we add multiples of one row in $A$ to another row in $A$, gets multiplied by $-1$ if we swap two rows in $A$, and gets multipled by $\lambda$ if we scale any row by $\lambda$.  (The same holds for columns.)
\item Suppose that a $n \times n$ matrix $A$ has $n$ eigenvalues, counted with multiplicity.  Then the determinant of $A$ is the product of its eigenvalues.
\end{enumerate}

We leave the proofs of these properties for the homework!


There is also one fairly sizeable theorem, the \textbf{spectral theorem}, that we need and leave for the homework as well; either prove this (hard, but doable!) or decide to accept it on faith!
\begin{thm}
(Spectral theorem.)  Suppose that $A$ is a real-valued symmetric $n \times n$ matrix.  Then there is a basis for $\mathbb{R}^n$ consisting of orthogonal eigenvectors for $A$.

In particular, if $G$ is a graph on $n$ vertices, the spectrum of $G$ contains $n$ values, counted with multiplicity.
\end{thm}

We use this to calculate some actual eigenvalues in the next section:

\section{Using Determinants to Calculate Spectra}



\begin{exmp}
The spectrum of $K_n$:  The adjacency matrix of $K_n$ is
\begin{align*}
\left( \begin{array}{ccccc}
 0 &  1 & 1 & \ldots &  1 \\
 1 &  0 & 1 & \ldots &  1 \\
 1 &  1 & 0 & \ldots &  1 \\
 \vdots &  \vdots & \vdots & \ddots &  \vdots\\
 1 &  1 & 1 & \ldots &  0 \\
\end{array}\right) = \left( \begin{array}{ccccc}
 1 &  1 & 1 & \ldots &  1 \\
 1 &  1 & 1 & \ldots &  1 \\
 1 &  1 & 1 & \ldots &  1 \\
 \vdots &  \vdots & \vdots & \ddots &  \vdots\\
 1 &  1 & 1 & \ldots &  1 \\
\end{array}\right) - I_n.
\end{align*}
Consequently, its characteristic polynomial has roots wherever the rows of
\begin{align*}
\left( \begin{array}{ccccc}
 -\lambda &  1 & 1 & \ldots &  1 \\
 1 &  -\lambda & 1 & \ldots &  1 \\
 1 &  1 & -\lambda & \ldots &  1 \\
 \vdots &  \vdots & \vdots & \ddots &  \vdots\\
 1 &  1 & 1 & \ldots &  -\lambda \\
\end{array}\right)
\end{align*}
are linearly dependent, with multiplicity equal to $n - ($number of linearly independent rows).  What are these roots and multiplicities? Well: when $\lambda = -1$, this matrix is the all-1's matrix, and thus has only one linearly independent row: so the eigenvalue $-1$ occurs with multiplicity $n-1$.  This leaves at most one root in the characteristic polynomial for us to find!

So: when $\lambda = n-1$, we have that the sum of all of the rows in our matrix is 0; therefore, this is also an eigenvalue of our matrix.  As we've found $n$ eigenvalues, we know that we've found them all, and can thus conclude that the spectrum of $K_n$ is $\{(n-1)^1, (-1)^{n-1}\}$ (where the superscripts here denote multiplicity, not being raised to a power,) and its characteristic polynomial is $(x-n+1)(x+1)^{n-1}$.
\end{exmp}


\begin{exmp}
The spectrum of $C_n$:  The adjacency matrix of $C_n$ is
\begin{align*}
A_{C_n} = \left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 1 \\
1 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 1 & 0 & 1 & \ldots & 0 \\
0 & 0 & 1 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 1 & 0 \\
\end{array} \right].
\end{align*}

This \ldots is kinda awful.  So: let's be clever!  Specifically, let's consider instead the \textbf{directed cycle} $D_n$, formed by taking the cycle graph $C_n$ and orienting each edge $\{i,i+1\}$ so that it goes from $i$ to $i+1$.  This graph has adjacency matrix given by the following:
\begin{align*}
A_{D_n} =  \left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 0 \\
0 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 0 & 0 & 1 & \ldots & 0 \\
0 & 0 & 0 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 0 & 0 \\
\end{array} \right].
\end{align*}

What's the characteristic polynomial of this matrix?  Well: it's what you get when you take the determinant
\begin{align*}
\det(A_{D_n} - \lambda I) = \det\left( \left[ \begin{array}{cccccc}
-\lambda & 1 & 0 & 0 &\ldots  & 0 \\
0 & -\lambda & 1 & 0 & \ldots  & 0 \\
0 & 0 & -\lambda & 1 & \ldots & 0 \\
0 & 0 & 0 & -\lambda & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 0 & -\lambda \\
\end{array} \right]\right).
\end{align*}
If we apply the definition of the determinant, we can expand along the top row of this matrix and write $\det(A_{D_n} - \lambda I)$ as 
\begin{align*}
&-\lambda \cdot \det \left(\left[ \begin{array}{ccccc}
-\lambda & 1 & 0 & \ldots  & 0 \\
 0 & -\lambda & 1 & \ldots & 0 \\
0 & 0 & -\lambda & \ddots & 0 \\
 \vdots & \vdots & \ddots & \ddots  & 1 \\
 0  & 0 & \ldots & 0 & -\lambda \\
\end{array} \right]\right) - 1 \cdot \det\left( \left[ \begin{array}{ccccc}
0 & 1 & 0 & \ldots  & 0 \\
0 & -\lambda & 1 & \ldots & 0 \\
0 & 0 & -\lambda & \ddots & 0 \\
\vdots & \vdots & \ddots & \ddots  & 1 \\
1  & 0 & \ldots & 0 & -\lambda \\
\end{array} \right]\right).\\
\end{align*}
The left matrix has determinant equal to the product of its diagonal entries; in general, any \textbf{upper-triangular} matrix, i.e. one where all of its nonzero entries are on or above the diagonal $(i,i)$, will have determinant equal to the product of its diagonal entries!  (If you haven't seen this before, it's not hard to prove.  If you use the property that the determinant of a matrix is equal to its transpose from the HW, you can see that this claim is equivalent to proving the same claim for \textbf{lower-triangular} matrices.  If you apply the recursive definition of the determinant here, our claim is proven by simply applying induction!)

The right matrix is a bit trickier: however, if we permute the columns of this matrix by sending the columns $1, 2, \ldots n-1$ to the columns $2, 3, \ldots n-1, 1$ we will change the determinant by $(-1)^{n-2}$ (as it takes $n-2$ swaps to make this $n-1$ cycle of columns.)   This gives us the following:
\begin{align*}
\det(A_{D_n} - \lambda I)  =&(-1)^n\lambda^n - (-1)^{n-2} \det\left( \left[ \begin{array}{ccccc}
1 & 0 & \ldots  & 0 & 0\\
-\lambda & 1 & \ldots & 0 & 0\\
0 & -\lambda & \ddots & 0 & 0\\
\vdots & \vdots & \ddots  & 1 & \vdots\\
0 & \ldots & 0 & -\lambda & 1\\
\end{array} \right]\right).\\
\end{align*}
This right matrix now has determinant given by $1$, because it is lower-triangular!   Therefore, we've shown that 
\begin{align*}
\det( A_{D_n} - \lambda I) = (\lambda^{n} - 1)\cdot (-1)^{n}.\\
\end{align*}


So: at first, this doesn't look too useful.  It would seem to tell us that the only eigenvalue is 1; however, you can check pretty easily that 1 is an eigenvalue of this matrix with multiplicity 1, as for any vector $\vec{x}$,
\begin{align*}
A_{D_n}\vec{x} =  \left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 0 \\
0 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 0 & 0 & 1 & \ldots & 0 \\
0 & 0 & 0 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 0 & 0 \\
\end{array} \right] \cdot \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \\ \vdots \\ x_n \end{bmatrix} =  \begin{bmatrix} x_2 \\ x_3 \\ \vdots \\ x_{n-1} \\ x_n \\ x_1 \end{bmatrix}.
\end{align*}
Therefore, if $A\vec{x} = 1 \vec{x}$, we have $x_i = x_{i+1}$, for all $i$; that is, $\vec{x}$ has the form $c \cdot (1,1,1\ldots 1)$ for some constant $c$.  But this means that $E_1$ is a one-dimensional space spanned by $(1,1,\ldots 1)$, and is thus one-dimensional!

So.  Where did all of the other eigenvalues go?

The answer lies in the complex numbers!  Specifically: the other roots of  $(\lambda^{n} - 1)$ are precisely the \textbf{$n$-th roots of unity}, i.e. the $n$ distinct numbers $1, e^{(2\pi i)/n}, e^{(2 \pi i)2/n}, \ldots  e^{(2 \pi i)(n-1)/n}$ such that any of these numbers $\zeta$, when raised to the $n$-th power, is 1.  Furthermore, we can actually see that each of these eigenvalues $\zeta$ has corresponding eigenvector given by $(1, \zeta, \zeta^2, \ldots \zeta^{n-1}),$ because
\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 0 \\
0 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 0 & 0 & 1 & \ldots & 0 \\
0 & 0 & 0 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 0 & 0 \\
\end{array} \right] \cdot \left[ \begin{array}{c} 1 \\ \zeta \\ \zeta^2 \\ \zeta^3 \\ \vdots \\ \zeta^{n-1} \\ \end{array} \right] = \left[ \begin{array}{c} \zeta \\ \zeta^2 \\ \zeta^3 \\ \zeta^4 \\ \vdots \\ 1 = \zeta^n \\ \end{array} \right] = \zeta \cdot \left[ \begin{array}{c} 1 \\ \zeta \\ \zeta^2 \\ \zeta^3 \\ \vdots \\ \zeta^{n-1} \\ \end{array} \right].
\end{align*}

Turning this into information about $C_n$ is not a difficult thing to do.  In particular, notice that 

\begin{align*}
A_{D_n} + A_{D_n}^T =&  \left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 0 \\
0 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 0 & 0 & 1 & \ldots & 0 \\
0 & 0 & 0 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 0 & 0 \\
\end{array} \right]  + \
\left[ \begin{array}{cccccc}
0 & 0 & 0 & 0 &\ldots  & 1 \\
1 & 0 & 0 & 0 & \ldots  & 0 \\
0 & 1 & 0 & 0 & \ldots & 0 \\
0 & 0 & 1 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
0 & 0  & 0 & \ldots & 1 & 0 \\
\end{array} \right]  \\
=& \left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 1 \\
1 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 1 & 0 & 1 & \ldots & 0 \\
0 & 0 & 1 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 1 & 0 \\
\end{array} \right] = A_{C_n}.
\end{align*}


Also, notice that all of our eigenvectors for $A_{D_n}$ are eigenvectors for $A_{D_n}^T$ as well:  

\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 0 \\
0 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 0 & 0 & 1 & \ldots & 0 \\
0 & 0 & 0 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 0 & 0 \\
\end{array} \right] \cdot \left[ \begin{array}{c} 1 \\ \zeta \\ \zeta^2 \\ \zeta^3 \\ \vdots \\ \zeta^{n-1} \\ \end{array} \right] = \left[ \begin{array}{c} \zeta^{n-1} \\ 1 \\ \zeta \\ \zeta^2 \\ \vdots \\ \zeta^{n-2} \\ \end{array} \right] = \zeta^{n-1} \cdot \left[ \begin{array}{c} 1 \\ \zeta \\ \zeta^2 \\ \zeta^3 \\ \vdots \\ \zeta^{n-1} \\ \end{array} \right],
\end{align*}
where the last equality is justified by noting that $\zeta^{n-1} \zeta^{k} = \zeta^n \zeta^{k-1} = \zeta^{k-1}$.

Consequently, if we plug in $(1, \zeta, \zeta^2, \ldots \zeta^{n-1})$ to the matrix $A_{C_n}$, we get

\begin{align*}
A_{C_n} (1, \zeta, \zeta^2, \ldots \zeta^{n-1})=& \left(A_{D_n} + A_{D_n}^T\right)  (1, \zeta, \zeta^2, \ldots \zeta^{n-1})\\
=& \left( \left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 0 \\
0 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 0 & 0 & 1 & \ldots & 0 \\
0 & 0 & 0 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 0 & 0 \\
\end{array} \right]  + \
\left[ \begin{array}{cccccc}
0 & 0 & 0 & 0 &\ldots  & 1 \\
1 & 0 & 0 & 0 & \ldots  & 0 \\
0 & 1 & 0 & 0 & \ldots & 0 \\
0 & 0 & 1 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
0 & 0  & 0 & \ldots & 1 & 0 \\
\end{array} \right] \right) \left[ \begin{array}{c} 1 \\ \zeta \\ \zeta^2 \\ \zeta^3 \\ \vdots \\ \zeta^{n-1} \\ \end{array} \right]\\
=& (\zeta + \zeta^{n-1})\left[ \begin{array}{c} 1 \\ \zeta \\ \zeta^2 \\ \zeta^3 \\ \vdots \\ \zeta^{n-1} \\ \end{array} \right].
\end{align*}

So $\zeta + \zeta^{n-1}$ is an eigenvalue, for every $\zeta \in \{1, e^{2\pi i/n}, e^{2\pi i 2/n}, \ldots, e^{2\pi i (n-1)/n}\}$.  But $\zeta \cdot \zeta^{n-1} = \zeta^n = 1$; so $\zeta^{n-1}$ is the multiplicative inverse of $\zeta$, i.e. $\frac{1}{\zeta} = \zeta^{n-1}$!  

Multiplicative inverses have some fairly beautiful properties in the complex numbers.  That is, suppose that $x+iy$ is a complex number with $||x + iy|| = 1;$ that is, with $x^2 + y^2 = 1$.  

Then
\begin{align*}
(x+iy)(x-iy) = x^2 + y^2 = 1;
\end{align*}
i.e. the multiplicative inverse of $x+iy$ is $x-iy$!  

Finally, notice that
\begin{align*}
e^{2\pi i k/n} = \cos(2\pi k/n) + i \sin (2 \pi k/n).
\end{align*} 

Therefore, for any $\zeta = e^{2\pi ik /n}$, we have
Finally, notice that
\begin{align*}
\zeta + \zeta^{n-1} = \zeta + \zeta^{-1} =& \cos(2\pi k/n) + i \sin (2 \pi k/n) + (\cos(2\pi k/n) + i \sin (2 \pi k/n))^{-1}\\
=& \cos(2\pi k/n) + i \sin (2 \pi k/n) + (\cos(2\pi k/n) - i \sin (2 \pi k/n))\\
=& 2\cos(2 \pi k/n).
\end{align*} 

This gives us a very nice form for our eigenvalues: for any $k \in \{0, 1, \ldots n-1\}$, we've proven that $2\cos(2\pi k/n)$ is an eigenvalue for $A_{C_n}$!  There are $n$ of these eigenvalues, so we know that there are no others and that each of these occur with multiplicity 1: i.e.
\begin{align*}
\textrm{Spec}(C_n) = \{ 2\cos(2\pi k/n) ~|~ k \in \{0,1,\ldots n-1\} \}.
\end{align*}
Cool!
\end{exmp}

So: we can calculate the spectra of various graphs, with varying degrees of effort.  Why do we care?  As it turns out, a number of very useful graph properties can be measured by looking at the spectra!  We study this in the following section:

\section{Applications of the Spectra}




In our introduction to graph theory course, pretty much the first interesting thing we did was characterize bipartite graphs.  As it turns out, we can do the same thing here in terms of the spectra:
\begin{proposition}
If a graph $G$ is bipartite, its spectrum is symmetric about 0; that is, for any bipartite graph $G$, $\lambda$ is an eigenvalue of $A_G$ if and only if $-\lambda$ is.
\end{proposition}
\begin{proof}
Write $G = (V_1 \cup V_2, E),$, where $V_1 = \{1,2,\ldots k\}$ and  $V_2 = \{k+1, k+2, \ldots n\}$ partition $G$'s vertices.   In this form, we know that the only edges in our graph are from $V_1$ to $V_2$.  Consequently, this means that $A_G$ is of the form
\begin{align*}
\begin{array}{|c|c|}
\hline
0 & B \\
\hline
B^T & 0 \\
\hline
\end{array},
\end{align*}
where the upper-left hand 0 is a $k \times k$ matrix, the lower-right hand 0 is a $n-k \times n-k$ matrix,  $B$ is a $(n - (k+1)) \times k$ matrix, and $B^T$ is the transpose of this matrix.

Choose any eigenvalue $\lambda$ and any eigenvector $(v_1, \ldots v_k, w_{k+1}, \ldots w_{n}) = (\mathbf{v}, \mathbf{w})$.  Then, we have
\begin{align*}
A_G \cdot (\mathbf{v}, \mathbf{w}) =
\begin{array}{|c|c|}
\hline
0 & B \\
\hline
B^T & 0 \\
\hline
\end{array} \cdot \left[ \begin{array}{c} \mathbf{v}\\ \mathbf{w} \end{array} \right] =  \left[ \begin{array}{c} B \cdot \mathbf{w} \\ B^T \cdot \mathbf{v} \end{array} \right] =   \left[ \begin{array}{c} \lambda\cdot \mathbf{v}\\ \lambda \cdot \mathbf{w} \end{array} \right] = \lambda \left[ \begin{array}{c} \mathbf{v}\\  \mathbf{w} \end{array} \right]
\end{align*}

But!  This is not the only eigenvector we can make out of $\mathbf{v}$ and $\mathbf{w}$.  Specifically, notice that if we multiply $A_G$ by the vector $(\mathbf{v}, -\mathbf{w})$, we get

\begin{align*}
A_G \cdot (\mathbf{v}, -\mathbf{w}) =
\begin{array}{|c|c|}
\hline
0 & B \\
\hline
B^T & 0 \\
\hline
\end{array} \cdot \left[ \begin{array}{c} \mathbf{v} \\ -\mathbf{w} \end{array} \right] =  \left[ \begin{array}{c} -B \cdot \mathbf{w} \\ B^T \cdot \mathbf{v} \end{array} \right] =   \left[ \begin{array}{c} -\lambda \cdot \mathbf{v} \\  \lambda \cdot \mathbf{w} \end{array} \right] = -\lambda \left[ \begin{array}{c} \mathbf{v}\\  -\mathbf{w} \end{array} \right].
\end{align*}
In other words, whenever $\lambda$ is an eigenvalue of $A_G$, $-\lambda$ is as well!
\end{proof}



As well, one of the next things we studied was how certain key properties (like $\chi(G)$) depended on the maximum degree of the graph, $\Delta(G)$.  As this provides an upper bound on the overall density of our graph, it seems like a natural candidate for something to bound our eigenvalues by.  We make this explicit in the following proposition:
\begin{proposition}
If $G$ is a graph and $\lambda$ is an eigenvalue of $A_G$, then $|\lambda| \leq \Delta(G)$.
\end{proposition}
\begin{proof}
Take any eigenvalue $\lambda$ of $A_G$, and let $\mathbf{v} = (v_1, \ldots v_n)$ be a corresponding eigenvector to $\lambda$.  Let $v_k$ be the largest co\"ordinate in $\mathbf{v}$, and (by scaling $\mathbf{v}$ if necessary) insure that $v_k = 1$.

We seek to show that $|\lambda| \leq \Delta(G)$.  To see this, simply look at the quantity $|\lambda \cdot v_k |$.  On one hand, we trivially have that this is $|\lambda|.$

On the other, we can use the observation that $\mathbf{v}$ is an eigenvector to notice that
\begin{align*}
|\lambda \cdot v_k | &= \left| (a_{k1}, a_{k2}, \ldots a_{kn}) \cdot (v_1, \ldots v_n) \right| \\
&= \left| \sum_{j=1}^n a_{kj} v_j \right| \leq \left| \sum_{j=1}^n a_{kj} v_k \right| = \left| v_k \sum_{j=1}^n a_{kj} \right| \\
&\leq \left| v_k \cdot \Delta(G) \right|  = \Delta(G).\\
\end{align*}
\end{proof}

When is the above bound tight?  With many graph properties (like, again, $\chi(G)$,) answering this question is usually difficult.  Here, however, it's actually quite doable, as we demonstrate in the next proposition:
\begin{proposition}
A connected graph $G$ is regular if and only if $\Delta(G)$ is an eigenvalue of $A_G$.
\end{proposition}
\begin{proof}
As this is an if and only if, we have two directions to prove.

($\Rightarrow$:)  If $G$ is regular, then each vertex in $G$ has degree $\Delta(G)$.  This means (amongst other things) that there are precisely $\Delta(G)$ 1's in every row of $A_G$.  Consequently, if we look at $A_G \cdot (1,1,1\ldots 1)$, we know that we get the vector $(\Delta(G), \Delta(G), \ldots \Delta(G))$: i.e. $\Delta(G)$ is an eigenvector!

($\Leftarrow$:)  As before, pick an eigenvector $\mathbf{v}$ for our eigenvalue $\Delta(G)$, let $v_k$ be the largest component of $\mathbf{v}$, and rescale $\mathbf{v}$ so that $v_k = 1$.  Then, just as before, we have
\begin{align*}
|\Delta(G)| &= |\Delta(G) \cdot v_k| = \left| (a_{k1}, \ldots a_{kn}) \cdot (v_1, \ldots v_n) \right|\\
&= \left| \sum_{i=1}^n a_{ki}v_i \right| \leq \left| \sum_{i=1}^n a_{ki}v_k \right| = \left| v_k\right| \left| \sum_{i=1}^n a_{ki} \right| = \deg(v_k) \\
&\leq \Delta(G),\\
\end{align*} 
and therefore $\deg(v) = \Delta(G)$.

But wait!   If the above is true, we actually have
\begin{align*}
|\Delta(G)|= \left| \sum_{i=1}^n a_{ki}v_i \right| = \Delta(G),\\
\end{align*} 
and therefore $v_i$ is equal to 1 for \textbf{every} $i$ adjacent to $k$!  Therefore, we can repeat the above argument for every $i$ adjacent to $k$, and show that the degree of all of these vertices are also $\Delta(G)$.  Repeating this process multiple times shows that the degree of \textbf{every} vertex is $\Delta(G)$, and therefore that $G$ is regular.
\end{proof}

In the proof above, we actually proved that $\Delta(G)$ was an eigenvalue of a connected graph $G$ if and only if $(1, \ldots 1)$ is an eigenvector of $A_G$!  In particular, the proof above shows that it is impossible for any $\vec{v}$ to be an eigenvector for $\Delta(G)$ without being a scalar multiple of $(1, \ldots 1)$.  This gives us a nice corollary:
\begin{cor}
If $\Delta(G)$ is an eigenvalue for $A_G$, then it has multiplicity 1.
\end{cor}


\begin{proposition}
If $G$ is a graph with diameter\footnote{The \textbf{diameter} of a graph $G$ is the longest distance between any two vertices in a graph.} $d \in \mathbb{N}$, then $A_G$ has at least $d + 1$ distinct eigenvalues.
\end{proposition}
\begin{proof}
First, recall the spectral theorem, which says that (because $A_G$ is real-valued and symmetric) we can find an orthonormal basis for $\mathbb{R}^n$ made out of $A_G$'s eigenvectors.  Let $\vec{e}_1, \ldots \vec{e}_n$ be such a basis of orthonormal eigenvectors, and let the collection of distinct eigenvalues of $A_G$ be $\theta_1, \ldots \theta_t$. 

Examine the product $D = (A_G - \theta_1 \cdot I)\cdot(A_G - \theta_2 \cdot I)\cdot\ldots (A_G - \theta_t \cdot I)$; specifically, notice that the order of the $\theta_i$'s doesn't matter in this above product, as
\begin{align*}
 &(A_G - \theta_1 \cdot I)\cdot(A_G - \theta_2 \cdot I)\cdot\ldots (A_G - \theta_t \cdot I)\\
 =& A_G^t - \left(\sum_{i=1}^n \theta_i\right)A_G^{t-1} + \ldots + (-1)^t\prod_{i=1}^t \theta_i \cdot I,\\
\end{align*}
and the $\theta$s in each of the coefficients above clearly commute.

What happens when we multiply $D$ on the right by any of these $\vec{e}_{i_t}$'s?  Well: if we permute the $(A_G-\theta I)$'s around so that $(A_G - \theta_{i_t} I)$ is the first term, we have
\begin{align*}
& (A_G - \theta_{i_1} \cdot I)\cdot(A_G - \theta_{i_2} \cdot I)\cdot\ldots (A_G - \theta_{i_t} \cdot I) \cdot e_{i_t}\\
=& (A_G - \theta_{i_1} \cdot I)\cdot(A_G - \theta_{i_2} \cdot I)\cdot\ldots \cdot (A_G\cdot e_{i_t} - (\theta_{i_t}\cdot I) \cdot e_{i_t} )\\
= &(A_G - \theta_{i_1} \cdot I)\cdot(A_G - \theta_{i_2} \cdot I)\cdot\ldots \cdot 0\\
=& 0.\\
\end{align*}

But this means that $D$ sends \textbf{all} of the $\vec{e}_i$'s to 0: i.e. that $D$ sends all of these basis vectors for $\mathbb{R}^n$ to 0!  In other words, this forces $D = 0$.

But what does this mean?  Using our expansion above of $D$ into a polynomial, we've just shown that
\begin{align*}
A_G^t - \left(\sum_{i=1}^n \theta_i\right)A_G^{t-1} + \ldots + \prod_{i=1}^t \theta_i \cdot I = 0,\\
\end{align*}
which means that 
\begin{align*}
A_G^t  =  \left(\sum_{i=1}^n \theta_i\right)A_G^{t-1} + \ldots - \prod_{i=1}^t \theta_i \cdot I. \\
\end{align*}

What would happen if the diameter $d$ is greater than $t - 1$?  It would mean that there are two vertices $i,j$ such that $d(i,j) = t$, at the very least!  But this would mean that the $(i,j)$-th entry of $A_G^t$ would be nonzero (as there is a path of length $t$ between them), while the $(i,j)$-th entry of $A_G^k$ would be zero for every $k < t$ (as there are no paths of shorter length linking them.)  But this is impossible, because we've written $A_G^t$ as the sum of these smaller matrices!  

Therefore, this cannot occur: i.e. we have $d \leq t-1$, which is what we wanted to prove.
\end{proof}

These properties are great; but they're not why I wanted to run these lectures.  Instead, this is why I wanted to run this lecture:

\section{The Petersen Graph}
\begin{center}
\includegraphics[width=5in]{petersen.pdf}
\end{center}
Just \textbf{look} at it.\\
\ldots \\
So cool!\\
\ldots \\
\ldots anything else like it?
\subsection{Yes!}

What do we mean by ``like\footnote{Do we mean ``like,'' or ``\textbf{like}-like?''}?'' What properties does the Petersen graph have that we'd like to find in other graphs?  

Well, one nice property it has is that it's \textbf{regular}: i.e. all of its vertices have degree 3.  Furthermore, it's \textbf{really} regular: if you look at any two adjacent vertices, they have no neighbors in common, and if you look at any two nonadjacent vertices, they have precisely one vertex in common.  

Because this is such an awesome property, let's give it a name!  Call such graphs \textbf{strongly regular} graphs (SRGs,) with parameters $(n,k,\lambda, \mu)$, if they have 
\begin{itemize}
\item $n$ vertices,
\item are regular with degree $k$,
\item every pair of adjacent vertices have $\lambda$ neighbors in common, and
\item every pair of nonadjacent vertices have $\mu$ neighbors in common.
\end{itemize}

In this notation, the Petersen graph is a $(10,3,0,1)$-SRG.

There are a few degenerate cases of SRG's: we note them here, and recommend that you check the validity of these claims on your own.
\begin{enumerate}
\item If $\mu = 0$, then $G$ is a disjoint union of $K_{k+1}$'s.
\item If $k = n-1$, then $G$ is $K_n$; if $k = 0$, then $G$ is a disjoint union of isolated vertices.
\item If $\lambda = k-1,$ then $G$ is a disjoint union of $K_k$'s.
\end{enumerate}

Apart from these cases, what can we say about these Petersen-like graphs?  We study this in the next section:
\subsection{The Integrality Conditions}
Strongly regular graphs, as it turns out, are \textbf{magic}.  We make this rigorous through the next three lemmas:

\begin{lemma}
Suppose that $G$ is a strongly regular graph, with parameters $(n,k\lambda, \mu)$.  Then $A_G$ has at most three distinct eigenvalues.
\end{lemma}
\begin{proof}
Consider $A_G^2$.  Specifically, consider $(A_G^2)_{ij}$, which we can write as
\begin{align*}
(a_{i1}, \ldots a_{in}) \cdot \left( \begin{array}{c} a_{1j} \\ \vdots \\ a_{nj} \\ \end{array}  \right) &= \sum_{i=1}^n a_{ik}a_{kj}. \\
\end{align*}
What is this?  
\begin{itemize}
\item If $i=j$, then we have that this is just the number of elements adjacent to vertex $i$, which is $k$ because our graph is regular.
\item If $(v_i, v_j)$ is an edge in our graph, then the elements $a_{ik}a_{kj}$ of this sum are nonzero precisely where $v_k$ is a common neighbor of $v_i$ and $v_j$; so this counts the number of common neighbors to $v_i$ and $v_j$, and is thus $\lambda.$
\item If $(v_i, v_j)$ is \textbf{not} edge in our graph, then the elements $a_{ik}a_{kj}$ of this sum are still nonzero precisely where $v_k$ is a common neighbor of $v_i$ and $v_j$; so this counts the number of common neighbors to $v_i$ and $v_j$, and is thus $\mu$.
\end{itemize}
So, in other words, we've just proven that 
\begin{align*}
A_G^2 &= k \cdot I + \lambda \cdot A_G + \mu \cdot A_{\overline{G}}\\
&= k \cdot I + \lambda \cdot A_G + \mu \cdot \left(J - I - A_G \right) \\
&= (k - \mu) \cdot I + (\lambda - \mu) \cdot A_G + \mu \cdot J, \\
\end{align*}
where $J$ is the all-1's matrix.

This looks suspiciously like a quadratic equation!  Except, you know, with matrices.  Does this form mean that our matrix can only have three eigenvalues?   Well: let's see!   Recall from earlier in the course that if $G$ is a $k$-regular graph, then the all-1's vector is an eigenvector for its adjacency matrix with eigenvalue $k$: this is because $A_G \cdot (1,\ldots 1)$ returns a vector with entries corresponding to the degrees of the vertices in $G$.   By the spectral theorem, we know that $A_G$ has an orthogonal basis of eigenvectors, and furthermore that we can pick such a basis that contains $(1,\ldots 1)$ as an element.

Choose any \textbf{other} eigenvalue $s$ and let  $\mathbf{y}$ be its corresponding eigenvector.  I claim that $\mathbf{y}$ is orthogonal to the all-1's vector; and in general that if $\vec{v}, \vec{w}$ are eigenvectors for different eigenvalues $\lambda, \theta$ then $\vec{v}, \vec{w}$ will be orthogonal.  

This is not hard to prove:  
\begin{lem}
If $A$ is a $n \times n$ symmetric matrix with eigenvector/value pairs $\vec{v}, \lambda$ and $\vec{w}, \theta$ with $\lambda \neq\theta$, then $\vec{v}$ is orthogonal to $\vec{w}$: that is, $\vec{v} \cdot \vec{w} = 0$.
\end{lem}
\begin{proof}
This is not too hard to see.  Notice that
\begin{align*}
\vec{v} \cdot \left( A \vec{w} \right) = \vec{v} \cdot (\theta \vec{w}) = \theta (\vec{v} \cdot \vec{w}),
\end{align*}
and also that
\begin{align*}
\vec{w} \cdot \left( A \vec{v} \right) = \vec{w} \cdot (\lambda \vec{v}) = \lambda (\vec{w} \cdot \vec{v}).
\end{align*}

However, by taking the transpose, we can see that
\begin{align*}
\left( \vec{w}  \cdot \left( A \vec{v} \right)  \right)^T &= \left( \begin{bmatrix} w_1 & \ldots & w_n \end{bmatrix} \begin{bmatrix} a_{11} & \ldots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{n1} & \ldots & a_{nn} \end{bmatrix} \begin{bmatrix} v_1 \\ \vdots \\ v_n \end{bmatrix} \right)^T\\
 &=  \begin{bmatrix} v_1 \\ \vdots \\ v_n \end{bmatrix}^T \begin{bmatrix} a_{11} & \ldots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{n1} & \ldots & a_{nn} \end{bmatrix}^T  \begin{bmatrix} w_1 & \ldots & w_n \end{bmatrix} ^T\\
&=\vec{v} \cdot (A^T \vec{w}),
\end{align*}
where we use the property that $(AB)^T = B^T A^T$ (which you may want to prove for the HW this week!)

But $A^T = A$ because $A$ is symmetric; so we actually have shown that $\vec{v} \cdot (A \vec{w}) = (\vec{w}  \cdot \left( A \vec{v}\right))^T$.  But $(\vec{w}  \cdot \left( A \vec{v}\right))^T = \vec{w}  \cdot \left( A \vec{v}\right)$, because the quantity in parentheses is a $1 \times 1$ matrix!  

Therefore, we can conclude that $\theta (\vec{v} \cdot \vec{w}) = \lambda (\vec{v} \cdot \vec{w})$; this forces $\vec{v} \cdot \vec{w} = 0$ whenever $\theta \neq \lambda$.

\end{proof}

We use this lemma here on our chosen eigenvector $\vec{y}$ for an eigenvalue $\neq k$.  This eigenvector by the above argument is orthogonal to $(1,\ldots 1)$, as this is an eigenvector for $k$; so in particular we have $J \vec{y} = \vec{0}$, as each column of $J$ is just an all-1's vector!  This tells us that
\begin{align*}
A_G^2\mathbf{y} &= \left((k - \mu) \cdot I + (\lambda - \mu) \cdot A_G + \mu \cdot J\right)\mathbf{y}\\
 &= (k - \mu) \cdot I\mathbf{y} + (\lambda - \mu) \cdot A_G\mathbf{y}  + \mu \cdot J\mathbf{y}\\
 &= (k - \mu)\mathbf{y} + (\lambda - \mu) \cdot s \mathbf{y}  + 0.\\
\end{align*}
On the other hand, because $\vec{y}$ is an eigenvector, we have
\begin{align*}
A_G^2\mathbf{y} = s\cdot A_G \mathbf{y} = s^2\mathbf{y}.
\end{align*}
Combining these results, we have that 
\begin{align*}
s^2 = s(\lambda - \mu) + (k-\mu),
\end{align*}
which we know has precisely two solutions:
\begin{align*}
\frac{(\lambda - \mu) \pm \sqrt{(\lambda - \mu)^2 + 4(k - \mu)}}{2}.
\end{align*}
So there are at most three eigenvalues:
\begin{align*}
k, \frac{(\lambda - \mu) \pm \sqrt{(\lambda - \mu)^2 + 4(k - \mu)}}{2}.
\end{align*}
\end{proof}


\begin{lemma}
Suppose that $G$ is a strongly regular graph, with parameters $(n,k,\lambda, \mu)$, and that we're not in any of our degenerate cases (i.e. $\mu > 0, k < n-1, \lambda < k-1.$) Then the three eigenvalues of $A_G$ have multiplicities 
\begin{align*}
1, \frac{1}{2}\left(n-1 \pm \frac{(n-1)(\mu-\lambda) - 2k}{\sqrt{(\mu-\lambda)^2 + 4(k-\mu)}}   \right).
\end{align*}
In particular, these quantities are \textbf{integers}.
\end{lemma}
\begin{proof}
First, notice that the eigenvalue $k$ has multiplicity 1, as proven earlier in the notes.  So it suffices to find the other multiplicities.

The only other eigenvalues, as proven above, are
\begin{align*}
\frac{(\lambda - \mu) + \sqrt{(\lambda - \mu)^2 + 4(k - \mu)}}{2},  \frac{(\lambda - \mu) - \sqrt{(\lambda - \mu)^2 + 4(k - \mu)}}{2}= r,s.
\end{align*}
Let $a$ be the multiplicity of the $r$ eigenvalue, and $b$ the multiplicity of the $s$ eigenvalue.   On the homework, you will (hopefully!) prove the following lemma:
\begin{lem}
Suppose that $A$ is a $n \times n$ matrix with $n$ eigenvalues $\lambda_1, \ldots \lambda_n$ counted with multiplicity.  Then the \textbf{trace}\footnote{The \textbf{trace} of a matrix $A$ is simply the sum $\sum_{i=1}^n a_{ii}$ of the elements on the diagonal of $A$.} of $A$ is equal to the sum of these eigenvalues; that is,
\begin{align*}
\sum_{i=1}^n a_{ii} = \sum_{i=1}^n \lambda_i.
\end{align*}
\end{lem}
Applying this theorem to $A_G$ for any adjacency matrix tells us in particular that the sum of all of the eigenvalues for any adjacency matrix of a graph is 0, as our graphs do not have loops (and therefore all of the entries on the diagonal of $A_G$ are 0.)

So, here, it tells us that
\begin{align*}
k + ra + sb = 0,
\end{align*}
as our $A_G$ has $k$ as an eigenvalue once, $r$ as an eigenvalue $a$ times, and $s$ as an eigenvalue $b$ times.

As well, because there are $n$ eigenvalues counting multiplicity, we know that
\begin{align*}
1 + a + b = n.
\end{align*}
Combining, this forces
\begin{align*}
a = -\frac{k+s(n-1)}{r-s}, b = \frac{k+r(n-1)}{r-s};
\end{align*}
i.e.
\begin{align*}
a,b =  \frac{1}{2}\left(n-1 \pm \frac{(n-1)(\mu-\lambda) - 2k}{\sqrt{(\mu-\lambda)^2 + 4(k-\mu)}}   \right).
\end{align*}
\end{proof}
\begin{lemma}
For a strongly regular graph as above, we have
\begin{align*}
k(k-\lambda - 1) = \mu(n-k-1).
\end{align*}
\end{lemma}
\begin{proof}

This is not hard to see!  Take any vertex $v \in G$, and consider counting triples of the form $\{v, w_1, w_2\}$ where $\{v, w_1\}, \{w_1, w_2\} \in E(G), \{v, w_2\} \notin E(G)$.  (I.e. count paths of length 2 starting at $v$, where these paths don't come from subgraphs of triangles.)

On one hand, if we count the $w_1$ choices first and then the $w_2$ choices, we can see that there are $k$ choices of $w_1$ (as $v$ has $k$ neighbors by definition) and for each $w_1$, $k-\lambda - 1$ many follow-up choices of $w_2$ (as each $w_1$ is connected to $k$ more vertices, of which we discard $\lambda$ choices that would form a triangle, and also discard the choice corresponding to choosing $v$.)

On the other, if we choose $w_2$ first, we have $n-k-1$ many choices, as there are $k$ vertices connected to $v$ and thus $n-k-1$ left over that are not connected to $v$.  From here, we want to choose for each $w_2$ a $w_1$ connected to both $w_2, v$: i.e. a mutual neighbor to two nonadjacent vertices.  There are $\mu$ such choices.

These quantities count the same number; therefore they are equal, and we have proven our claim!
\end{proof}

\begin{lemma}
If $r,s$ as above are not integers, then $a=b$, and our strongly regular graph is specifically of the form $(4t+1, 2t, t-1, t)$ if it's not degenerate.
\end{lemma}
\begin{proof}
If $a \neq b$, then the numerator in the fraction part of each multiplicity must be nonzero (to make them distinct); this forces the denominator part of each of these fractions to be rational, which in turn forces $r,s$ to be rational.  But if $r,s$ are a pair of rational roots to a monic polynomial with integer coefficients, they must be in fact integers!

So, the only other case left to us is when $a=b$.  In this case, we have 
\begin{align*}
0 &= \frac{1}{2}\left(n-1 + \frac{(n-1)(\mu-\lambda) - 2k}{\sqrt{(\mu-\lambda)^2 + 4(k-\mu)}}   \right) - \frac{1}{2}\left(n-1 - \frac{(n-1)(\mu-\lambda) - 2k}{\sqrt{(\mu-\lambda)^2 + 4(k-\mu)}}   \right)\\
\Rightarrow 0 &= \frac{(n-1)(\mu-\lambda) - 2k}{\sqrt{(\mu-\lambda)^2 + 4(k-\mu)}}\\
\Rightarrow 0 &= (n-1)(\mu-\lambda) - 2k\\
\Rightarrow 2k &= (n-1)(\mu-\lambda).\\
\end{align*}
What does this force?  Well: if $\mu - \lambda \geq 2$, we'd have to have $k \geq n-1$, which we disallowed as a degenerate case.  So we must have $\mu- \lambda = 1,$ (as otherwise forces $k = 0$, which is also a degenerate case.)  This forces $n = 2k+1$, and thus that (by the third lemma) we have
\begin{align*}
k(k-\lambda - 1) &= \mu(n-k-1) = \mu k \\
\Rightarrow k - \lambda  -1 &= \mu  \\
\Rightarrow k - 2\lambda - 1 &= (\mu - \lambda)  = 1\\
\Rightarrow k -2&= 2\lambda  \\
\Rightarrow (k/2) - 1 &= \lambda.\\
\end{align*}

In particular, if we set $t = \lambda + 1$, we get that our graph is of the form $(4t+1, 2t, t-1, t)$.
\end{proof}

This gives us a particularly nice corollary:
\begin{cor}
If $G$ is a strongly regular graph not of the form $(4t+1, 2t, t-1, t)$, then all of $G$'s eigenvalues are integers.
\end{cor}


\subsection{Petersen-Like Graphs}

So: when we started this section we did so in the hopes of finding more graphs that are ``like'' the Petersen graph.  With the language of strongly regular graphs, we can perhaps be a bit more precise: the Petersen graph is a $(10, 3, 0, 1)$.  For what other values of $n, k$ can we find a $(n, k, 0 ,1)$ strongly regular graph?

Well: by the above, the only such graph with non-integer eigenvalues is a $(5,2,0,1)$ -- that is, a pentagon!  

What can we say for the graphs that have integer eigenvalues?  Well: if we use the relation
\begin{align*}
k(k-\lambda - 1) = \mu(n-k-1)
\end{align*}
we derived earlier, and plug in $\lambda = 0, \mu = 1,$ we get $n = k^2 + 1.$

That's something.  What else can we get?  Well: if $r,s$ are integers, then in specific the denominator 
\begin{align*}
 \sqrt{(\lambda - \mu)^2 + 4(k - \mu)}
 \end{align*}
must also be an integer.  In specific, because $\lambda = 0, \mu = 1$, this means that $\sqrt{4k -3}$ is an integer: i.e. that $4k-3$ is a square of some integer!  Denote this square as $s$, and by solving for $k$ write $k = \frac{1}{4}(s^2 + 3)$.  Then, if you plug first our formula $n = k^2 + 1$ and then this formula $k = \frac{1}{4}(s^2 + 3)$ into the formula for one of our multiplicities (say the one for $r$), we get
\begin{align*}
a &= \frac{1}{2}\left(n-1 + \frac{(n-1)(\mu-\lambda) - 2k}{\sqrt{(\mu-\lambda)^2 + 4(k-\mu)}}   \right)\\
& = \frac{1}{2} \left( (k^2 + 1) - 1 + \frac{(k^2 + 1 - 1)(1) - 2k}{\sqrt{4k-3}} \right) \\
& = \frac{1}{2} \left( \frac{1}{16}(s^2+3)^2 + \frac{\frac{1}{16}(s^2+3)^2 - \frac{1}{2}(s^2+3)}{s} \right) \\
\Rightarrow 32a \cdot s &= s(s^2 + 3)^2 + (s^2+3)^2 - 8(s^2 + 3) \\
&= s^5 + s^4 + 6s^3 - 2s^2 + 9s - 15 \\
\Rightarrow 15 &= s^5 + s^4 + 6s^3 - 2s^2 + (9 - 32a)s\\
 &= s\left( s^4 + s^3 + 6s^2 - 2s + (9 - 32a)\right).\\
\end{align*}
Because all of the quantities on the right-hand-side above are integers, we must have that $s$ divides $15$: i.e. $s$ can be one of $1,3,5,$ or $15$, which forces $k$ to be one of $1,3,7, 57$.  Plugging in, using our identity $n = k^2 + 1$, and remembering the pentagon which we already considered, we can see that any possible $(n,k,0,1)$ graph must have one of the following five parameter sets:
\begin{align*}
(2,1,0,1), (5,2,0,1), (10,3,0,1), (50, 7,0,1), (3250, 57, 0,1).
\end{align*}
The first is just $K_2$; the second is $C_5$, a pentagon; and the third is the Petersen graph.  How about the fourth?
\section{A Really Pretty Picture}
\begin{center}
\includegraphics[width=5.5in]{hoffman_singleton.pdf}
\end{center}
This graph is the \textbf{Hoffman-Singleton} graph\footnote{Roughly speaking, it's a bunch of Petersen graphs inside of Petersen graphs.  Depending on which meme you prefer, you can caption this as either ``Peteception'' or ``Yo dawg, I heard you like the Petersen graph so I put a Petersen graph in your Petersen graph so you can disprove conjectures while you disprove conjectures.'' }, and is formed as follows: Take five stars $P_0, \ldots P_4$ and five pentagons $Q_0, \ldots Q_4$.  Enumerate the vertices of each pentagon and star in counterclockwise order as $0,1,2,3,4$, and  for every $i,j,k$ connect the vertex $i$ in $P_j$ to the vertex $i + jk$ in $Q_k$.

Gorgeous!  This leaves just one set of parameters to study: $(3250, 57, 0,1)$.  Determining whether a SRG exists with these parameters is\ldots surprisingly, an open problem!  (In general, determining which sets of parameters admit strongly regular graphs is an open problem: see \href{http://math.ucsb.edu/~padraic/ucsb_2014_15/ccs_problem_solving_w2015/ccs_problem_solving_w2015_project_srgs.pdf}{this project description} from the Winter Problem-Solving course, and \href{http://www.win.tue.nl/~aeb/graphs/srg/srgtab.html}{this table} of known results and open problems!

\end{document}