\documentclass[12pt]{article}
\author{David Alves}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{dirtytalk}
\usepackage[a4paper]{geometry}
\usepackage{forest}
\usepackage{listings}
\usepackage{mathtools}
\usepackage{nth}
\usepackage{relsize}
\usepackage{skak}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{titling}
\usepackage{wrapfig}
\usepackage{xcolor}

\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{patterns}

\def\multichoose#1#2{\ensuremath{\left(\kern-.3em\left(\genfrac{}{}{0pt}{}{#1}{#2}\right)\kern-.3em\right)}}

\newcommand{\ts}[1]{\textsuperscript{#1}}

\newcommand{\ProblemStatement}[1]{
\subsection*{Problem Statement}
#1
\subsection*{Solution}
}

% If uncommented, next line hides problem statements
%\renewcommand{\ProblemStatement}[1]{}

\title{Math 142 Problem Set 10}
\author{David Alves}
\date{2016-11-03}

\begin{document}
\pagenumbering{gobble}

\begin{center}
\large \thetitle \\
\theauthor \\
\thedate
\end{center}

\subsection*{Sources}

    \begin{itemize}
    \item http://tex.stackexchange.com and https://www.sharelatex.com for help with \LaTeX
    \end{itemize}

\section{Stirling Numbers}
\ProblemStatement{
For general $n$, what are the Stirling numbers of the second kind $S(n,0)$, $S(n,1)$, and $S(n,2)$?
}

The Stirling number of the second kind $S(n,k)$ can be defined as the number of ways to put $n$ distinguishable balls into $k$ indistinguishable bins such that each bin contains at least one ball.

\subsubsection{$n$ Balls into Zero Bins}
\[
    S(n, 0) =
    \begin{cases}
        1&: n=0\\
        0&: n \ge 1
    \end{cases}
\]

For $S(0,0)$, there is one way to put zero balls into zero bins such that all bins have at least one ball (it is vacuously true that all zero bins contain at least one ball). For one or more balls, it is impossible to place them into bins since there are zero bins, therefore $S(n, 0) = 0: n \ge 1$.

\subsubsection{$n$ Balls into One Bin}
\[
    S(n, 1) =
    \begin{cases}
        0&: n=0\\
        1&: n \ge 1
    \end{cases}
\]

For $S(0, 1)$, there is no way to put zero balls into one bin such that the bin contains at least one ball. For $S(n, 1): n \ge 1$, there is one choice for each ball, so there is one choice by the product principle.

\subsubsection{$n$ Balls into Two Bins}
\[
    S(n, 2) =
    \begin{cases}
        0&: n=0, 1\\
        2^{n-1}-1&: n \ge 2
    \end{cases}
\]

For $S(0, 2)$ and $S(1, 2)$, there are no ways to put the balls into the bins such that each bin contains at least one ball because there are not enough balls. For $S(n, 2): n \ge 2$, there is only one choice for the first ball because the bins are indistinguishable. After placing the first ball, the bins become distinguishable. Label the bins $A$, which contains the first ball, and $B$, which does not. Thus we must place the remaining $n-1$ balls into 2 distinguishable bins. There are $2^{n-1}$ ways to do so by the product principle. Out of those $2^{n-1}$ configurations, there is exactly one which is not legal: the one which places all $n-1$ balls into $A$, since that leaves $B$ empty. Every other configuration places at least one ball into $B$, and $A$ already has one ball. Thus there are $2^{n-1}-1$ ways to place $n$ balls into 2 bins for $n >= 2$ such that each bin contains at least one ball.

\section{Counting Primes}
\ProblemStatement{
Find the number of primes less than or equal to 111. (Hint: the number of integers 1 through $n$ divisible by $k$ is $\floor{\frac{n}{k}}$. You can take it for granted that all composite numbers less than 111 are divisible by at least one of 2, 3, 5 or 7
}

There are 29 primes in $[1, 111]$.

\begin{proof}
We solve this using the inclusion-exclusion principle. Let $D_n$ be the set of positive integers less than or equal to 111 that are divisible by $n$. By the inclusion-exclusion principle, we know that

\newcommand{\dlist}[1]{D_{#1}}
\begin{multline*}
    |\dlist{2} \cup \dlist{3} \cup \dlist{5} \cup \dlist{7}| = |\dlist{2}| + |\dlist{3}| + |\dlist{5}| + |\dlist{7}|\\
    -|\dlist{2} \cap \dlist{3}| - |\dlist{2} \cap \dlist{5}| - |\dlist{2} \cap \dlist{7}| - |\dlist{3} \cap \dlist{5}| - |\dlist{3} \cap \dlist{7}| - |\dlist{5} \cap \dlist{7}|\\
    +|\dlist{2} \cap \dlist{3} \cap \dlist{5}| + |\dlist{2} \cap \dlist{3} \cap \dlist{7}| + |\dlist{2} \cap \dlist{5} \cap \dlist{7}| + |\dlist{3} \cap \dlist{5} \cap \dlist{7}|\\
    -|\dlist{2} \cap \dlist{3} \cap \dlist{5} \cap \dlist{7}|
\end{multline*}

The size of an individual set $|D_k| = \floor{\frac{111}{k}}$. The intersection of two sets $D_i$ and $D_j$ is all numbers divisible by both, which is therefore $|D_i \cap D_j| = |D_{ij}| = \floor{\frac{111}{ij}}$. Thus the above equation simplifies to

\newcommand{\dfloor}[1]{\floor*{\frac{111}{#1}}}
\begin{multline*}
    |\dlist{2} \cup \dlist{3} \cup \dlist{5} \cup \dlist{7}| = \dfloor{2} + \dfloor{3} + \dfloor{5} + \dfloor{7}\\
    -\dfloor{2\times3} - \dfloor{2\times5} - \dfloor{2\times7} - \dfloor{3\times5} - \dfloor{3\times7} - \dfloor{5\times7}\\
    +\dfloor{2\times3\times5} + \dfloor{2\times3\times7} + \dfloor{2\times5\times7} + \dfloor{3\times5\times7} -\dfloor{2\times3\times5\times7}
\end{multline*}

\begin{multline*}
    |\dlist{2} \cup \dlist{3} \cup \dlist{5} \cup \dlist{7}| = 55 + 37 + 22 + 15 - 18 - 11 - 7 - 7 - 5 - 3\\
    +3 + 2 + 1 + 1 - 0 = 85
\end{multline*}

Thus there are 85 numbers less than or equal to 111 that are divisible by 2, 3, 5, or 7, leaving 111-85=26 numbers which are not. One of these 26 numbers is 1, which is defined as not prime, leaving 25 which are primes. Additionally, the numbers 2, 3, 5 and 7 are all prime but are in $\dlist{2} \cup \dlist{3} \cup \dlist{5} \cup \dlist{7}$. Thus we have $26-1+4 = 29$ primes in $[1, 111]$.
\end{proof}

\section{Spider Socks}
\ProblemStatement{
A spider has 8 different feet, 8 different socks, and 8 different shoes. Find the number of orders that the spider can put on socks and shoes such that all socks and shoes are put on once and the $n\ts{th}$ sock is put on before the $n\ts{th}$ shoe for all $n$. Note that any sock can go on any foot and any shoe can go on any foot.}
There are $\frac{8!^216!}{2^8}$ different valid orders.

\begin{proof}
Let the $n\ts{th}$ shoe be $S_n$ and the $n\ts{th}$ sock be $O_n$. Suppose we wanted to always place the $n\ts{th}$ sock onto the $n\ts{th}$ foot and the $n\ts{th}$ shoe onto the $n\ts{th}$ foot. Then we would want to find all lists consisting of the elements $S_1, S_2, \dots, S_8$, $O_1, O_2, \dots, O_8$ once each in some order such that $O_n$ comes before $S_n$ for all $n$. There are $16!$ permutations of the 16 elements in the list. We then need to divide by two for each $O_i, S_i$ pair by the quotient principle since regardless of whether the sock or shoe comes first when considering that pair, we only want to count one relative ordering of that sock and shoe. This gives a a total of $\frac{16!}{2^8}$ valid orders where the positions of the socks and shoes are fixed. We then multiply by $8!^2$ to account for all the permutations of which sock goes on which foot and which shoe goes on which foot, giving a total of $\frac{8!^216!}{2^8}$.
\end{proof}

\section{Five Coins}
\ProblemStatement{
You and your friend flip 5 fair and independent coins in a row. If any two consecutive coins are HT in order, you score a \say{hit}. If any two consecutive coins are TT in order, your friend scores a \say{hit}. What's the probability that you score one or more hits and your friend does not? What's the probability that you and your friend both score one or more hits?
}

The probability that you and your friend both \say{hit} and the probability that you \say{hit} while your friend does not are both $\frac{21}{32}$.

\begin{proof}
The figure below systematically enumerates all possible sequences of flips. Each state consists of a sequence so far, with the upper and lower outgoing edges indicating heads and tails on the next flip, respectively. States in bold indicate you have gotten at least one \say{hit} so far, while underlined states indicate that your friend has gotten at least one \say{hit} so far. After 5 flips, there are $2^5 = 32$ outcomes. There are 21 outcomes where you have gotten a \say{hit} and your friend has not, and 21 outcomes where you and your friend have both gotten a \say{hit}. Since the five coins are independent and fair, the 32 possible outcomes are equally likely and thus each have probability $\frac{1}{32}$. Since the outcomes are disjoint, the probability of any of them happening is the sum of their individual probabilities, giving $\frac{21}{32}$ as the total. Thus the probability that you and your friend both \say{hit} and the probability that you \say{hit} while your friend does not are both $\frac{21}{32}$.
\end{proof}

\scalebox{0.70}{
\begin{forest}
  for tree={
    grow'=0,
    child anchor=west,
    parent anchor=east,
    anchor=west,
    calign=center,
    inner ysep=0.0pt,
    fit=band,
    before computing xy={l=110pt},
  }
[Initial State
[$H$
    [$HH$
        [$HHH$
            [$HHHH$
                [$HHHHH$ ]
                [$\textbf{HHHHT}$ ]
            ]
            [$\textbf{HHHT}$
                [$\textbf{HHHTH}$ ]
                [$\underline{\textbf{HHHTT}}$ ]
            ]
        ]
        [$\textbf{HHT}$
            [$\textbf{HHTH}$
                [$\textbf{HHTHH}$ ]
                [$\textbf{HHTHT}$ ]
            ]
            [$\underline{\textbf{HHTT}}$
                [$\underline{\textbf{HHTTH}}$ ]
                [$\underline{\textbf{HHTTT}}$ ]
            ]
        ]
    ]
    [$\textbf{HT}$
        [$\textbf{HTH}$
            [$\textbf{HTHH}$
                [$\textbf{HTHHH}$ ]
                [$\textbf{HTHHT}$ ]
            ]
            [$\textbf{HTHT}$
                [$\textbf{HTHTH}$ ]
                [$\underline{\textbf{HTHTT}}$ ]
            ]
        ]
        [$\underline{\textbf{HTT}}$
            [$\underline{\textbf{HTTH}}$
                [$\underline{\textbf{HTTHH}}$ ]
                [$\underline{\textbf{HTTHT}}$ ]
            ]
            [$\underline{\textbf{HTTT}}$
                [$\underline{\textbf{HTTTH}}$ ]
                [$\underline{\textbf{HTTTT}}$ ]
            ]
        ]
    ]
]
[$T$
    [$TH$
        [$THH$
            [$THHH$
                [$THHHH$ ]
                [$\textbf{THHHT}$ ]
            ]
            [$\textbf{THHT}$
                [$\textbf{THHTH}$ ]
                [$\underline{\textbf{THHTT}}$ ]
            ]
        ]
        [$\textbf{THT}$
            [$\textbf{THTH}$
                [$\textbf{THTHH}$ ]
                [$\textbf{THTHT}$ ]
            ]
            [$\underline{\textbf{THTT}}$
                [$\underline{\textbf{THTTH}}$ ]
                [$\underline{\textbf{THTTT}}$ ]
            ]
        ]
    ]
    [$\underline{TT}$
        [$\underline{TTH}$
            [$\underline{TTHH}$
                [$\underline{TTHHH}$ ]
                [$\underline{\textbf{TTHHT}}$ ]
            ]
            [$\underline{\textbf{TTHT}}$
                [$\underline{\textbf{TTHTH}}$ ]
                [$\underline{\textbf{TTHTT}}$ ]
            ]
        ]
        [$\underline{TTT}$
            [$\underline{TTTH}$
                [$\underline{TTTHH}$ ]
                [$\underline{\textbf{TTTHT}}$ ]
            ]
            [$\underline{TTTT}$
                [$\underline{TTTTH}$ ]
                [$\underline{TTTTT}$ ]
            ]
        ]
    ]
]
]
\end{forest}
}

\section{Choosing Compositions}
\ProblemStatement{
Prove that for any fixed positive integer $k$, each positive integer $n$ has a unique representation in the form
\[
    n = \binom{b_1}{1} + \binom{b_2}{2} + \binom{b_3}{3} +\dots + \binom{b_k}{k}
\]
where $0 \le b_1 < b_2 < \dots < b_k$.
}

We prove this by providing a method to construct such a representation given $n$ and $k$.
We know that $\binom{b_k}{k} \le n$ because each of the terms $\binom{b_1}{1} + \binom{b_2}{2} + \binom{b_3}{3} +\dots + \binom{b_{k-1}}{k-1}$ is greater than or equal to zero, therefore their sum must be greater than or equal to zero. Let $c_k$ be the largest integer such that $\binom{c_k}{k} \le n$.

We prove that $b_k = c_k$ by contradiction. Assume $b_k$ = $c_k - 1$. Then the largest possible value for $b_{k-1}$ is $c_k-2$, the largest possible value for $b_{k-2}$ is $c_k-3$, etc. This gives $\sum_{i=1}^{k} \binom{c_k-i}{k+1-i} \ge n$. We know that the sum of diagonal elements in Pascal's triangle is $\binom{n}{k} = \sum_{i=1}^{n} \binom{n-i}{k+1-i}$. Thus we have
\begin{align*}
    \binom{c_k}{k} &= \left(\sum_{i=1}^{k} \binom{c_k-i}{k+1-i}\right)+\left(\sum_{i=k+1}^{n} \binom{c_k-i}{k+1-i}\right)\\
    \binom{c_k}{k} - \left(\sum_{i=k+1}^{n} \binom{c_k-i}{k+1-i}\right)&= \left(\sum_{i=1}^{k} \binom{c_k-i}{k+1-i}\right) \ge n\\
    \binom{c_k}{k} - \left(\sum_{i=k+1}^{n} \binom{c_k-i}{k+1-i}\right)&\ge n\\
    \binom{c_k}{k} &\ge n + \left(\sum_{i=k+1}^{n} \binom{c_k-i}{k+1-i}\right)
\end{align*}
$\sum_{i=k+1}^{n} \binom{c_k-i}{k+1-i}$ (need to demonstrate this) is positive, therefore this contradicts our definition of $c_k \le n$. Thus our assumption must be false, and $b_k$ must be $c_k$ since the maximal value when $b_k < c_k$ is too low. Therefore we know $b_k$ = $c_k$ and can apply the same logic recursively for $b_{k-1} = c_{k-1}$, etc. all the way down to $b_1$. Thus we have shown that there is only one choice for each $b_x$ term, so the solution if it exists is unique.

(This proves uniqueness but not existence. Unfortunately I don't have time to finish this proof.)

\section{Time Spent \& Thoughts}
Problems 1-4 weren't very hard but some of them took a long time to write up correctly. I was very unsure about how we were supposed to write up 4 -- are we supposed to start from first principles like the definition of probability measure, or is it ok to gloss over a lot of intuitive stuff? Since we haven't had a probability problem before I wasn't really sure what to do. I probably spent about 10 hours on 1-4.
Problem 5 was very hard but was interesting. I wrote a program to check for counterexamples and then reworked it to print out how various numbers are decomposed which helped lead me towards a solution, but wasn't able to finish the proof.
\end{document}


\subsection{Preliminaries}
  We now move on to some preliminary definitions and results.
  \subimport{common/definitions/}{trustreduction.tex}

  \subimport{common/theorems/}{saturationtheorem.tex}
  \subimport{common/proofsketches/}{saturationproofsketch.tex}

  \subimport{common/corollaries/}{trusttransfercorollary.tex}
  \subimport{common/proofs/}{trusttransferproof.tex}

  \subimport{common/theorems/}{invtrustrednaivetheorem.tex}
  \subimport{common/proofs/}{invtrustrednaiveproof.tex}

  Until now $MaxFlow$ has been viewed purely as an algorithm. This algorithm is not guaranteed to always return the same
  flow configuration when executed muliple times on the same graph. However, the corresponding flow value, $maxFlow$, is
  always the same. Thus $maxFlow$ can be also viewed as a function from a matrix of capacities to a non-negative real number.
  Under this perspective, we prove the following theorem. Let $\mathcal{C}$ be the family of all capacity matrices
  $C = [c_{vw}]_{\mathcal{V} \times \mathcal{V}}$.
  \subimport{common/theorems/}{maxflowcontinuitytheorem.tex}
  \subimport{common/proofsketches/}{maxflowcontinuityproofsketch.tex}


% !TEX program = pdflatex
% !BIB program = bibtex
% !TEX enableSynctex = true

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\onehalfspacing
\usepackage{graphicx}
\usepackage{float}
\usepackage{appendix}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\usepackage{pdflscape}
\usepackage{color}   %May be necessary if you want to color links
\usepackage[colorlinks = true,
            linkcolor = blue,
            urlcolor  = blue,
            citecolor = blue,
            anchorcolor = blue]{hyperref}
\hypersetup{
    colorlinks=true, %set true if you want colored links
    linktoc=all,     %set to all if you want both sections and subsections linked
    linkcolor=blue,  %choose some color if you want links to stand out
}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{bbm}

%For margins
\textheight = 22.62cm
\textwidth = 15.92cm
\topmargin = -0.54cm
\oddsidemargin= 0cm
\parindent=05mm
\usepackage{dashrule}
\usepackage{booktabs}
\usepackage{bbold}
\usepackage{amsmath}

\newtheorem{theorem}{Theorem}
\newtheorem{remark}{Remark}
\newtheorem{definition}[theorem]{Definition}
\DeclareMathOperator{\trace}{trace}
\DeclareMathOperator{\Var}{Var}

%Title Definition
\title{{\Large \vspace{-5em} \textbf{KSS Bias Correction : Outline} }}
\author{}
\date{}

\begin{document}
\maketitle
\section{Introduction}
Consider a linear model with nonrandom $x_i \in \mathbbm{R}^k$.

\begin{align*}
    y_i = x_i' \beta + \varepsilon_i
\end{align*}
where $i = 1,\dots,n$ and $\varepsilon \sim N(0, \sigma_i^2)$.

\begin{definition}
A (co)variance component is a quadratic form $\theta = \beta' A \beta $, where $A$ is a $k\times k$ matrix. When A is positive semi-definite we call it a variance component and when A is non-definite we call it covariance component.
\end{definition}

\begin{remark}
The plug-in estimator for the (co)variance component $\theta$ is biased. In particular, we can write

\begin{align*}
    \mathbbm{E}(\hat{\theta}) = \theta + \underbrace{ \trace(A \Var(\hat{\beta}))}_\text{bias}
\end{align*}

\noindent And the bias term can be written as $\sum_{i=1}^n B_{ii} \sigma_i^2$, where $B_{ii} = x_i' S_{xx}^{-1} A S_{xx}^{-1} x_i  $, $S_{xx} = \sum_{i=1}^n x_i x_i'$.
\end{remark}

\begin{remark}
The previous remark suggest that we can estimate the bias as

\begin{align*}
    \hat{bias} &= \sum_{i=1}^n B_{ii} \hat{\sigma_i}^2 \\
    \hat{\sigma_i}^2 &= y_i (y_i - x_i' \hat{\beta}_{-i}) = y_i \frac{(y_i - x_i ' \hat{\beta})}{1-P_{ii}}\\
\end{align*}
where $P_{ii}$ is the statistical leverage of observation $i$, and it's defined as $P_{ii} := (X (X'X) X')_{ii}$.

\end{remark}

\clearpage
\begin{remark}
If we compute $\hat{\beta}$, $B_{ii}$ and $P_{ii}$ then we can compute the ``bias-corrected'' estimator of the (co)variance components

\begin{align*}
    \hat{\theta}_{KSS} =  \hat{\beta}' A \hat{\beta} - \sum_{i=1}^n B_{ii} y_i \frac{(y_i - x_i ' \hat{\beta})}{1-P_{ii}}
\end{align*}
\end{remark}

\vspace{0.5cm}
Our model of interest is the two-way fixed effects model given by

\begin{align*}
y_{gt} = \alpha_{g} + \psi_{j(g,t} + x_{gt}' \delta + \varepsilon_{gt}
\end{align*}

\noindent where $g \in \{1,\dots,N\}$ denotes the worker identity, $t$ denotes the time period, $j(g,t) \in \{1,\dots,J\}$ denotes the firm of worker $g$ at time $t$. Moreover, we can index the observations using $i$ instead of $g,t$ and we will denote $n$ as the total number of observations.

The (co)variance components in this context take the form

\begin{align*}
    \sigma_{\psi}^2 &= \frac{1}{n} \sum_{g=1}^{N} \sum_{t=1}^{T_g} (\psi_{j(g,t)} - \Bar{\psi})^2  \\
    \sigma_{\alpha, \psi}^2 &= \frac{1}{n} \sum_{g=1}^{N} \sum_{t=1}^{T_g} (\psi_{j(g,t)} - \Bar{\psi}) \alpha_g  \\
    \sigma_{\alpha}^2 &= \frac{1}{n} \sum_{g=1}^{N} \sum_{t=1}^{T_g} (\alpha_{g} - \Bar{\alpha})^2   \\
\end{align*}
where $\Bar{\psi} = \frac{1}{n} \sum_{g=1}^{N} \sum_{t=1}^{T_g} \psi_{j(g,t)}$. Let $f_i = (\boldsymbol{1}_{\{j(g,t)=1\}},\dots,\boldsymbol{1}_{\{j(g,t)=J\}})'$ and $d_i = (\boldsymbol{1}_{\{g=1\}},\dots,\boldsymbol{1}_{\{g=N\}})'$ . We can compute the (co)variance components in this model in quadratic forms using the following $A$ matrices

\begin{align*}
A_{\psi} = \begin{bmatrix}
0 & 0 & 0\\
0 & A_{ff} & 0\\
0 & 0 & 0
\end{bmatrix} \quad \text{where} \quad A_{ff} = \frac{1}{n} \sum_{i=1}^n (f_i - \Bar{f})(f_i - \Bar{f})'
\end{align*}

\begin{align*}
A_{\alpha,\psi} = \begin{bmatrix}
0 & A_{df} & 0\\
A_{df}' & 0 & 0\\
0 & 0 & 0
\end{bmatrix} \quad \text{where} \quad A_{df} = \frac{1}{n} \sum_{i=1}^n (d_i - \Bar{d})(f_i - \Bar{f})'
\end{align*}

\begin{align*}
A_{\alpha} = \begin{bmatrix}
A_{dd} & 0 & 0\\
0 & 0 & 0\\
0 & 0 & 0
\end{bmatrix} \quad \text{where} \quad A_{dd} = \frac{1}{n} \sum_{i=1}^n (d_i - \Bar{d})(d_i - \Bar{d})'
\end{align*}

\section{Matrix Form of the Model}

Define the dummy variable matrices

\begin{align*}
    \underbrace{D}_\text{Worker Dummies} &= \underbrace{\begin{bmatrix} \boldsymbol{1}_{\{g=1\}} \iota_n \dots \boldsymbol{1}_{\{g=N\}} \iota_n  \end{bmatrix}}_\text{One non-zero value per row at most} \quad \text{where} \quad \iota_n = (1, \dots, 1)' \in \mathbbm{R}^n
\end{align*}

\begin{align*}
    \underbrace{F*S}_\text{Firm Dummies} &= \underbrace{\begin{bmatrix} \boldsymbol{1}_{\{j(g,t)=1\}} \iota_n \dots \boldsymbol{1}_{\{j(g,t)=J\}} \iota_n  \end{bmatrix}}_\text{One non-zero value per row at most} * \underbrace{\begin{bmatrix} I_{J-1} & 0 \\ 0 & 0 \end{bmatrix}}_\text{Normalize last firm effect to 0}
    \quad \text{where} \quad I_{J-1}:= \text{identity matrix}
\end{align*}

\begin{align*}
    \underbrace{C}_\text{Control Variables} &= \begin{bmatrix} x_1' \\ \vdots \\ x_n'  \end{bmatrix}
\end{align*}

Then we can write the model in matrix form as

 \begin{align*}
     Y &= \begin{bmatrix} D & F*S & C \end{bmatrix} \begin{bmatrix} \alpha \\ \psi \\ \delta \end{bmatrix} + \varepsilon\\
     &= X \beta + + \varepsilon
\end{align*}

And we can estimate $\beta$ by solving the least-squares problem, and notice that the design matrix, $X$, is very sparse based on the definitions of $D$ and $F*S$.

\section{Computation of $B_{ii}$ and $P_{ii}$}

It can be shown that

\begin{align*}
    P_{ii} = x_i' S_{xx}^{-1} x_i \quad \text{and} \quad B_{ii} = x_i' S_{xx}^{-1} A  S_{xx}^{-1} x_i
\end{align*}

\noindent But in practice the computation of $S_{xx}^{-1}$ can be difficult given the high dimension of parameters in the model. The approach taken in KSS is to avoid the computation of this inverse and instead compute

\begin{align*}
    z_i^{exact} = S_{xx}^{-1} x_i \quad \text{for each} \quad i=1,\dots,n
\end{align*}

In other words, we solve separately for each column of $Z$ in the following system

\begin{align*}
    \underbrace{S_{xx}}_{k\times k} \underbrace{Z_{exact}}_{k\times n}  = \underbrace{X'}_{k\times n}
\end{align*}

\noindent With that solution we compute $P_{ii} = x_i' z_i^{exact}$ and $B_{ii} = {z_i^{exact}}' A z_i^{exact}$

\begin{remark}
Exact computation can be infeasible given the dimensionality of the problem. The authors propose a dimension reduction via Rademacher matrices, also known as Johnson-Lindenstrauss Approximation (JLA). In particular, it consists on transforming the system so that we only require to solve $p$ systems instead of $n$ systems, where $p$ can be significantly smaller than $n$.

In other words, we solve separately for each column of Z in the following system

\begin{align*}
    \underbrace{S_{xx}}_{k\times k} \underbrace{Z_{JLA}}_{k\times p}  = \underbrace{(R_p *X)'}_{k\times p}
\end{align*}

\end{remark}

\includegraphics[scale=0.7]{JLA_algorithm.jpg}

\begin{remark}
When there are no controls in the design matrix, the model simplifies to
\begin{align*}
    X = \begin{bmatrix} D & F*S \end{bmatrix} \quad \beta = \begin{bmatrix} \alpha \\ \psi \end{bmatrix}
\end{align*}

\noindent Moreover, there's no loss of generality of rewriting as
\begin{align*}
    X = \begin{bmatrix} D & -F*S \end{bmatrix} \quad \beta = \begin{bmatrix} \alpha \\ -\psi \end{bmatrix}
\end{align*}

\noindent If we do this $X'X$ is symmetric and diagonally dominant, and the normal equations can be solved as a Laplacian system. This is where the preconditioner \textit{CMG} comes into play in the code.

\end{remark}

\section{Leave-One-Out for Clusters}

We can extend this framework to allow for leave-out estimation of clusters of observations. Suppose there are $c\in \{1,C\}$ clusters of $n_c$ observations. We can redefine the model as follows

\begin{align*}
    y_c = X_c \quad \beta + \varepsilon_c
\end{align*}

\begin{align*}
    y_c = \begin{bmatrix} y_{c,1} \\ \vdots \\ y_{c,n_c}  \end{bmatrix} \quad X_c = \begin{bmatrix} x_{c,1}' \\ \vdots \\ x_{c,n_c}'  \end{bmatrix} \quad \varepsilon_c = \begin{bmatrix} \varepsilon_{c,1} \\ \vdots \\ \varepsilon_{c,n_c}  \end{bmatrix}
\end{align*}

In this case, we can define an analogue for the bias corrected estimator

\begin{align*}
    \hat{\theta}_{KSS} =  \hat{\beta}' A \hat{\beta} - \sum_{i=c}^C y_c' B_c (1- P_c)^{-1} (y_c - X_c   \hat{\beta})
\end{align*}

where

\begin{align*}
    P_c = X_c S_{xx}^{-1} X_c' = \underbrace{ \begin{bmatrix} x_{c,1}' S_{xx}^{-1}  x_{c,1} & \dots & x_{c,1}' S_{xx}^{-1}  x_{c,n_c}  \\ \vdots & \vdots & \vdots \\ x_{c,n_c}' S_{xx}^{-1}  x_{c,1} & \dots & x_{c,1}' S_{xx}^{-1}  x_{n_c,n_c} \end{bmatrix} }_\text{From symmetry we only need to compute upper or lower triangular half }
\end{align*}

\begin{align*}
    B_c = X_c S_{xx}^{-1} A S_{xx}^{-1} X_c' = \underbrace{ \begin{bmatrix} x_{c,1}' S_{xx}^{-1} A S_{xx}^{-1} x_{c,1} & \dots & x_{c,1}' S_{xx}^{-1} A S_{xx}^{-1} x_{c,n_c}  \\ \vdots & \vdots & \vdots \\ x_{c,n_c}' S_{xx}^{-1} A S_{xx}^{-1}  x_{c,1} & \dots & x_{c,1}' S_{xx}^{-1} A S_{xx}^{-1}  x_{n_c,n_c} \end{bmatrix} }_\text{From symmetry we only need to compute upper or lower triangular half }
\end{align*}

Now, we can solve $M$ systems of equations and solve for
 \begin{align*}
     z_{c,l}^{exact} = S_{xx}^{-1} x_{c,l} \quad \text{where} \quad c\in\{1,\dots,C\} \quad and \quad l\in\{1,\dots,n_c\}
 \end{align*}

The function \textit{index\_constr()} is the one in charge of computing which observations belong to the same cluster, so that we only need to compute $M$ numbers because of the symmetry of these matrices.

\clearpage
\appendix

\section{Simple Network Example}

Suppose we are given the following dataset

\begin{table}[h!]
    \centering
\begin{tabular}{|c c c c|}
 \hline
 id & year & firmid & outcome \\ [0.5ex]
 \hline\hline
 1 & 1 & A &  0,1462\\
 \hline
 1 & 2 & B & 0,2968 \\
 \hline
 2 & 1 & A &  0,5434\\
 \hline
 2 & 2 & A & 0,4326 \\
 \hline
 3 & 1 & A & 0,4648 \\
 \hline
 4 & 1 & A & 0,7306 \\
 \hline
 4 & 2 & B & 0,6192 \\
 \hline
 5 & 1 & B &  0,7534\\
 \hline
 5 & 2 & B &  0,0863\\
 \hline
6 & 1 & B &  0,3720\\
 \hline
 6 & 2 & C & 0,9580 \\ [1ex]
 \hline
\end{tabular}
\end{table}

We can write the corresponding bipartite graph as follows
\begin{figure}[h!]
    \centering
\includegraphics[scale=0.7]{minimal_unit.png}    \end{figure}

The function $\textit{find\_connected\_set()}$ will find the largest connected component of this network, which corresponds to the whole network. This means that we can estimate the coefficients for every worker effect and every firm effect.

Now, the function $\textit{prunning\_connected\_set()}$ will prune the worker vertex that are articulation points and find the largest connected set until no more articulation points are found. In this network it corresponds to worker 6, so all of its edges will be pruned. Notice that this will disconnect firm C with the rest of the network. After that, the network is also the largest connected component with no more articulation points, so the function stops at that point. The network that we get as an output is the following

\begin{figure}[h!]
    \centering
\includegraphics[scale=0.7]{pruning.png}
\end{figure}

Finally, the function $\textit{drop\_single\_obs()}$ will delete the workers that only have one observation(edge). In this particular case it corresponds to worker 3. We are required to prune these workers because once we leave-out that observation we can no longer estimate the coefficient for worker 3's effect. Therefore, the leave-one-out connected set is structured as follows

\begin{figure}[h!]
    \centering
\includegraphics[scale=0.6]{leaveoutnetwork.png}
\end{figure}

If we allow ourselves to relabel the vertex of this network starting from the workers we get the following graph:

\begin{figure}[H]
    \centering
\includegraphics[scale=0.6]{leaveoutnetwork_relabeled.png}
\end{figure}

The dummy matrix for workers (now relabeled as vertex 1,2,3,4) can be written as:

\begin{align*}
D = \begin{bmatrix}
1 & 0 & 0& 0\\
1 & 0 & 0& 0\\
0 & 1 & 0& 0\\
0 & 1 & 0& 0\\
0 & 0 & 1& 0\\
0 & 0 & 1& 0\\
0 & 0 & 0& 1\\
0 & 0 & 0& 1\\
\end{bmatrix}
\end{align*}

The dummy matrix for firms (now relabeled as vertex 5,6) can be written as:

\begin{align*}
F = \begin{bmatrix}
1 & 0 \\
0 & 1 \\
1 & 0 \\
1 & 0 \\
1 & 0 \\
0 & 1 \\
0 & 1 \\
\end{bmatrix}
\end{align*}

Our design matrix X corresponds to  $X = \begin{bmatrix} D & -F \end{bmatrix}$. Now notice what the operation $X'*X$ does :

\begin{align*}
X'*X = \begin{bmatrix}
2 & 0 & 0 & 0 & -1 & -1 \\
0 & 2 & 0 & 0 & -2 & 0 \\
0 & 0 & 2 & 0 & -1 & -2 \\
0 & 0 & 0 & 2 & 0 & 0 \\
-1 & -2 & -1 & 0 & 4 & 0 \\
-1 & 0 & -1 & -2 & 0 & 4 \\
\end{bmatrix}
\end{align*}

Notice that the diagonals are the degree of each vertex, while the non diagonal elements represent the negative of the number of edges between vertex. Since this is a bipartite graph there are no edges between workers , or edges between firms.  In other words, the matrix $X'*X$ is a Laplacian matrix. When we normalize the last firm effects to zero it is equivalent to working with the Grounded Laplacian version of this, which eliminates the last row and column from $X'*X$.

\clearpage
\section{Linear Algebra Stuff}

Recall that the model of interest is
\begin{align*}
y_{gt} = \alpha_{g} + \psi_{j(g,t)} + x_{gt}' \delta + \varepsilon_{gt}
\end{align*}

We can define the following matrices
\begin{align*}
    \underbrace{D}_\text{Worker Dummies} &= \underbrace{\begin{bmatrix} \boldsymbol{1}_{\{g=1\}} \iota_n \dots \boldsymbol{1}_{\{g=N\}} \iota_n  \end{bmatrix}}_\text{One non-zero value per row at most} \quad \text{where} \quad \iota_n = (1, \dots, 1) \in \mathbbm{R}^n
\end{align*}

\begin{align*}
    \underbrace{F*S}_\text{Firm Dummies} &= \underbrace{\begin{bmatrix} \boldsymbol{1}_{\{j(g,t)=1\}} \iota_n \dots \boldsymbol{1}_{\{j(g,t)=J\}} \iota_n  \end{bmatrix}}_\text{One non-zero value per row at most} * \underbrace{\begin{bmatrix} I_{J-1} & 0 \\ 0 & 0 \end{bmatrix}}_\text{Normalize last firm effect to 0}
    \quad \text{where} \quad I_{J-1}:= \text{identity matrix}
\end{align*}

\begin{align*}
    \underbrace{C}_\text{Control Variables} &= \begin{bmatrix} x_1' \\ \vdots \\ x_n'  \end{bmatrix}
\end{align*}

and write the model in matrix notation

 \begin{align}
     Y &= \begin{bmatrix} D & F*S & C \end{bmatrix} \begin{bmatrix} \alpha \\ \psi \\ \delta \end{bmatrix} + \varepsilon\\
     &= X \beta + + \varepsilon
     \label{eq:matrix}
\end{align}

Our quadratic forms of interest are of the form $\theta = \beta' A \beta$ for different choices of matrices $A$. Let $d_i = row_i(D) = (\boldsymbol{1}_{\{j(g,t)=1\}}  \dots \boldsymbol{1}_{\{j(g,t)=J\}})'$,  $f_i = row_i(F) = (\boldsymbol{1}_{\{j(g,t)=1\}} \dots \boldsymbol{1}_{\{j(g,t)=J\}} )'$, and denote $\Bar{d}$ and $\Bar{f}$ as the sample means. The $A$ matrices that we're interested in are the following three:

\begin{align*}
A_{\psi} = \begin{bmatrix}
0 & 0 & 0\\
0 & A_{ff} & 0\\
0 & 0 & 0
\end{bmatrix} \quad \text{where} \quad A_{ff} = \frac{1}{n} \sum_{i=1}^n (f_i - \Bar{f})(f_i - \Bar{f})'
\end{align*}

\begin{align*}
A_{\alpha,\psi} = \begin{bmatrix}
0 & A_{df} & 0\\
A_{df}' & 0 & 0\\
0 & 0 & 0
\end{bmatrix} \quad \text{where} \quad A_{df} = \frac{1}{n} \sum_{i=1}^n (d_i - \Bar{d})(f_i - \Bar{f})'
\end{align*}

\begin{align*}
A_{\alpha} = \begin{bmatrix}
A_{dd} & 0 & 0\\
0 & 0 & 0\\
0 & 0 & 0
\end{bmatrix} \quad \text{where} \quad A_{dd} = \frac{1}{n} \sum_{i=1}^n (d_i - \Bar{d})(d_i - \Bar{d})'
\end{align*}

The code uses the following representation to facilitate the computation of such matrices:

\begin{align*}
    A_\phi &= A_f'A_f\\
    A_\alpha &= A_d'A_d\\
    A_{\alpha,\phi} &= \frac{1}{2} (A_f'A_d + A_d'A_f)
\end{align*}

where

\begin{equation}
    A_f = n^{-1/2} \begin{bmatrix}
0 & f_1 - \Bar{f} & 0\\
0 & \dots & 0\\
0 & f_n - \Bar{f} & 0
\end{bmatrix}
\end{equation}

\begin{equation}
    A_d = n^{-1/2} \begin{bmatrix}
d_1 - \Bar{d} & 0 & 0\\
\dots & 0 & 0\\
d_n - \Bar{d} & 0 & 0
\end{bmatrix}
\end{equation}

The systems that we want to solve are then the following

\begin{equation}
    \underbrace{S_{xx}}_{k\times k} \underbrace{Z_{exact}}_{k\times n}  = \underbrace{ X'}_{k\times n}
\label{eq:exact}
\end{equation}

\begin{equation}
    \underbrace{S_{xx}}_{k\times k} \underbrace{Z_{JLA}^0}_{k\times p}  = \underbrace{(R_p *X)'}_{k\times p}
    \label{eq:JLA1}
\end{equation}

\begin{equation}
    \underbrace{S_{xx}}_{k\times k} \underbrace{Z_{JLA}^1}_{k\times p}  = \underbrace{(R_b *A_f)'}_{k\times p}
        \label{eq:JLA2}
\end{equation}

\begin{equation}
    \underbrace{S_{xx}}_{k\times k} \underbrace{Z_{JLA}^2}_{k\times p}  = \underbrace{(R_b *A_d)'}_{k\times p}
        \label{eq:JLA3}
\end{equation}

\noindent where $S_{xx} = X'X$, and $R_b$, $R_p$ are two independent $p\times n$ matrices with Rademacher entries.

\noindent Notice that the operation $R_b *A_f$ is equivalent to "de-meaning" the Rademacher matrix instead of the $A$ matrix. In other words, we redefine

\begin{align}
    R_b =  R_b .- \text{mean}(R, dims=2)
\end{align}

\begin{align}
    A_d =  \begin{bmatrix}
d_1  & 0 & 0\\
\dots & 0 & 0\\
d_n  & 0 & 0
\end{bmatrix} =   \begin{bmatrix} D & F*S * 0 & C*0 \end{bmatrix} =  \begin{bmatrix} D & 0 & 0 \end{bmatrix}
\end{align}

\begin{align}
    A_f =  \begin{bmatrix}
0 & f_1  & 0\\
0 & \dots & 0\\
0 & f_n  & 0
\end{bmatrix} =   \begin{bmatrix} D*0 & F*S & C*0 \end{bmatrix} =  \begin{bmatrix} 0 & F*S & 0 \end{bmatrix}
\end{align}

\noindent where $A_d$ and $A_f$ are now just taking one block from the $X$ matrix shown in Equation 2 and filling the rest of the entries with zeros.

\vspace{0.5cm}

\noindent Finally, Equations 5 and 6 can be written in terms of an augmented system :

\begin{equation}
  \begin{bmatrix}
I & X \\
X' & 0
\end{bmatrix}  \begin{bmatrix} U \\ Z_{exact} \end{bmatrix} = \begin{bmatrix} I_{n\times n} \\ 0 \end{bmatrix}
\label{aug:exact}
\end{equation}

\begin{equation}
  \begin{bmatrix}
I & X \\
X' & 0
\end{bmatrix}  \begin{bmatrix} U \\ Z_{JLA}^0 \end{bmatrix} = \begin{bmatrix} R_p' \\ 0 \end{bmatrix}
\label{aug:JLA1}
\end{equation}

\noindent where $U$ is the matrix of residuals and $Z$ is the matrix of solutions that we're interested in. We are currently unsure whether we can write Equations 7 and 8 in terms of an augmented system.

\clearpage

Whenever we have a system with $S_xx$ on the left hand side we have the following \textbf{single} right hand sides:

\begin{enumerate}
    \item $row_k(X)$ for the exact $P_{ii}$ computation.
    \item $row_k(R_p * X)$, which is equivalent to using the $1\times n$ vector $rademacher$ and computing $rademacher * X$. This is used for the JLA computation of $P_{ii}$.

    \item $row_k(R_b * A_f)$, which is equivalent to using the $1\times n$ vector $rademacher$ and computing $rademacher * A_f$. This is used for the JLA computation of $B_{ii}$.

    \item $row_k(R_b * A_f)$, which is equivalent to using the $1\times n$ vector $rademacher$ and computing $rademacher * A_d$. This is used for the JLA computation of $B_{ii}$.

    \item $X'*y$. This is used for the computation of the fixed effects coefficients.
\end{enumerate}

It is important to mention that the matrices $A_f$ and $A_d$ can be constructed as transformations of the design matrix, $X$. The construction is done, avoiding the $n^{-1/2}$ normalization and demeaning, in the following way:

\begin{align}
    A_f =      \begin{bmatrix}
0_{n \times N} & X[N+1:N+J] \\
\end{bmatrix}
\end{align}

\begin{align}
A_d  =   \begin{bmatrix}
  X[1:N] & 0_{n \times J} \\
\end{bmatrix}
\end{align}

\clearpage
\section{Inference}

Recall the unfeasible estimator of the (co)variance component:

\begin{align}
\theta^* = \Hat{\beta}' A \Hat{\beta} - \sum_{i=1}^n B_{ii} \sigma_i^2
\end{align}

The finite sample inference results on the (co)variance component will rely on the eigen-decomposition of the following matrix:

\begin{align}
    \Tilde{A} = S_{xx}^{-1/2}  A S_{xx}^{-1/2}
\end{align}

The eigenvalue problem solves

\begin{align}
    \Tilde{A}  Q = Q D
\end{align}

where $D=diag(\lambda_1,\dots,\lambda_r)$ and $Q$ is a matrix of orthonormal eigenvectors. We can define the following vector $b$, which is a linear combination of r elements of $\Hat{\beta}$, and a matrix of generalized eigenvectors:

\begin{align}
    \Hat{b} = Q' S_{xx}^{1/2} \Hat{\beta}
\end{align}

\begin{align}
    \tilde{Q} = S_{xx}^{-1/2} Q
\end{align}

Using these definition we apply Lemma 2, and show that if $\epsilon_i \sim N(0,\sigma_i^2)$ then the following equations must hold:

\begin{align}
\Hat{\beta}' A \Hat{\beta} &= \sum_{l=1}^r \lambda_l \Hat{b}^2
\end{align}

\begin{align}
Var(\Hat{b}) &= Q' S_{xx}^{1/2} Var(\Hat{\beta}) S_{xx}^{1/2}Q \\
&= Q' S_{xx}^{1/2} S_{xx}^{-1} X' diag(\sigma_i^2) X S_{xx}^{-1}  S_{xx}^{1/2} Q \\
&= \Tilde{Q}' X' diag(\sigma_i^2) X \Tilde{Q}
\end{align}

\begin{align}
    \theta^* = \sum_{l=1}^r \lambda_l (\Hat{b}_l^2 - Var(\Hat{b_l}))
\end{align}

Now notice that instead of solving for $Q$ and constructing $\Tilde{Q}$ manually (that involves computing $S_{xx}^{-1/2}$, we can solve for $\Tilde{Q}$ in the following generalized eigendecomposition problem by manipulating the original one:

\begin{align}
    S_{xx}^{-1/2} A     S_{xx}^{-1/2} Q &= Q D \\
    A  S_{xx}^{-1/2} Q &=     S_{xx}^{1/2} Q D \\
    A \Tilde{Q} &= S_{xx}     S_{xx}^{-1/2} Q D \\
    A \Tilde{Q} &= S_{xx} \Tilde{Q} D
\end{align}

where $Q'Q = I$, so that $\Tilde{Q}'\Tilde{Q} = S_{xx}^{-1}$, i.e. these eigenvectors must be $S_{xx}$ normalized. This last fact and equation 21 can be used to check if our code is giving us the right solution to the eigendecomposition problem shown in equation 29.

\end{document}

\end{document}


\section{$n$-step Bootstrapping}

\subsection{$n$-step TD Prediction}

$n$-step TD prediction is still TD because it changes earlier estimate.

It did not update anything for the first $n-1$ steps. If $t + n \geq T$, the missing terms are treated as $0$. It is defined as:

\begin{equation}
	G_{t:t+n} = R_{t+1} + \gamma R_{t+2} + \dots + \gamma^{n-1} R_{t+n} + \gamma^n V_{t+n-1}(S_{t+n})
\end{equation}

The algorithm (\ref{algo:nsteptdpredition}) contains detail.

\begin{algorithm}
	\caption{$n$-step TD prediction, estimate $v_\pi$}\label{algo:nsteptdpredition}

	\begin{algorithmic}[1]
		\State $ \alpha \in (0,1]$
		\State $V(s) \gets$ random
		\State $t \gets 0$

		\Statex

		\Loop
			\State choose $S_0$
			\State $T \gets \infty$
			\While{$\tau < T - 1$}
				\If{$t < T$}
					\State take action according to $\pi(\cdot|S_t)$
					\State store $R_{t+1}$ and $S_{t+1}$
					\If{$S_{t+1}$ is terminal}
						\State $T \gets t+1$
					\EndIf
				\EndIf

				\State $\tau \gets t - n + 1$ \Comment $\tau$ is the pivot of update

				\If{$\tau \geq 0$}
					\State $G \gets \sum\limits_{i=\tau+1}^{\min (\tau+n,T)} \gamma^{i-\tau-1} R_i$ \Comment $G_{\tau:\tau+n}$
					\If{$\tau + n < T$}
						\State $G \gets G + \gamma^n V(S_{\tau + n})$
					\EndIf

					\State $V(S_\tau) \gets V(S_\tau) + \alpha \Big(G - V(S_\tau)\Big)$
				\EndIf

				\State $t \gets t+1$
			\EndWhile
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsection{$n$-step Sarsa}

It is the same as $n$-step TD prediction with $q$ and $\varepsilon$-greedy.

\begin{equation}
	G_{t:t+n} = R_{t+1} + \gamma R_{t+2} + \dots + \gamma^{n-1} R_{t+n} + \gamma^n Q_{t+n-1}(S_{t+n},A_{t+n})
\end{equation}

The algorithm (\ref{algo:nstepsarsa}) contains detail.

\begin{algorithm}
	\caption{$n$-step Sarsa, estimate $q_\pi$ or $q_*$}\label{algo:nstepsarsa}

	\begin{algorithmic}[1]
		\State $ \alpha \in (0,1]$
		\State $Q(s,a) \gets$ random
		\State $\pi \gets$ random $\varepsilon$-greedy policy or a given fixed policy
		\State $t \gets 0$

		\Statex

		\Loop
			\State choose $S_0$
			\State choose action $A_0 \sim \pi (\cdot | S_0)$
			\State $T \gets \infty$
			\While{$\tau < T - 1$}
				\If{$t < T$}
					\State take action $A_t$ and store $R_{t+1}$ and $S_{t+1}$
					\If{$S_{t+1}$ is terminal}
						\State $T \gets t+1$
					\Else
						\State choose $A_{t+1} \sim \pi(\cdot|S_{t+1})$
					\EndIf
				\EndIf

				\State $\tau \gets t - n + 1$ \Comment $\tau$ is the pivot of update

				\If{$\tau \geq 0$}
					\State $G \gets \sum\limits_{i=\tau+1}^{\min (\tau+n,T)} \gamma^{i-\tau-1} R_i$
					\If{$\tau + n < T$}
						\State $G \gets G + \gamma^n Q(S_{\tau + n}, A_{\tau + n})$ \Comment $G_{\tau:\tau+n}$
					\EndIf

					\State $Q(S_{\tau}, A_{\tau}) \gets Q(S_{\tau}, A_{\tau}) + \alpha \Big(G - Q(S_{\tau}, A_{\tau})\Big)$
					\State update $\pi_*$ \Comment update as a $\varepsilon$-greedy policy if calculating $q_*$
				\EndIf

				\State $t \gets t+1$
			\EndWhile
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsection{$n$-step Expected Sarsa}

It is the same as $n$-step Sarsa except that it uses expectation at the last step:

\begin{equation}
	G_{t:t+n} = R_{t+1} + \gamma R_{t+2} + \dots + \gamma^{n-1} R_{t+n} + \gamma^n \sum_a \pi(a|S_{t+n}) Q_{t+n-1}(S_{t+n},a)
\end{equation}

\subsection{$n$-step Off-policy Learning}

note: $V_{t+n}$ and $Q_{t+n}$ are the result of ($t+n$)th iteration.

\subsubsection{$n$-step Off-policy TD}

for $0 \leq t < T$, the update formula is:

\begin{equation}
	V_{t+n}(S_t)=V_{t+n-1}(S_t)+\alpha \prod_{k=t}^{\min (h,T-1)} \frac{\pi(A_k|S_k)}{b(A_k|S_k)} [G_{t:t+n} - V_{t+n-1}(S_t)]
\end{equation}

\subsubsection{$n$-step Off-policy Sarsa}

for $0 \leq t < T$, the update formula is:

\begin{equation}
\begin{split}
	Q_{t+n}(S_t,A_t)=&Q_{t+n-1}(S_t,A_t) \\
	&+\alpha \prod_{k=t}^{\min (h,T-1)} \frac{\pi(A_k|S_k)}{b(A_k|S_k)} [G_{t:t+n} - Q_{t+n-1}(S_t,A_t)]
\end{split}
\end{equation}

See Algorithm (\ref{algo:nstepoffsarsa}) for detail.

\begin{algorithm}
	\caption{Off-policy $n$-step Sarsa, estimate $q_\pi$ or $q_*$}\label{algo:nstepoffsarsa}

	\begin{algorithmic}[1]
		\State $ \alpha \in (0,1]$
		\State $Q(s,a) \gets$ random
		\State $\pi \gets$ random $\varepsilon$-greedy policy
		\State $t \gets 0$

		\Statex

		\Loop
			\State choose $S_0$
			\State choose action $A_0 \sim \pi (\cdot | S_0)$
			\State $T \gets \infty$
			\While{$\tau < T - 1$}
				\If{$t < T$}
					\State take action $A_t$ and store $R_{t+1}$ and $S_{t+1}$
					\If{$S_{t+1}$ is terminal}
						\State $T \gets t+1$
					\Else
						\State choose $A_{t+1} \sim \pi(\cdot|S_{t+1})$
					\EndIf
				\EndIf

				\State $\tau \gets t - n + 1$ \Comment $\tau$ is the pivot of update

				\If{$\tau \geq 0$}
					\State $\rho \gets \prod\limits_{i=\tau+1}^{\min (\tau+n-1,T-1)} \frac{\pi(A_i|S_i)}{b(A_i|S_i)}$
					\State $G \gets \sum\limits_{i=\tau+1}^{\min (\tau+n,T)} \gamma^{i-\tau-1} R_i$

					\If{$\tau + n < T$}
						\State $G \gets G + \gamma^n Q(S_{\tau + n}, A_{\tau + n})$ \Comment $G_{\tau:\tau+n}$
					\EndIf

					\State $Q(S_{\tau}, A_{\tau}) \gets Q(S_{\tau}, A_{\tau}) + \alpha \rho \Big(G - Q(S_{\tau}, A_{\tau})\Big)$
					\State update $\pi_*$ \Comment update as a $\varepsilon$-greedy policy if calculating $q_*$
				\EndIf

				\State $t \gets t+1$
			\EndWhile
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsection{$n$-step Tree Backup Algorithm}

This is an \cindex{off-policy} learning algorithm without \cindex{importance sampling}. For each step along the sampling, the non-visited notes contribute probabilistic result according to the policy. The visited node will contribute the updated bootstrapping result.

\begin{equation}
	\begin{split}
		G_{t:t+n}&=R_{t+1}\\
		&+\gamma \sum_{a\neq A_{t+1}} \pi(a|S_{t+1}) Q_{t+n-1}(S_{t+1},a) \text{  \# other branches} \\
		&+ \gamma \pi(A_{t+1}|S_{t+1})G_{t+1:t+n} \text{  \# main sample path}
	\end{split}
\end{equation}

See Algorithm (\ref{algo:nsteptreebackup}) for detail.

\begin{algorithm}
	\caption{$n$-step tree backup, estimate $q_\pi$ or $q_*$}\label{algo:nsteptreebackup}

	\begin{algorithmic}[1]
		\State $ \alpha \in (0,1]$
		\State $Q(s,a) \gets$ random
		\State $\pi \gets$ random $\varepsilon$-greedy policy

		\Statex

		\Loop
			\State choose $S_0$
			\State choose action $A_0 \sim \pi (\cdot | S_0)$
			\State $T \gets \infty$
			\State $t \gets 0$
			\While{$\tau < T - 1$}
				\If{$t < T$}
					\State take action $A_t$ and store $R_{t+1}$ and $S_{t+1}$
					\If{$S_{t+1}$ is terminal}
						\State $T \gets t+1$
					\Else
						\State choose $A_{t+1} \sim \pi(\cdot|S_{t+1})$
					\EndIf
				\EndIf

				\State $\tau \gets t - n + 1$ \Comment $\tau$ is the pivot of update

				\If{$\tau \geq 0$}
					\If{$t+1 \geq T$}
						\State $G \gets R_T$
					\Else
						\State $G \gets R_{t+1} + \gamma \sum\limits_a \pi(a|S_{t+1}) Q(S_{t+1},a)$
					\EndIf

					\State \Comment update $G$ backward using tree-backup method

					\For{$k \gets [\tau+1,\dots,\min (t,T-1)]$}
						\State $G \gets R_k + \gamma \sum\limits_{a\neq A_k} \pi(a|S_k)Q(S_k,a) + \gamma \pi (A_k|S_k)G$
					\EndFor

					\State $Q(S_{\tau}, A_{\tau}) \gets Q(S_{\tau}, A_{\tau}) + \alpha  \Big(G - Q(S_{\tau}, A_{\tau})\Big)$
					\State update $\pi_*$ \Comment update as a $\varepsilon$-greedy policy if calculating $q_*$
				\EndIf

				\State $t \gets t+1$
			\EndWhile
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsection{$n$-step off-policy $Q(\sigma )$}

Let random variable $\sigma_t \sim \text{Bern}(0,1)$ be the probability of sampling on step $t$, with $\sigma = 1$ means full sampling and $\sigma = 0$ means pure expectation. The formula is:

\begin{equation}
	\begin{split}
		G_{t:h} =& R_{t+1}+\gamma \sum_{a\neq A_{t+1}} \pi(a|S_{t+1}) Q_{h-1}(S_{t+1},a) + \gamma \pi(A_{t+1}|S_{t+1})G_{t+1:h} \\
		=& R_{t+1} + \left (\gamma \sum_a \pi(a|S_{t+1})Q_{h-1}(S_{t+1},a) - \gamma \pi(A_{t+1}|S_{t+1})Q_{h-1}(S_{t+1},A_{t+1}) \right)\\
		&+ \gamma \pi(A_{t+1}|S_{t+1})G_{t+1:h} \\
		=& R_{t+1} + \gamma \sum_a \pi(a|S_{t+1})Q(S_{t+1},a) \\
		&+ \gamma \pi(A_{t+1}|S_{t+1})\Big (G_{t+1:h} -Q_{h-1}(S_{t+1},A_{t+1})  \Big)
	\end{split}
\end{equation}

Replace $\pi(A_{t+1}|S_{t+1})$ by $\Big(\sigma_{t+1} \rho_{t+1} + (1-\rho_{t+1})\pi(A_{t+1}|S_{t+1}) \Big)$ ($\rho$ is the important sampling ratio defined in formula (\ref{importancsamplingratio})) we have:

\begin{equation}
	\begin{split}
		G_{t:h} =& R_{t+1} + \gamma \sum_a \pi(a|S_{k+1})Q(S_{k+1},a) \\
		&+ \gamma \Big ( \sigma_{t+1} \rho_{t+1} + (1-\rho_{t+1})\pi(A_{t+1}|S_{t+1}) \Big) \Big(G_{t+1:h} -Q_{h-1}(S_{t+1},A_{t+1}) \Big)
	\end{split}
\end{equation}

$\sum\limits_a \pi(a|S_{t})Q(S_{t},a)$ is called \cindex{expected approximate value} of state $S_t$.

See Algorithm (\ref{algo:nstepoffrho}) for detail.

\begin{algorithm}
	\caption{Off-policy $n$-step $Q(\sigma)$, estimate $q_\pi$ or $q_*$}\label{algo:nstepoffrho}

	\begin{algorithmic}[1]
		\State $ \alpha \in (0,1]$
		\State $Q(s,a) \gets$ random
		\State $\pi \gets$ random $\varepsilon$-greedy policy
		\State random policy $b$ that $\forall a\in \mathcal{A}, s\in \mathcal{S}, b(a|s) > 0$
		\State $t \gets 0$

		\Statex

		\Loop
			\State choose $S_0$
			\State choose action $A_0 \sim b (\cdot | S_0)$
			\State $T \gets \infty$
			\While{$\tau < T - 1$}
				\If{$t < T$}
					\State take action $A_t$ and store $R_{t+1}$ and $S_{t+1}$
					\If{$S_{t+1}$ is terminal}
						\State $T \gets t+1$
					\Else
						\State choose $A_{t+1} \sim b(\cdot|S_{t+1})$
						\State choose $\sigma_{t+1} \in \{ 0, 1\}$ \Comment $\sigma$ is either $0$ or $1$
						\State $\rho_{t+1} \gets \frac{\pi(A_{t+1}|S_{t+1})}{b(A_{t+1}|S_{t+1})}$
					\EndIf
				\EndIf

				\State $\tau \gets t - n + 1$ \Comment $\tau$ is the pivot of update

				\If{$\tau \geq 0$}
					\For{$k \gets \Big [\min (t+1,T),\dots,\tau+1 \Big ]$}
						\If{$k=T$}
							\State $G \gets R_T$
						\Else
							\State $\overline{V} \gets \sum\limits_a \pi(a|S_{k})Q(S_{k},a)$
							\State $G \gets R_{k} + \gamma \overline{V} + \gamma \Big ( \sigma_{k} \rho_{k} + \big(1-\rho_{k})\pi(A_{k}|S_{k}) \Big) \Big(G -Q(S_{k},A_{k}) \Big  )$
						\EndIf
					\EndFor
					\State $G(S_\tau,A_\tau) \gets G(S_\tau,A_\tau) + \alpha \Big(G - G(S_\tau,A_\tau)\Big)$
					\State update $\pi_*$ \Comment update as a $\varepsilon$-greedy policy if calculating $q_*$
				\EndIf

				\State $t \gets t+1$
			\EndWhile
		\EndLoop
	\end{algorithmic}
\end{algorithm}


\label{sfp}
\begin{chapterbox}
\vspace{-60pt}
\chapter{Symmetries, Fields and Particles}\label{chap:sfp}
\vspace{-30pt}
\centering\normalsize\textit{Michaelmas Term 2017 - Professor N. Dorey}
\end{chapterbox}
\vspace{20pt}
%\begin{multicols*}{2}
\minitoc
\newpage
\section{Introduction}
\subsection{Mathematical Formulation}

\begin{definitionbox}
A Lie Group\index{group!Lie}, $\group$, is a group which is also a smooth manifold\index{manifold}. Each point on the manifold corresponds to an element of the group.
\end{definitionbox}
We need the group and manifold structure to be compatible, requiring continuity and smoothness for multiplicative and inverse properties of the group. This ensures $\group$ is almost entirely determined by the behaviour near $e$, i.e. by tangent vectors, $V \in \mathcal{T}_e(\group)$. $\mathcal{T}_e(\group)$ is equipped with a Lie Bracket:
$$\left[\,\,\, , \,\,\,\right]:\mathcal{T}_e(\group)\times \mathcal{T}_e(\group) \rightarrow \mathcal{T}_e(\group)$$
which defines a Lie Algebra, $\mathcal{L}(\group)$. \boxed{\textbf{I.i}} \boxed{\textbf{I.ii}} \boxed{\textbf{I.iii}}

\subsection{Simple, Complex Lie Algebras}

\subsubsection{Cartan Classification}

\begin{definitionbox}
All \emph{finite dimensional semi-simple} Lie Algebras over $\mathbb{C}$ either belong to four infinite families: $A_n, B_n, C_n, D_n$ with $n \in \mathbb{N}$, or are one of the five exceptional cases: $E_6, E_7, E_8, G_2, F_4$.
\end{definitionbox}
In quantum mechanics, the states of the system are states in some Hilbert space, $\mathfrak{H}$. To understand the symmetries, we just need to understand the commutators of the symmetry, e.g. $\left[ \hat{L}_i , \hat{L}_j \right] = i\epsilon\indices{_{ijk}} \hat{L}_k$ which is the algebra of $\mathcal{L}\left(\textrm{SO}(3)\right)$. The operators often act on some finite dimensional vector space, $\mathcal{H}$, the \emph{representation space}. For an electron, this is $\mathcal{H} = \mathbb{C}^2$, the operators then lie in a 2-dimensional representation of $\mathcal{L}\left(\textrm{SO}(3)\right)$: the Pauli matrices, $\sigma_i$ which preserves the Lie bracket structure. If the system is invariant under this symmetry, then we have $\left[ \mathcal{H} , \hat{L}_i \right] = 0$ and thus all the states in some irreducible representation have the same energy. This can be generalised:
\begin{definitionbox}
Degeneracies in the spectrum of a quantum system are determined by irreducible representations of a global symmetry.
\end{definitionbox}
\noindent Global symmetries split into two classes (note that these are distinct from gauge symmetries):
\begin{itemize}
\item \emph{Spacetime symmetries:} rotational, Lorentz, Poincar�, supersymmetry (?)
\item \emph{Internal symmetries:} electric charge, flavour, baryon number
\end{itemize}

\subsection{Gauge Symmetry}

In contrast, a gauge symmetry\index{symmetry!gauge} is a redundancy in the mathematical description, for example in the phase of the wavefunction, $\psi \rightarrow e^{i\delta}\psi$, or in Electromagnetism, $A_{\mu} \rightarrow A_{\mu} + \partial_{\mu}\chi$. The Standard Model is a non-Abelian gauge theory with $\group_{\textrm{SM}}=\textrm{SU}(3) \times \textrm{SU}(2) \times \textrm{U(1)}$.
\newpage
\section{Lie Groups}

\subsection{Manifolds}

We can cover a manifold of dimension $n$ with one-to-one functions called \emph{charts}\index{chart}, $\phi_{\alpha} : U_{\alpha} \rightarrow V_{\alpha} \subset \mathbb{R}^n$.

\begin{thm}\label{thm:manifold}
Suppose we have a map $F : \mathbb{R}^n \rightarrow \mathbb{R}^m$ where $m<n$ with co-ordinates $\left\{ x_i \right\}$, $i = 1, \ldots, n$ and $\left\{ w_{\alpha} \right\}$, $\alpha = 1, \ldots, m$. A manifold $\mathcal{M}$ is a solution to the equations:
\begin{dmath}
F_{\alpha}\left( x_1, \ldots, x_n \right) \hiderel{=} w^{(0)}_{\alpha} \hiderel{\iff} \mathcal{M} \hiderel{=} F^{-1}\left( \bm{w}^{(0)} \right) = \left\{ \bm{x} \hiderel{\in} \mathbb{R}^n \hiderel{:} F_{\alpha}\left( \bm{x} \right) \hiderel{=} w^{(0)}_{\alpha} \right\}
\end{dmath}
Now define the Jacobian\index{Jacobian} matrix:
\begin{equation}
\mathfrak{J}\indices{_{\alpha i}}=\frac{\partial F_{\alpha}}{\partial x_i}
\end{equation}
Then, if $\mathfrak{J}$ has full rank, $m$, $\mathcal{M}$ is a manifold of dimension $(n-m)$.
\end{thm}

\subsection{Back to Lie Groups}

The dimension of $\group$, $\dim \group$, is the dimension of the group manifold $\mathcal{M}\left( \group \right)$. We can introduce co-ordinates $\left\{ \theta^i \right\}$, $i = 1, \ldots, \dim \group$ in some co-ordinate patch containing the identity $e \in \group$. Then the group elements depend continuously on $\bm{\theta}$, $g = g(\bm{\theta})$. Then:

\begin{enumerate}
\item \emph{Group Multiplication:} corresponds to a smooth map from $\group \times \group \rightarrow \group$. The co-ordinates
$$\phi^i = \phi^i \left( \bm{\theta}, \bm{\theta}' \right)$$
are differentiable and continuous. Then $g(0) = e \Rightarrow \phi^{i} \left( \bm{\theta}, 0 \right) = \theta^{i}, \,\,\, \phi^{i} \left( 0, \bm{\theta}' \right)  = \theta^{\prime i}$.
\item \emph{Group Inversion:} This defines a smooth map from $\group \rightarrow \group$ where the co-ordinates:\footnote{To be a bit more precise, consider a map $f: \mM(\group) \rightarrow \mM(\group)$ that induces a map $\theta \mapsto \tilde{\theta}$. Suppose we have charts $\phi$ and $\tilde{\phi}$ on the domain space and the image space respectively, then the statement that $\theta \mapsto \tilde{\theta}$ is a smooth map is really the property that $\tilde{\phi}^{-1} \circ f \circ \phi$ is a smooth map from $\RR^{n}$ to $\RR^{n}$ where $\dim \mM(\group) = n$.}
$$\tilde{\theta}^i = \tilde{\theta}^i\left( \bm{\theta} \right)$$

\noindent are continuous and differentiable.
\end{enumerate}

\subsection{Matrix Groups\index{group!matrix}}\label{mat}

We can define the general linear group\index{group!general linear} and the special linear group\index{group!special linear} as subsets of the set of $n \times n$ matrices, $\textrm{Mat}_n \left( \mathbb{F} \right)$:
\begin{align}
\textrm{GL} \left( n, \mathbb{F} \right) &= \left\{ \textrm{M} \in \textrm{Mat}_n \left( \mathbb{F} \right) : \det \textrm{M} \neq 0 \right\} \\
\textrm{SL} \left( n, \mathbb{F} \right) &= \left\{ \textrm{GL}_n \left( n, \mathbb{F} \right) : \det \textrm{M} = 1 \right\}
\end{align}
Using a construction as in Theorem \ref{thm:manifold} for the case $\textrm{SL} \left( n, \mathbb{R} \right)$ we can choose $F : \mathbb{R}^{n^2} \rightarrow \mathbb{R}$ to be $F\left( \textrm{M} \right) = \det \textrm{M}$ which can be shown to have full rank. Then we deduce $\textrm{SL} \left( n, \mathbb{R} \right)$ is a Lie Group of dimension $(n^2 - 1)$. This can be done less obviously for $\textrm{GL} \left( n, \mathbb{F} \right)$ to find:\footnote{To understand the case of $\text{GL}\left(n, \mathbb{F}\right)$, one can view the condition $\det \text{M} \neq 0$ as excluding a set of matrices of measure $0$ in the space of $n \times n$ matrices. To understand why it is a manifold at all, it is useful to consider the idea of algebraic varieties. Note that $\det \text{M} = 0$ is an algebraic relation between the co-ordinates (matrix elements). The resulting subset of the larger group (in this case $\text{Mat}(n, \mathbb{F})$) is a manifold provided there are no singularities. Arguing as follows, suppose there was some singularity at $g_1 \in \group$, then there must be singularities everywhere since $g_2 g^{-1}_1$ is smooth in the larger group. This is a contradiction, so algebraically defined subgroups are indeed manifolds, and hence are Lie groups.}
\begin{center}
\begin{mytable}{lc}
	\textbf{Group, }$\group$ 				& \textbf{Dimension, }$\dim \group$	\\ \midrule
    	$\textrm{SL} \left( n, \mathbb{R} \right)$	& $n^2 - 1$					\\
	$\textrm{SL} \left( n, \mathbb{C} \right)$	& $2n^2 - 2$					\\
	$\textrm{GL} \left( n, \mathbb{R} \right)$	& $n^2$						\\
	$\textrm{GL} \left( n, \mathbb{C} \right)$	& $2n^2$
\end{mytable}
\captionof{table}{Matrix Lie Groups and their dimensions, note that in the case of $\textrm{SL} \left( n, \mathbb{C} \right)$, the complex dimension of the space has decreased by $1$, and so the real dimension decreases by $2$.}
\end{center}
\begin{definitionbox}
A subgroup, $\mathscr{H}$ of a Lie Group, $\group$, such that $\mathscr{H}$ is also a submanifold of $\group$ is a Lie subgroup\index{subgroup!Lie}.
\end{definitionbox}

\subsubsection{Subgroups of $\textrm{GL} \left( n, \mathbb{R} \right)$\index{subgroup!matrix}}

\subsubsection*{Orthogonal Groups\index{group!orthogonal}}

We define the orthogonal group, $\textrm{O}(n)$ by:
\begin{equation}
\textrm{O}(n) = \left\{ \textrm{M} \in \textrm{GL} \left( n, \mathbb{R} \right) : \textrm{M}^T \textrm{M} = \mathbb{I}_n \right\}
\end{equation}
We know that $\textrm{M} \in \textrm{O}(n)$ has $\det \textrm{M} = \pm 1$, so as a Lie group it has two disconnected components which follows from the lemma below applied to the function $\det : \textrm{O}(n) \rightarrow \left\{+1, -1\right\}$:
\begin{thm}\label{thm:cts}
Any continuous map from a continuous space to a discrete space must be a constant.
\end{thm}
If we pick only the part containing the identity we are just left with $\textrm{SO}(n)$. By considering the real constraints placed on the matrices and noting that since $\textrm{SO}(n)$ is the identity part of $\textrm{O}(n)$, it must have the same dimension as a manifold, we may deduce that:
\begin{equation}
\dim \textrm{SO}(n) = \dim \textrm{O}(n) = \tfrac{1}{2}n(n-1)
\end{equation}
We now investigate the manifold structure of $\textrm{SO}(2)$\index{SO(2)} and $\textrm{SO}(3)$\index{SO(3)}. For matrices in $\textrm{O}(n)$, the following holds:
\begin{itemize}
\item $\lambda$ is an eigenvalue $\Rightarrow$ $\lambda^*$ is also.
\item $\left| \lambda \right|^2 = 1$
\end{itemize}
We apply this to the two examples mentioned.
\begin{examplebox}[$\textrm{SO}(2)$]
For $\group = \textrm{SO}(2)$, the eigenvalues must be $e^{i \theta}$, $e^{-i \theta}$, which in turn implies that;
\begin{equation}
\textrm{M}(\theta) = \twobytwo{\cos\theta}{-\sin\theta}{\sin\theta}{\cos\theta}
\end{equation}
On $\textrm{SO}(2)$, $\textrm{M}(\theta_1)\textrm{M}(\theta_2) = \textrm{M}(\theta_1 + \theta_2) = \textrm{M}(\theta_2)\textrm{M}(\theta_1)$, i.e. it is abelian. Noting further that $\theta \sim \theta + 2\pi$, $\theta \in \mathbb{R}$ we deduce that the group manifold is $\mathcal{M}\left( \textrm{SO}(2) \right) = \mathcal{S}^1$.
\end{examplebox}
\begin{examplebox}[$\textrm{SO}(3)$]
The example of $\textrm{SO}(3)$ is less trivial. $\text{M} \in \SO{3}$ has eigenvalues $\set{e^{i\theta}, e^{-i\theta}, +1}$. Now consider eigenvector associated to $\lambda = 1$, $\vec n \in \mathbb{R}^3$ which satisfies $\text{M} \vec n = \vec n$. This is the axis of rotation. Now a general group element is;
\begin{equation}
\text{M}(\vec n, \theta)_{ij} = \cos \theta \delta_{ij} + (1- \cos \theta) n_i n_j + \sin \theta \epsilon_{ijk} n_k
\end{equation}
Now since $\cos(2\pi - \theta) = \cos \theta$ and $\sin(2\pi - \theta) = -\sin \theta$, we deduce that $\text{M}(\vec n, 2\pi - \theta) = \text{M}(-\vec n, \theta)$. Hence we must restrict to $0 \leq \theta \leq \pi$, but with the identification $(\vec n, +\pi) \sim (-\vec n, -\pi)$. Considering the vector $\vec w = \theta \vec n$, we see that it lies within the $3$-ball, $\mathcal{B}_3 = \set{\vec w \in \mathbb{R}^3 : \abs{\vec w} \leq \pi} \subset \mathbb{R}^3$ with the additional structure that antipodal points on the boundary, $\del \mathcal{B}_3 = \set{\vec w \in \mathbb{R}^3 : \abs{\vec w} = \pi}$ are identified. This makes the $3$-ball a manifold, and hence the manifold, $\mathcal{M}\left(\SO{3}\right)$ is the $3$-ball with boundary, with antipodal points identified.\footnotemark
\end{examplebox}
\footnotetext{This is also isomorphic to the real projective space $\mathbb{R}\mathbb{P}^3$}
There is a little more to say about $\mathcal{M}\left(\SO{3}\right)$;
\begin{enumerate}
\item It is compact\index{compact}, i.e. it is closed and bounded where closed means the manifold contains all limit points, and bounded means $\exists A > 0 : \forall x \in \mathcal{M}\left(\SO{3}\right), \| x \| < A$
\item It is without boundary due to the identification
\item It is connected\index{connected}, but not simply connected\index{connected!simply}. We can draw paths between any two points but not all loops\index{loop} are contractible\index{loop!contractible}. A loop is a function $f : \mathcal{S}^1 \rightarrow \mathcal{M}$. Loops are equivalent if they can be continuously transformed. Then the \emph{homotopy group} is the set of equivalence classes of loops with composition\index{group!homotopy}. Here the loop $\ell = \set{\alpha \vec v : \alpha \in [-\pi, \pi]}$ is not contractible (joins two points on the boundary through the centre of the sphere), so $\ell \not\sim \set{1}$, but $\ell^2$ is (can move point at $\alpha = \pi$, say, both ways round the sphere to contract the loop to the identity at $\alpha = - \pi$. So the first homotopy group is $\pi_1\left(\SO{3}\right) = \mathbb{Z}_2$.
\end{enumerate}
\subsubsection*{Non-compact Subgroups of $\text{GL}(n, \mathbb{R})$}
$\text{M} \in \Orth{n}$ preserve the Euclidean metric on $\mathbb{R}^n$. More generally, $\Orth{p,q}$ transformations preserve the flat metric with signature $(p, q)$. A key example of this is the Lorentz group\index{group!Lorentz}, $\Orth{3,1}$ which preserves the Minkowski metric\index{Minkowski metric}. The corresponding group manifolds are non-compact, e.g. $\SO{1,1}$ has matrices of the form,
\begin{equation*}
\twobytwo{\cosh \phi}{\sinh \phi}{\sinh \phi}{\cosh \phi}
\end{equation*}
where $\phi \in \mathbb{R}$, so $\SO{1,1} \simeq \mathbb{R}$.
\subsubsection{Subgroups of $\text{GL}(n, \mathbb{C})$}
\subsubsection*{Unitary Groups\index{group!unitary}}
\begin{equation}
\Uni{n} = \set{\text{U} \in \text{GL}(n, \mathbb{C}) : \text{U}^{\dagger}\text{U} = \mathbb{I}_n}
\end{equation}
Unitary transformations take vectors, $\vec v \in \mathbb{C}^n$ and preserve the length $\abs{\vec v} = \vec{v}^{\dagger} \vec v$. $\text{U} \in \Uni{n}$ have $\det \text{U} = e^{i\delta}$ for some $\delta \in [0,2\pi)$. The fact that this is a continuous function of $\delta$ ensures that the unitary group will be connected unlike the orthogonal group.
\subsubsection*{Special Unitary Groups\index{group!special unitary}}
\begin{equation}
\SU{n} = \set{\text{U} \in \Uni{n} : \det \text{U} = 1}
\end{equation}
Since $\SU{n}$ and $\Uni{n}$ have a manifold structure, they are Lie groups, and hence Lie subgroups of $\text{GL}(n, \mathbb{C})$. The dimensions of the groups follows by considering the $n^2$ constraints on $\Uni{n}$ encoded in the columns of the matrix and their normalisation. The determinant condition then imposes one additional constraint. This is shown in Table \ref{tab:dim_orth_uni}.
\begin{center}
\begin{mytable}{lc}
	\textbf{Group, }$\group$ 				& \textbf{Dimension, }$\dim \group$	\\ \midrule
    	$\Orth{n}$						& $\tfrac{1}{2}n(n - 1)$					\\
	$\SO{n}$							& $\tfrac{1}{2}n(n - 1)$					\\
	$\Uni{n}$							& $n^2$						\\
	$\SU{n}$							& $n^2 - 1$
\end{mytable}
\captionof{table}{Dimensions of the Unitary and Orthogonal Groups}
\label{tab:dim_orth_uni}
\end{center}
\begin{definitionbox}[Lie Group Isomorphisms]
Two Lie Groups $\group$ and $\group^{\prime}$ are isomorphic\index{group!Lie!isomorphism} if $\exists$ $1$:$1$ smooth map $f : \group \rightarrow \group^{\prime}$ such that $\forall g_1, g_2 \in \group$, $f(g_1, g_2) = f(g_1, g_2)$ i.e. it is a homeomorphism of manifolds that preserves the group structure.
\end{definitionbox}
A simple example of this idea is $\Uni{1}$ and $\SO{2}$. We can parametrise $z \in \Uni{1}$ by $\theta \in [0, 2\pi)$. Then an element in $\SO{2}$ can be written,
\begin{equation}
g = \text{M}(\theta) = \twobytwo{\cos\theta}{\sin\theta}{-\sin\theta}{\cos\theta}
\end{equation}
where the periodicity ensures, $\theta \sim \theta + 2\pi$. So $\Uni{1} \simeq \mathcal{S}^1 \simeq \SO{2}$.
\begin{examplebox}[The case of $\SU{2}$]
It can be shown that $\forall g \in \SU{2}$\footnotemark,  we can write;
\begin{equation}
\label{eq:pauli}
g = a_0 \mathbb{I}_2 + i \vec a \cdot \vec \sigma, \quad a_0^2 + a_1^2 + a_2^2 + a_3^2 = 1
\end{equation}
Thus we deduce that $\mathcal{M}\left(\SU{2}\right) = \mathcal{S}^3$. Now $\pi_1\left(\mathcal{S}^3\right) = \pi_1\left(\SU{2}\right) = \varnothing$, so it cannot be the case that $\SU{2} \simeq \SO{3}$ even though they have the same dimension.
\end{examplebox}
\footnotetext{Simply expand the expression in \eqref{eq:pauli} in terms of the Pauli matrices, and apply the determinant condition.}
\newpage
\section{Lie Algebras}
A Lie algebra\index{Lie!algebra}, $\alge$ is a vector space with a bracket, $\left[\,\,\,, \,\,\right] : \alge \times \alge \rightarrow \alge$ which satisfies;
\begin{enumerate}
\item Anti-symmetry - $\left[X, Y\right] = -\left[Y, X\right] \forall X, Y \in \alge$
\item Linearity - $\left[\alpha X + \beta Y, Z\right] = \alpha\left[X, Z\right] + \beta\left[Y, Z\right] \forall X, Y, Z \in \alge$
\item Jacobi Identity\index{identity!Jacobi} - $\left[X, [Y, Z]\right] + \left[Z, [X, Y]\right] + \left[Y, [Z, X]\right] = 0$
\end{enumerate}
With this in mind, if a vector space, $\mathcal{V}$, has an associative product $\star : \mathcal{V} \times \mathcal{V} \rightarrow \mathcal{V}$ then we can make it a Lie Algebra by setting $[X, Y] = X \star Y - Y \star X$. The dimension of a Lie algebra, $\alge$, is the dimension of the vector space. As it is a vector space, we can choose a basis $\mathcal{B}$ for $\alge$;
\begin{equation}
\mathcal{B} = \set{T^a, a = 1, \ldots \dim \alge}
\end{equation}
then we can write $X \in \alge$ as $X = X_a T^a$ with $X^a \in \mathbb{F}$. Then brackets of the basis elements define the brackets of the vectors $X, Y, \ldots \in \alge$
\begin{equation}
\left[X, Y\right] = X_a Y_b \left[T^a, T^b\right], \quad \left[T^a, T^b\right] = f\indices{^{ab}_{c}}T^c
\end{equation}
where the $\set{f\indices{^{ab}_{c}}}$ are the structure constants satisfying $f\indices{^{(ab)}_{c}} = 0$.
\begin{definitionbox}[Lie Algebra Isomorphism]
Two Lie algebras $\alge$, $\alge^{\prime}$ are isomorphic\index{Lie!algebra!isomorphism} if $\exists$ a $1$:$1$ linear map $f : \alge \rightarrow \alge^{\prime}$ such that the bracket structure is preserved;
\begin{equation}
\left[f(X), f(Y)\right] = f\left([X, Y]\right), \quad \forall X, Y \in \alge
\end{equation}
\end{definitionbox}
A \emph{subalgebra}\index{subalgebra} $\mathfrak{h} \subset \alge$ is a subset of $\alge$ that is also a Lie algebra. Furthermore, an \emph{ideal}\index{ideal!of a Lie algebra} is a subalgebra $\mathfrak{h}$ of $\alge$ such that $[X, Y] \in \mathfrak{h} \forall X \in \alge, Y \in \mathfrak{h}$. Every Lie algebra has two trivial ideals; $\mathfrak{h} = \varnothing, \mathfrak{h} = \alge$, but there are two less trivial examples;
\begin{enumerate}
\item The \emph{derived} algebra\index{algebra!derived}\index{ideal!derived algebra};
\begin{equation}
\mathfrak{i} \coloneqq [\alge, \alge] = \vecspan\set{[X, Y] : X, Y \in \alge}
\end{equation}
\item The \emph{centre}\index{ideal!centre};
\begin{equation}
\zeta(\alge) = \set{X \in \alge : [X, Y] = 0 \quad \forall Y \in \alge}
\end{equation}
An abelian Lie algebra\index{Lie algebra!abelian} is one for which $\zeta(\alge) = \alge \Rightarrow \mathfrak{i} = \varnothing$.
\end{enumerate}
\begin{definitionbox}[Simple Lie Algebras]
$\alge$ is \emph{simple}\index{Lie algebra!simple} if it is non-abelian and possesses no non-trivial ideal. Cartan's classification encompasses all finite dimensional, complex ($\mathbb{C}$), simple Lie algebras.
\end{definitionbox}
\subsection{Lie Algebras from Lie Groups}
\subsubsection{Preliminaries}
Let $\mathcal{M}$ be a smooth manifold, with $\dim \mathcal{M} = D$, and let $p \in \mathcal{M}$. Introduce co-ordinates $\set{x^i}, i = 1, \ldots, D$ in some region $\mathcal{P} \subset \mathcal{M}$ with $p$ at $x^i = 0$. Then;
\begin{itemize}
\item The tangent space\index{tangent space} $\TpM$ to $\mathcal{M}$ at $p$ is a $D$-dimensional vector space spanned by $\set{\tfrac{\del}{\del x^i}}$ acting on functions $f : \mathcal{M} \rightarrow \mathbb{R}$. Then a tangent vector\index{tangent vector} is defined by;
\begin{equation}
v = v^i \frac{\del}{\del x^i} \in \TpM, v^i \in \mathbb{R}
\end{equation}
which acts on functions, $f = f(x)$ via;
\begin{equation}
v \cdot f = \left.v^i \frac{\del f}{\del x^i}\right|_{x = 0}
\end{equation}
\item Let $\mathcal{C}$ be a smooth curve passing through $p$, then;
\begin{equation*}
\mathcal{C} : t \in \mathbb{R} \mapsto x^i(t) \in \mathbb{R}
\end{equation*}
where the $\set{x^i(t)}$ are continuous and differentiable with $x^i(0) = 0 \,\, \forall i$.
\item The tangent vector to a curve $\mathcal{C}$ at the point $p$ is an element of $\TpM$, $v_{\mathcal{C}} = \dot{x}^i(0)\tfrac{\del}{\del x^i}$. Acting on functions corresponds to the derivative of $f$ along $\mathcal{C}$;
\begin{equation}
v_{\mathcal{C}} \cdot f = \left.\dot{x}^i(0) \frac{\del f(x)}{\del x^i}\right|_{x=0} = \left.\frac{\ud f}{\ud t}\right|_{t = 0}
\end{equation}
\end{itemize}
\subsubsection{The Lie Algebra, $\lie{\group}$}
Let $\group$ be a Lie group of dimension $D$. Introduce co-ordinates $\set{\theta^i}$ in some region containing the identity ($g = g(\theta) \in \group, g(0) = e$). Then the tangent space at the identity, $\TeG$ is $D$-dimensional vector space. We can define a bracket $[\,\,\,,\,\,] : \TeG \times \TeG \rightarrow \TeG$ such that $\lie{\group} = \left(\TeG, [\,\,\,,\,\,]\right)$ is a Lie algebra. We start by doing this for matrix groups. Let $\group \subset \text{Mat}_n(\mathbb{F})$ for some $n \in \mathbb{N}$. Now we can map tangent vectors to matrices;
\begin{equation}
e : \TeG \rightarrow \text{Mat}_n(\mathbb{F}), \quad v^i \frac{\del}{\del \theta^i} \in \TeG \mapsto \left.v^i \frac{\del g(\theta)}{\del \theta^i}\right|_{\theta = 0} \in \text{Mat}_n(\mathbb{F})
\end{equation}
This allows us to identify $\TeG$ with a subspace of $\text{Mat}_n(\mathbb{F})$ spanned by $\set{\left.\tfrac{\del g(\theta)}{\del \theta^i}\right|_{\theta = 0}}$, which is valid since $e$ is linear and injective (it will span some subspace of $\text{Mat}_n(\mathbb{F})$). Now the obvious bracket is just the matrix commutator;
\begin{equation}
[X, Y] \overset{\textrm{\tiny def}}{=} XY - YX, \quad \forall X, Y \in \TeG
\end{equation}
where we make the identification of $X, Y$ with $e(X), e(Y)$. Then since it is just a matrix commutator, all that remains is to show that the bracket is closed i.e. $[X, Y] \in \lie{\group} \,\,\forall X, Y \in \lie{\group}$\footnotemark. To prove this we use the correspondence between tangent vectors and curves; it is sufficient to construct a curve with tangent vector $[X_1, X_2]$ from two curves with tangent vectors $X_1, X_2$.
\footnotetext{This ensures that it is okay to make the identification $X, Y \mapsto e(X), e(Y)$ as $e$ is only injective. If the commutator went outside the algebra, we would not have a defined inverse to map back to an element of the Lie algebra.}

\paraskip
Let $\mC$ be a smooth curve\index{curve!in a Lie group} on $\group$ passing through the identity, $\mC : t \mapsto g(t) \in \group, g(0) = \mathbb{I}_n$. Then;
\begin{equation}
\frac{\ud g(t)}{\ud t} = \frac{\ud \theta^i (t)}{\ud t} \frac{\del g(\theta)}{\del \theta^i} \Rightarrow \dot{g}(0) = \dot{\theta}^i(0)\left.\frac{\del g(\theta)}{\del \theta^i}\right|_{\theta = 0} \in \TeG
\end{equation}
Now near $t = 0$, $g(t) = \II_n + X t + o(t)$ with $X = \dot{g}(0) \in \lie{\group} \simeq \TeG$.\footnotemark$\,\,$ Then we can construct curves, $\mC_{k} : t \mapsto g_k(t) \in \group$ such that near $t = 0$;
\begin{equation}
g_1(t) = \II_n + X_1 t + W_1 t^2 + o(t^2), \quad g_2(t) + X_2 t + W_2 t^2 + o(t^2)
\end{equation}
for some $W_1, W_2 \in \text{Mat}_n(\FF)$ and $X_1 = \dot{g}_1(0), X_2 = \dot{g}_2(0) \in \lie{\group}$. Finally consider the curve, $h(t) = g_1^{-1}(t)g_2^{-1}(t)g_1(t)g_2(t) \in \group$. Expanding near $t = 0$ we find that;
\begin{equation}
h(t) = \II_n + [X_1, X_2] t^2 + o(t^3)
\end{equation}
Thus, defining a curve, $\mC_3 : s \mapsto g_3(s) \coloneqq h(\sqrt{s})$, we see that;
\begin{equation}
g_3(s) = \II_n + s[X_1, X_2] + o\left(s^{\tfrac{3}{2}}\right) \Rightarrow \dot{g}_3(0) = [X_1, X_2] \in \lie{\group}
\end{equation}
\footnotetext{Note that whilst in general $\dot{g}(0) \in \text{Mat}_n (\FF)$, it is not generally in $\group$. This is just because the Lie algebra has a different algebraic structure to the group.}

Thus, $\lie{\group} = \left(\TeG, [\,\,\,,\,\,]\right)$ is a Lie algebra of dimension $D$.\footnote{To fill in the details, we only need our curve to be $\mC^1$. Differentiating gives lowest order terms $\mathcal{O}\left(s^{\tfrac{1}{2}}\right)$, so $\mC_3 \in \mC^1$.} We can apply these ideas to examples of matrix Lie groups covered in previous sections. Consider the case $\SO{n}$, we may write $g(t) = \text{R}(t) \in \SO{n} : \text{R}(0) = \II_n$, so $\text{R}^{\text{T}}(t) \text{R}(t) = \II_n$. Differentiating we find;
\begin{equation}
\dot{\text{R}}^{\text{T}}(t)\text{R}(t) + \text{R}^{\text{T}}\dot{\text{R}}(t) = 0 \,\,\, \forall t \in \RR \overset{t = 0}{\Longrightarrow} X^{\text{T}} + X = 0
\end{equation}
where we have set $X = \dot{\text{R}}(0)$ and used $\text{R}(0) = \text{R}^{\text{T}}(0) = \II_n$. Importantly, no further constraints come from the determinant condition since we are already in the neighbourhood of $\II_n$ and hence the determinant must be $1$ as $\Orth{n}$ is disconnected. Hence, $\lie{\Orth{n}} \simeq \lie{\SO{n}} \simeq \set{X \in \text{Mat}_n(\RR) : X^{\text{T}} = - X}$. We could do the same for $\Uni{n}$ and $\SU{n}$ (where now we do need the determinant condition\footnote{We make use of the identity $\det\left(\II_n + Zt + o(t)\right) = 1 + t(\text{tr}Z) + o(t)$ to deduce that $\text{tr}Z = 0$ in the case of $\SU{n}$.}) to find;
\begin{equation}
\lie{\SU{n}} = \set{Z \in \text{Mat}_n(\CC) : Z^\dagger = - Z, \text{tr}Z = 0}
\end{equation}
i.e. the set of traceless\index{traceless}, anti-hermitian\index{anti-hermitian} $n \times n$ matrices. Immediately we see that $\dim \SU{n} = \dim \lie{\SU{n}} = n^2 -1$. We can apply this directly to $\lie{\SU{2}}$ which has dimension $3$. The three basis elements are provided by the Pauli matrices\footnotemark\index{Pauli matrices}, $\sigma_a$, which are made anti-hermitian by defining the basis $T^a = -\tfrac{1}{2} i \sigma_a$. We can calculate the structure constants;
\footnotetext{Recall that the Pauli matrices are given by;
\begin{equation*}
\sigma_1 = \twobytwo{0}{1}{1}{0}, \quad \sigma_2 = \twobytwo{0}{-i}{i}{0},\quad \sigma_3 = \twobytwo{1}{0}{0}{-1}
\end{equation*}
}
\begin{equation}
[T^a, T^b] = -\tfrac{1}{4}[\sigma_a, \sigma_b] = -\tfrac{1}{2}i\epsilon_{abc}\sigma_c = \epsilon_{abc}T^c \Rightarrow f\indices{^{ab}_{c}} = \epsilon_{abc}
\end{equation}
Picking the obvious basis for $\lie{\SO{3}}$ now;
\begin{equation*}
\tilde{T}^1 = \thrbythr{0 & 0 & 0}{0 & 0 & -1}{0 & 1 & 0}, \quad \tilde{T}^2 = \thrbythr{0 & 0 & 1}{0 & 0 & 0}{-1 & 0 & 0}, \quad \tilde{T}^3 = \thrbythr{0 & -1 & 0}{1 & 0 & 0}{0 & 0 & 0}
\end{equation*}
which can be shown to have the same structure constants\index{structure constants} as $\lie{\SU{2}}$.
\begin{definitionbox}
It is sufficient that the structure constants are the same for two Lie algebras to be isomorphic. Hence $\lie{\SO{3}} \simeq \lie{\SU{2}}$ despite the fact that $\SO{3} \not\simeq \SU{2}$. Indeed it is the case that $\SO{3} \simeq \SU{2} / \ZZ_2$
\end{definitionbox}
To prove this last statement, suppose we have two Lie algebras $\alge_1$, $\alge_2$ of the same dimension with bases $\set{T^a_1}$ and $\set{T^a_2}$ respectively such that;
\begin{equation*}
[T_1^a, T_1^b] = f\indices{^{ab}_{c}}T^c, \qquad [T^a_2, T^b_2] = g\indices{^{ab}_{c}}T^c_2
\end{equation*}
To show that the two are isomorphic, it is sufficient to construct a Lie algebra isomorphism $\phi : \alge_1 \rightarrow \alge_2$. In other words, a linear vector space automorphism that preserves the bracket structure $\phi([A, B]) = [\phi(A), \phi(B)]$. We propose the linear map that maps $\phi(T_a^2) = T^a_2$ which are clearly linearly independent in $\alge_2$ since $\set{T^a_2}$ is a basis. They also span $\alge_2$ so this is bijective. Now, consider;
\begin{align*}
\phi([T^a_1, T^b_1]) &= \phi(f\indices{^{ab}_{c}}T^c_1) \\
&= f\indices{^{ab}_{c}}\phi(T^c_1) \\
&= f\indices{^{ab}_{c}}T^c_2 \\
[\phi(T^a_1), \phi(T^b_1)] &= [T^a_2, T^b_2] \\
&= g\indices{^{ab}_{c}}T^c_2
\end{align*}
So we see that it is sufficient that $f\indices{^{ab}_{c}} = g\indices{^{ab}_{c}}$ for the Lie algebra isomorphism property to hold (taking suitable linear combinations of basis vectors). It is not necessary however since the structure constants are basis dependent.
\subsection{Why are Lie Groups special?}
For each $h \in \group$, consider constructing the smooth maps;\footnote{They must be smooth since multiplication is smooth in $\mM(\group)$.}
\begin{itemize}
\item $L_h : \group \rightarrow \group$ such that $g \in \group \mapsto hg \in \group$
\item $R_h : \group \rightarrow \group$ such that $g \in \group \mapsto gh \in \group$
\end{itemize}
These are known as left/right translations\index{translation}. We will now show that these are in fact bijections on $\group$;

\paraskip
\textbf{Surjective} Consider $h \in \group$, now for all $g\pr \in \group$, construct $h^{-1}g\pr$ which must be in the group. So $h^{-1}g\pr = g$ for some $g \in \group$. So $\forall g\pr \in \group$ $\exists g \in \group$ such that $g\pr = hg$. So $\group = h\group$.

\paraskip
\textbf{Injective} Suppose that $L_h(g) = L_h(g\pr)$, then $hg = hg\pr$, but $h^{-1} \in \group$, so $g = h^{-1}hg\pr \Rightarrow g = g\pr$.

\paraskip
So $L_h$ (and in an identical fashion $R_h$) is injective and surjective, so it is bijective. We now switch focus from $\group$ to $\mM(\group)$. As mentioned above, $L_h$ is smooth as a map on $\mM(\group)$ and we have just shown it is a bijection, so $L_h$ are \emph{diffeomorphisms of} $\mM(\group)$. Now, if we introduce co-ordinates on the manifold $\set{\theta^i}$ in some region containing the identity, and let $\tilde{g} = g(\tilde{\theta}) \coloneqq L_h\left(g(\theta)\right) = h\cdot g(\theta)$. Then $L_h$ is specified by $D$ real functions $\tilde{\theta}^i(\theta)$. But, $L_h$ is a diffeomorphism as a map on manifolds, so the Jacobian;
\begin{equation*}
J\indices{^{i}_{j}} = \frac{\del \tilde{\theta}^i}{\del \theta^j}
\end{equation*}
is non-degenerate/invertible. This is the key feature to what follows.
\subsubsection{Vector Fields on $\mM(\group)$}
We can view the map $L_h$ (or diffeomorphisms in general) as a change of co-ordinates on our manifold $\theta \mapsto \tilde{\theta}$. In a co-ordinate basis, the tangent spaces are spanned by $\del/\del\theta^i$, so it is natural that $L_h : \mM(\group) \rightarrow \mM(\group)$ should induce a map $L_h^{\star}$ from tangent vectors at $g$ to tangent vectors at $L_h(g)$. We can think of this is a few ways; firstly we can imagine pulling back the vector/co-ordinates from the point $L_h(g)$. Secondly we can imagine changing co-ordinates across the manifold and leaving the vectors in place. More explicitly;
\begin{equation*}
L_h^{\star} : \mathcal{T}_g(\group) \rightarrow \mathcal{T}_{hg}(\group)
\end{equation*}
maps $v = v^i \del_{\theta^i}$ to $\tilde{v} = \tilde{v}^i \del_{\tilde{\theta}^i}$, where;
\begin{equation*}
\tilde{v}^i = J\indices{^{i}_{j}} v^j
\end{equation*}
$L_h^{\star}$ is known as the \emph{differential}\index{differential} of $L_h$. As we mentioned above, the invertibility of $J$ is key here to ensure that this map has a trivial kernel i.e. no non-zero $v$ can be mapped to $\tilde{v} = 0$. Taking this further, a \emph{vector field}\index{vector field} on $\mM(\group)$, $V$ specifies a tangent vector $V(g) \in \mathcal{T}_g(\group)$ at each point $g \in \group$. In co-ordinates;
\begin{equation*}
V(\theta) = v^i(\theta)\frac{\del}{\del \theta^i} \in \mathcal{T}_{g(\theta)}(\group)
\end{equation*}
The vector field is smooth if the component functions $v^i(\theta)$ are differentiable. We are now in a position to understand the answer to the question posed at the start of this section. Starting from a tangent vector $\omega \in \mathcal{T}_e(\group)$, we can define a vector field on $\group$;\footnote{Note that we have been somewhat lazy throughout this section about when we use $\group$ and when we use $\mM(\group)$. Essentially the Lie group structure ensures there is a one-to-one correspondence between the two which does not break the algebraic/differentiable structures in each object. As long as you are happy that, for example, $\group$ doesn't have the notion of a tangent space (it is a group), but $\mM(\group)$ does so we can do the calculations there and transform back, then $\mathcal{T}_g(\group)$ should cause no confusion.}
\begin{equation}
V(g) = L_g^{\star}(\omega) \qquad \forall g \in \group
\end{equation}
We know that $L_g^{\star}$ is smooth, and more importantly invertible. If $\omega \neq 0$ initially, then it will remain as such. So $V(g)$ is smooth and everywhere non-vanishing. Starting from a basis $\set{\omega^a}$ of $\mathcal{T}_e(\group)$, we can thus construct $D$ nowhere vanishing vectors fields known as \emph{left-invariant vector fields}\index{vector field!left-invariant} on $\group$; $V^a(g) = L_g^\star(\omega^a)$. This is a very strong constraint on $\mM(\group)$. Indeed for $D = 2$, the hairy ball theorem states that $S^2$ does not admit a nowhere vanishing vector field, so it \emph{cannot be the case} that $\mM(\group) = S^2$ for any Lie group $\group$. In fact, in $D = 2$, the only compact manifold that admits these vector fields is the torus $T^2 = S^1 \times S^1$, so we can deduce that the only compact $2$-dimensional Lie group is actually $\Uni{1} \times \Uni{1}$
\subsubsection*{Left Translation in a Matrix Group}
Suppose now we have a matrix Lie Group $\group \subset \text{Mat}(n, \mathbb{F})$, then $\forall h \in \group$ and $X \in \mL(\group)$, we have $L_h^{\star} = hX \in \mathcal{T}_h(\group)$ where we can unambiguously understand $hX$ as matrix multiplication. We should check that $hX$ really lies in the tangent space at $h$;
\begin{examplebox}[Left Translation of a Curve]
Consider the curve $C : t \in \RR \mapsto g(t) \in \group$ such that $g(0) = e$ and $\dot{g}(0) = X$. Then near $t = 0$ we must have;
\begin{equation*}
g(t) = \mathbb{I}_n + tX + o(t)
\end{equation*}
Now, define a new curve $C\pr : t\in \RR \mapsto h(t) = hg(t) \in \group$, then near $t = 0$ we have;
\begin{equation*}
h(t) = h + t hX + o(t)
\end{equation*}
So we see that indeed $hX \in \mathcal{T}_h(\group)$.
\end{examplebox}
We can extend this idea, indeed for any $V \in \mathcal{T}_g(\group)$, $L_h^\star(V) \in \mathcal{T}_{hg}(\group)$. Given a smooth curve $g(t) \in \group$, $\dot{g}(t) \in \mathcal{T}_{g(t)}(\group)$. Then, using our construction above;
\begin{equation}
L_{g^{-1}(t)}^{\star}\left(g(t)\right) \in \mathcal{T}_{g^{-1}(t)g(t)}(\group) \Rightarrow g^{-1}(t)\dot{g}(t) \in \mathcal{T}_e(\group) \equiv \mL(\group)
\end{equation}
So we can always construct an element of the \emph{Lie algebra} from $g^{-1}(t)\dot{g}(t)$. Seen another way, suppose we are given $X \in \mL(\group)$, we can reconstruct a curve $C : \RR \rightarrow \group$ by solving the ODE:
\begin{equation}
\label{eq:matrixexp}
g^{-1}(t)\frac{\ud g(t)}{\ud t} = X \qquad \forall t \in \RR
\end{equation}
with boundary conditions $g(0) = \mathbb{I}_n$. If we define the exponential of a matrix;
\begin{equation*}
\exp(M) = \sum_{l = 0}^{\infty}{\frac{1}{l!}M^l} \in \text{Mat}(n, \mathbb{F})
\end{equation*}
Then we can solve \eqref{eq:matrixexp} by setting $g(t) = \exp(t X)$ for all $t \in \RR$. This follows just by noting that clearly $g(0) = \mathbb{I}_n$ and;
\begin{equation*}
\dot{g}(t) = \sum_{l = 1}^{\infty}{\frac{1}{(l - 1)!}t^{l - 1}X^l} = \exp(tX)X
\end{equation*}
The fact that $g(t)$ solves this differential equation is enough to deduce that $g(t) = \exp(tX) \in \group$. So we can exponentiate elements of the Lie algebra to get elements of the group. For a suitable range $J$, the set;
\begin{equation*}
S_{X, J} = \set{g(t) = \exp(t X), \,\, \forall t \in J \subset \RR}
\end{equation*}
is an Abelian Lie subgroup of $\group$, known as a \emph{one-parameter subgroup}.\index{one-parameter subgroup}
\subsection{Constructing $\group$ from $\mL(\group)$}
If we set $t = 1$ then we have a map $\exp : \mL(\group) \rightarrow \group$ that is $1$:$1$ in some neighbourhood of the identity. In such a region we can construct group elements $g_X = \exp(X)$, $g_Y = \exp(Y)$ for some $X, Y \in \mL(\group)$. The question then is how to take group products $g_X g_Y$. It turns out that if we identify $g_X g_Y = \exp(Z) = g_Z$, then we can construct $Z$ \emph{entirely from Lie Algebra operations} via the Baker-Campbell-Hasudorff formula;
\begin{equation}
Z = X + Y + \frac{1}{2}[X, Y] + \frac{1}{12}\left([X, [X, Y]] + [Y, [Y, X]]\right) + \cdots
\end{equation}
Note that this expression definitely lies within the Lie algebra since the Lie bracket is closed. We see then that in a suitable neighbourhood of the identity, the Lie algebra, $\mL(\group)$, completely determines $\group$. However, $\exp$ is not globally bijective. In particular, $\exp$ is not surjective when $\group$ is not connected as is the case for $\text{O}(3)$. This is because $\exp$ is continuous and so can only have an image which lies in the neighbourhood of the identity. More generally, the image of $\mL(\group)$ under $\exp$ is the whole of the component connected to the identity.

\paraskip
As an example of this consider $\group = \text{O}(n)$. Now $\mL\left(\text{O}(n)\right) = \set{X \in \text{Mat}(n, \RR): X + X^{\text{T}} = 0}$. So $X \in \mL\left(\text{O}(n)\right) \Rightarrow \tr X = 0$. We can then use;\footnote{To prove this, or at least convince yourself of its validity, transform to a basis in which $X$ is diagonal.}
\begin{equation*}
\det\left(\exp X\right) = \exp\left(\tr X\right) \Rightarrow \det\left(\exp X\right) = 1 \,\,\text{for}\,\,X \in \mL\left(\text{O}(n)\right)
\end{equation*}
So we see that indeed $\exp X \in \SO{n}$.
\subsubsection{Back to $\SU{2}$ vs. $\SO{3}$}
Returning to the discussion of $\SU{2}$ and $\SU{3}$, we have seen that $\mL\left(\SU{2}\right) \simeq \mL\left(\SO{3}\right)$, but that the two groups are not isomorphic since they have different homotopy classes. Now, we can construct a \emph{double-covering}\footnote{A globally $2$:$1$ map.} of $\SO{3}$ as follows;
\begin{equation}
d : \SU{2} \rightarrow \SO{3}, \qquad d(A)_{ij} = \frac{1}{2}\tr\left(\sigma_i A \sigma_j A\dagg\right)
\end{equation}
We see that $d(A) = d(-A)$. This map provides an explicit isomorphism;
\begin{equation*}
\SO{3} \simeq \SU{2}/\ZZ_2
\end{equation*}
where $\ZZ_2 = \set{\mathbb{I}, - \mathbb{I}}$ is the centre of $\SU{2}$. Geometrically, $\SU{2} \simeq S^3$, so $\SO{3} \simeq S^3/\ZZ_2$, which is the $3$-sphere with antipodal points identified as we found previously. Thus we can parametrise $\SO{3}$ by the upper hemisphere with points on the equator identified.
\newpage
\section{Introduction to Representations}
In what follows, it is useful to keep in mind that there is a clear distinction between \emph{group} representations and representations of the \emph{Lie algebra}, although they are very much related as we shall show below.
\subsection{Representations of Lie Groups}
\begin{definitionbox}[Representation]
A \emph{representation}, $D(\group)$ of any group, $\group$ (not necessarily Lie), is a linear group action $v \mapsto D(g)v$ of $\group$ on a vector space $V$ by invertible transformations. Equivalently, a representation is a set of non-singular matrices;
\begin{equation*}
\set{D(g) \in \text{Mat}(n, \mathbb{F}), g \in \group}
\end{equation*}
The fact that $D(g)$ is a linear map says that;
\begin{equation}
D(g)(\alpha v_1 + \beta v_2) = \alpha D(g)v_1 + \beta D(g)v_2
\end{equation}
In order to be a representation, it must also satisfy;
\begin{equation}
D(g_1 g_2) = D(g_1) D(g_2) \qquad \forall g_1, g_2 \in \group
\end{equation}
which is simply the statement that $D$ is a group homomorphism. In other words, the representation should preserve the group structure.
\end{definitionbox}
The vector space $V \simeq \mathbb{F}^n$ is known as the \emph{representation space}. The dimension of $V$ is the dimension of the representation. A representation is called \emph{faithful} if $D(g) = \mathbb{I}_N$ only for $g = e$. If $\group$ is also a Lie group, then we further need that $D$ is smooth.\index{representation!faithful}
\subsubsection{Types of Representation}
There are a number of representations that are present for all Lie groups. These will reappear when we discuss representations of Lie algebras, whose form can be deduced from those below. In our opinion however, it is more natural to see the group representations first as they appear to be more canonical.
\begin{enumerate}
\item Let $\group$ be a matrix Lie group with matrices of dimension $N$, then the representation $D(g) = g$ is called the \emph{fundamental} representation of the group and is $N$-dimensional.
\item The representation of $\group$ that sets $D(g) = \mathbb{I}_N$ for all $g \in \group$ is known as the \emph{trivial} representation.\index{representation}\index{representation!fundamental}\index{representation!trivial}\index{representation!adjoint}
\item Let $\group$ be a matrix Lie group, and let $V = \mL(\group)$. The \emph{adjoint} representation, $\text{Ad}$, is the natural representation of $\group$ on $\mL(\group)$.
\begin{equation}
D(g)X \equiv \text{Ad g}X \coloneqq g X g^{-1}, \quad g \in \group, \quad X \in \mL(\group)
\end{equation}
We should do a few checks to see that this is a well-defined representation.
\begin{itemize}
\item \textbf{Closure:} $g X g^{-1} \in \mL(\group)$ follows since there exists some curve $h(t) = \mathbb{I} + t X + \cdots$ in $\group$ with tangent $X$ at $t = 0$. Then $\tilde{h}(t) = g\cdot h(t)\cdot g^{-1}$ is another curve in $\group$ by group multiplication. But;
\begin{equation*}
\tilde{h}(t) = \mathbb{I} + t gX g^{-1} + \cdots
\end{equation*}
So we have constructed a curve with tangent $gX g^{-1}$, so $g X g^{-1} \in \mL(\group)$.
\item \textbf{Representation:} We should also show that $\text{Ad}$ really is a representation. This follows as;
\begin{align*}
(\text{Ad}g_1 g_2)X &= g_1 g_2 X (g_1 g_2)^{-1} \\
&= g_1 g_2 X g_2^{-1} g_1^{-1} \\
&= \left(\text{Ad}g_1\right)\left(\text{Ad}g_2\right)X
\end{align*}
\end{itemize}
\item An $N$-dimensional representation $D$ of $\group$ is said to be \emph{unitary} if $D(g) \in \Uni{N}$ for all $g \in \group$.
\item Two representations are \emph{equivalent} if $\tilde{D}(g) = AD(g)A^{-1}$ for some fixed invertible transformation $A$ on $V$. This is just the statement that the two representations are related by a change of basis on $V$.
\end{enumerate}

%\end{multicols*}