\chapter{Perturbative analysis}

\begin{dfn}
\thmtitle{Correct to order $p$}
Let
$
  X\ord{p^-}
$
and
$
  X\ord{p^+}
$
denote
$
  X\ord{0}
+
  X\ord{1}
+
  \cd
+
  X\ord{p}
$
and
$
  X\ord{p}
+
  X\ord{p+1}
+
  \cd
+
  X\ord{\infty}
$.
We say that an approximation to $X$ is \textit{correct to order $p$} if it contains all of the contributions in $X\ord{p^-}$.
\end{dfn}

\begin{dfn}
\thmtitle{Truncated CI and CC}
Let $\text{CISDTQPH7}{\cd}m$ denote truncation of the CI Ansatz at $m$-tuples.
Similarly, $\text{CCS}{\cd}m$ means that we omit cluster operators of excitation level $k>m$.
Note that, unlike $C_k$, the cluster operator $T_k$ in truncated CC describes only \textit{connected $k$-tuples}, which are residual correlations that cannot be decomposed into products of smaller clusters.
As a result, truncated CC actually contains much higher excitations than CI.
\end{dfn}

\begin{ntt}
Let
$\bm{\F}_k$
be a row vector containing all unique $k$-fold substitutions of $\F$,
so that $\bm{\F}=\pma{\F\ \bm{\F}_1\,\cd\,\bm{\F}_n}$ spans $\mc{F}_n$.
Using $\bo{c}$ and $\bo{t}$ to denote column vectors of CI coefficients and CC amplitudes leads to the following relationships.
\begin{align}
  \bo{\F}\cdot\bo{c}
=
  (1 + C_1+\cd +C_n)\F
&&
  \bo{\F}\cdot\bo{t}
=
  (1 + T_1+\cd +T_n)\F
\end{align}
In Dirac notation the bra $\br{\bo{\F}}$ is transposed, so that
$
  \ip{\bm{\F}|W|\bm{\F}}
=
  [\ip{\F_\si|W|\F_\ta}]
$
is the matrix representation of $W$ in $\mc{F}_n$.
Such matrix representations will be denoted with bolded letters,
$
  \bo{W}
\equiv
  \ip{\bm{\F}|W|\bm{\F}}
$.
\end{ntt}

\begin{rmk}
\label{rmk:ci-perturbative-analysis}
\thmtitle{Perturbative analysis of CI}
Writing the CI eigenvalue equation $\bo{H}_{\text{c}}\,\bo{c}=E_{\text{c}}\,\bo{c}$ in terms of model-Hamiltonian and fluctuation-potential matrices leads to the following rearranged matrix equation
\begin{align}
\label{eq:ci-matrix-equation}
  (
  -
    \bo{H}_0
  +
    E_{\text{c}}
  )\,
  \bo{c}
=
  \bo{V}_{\text{c}}\,
  \bo{c}
\end{align}
which provide a convenient starting point for perturbative analysis and for comparison to the coupled-cluster equations.
The matrix elements of the model Hamiltonian are given by
$
  \ip{\F_\si|H_0|\F_\ta}
=
  \mc{E}_\ta
  \delta_{\si\ta}
$,
so the matrix on the left is diagonal with eigenvalues
$
-
  \mc{E}_{i_1\cd i_k}^{a_1\cd a_k}
+
  E_{\text{c}}
$.
The rows of this equation can be written in terms of CI operators as follows\footnote{See \url{https://en.wikipedia.org/wiki/Floor_and_ceiling_functions} for details on the floor and ceiling functions.}
\begin{align}
\label{eq:ci-reference-equation}
  \underset{(2^+)}{\vphantom{(}
    E_{\text{c}}
  }
=&\
  \ip{\F|
  \underset{(1)}{\vphantom{(}
    V_{\text{c}}
  }
    (
    \underset{((1^+))}{\vphantom{(}
      C_1
    }
    +
    \underset{(1^+)}{\vphantom{(}
      C_2
    }
    )
  |\F}
\\
\label{eq:ci-singles-equation}
  \underset{(1^+)}{\vphantom{(}
  c_a^i
  }
  (\hspace{1pt}
  \underset{(0)}{\vphantom{(}
    \mc{E}_a^i
  }
  +
  \underset{(2^+)}{\vphantom{(}
    E_{\text{c}}
  }
  \hspace{-2pt}
  )
=&\
  \ip{\F_i^a|
  \underset{(1)}{\vphantom{(}
    V_{\text{c}}
  }
    (
    \underset{((0))}{\vphantom{(}
      1
    }
    +
    \underset{(1^+)}{\vphantom{(}
      C_1
    }
    +
    \underset{(1^+)}{\vphantom{(}
      C_2
    }
    +
    \underset{(2^+)}{\vphantom{(}
      C_3
    }
    )
  |\F}
\\
\label{eq:ci-doubles-equation}
  \underset{(1^+)}{\vphantom{(}
  c_{ab}^{ij}
  }
  (\hspace{1pt}
  \underset{(0)}{\vphantom{(}
    \mc{E}_{ab}^{ij}
  }
  +
  \underset{(2^+)}{\vphantom{(}
    E_{\text{c}}
  }
  \hspace{-2pt}
  )
=&\
  \ip{\F_{ij}^{ab}|
  \underset{(1)}{\vphantom{(}
    V_{\text{c}}
  }
    (
    \underset{(0^+)}{\vphantom{(}
      1
    }
    +
    \underset{(1^+)}{\vphantom{(}
      C_1
    }
    +
    \underset{(1^+)}{\vphantom{(}
      C_2
    }
    +
    \underset{(2^+)}{\vphantom{(}
      C_3
    }
    +
    \underset{(2^+)}{\vphantom{(}
      C_4
    }
    )
  |\F}
\\
  \underset{(2^+)}{\vphantom{(}
  c_{abc}^{ijk}
  }
  (\hspace{1pt}
  \underset{(0)}{\vphantom{(}
    \mc{E}_{abc}^{ijk}
  }
  +
  \underset{(2^+)}{\vphantom{(}
    E_{\text{c}}
  }
  \hspace{-2pt}
  )
=&\
  \ip{\F_{ijk}^{abc}|
  \underset{(1)}{\vphantom{(}
    V_{\text{c}}
  }
    (
    \underset{(1^+)}{\vphantom{(}
      C_1
    }
    +
    \underset{(1^+)}{\vphantom{(}
      C_2
    }
    +
    \underset{(2^+)}{\vphantom{(}
      C_3
    }
    +
    \underset{(2^+)}{\vphantom{(}
      C_4
    }
    +
    \underset{(3^+)}{\vphantom{(}
      C_5
    }
    )
  |\F}
\\
  \underset{(2^+)}{\vphantom{(}
  c_{abcd}^{ijkl}
  }
  (\hspace{1pt}
  \underset{(0)}{\vphantom{(}
    \mc{E}_{abcd}^{ijkl}
  }
  +
  \underset{(2^+)}{\vphantom{(}
    E_{\text{c}}
  }
  \hspace{-2pt}
  )
\underset{\hspace{2pt}\vdots}{\vphantom{(}
=
}&\
  \ip{\F_{ijkl}^{abcd}|
  \underset{(1)}{\vphantom{(}
    V_{\text{c}}
  }
    (
    \underset{(1^+)}{\vphantom{(}
      C_2
    }
    +
    \underset{(2^+)}{\vphantom{(}
      C_3
    }
    +
    \underset{(2^+)}{\vphantom{(}
      C_4
    }
    +
    \underset{(3^+)}{\vphantom{(}
      C_5
    }
    +
    \underset{(3^+)}{\vphantom{(}
      C_6
    }
    )
  |\F}
\\
\label{eq:ci-k-tuples-equation}
  \underset{(\ceil{k/2}^+)}{\vphantom{(}
  c_{a_1\cd a_k}^{i_1\cd i_k}
  }
  (\hspace{1pt}
  \underset{(0)}{\vphantom{(}
    \mc{E}_{a_1\cd a_k}^{i_1\cd i_k}
  }
  +
  \underset{(2^+)}{\vphantom{(}
    E_{\text{c}}
  }
  \hspace{-2pt}
  )
=&\
  \ip{\F_{i_1\cd i_k}^{a_1\cd a_k}|
  \underset{(1)}{\vphantom{(}
    V_{\text{c}}
  }
    (
    \underset{(\ceil{k/2}^+-1)}{\vphantom{(}
      C_{k-2}
    }
    +
    \underset{(\ceil{(k-1)/2}^+)}{\vphantom{(}
      C_{k-1}
    }
    +
    \underset{(\ceil{k/2}^+)}{\vphantom{(}
      C_k
    }
    +
    \underset{(\ceil{(k+1)/2}^+)}{\vphantom{(}
      C_{k+1}
    }
    +
    \underset{(\ceil{k/2}^++\,1)}{\vphantom{(}
      C_{k+2}
    }
    )
  |\F}
\end{align}
where the numbers in parentheses denote orders in perturbation theory and the double parentheses denote terms which vanish under Brillouin's theorem.
The orders of the CI operators follow from the fact that each order in perturbation theory increases the maximum excitation level of the wavefunction by $+2$, starting from $\Y\ord{1}$ which contains up to doubles.
Therefore the leading contributions to $C_k$ have order $\ceil{k/2}$.
If Brillouin's theorem holds, the first-order contribution to $C_1$ vanishes and singles contribute at order $2^+$ in perturbation theory.
\end{rmk}

\begin{ex}
\label{ex:analysis-of-cisd-throuh-q}
The analysis of remark~\ref{rmk:ci-perturbative-analysis} shows that CISD is only correct to first order in the wavefunction, since triples contribute at second order.
However, $C_1$ and $C_2$ are both correct to second order, ensuring that the the CISD correlation energy is correct to third order.
In order to gain an order in perturbation theory we have to increase the truncation level by at least two, since triples and quadruples contribute at the same order.
CISDTQ is correct to second order in the wavefunction and fifth order in the energy.
\end{ex}

\begin{prop}
\label{prop:ci-orders}
\thmstatement{
$\text{CIS}{\cd}m$
is correct to order
$\floor{m/2}$
in the wavefunction and order
$2\floor{m/2}+1$
in the energy.
}
\thmproof{
The terms omitted from $\Y$ and from $E_{\text{c}}=\ip{\Y|H_{\text{c}}|\Y}/\ip{\Y|\Y}$ when we truncate at $m$-tuples are
\begin{align*}
  \Y
=
  (
    1
  +
    C_1
  +
    \cd
  +
    \cancel{C_{m+1}}
  +
    \cd
  +
    \cancel{C_n}
  )
  \F
&&
  E_{\text{c}}
=
  \fr{
    \ip{\F|H_{\text{c}}\,C_1|\F}
  +
    \cd
  +
    \ip{\F|\cancel{
        C_{m+1}\dg H_{\text{c}}\,C_{m+1}
    }|\F}
  +
    \cd
  +
    \ip{\F|\cancel{
      C_n\dg H_{\text{c}}C_n
    }|\F}
  }{
    \ip{\F|\F}
  +
    \cd
  +
    \ip{\F|\cancel{C_{m+1}\dg C_{m+1}}|\F}
  +
    \cd
  +
    \ip{\F|\cancel{C_n\dg C_n}|\F}
  }
\end{align*}
yielding errors of $\ceil{(m+1)/2}$ in the wavefunction and $2\ceil{(m+1)/2}$ in the energy.\footnote{
  There are also higher-order errors due to the indirect effect of truncation on $C_1$ through $C_m$, but these are always smaller than the direct error
}
Therefore, the wavefunction is correct to order
$
  \ceil{(m+1)/2} - 1
=
  \floor{m/2}
$
and the energy is correct to order
$
  2\ceil{(m+1)/2} - 1
=
  2\floor{m/2} + 1
$.
}
\end{prop}

\begin{rmk}
\label{rmk:cc-perturbative-analysis}
\thmtitle{Perturbative analysis of CC}
The CC equations can be written as a non-linear matrix equation.
\begin{align}
\label{eq:cc-matrix-equation}
(
-
  \bo{H}_0
+
  E_{\text{c}}\,
  \ip{\bm{\F}|\F}
  \ip{\F|\bm{\F}}
)
  \bo{t}
=
  \ip{\bm{\F}|
    V_{\text{c}}\,
    \text{exp}(T(\bo{t}))
  |\F}_{\text{c}}
\end{align}
To make the comparison with equation~\ref{eq:ci-matrix-equation} more transparent, note that the right-hand side equals
$
  (
    \bo{V}_{\text{c}}\hspace{0.8pt}
    \bo{t}
  )_{\text{C}}
+
  \mc{O}(\bo{t}^2)
$.
Non-vanishing contributions to the rows of this matrix equation can be expressed in terms of cluster operators as follows
% % ERROR
% \begin{align}
% \label{eq:cc-reference-equation}
%   \underset{(2^+)}{\vphantom{(}
%   E_{\text{c}}
%   }
% =&\
%   \ip{\F|
%   \underset{(1)}{\vphantom{(}
%     V_{\text{c}}
%   }
%     (
%     \underset{((1^{+}))}{\vphantom{(}
%       T_1
%     }
%     +
%     \underset{(1^{+})}{\vphantom{(}
%       T_2
%     }
%     +
%       \tfr{1}{2}
%     \underset{(2^{+})}{\vphantom{(}
%       T_1^2
%     }
%     )
%   |\F}_{\text{c}}
% \\[3pt]
%   \underset{(1^+)}{\vphantom{(}
%   t_a^i
%   }
%   \underset{(0)}{\vphantom{(}
%   \mc{E}_a^i
%   }
% =&\
%   \ip{\F_i^a|
%   \underset{(1)}{\vphantom{(}
%     V_{\text{c}}
%   }
%     (
%     \underset{((0))}{\vphantom{(}
%       1
%     }
%     +
%     \underset{(1^{+})}{\vphantom{(}
%       T_1
%     }
%     +
%     \underset{(1^{+})}{\vphantom{(}
%       T_2
%     }
%     +
%     \underset{(2^{+})}{\vphantom{(}
%       T_3
%     }
%     +
%       \tfr{1}{2}
%     \underset{(2^{+})}{\vphantom{(}
%       T_1^2
%     }
%     +
%     \underset{(2^{+})}{\vphantom{(}
%       T_1T_2
%     }
%     +
%       \tfr{1}{3!}
%     \underset{(3^{+})}{\vphantom{(}
%       T_1^3
%     }
%     )
%   |\F}_{\text{c}}
% \\[3pt]
% \nonumber
%   \underset{(1^+)}{\vphantom{(}
%   t_{ab}^{ij}
%   }
%   \underset{(0)}{\vphantom{(}
%   \mc{E}_{ab}^{ij}
%   }
% =&\
%   \br{\F_{ij}^{ab}}
%   \underset{(1)}{\vphantom{(}
%     V_{\text{c}}
%   }
%     (
%     \underset{(0)}{\vphantom{(}
%       1
%     }
%     +
%     \underset{(1^{+})}{\vphantom{(}
%       T_1
%     }
%     +
%     \underset{(1^{+})}{\vphantom{(}
%       T_2
%     }
%     +
%     \underset{(2^{+})}{\vphantom{(}
%       T_3
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_4
%     }
%     +
%       \tfr{1}{2}
%     \underset{(2^{+})}{\vphantom{(}
%       T_1^2
%     }
%     +
%     \underset{(2^{+})}{\vphantom{(}
%       T_1T_2
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_1T_3
%     }
% \\
% \label{eq:cc-doubles-equation}
% &
% \makebox[0.75\linewidth][r]{\ensuremath{
%     +
%       \tfr{1}{2}
%     \underset{(2^{+})}{\vphantom{(}
%       T_2^2
%     }
%     +
%       \tfr{1}{3!}
%     \underset{(3^{+})}{\vphantom{(}
%       T_1^3
%     }
%     +
%       \tfr{1}{2}
%     \underset{(3^{+})}{\vphantom{(}
%       T_1^2T_2
%     }
%     +
%       \tfr{1}{4!}
%     \underset{(4^{+})}{\vphantom{(}
%       T_1^4
%     }
%     )
%   \kt{\F}_{\text{c}}
% }}
% \\[3pt]
% \nonumber
%   \underset{(2^+)}{\vphantom{(}
%   t_{abc}^{ijk}
%   }
%   \underset{(0)}{\vphantom{(}
%   \mc{E}_{abc}^{ijk}
%   }
% =&\
%   \br{\F_{ijk}^{abc}}
%   \underset{(1)}{\vphantom{(}
%     V_{\text{c}}
%   }
%     (
%     \underset{(1^{+})}{\vphantom{(}
%       T_2
%     }
%     +
%     \underset{(2^{+})}{\vphantom{(}
%       T_3
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_4
%     }
%     +
%     \underset{(4^{+})}{\vphantom{(}
%       T_5
%     }
%     +
%     \underset{(2^{+})}{\vphantom{(}
%       T_1T_2
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_1T_3
%     }
%     +
%       \tfr{1}{2}
%     \underset{(2^{+})}{\vphantom{(}
%       T_2^2
%     }
%     +
%     \underset{(4^{+})}{\vphantom{(}
%       T_1T_4
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_2T_3
%     }
% \\
% \label{eq:cc-triples-equation}
% &
% \makebox[0.75\linewidth][r]{\ensuremath{
%     +
%       \tfr{1}{2}
%     \underset{(3^{+})}{\vphantom{(}
%       T_1^2T_2
%     }
%     +
%       \tfr{1}{2}
%     \underset{(4^{+})}{\vphantom{(}
%       T_1^2T_3
%     }
%     +
%       \tfr{1}{2}
%     \underset{(3^{+})}{\vphantom{(}
%       T_1T_2^2
%     }
%     +
%       \tfr{1}{3!}
%     \underset{(4^{+})}{\vphantom{(}
%       T_1^3T_2
%     }
%     )
%   \kt{\F}_{\text{c}}
% }}
% \\[3pt]
% \nonumber
%   \underset{(3^+)}{\vphantom{(}
%   t_{abcd}^{ijkl}
%   }
%   \underset{(0)}{\vphantom{(}
%   \mc{E}_{abcd}^{ijkl}
%   }
% =&\
%   \br{\F_{ijkl}^{abcd}}
%   \underset{(1)}{\vphantom{(}
%     V_{\text{c}}
%   }
%     (
%     \underset{(2^{+})}{\vphantom{(}
%       T_3
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_4
%     }
%     +
%     \underset{(4^{+})}{\vphantom{(}
%       T_5
%     }
%     +
%     \underset{(5^{+})}{\vphantom{(}
%       T_6
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_1T_3
%     }
%     +
%       \tfr{1}{2}
%     \underset{(2^{+})}{\vphantom{(}
%       T_2^2
%     }
%     +
%     \underset{(4^{+})}{\vphantom{(}
%       T_1T_4
%     }
%     +
%     \underset{(3^{+})}{\vphantom{(}
%       T_2T_3
%     }
%     +
%     \underset{(5^{+})}{\vphantom{(}
%       T_1T_5
%     }
%     +
%     \underset{(4^{+})}{\vphantom{(}
%       T_2T_4
%     }
%     +
%       \tfr{1}{2}
%     \underset{(4^{+})}{\vphantom{(}
%       T_3^2
%     }
% \\
% \underset{\displaystyle\vdots}{{}}\hspace{2pt}
% &
% \makebox[0.75\linewidth][r]{\ensuremath{
%     +
%       \tfr{1}{2}
%     \underset{(4^{+})}{\vphantom{(}
%       T_1^2T_3
%     }
%     +
%       \tfr{1}{2}
%     \underset{(3^{+})}{\vphantom{(}
%       T_1T_2^2
%     }
%     +
%       \tfr{1}{2}
%     \underset{(5^{+})}{\vphantom{(}
%       T_1^2T_4
%     }
%     +
%     \underset{(4^{+})}{\vphantom{(}
%       T_1T_2T_3
%     }
%     +
%       \tfr{1}{3!}
%     \underset{(3^{+})}{\vphantom{(}
%       T_2^3
%     }
%     +
%       \tfr{1}{3!}
%     \underset{(5^{+})}{\vphantom{(}
%       T_1^3T_3
%     }
%     +
%       \tfr{1}{2!2!}
%     \underset{(4^{+})}{\vphantom{(}
%       T_1^2T_2^2
%     }
%     )
%   \kt{\F}_{\text{c}}
% }}
% \\[3pt]
% \label{eq:cc-k-tuples-equation}
%   \underset{({k^+}{-}\,1)}{\vphantom{(}
%   t_{a_1\cd a_k}^{i_1\cd i_k}
%   }
%   \underset{(0)}{\vphantom{(}
%   \mc{E}_{a_1\cd a_k}^{i_1\cd i_k}
%   }
% =&\
%   \br{\F_{i_1\cd i_k}^{a_1\cd a_k}}
%   \underset{(1)}{\vphantom{(}
%     V_{\text{c}}
%   }
%     (
%     \underset{({k^+}{-}\,2)}{\vphantom{(}
%       T_{k-1}
%     }
%     +
%     \underset{({k^+}{-}\,1)}{\vphantom{(}
%       T_k
%     }
%     +
%     \hspace{2pt}
%     \underset{(k^+)}{\vphantom{(}
%       T_{k+1}
%     }
%     \hspace{1pt}
%     +
%     \underset{({k^+}{+}\,1)}{\vphantom{(}
%       T_{k+2}
%     }
%     +
%       \sum_{p=2}^4
%       \fr{1}{p!}
%       \sum_{h=p-2}^{2}
%       \sum_{\bm{k}}^{\mc{C}_p(k+h)}
%     \underset{({k^+}{+}\,h-p+\f_{\bm{k}})}{\vphantom{(}
%       T_{k_1}
%       \cd
%       T_{k_p}
%     }
%     )
%   \kt{\F}_{\text{c}}
% \end{align}
where $\mc{C}_k(m)$ denotes the set of $k$-part integer compositions of $m$
and $\f_{\bm{k}}$ is the number of 1's in
$
  \bm{k}
=
  (k_1,\ld,k_p)
$.
The orders of the cluster operators follow from straightforward induction on the fact that the lowest order contribution to $T_k$ always comes from
$
(
  V_{\text{c}}
  T_{k-1}
)_{\text{c}}
$,
which means that each $T_k$ contributes at one order above $T_{k-1}$, starting from $k=3$.
If Brillouin's theorem holds, $T_1$ has order $2^+$ and the orders of the disconnected products become ${k^+}{+}\,h-p+2\,\f_{\bm{k}}$.
\end{rmk}

\begin{prop}
\label{prop:cc-orders}
\thmstatement{
$\text{CCS}{\cd}m$ is correct to order $m-1$ in the wavefunction and order $m+\floor{m/2}$ in the energy.
}
\thmproof{
  According to \cref{rmk:cc-perturbative-analysis}, $T_{m+1}$ contributes at order $m$, implying that the wavefunction is correct to order $m-1$.
  Truncation also leaves $T_m$ and $T_{m-1}$ correct to order $m$, and propagating these truncation errors down to $T_{m-2h}$ and $T_{m-1-2h}$ makes the latter correct to $m+h$.
  One of these operators is $T_2$ when $h=\floor{m/2}-1$.
  Since $T_2$ limits the error in equation \ref{eq:cc-reference-equation}, the energy is correct to order $m+\floor{m/2}$.
}
\end{prop}

\begin{ex}
Props~\ref{prop:ci-orders} and \ref{prop:cc-orders} allow us to compare the accuracies of CI and CC.
At double excitations, CI and CC are both correct to first order in the wavefunction and third order in the energy.
Triples yield no improvement for CI, whereas CC gains an order in both wavefunction and energy.
In general, the CCS${\cd}m$ wavefunction and energy improve upon the wavefunction and energy obtained from
CIS${\cd}m$ by
$
  m
-
  \floor{m/2}
-
  1
=
  \floor{(m-1)/2}
$
orders in perturbation theory.
\end{ex}

\begin{dfn}
\thmtitle{Order $p$ truncation}
If $X$ is a polynomial in $T_1,T_2,\ld,T_n$, we define
its \textit{order $p$ truncation}, denoted $X\bord{p}$,
to include all terms in the polynomial with leading contributions of order $p$ or less.
This makes $X\bord{p}$ correct to order $p$ without isolating specific orders in the cluster operators, which will in general have infinite-order contributions.
\end{dfn}

\begin{samepage}
\begin{ex}
\thmtitle{The $[\text{T}]$ correction}
Assuming Brillouin's theorem, we can complete the energy to fourth order using
\begin{align}
  t_{ab}^{ij}
\,{=}\,
  \br{\F_{ij}^{ab}}
    R_0
    V_{\text{c}}
    (
      1
    \,{+}\,
      T_1
    \,{+}\,
      T_2
    \,{+}\,
      T_3^{[2]}
    \,{+}\,
      \tfr{1}{2}
      T_1^2
    \,{+}\,
      T_1T_2
    \,{+}\,
      \tfr{1}{2}
      T_2^2
    \,{+}\,
      \tfr{1}{3!}
      T_1^3
    \,{+}\,
      \tfr{1}{2}
      T_1^2T_2
    \,{+}\,
      \tfr{1}{4!}
      T_1^4
    )
  \kt{\F}_{\text{c}}
&&
  {}\bord{2}
  t_{abc}^{ijk}
\,{=}\,
  \br{\F_{ijk}^{abc}}
    R_0
    V_{\text{c}}
    T_2
  \kt{\F}_{\text{c}}
\end{align}
where the resulting energy correction is
$
  E
-
  E^{\text{CCSD}}
=
  \ip{\F|
    V_{\text{c}}
    R_0
    V_{\text{c}}
    T_3\bord{2}
  |\F}
$.
We can introduce additional infinite order contributions by noting that
$
  T_2
  \F
=
  R_0
  V_{\text{c}}
  \F
+
  \mc{O}(V_{\text{c}}^2)
$
and that the additional terms in
$
  \ip{\F|
    T_2\dg
    V_{\text{c}}
    T_3\bord{2}
  |\F}
$
are also valid energy contributions in perturbation theory.
There is no risk of double counting since all of these contributions involve connected triples, which are absent in CCSD.
With converged CCD or CCSD $T_2$-amplitudes, this defines the $[\text{T}]$ correction.
\begin{align}
  E_{[\text{T}]}
\equiv
  \ip{\F|T_2\dg V_{\text{c}} T_3\bord{2}|\F}
=
\diagram{
  \interaction{2}{2t}{(0,+0.5)}{ddot}{overhang};
  \interaction{3}{3t}{(0,-0.5)}{ddot}{overhang};
  \node[right=2pt of 3t3 ] {[2]};
  \draw[->-,bend left ] (3t1) to (2t1);
  \draw[-<-,bend right] (3t1) to (2t1);
  \draw[->-,bend left ] (3t2) to (2t2);
  \draw[-<-=0.25,-<-=0.75, bend right]
    (3t2)
    to
      node[ddot,midway] (g1) {}
    (2t2);
  \draw (2,0) node[ddot] (g2) {};
  \draw[sawtooth] (g1) to (g2);
  \draw[->-,bend left=40 ] (3t3) to (g2);
  \draw[-<-,bend right=40] (3t3) to (g2);
}\hspace{-8pt}
+
\diagram{
  \interaction{2}{2t}{(0,+0.5)}{ddot}{overhang};
  \interaction{3}{3t}{(0,-0.5)}{ddot}{overhang};
  \node[right=2pt of 3t3 ] {[2]};
  \draw[-<-,bend left ] (3t1) to (2t1);
  \draw[->-,bend right] (3t1) to (2t1);
  \draw[-<-,bend left ] (3t2) to (2t2);
  \draw[->-=0.25,->-=0.75, bend right]
    (3t2)
    to
      node[ddot,midway] (g1) {}
    (2t2);
  \draw (2,0) node[ddot] (g2) {};
  \draw[sawtooth] (g1) to (g2);
  \draw[-<-,bend left=40 ] (3t3) to (g2);
  \draw[->-,bend right=40] (3t3) to (g2);
}
&&&&
\diagram{
  \interaction{3}{t}{(0,-0.5)}{ddot}{overhang};
  \draw[->-] (t1) to ++(-0.25,1);
  \draw[-<-] (t1) to ++(+0.25,1);
  \draw[->-] (t2) to ++(-0.25,1);
  \draw[-<-] (t2) to ++(+0.25,1);
  \draw[->-] (t3) to ++(-0.25,1);
  \draw[-<-] (t3) to ++(+0.25,1);
  \node[right=2pt of t3 ] {[2]};
}\hspace{-10pt}
\equiv
\diagram{
  \interaction{2}{t}{(0,-0.5)}{ddot}{overhang};
  \draw[->-] (t1) to ++(-0.25,1);
  \draw[-<-] (t1) to ++(+0.25,1);
  \draw[->-] (t2) to ++(-0.25,1);
  \draw[-<-=0.25,-<-=0.85]
      (t2)
    to
      node[ddot,midway] (g1) {}
    ++(+0.25,1);
  \draw[sawtooth] (g1) to ++(1,0) node[ddot] (g2) {};
  \draw[->-=0.65] (g2) to ++(-0.25,0.5);
  \draw[-<-=0.65] (g2) to ++(+0.25,0.5);
  \draw[thick,flexdotted] (-0.3,0.25) to ++(2.7,0);
}
\,{+}\,
\diagram{
  \interaction{2}{t}{(0,-0.5)}{ddot}{overhang};
  \draw[-<-] (t1) to ++(-0.25,1);
  \draw[->-] (t1) to ++(+0.25,1);
  \draw[-<-] (t2) to ++(-0.25,1);
  \draw[->-=0.25,->-=0.85]
      (t2)
    to
      node[ddot,midway] (g1) {}
    ++(+0.25,1);
  \draw[sawtooth] (g1) to ++(1,0) node[ddot] (g2) {};
  \draw[-<-=0.65] (g2) to ++(-0.25,0.5);
  \draw[->-=0.65] (g2) to ++(+0.25,0.5);
  \draw[thick,flexdotted] (-0.3,0.25) to ++(2.7,0);
}
\end{align}
\end{ex}
\end{samepage}

\begin{rmk}
\label{rmk:lowdin-partitioning}
\thmtitle{The L\"owdin partitioning method}
Partitioning the determinant basis as
$
  \bo{\F}
=
\pma{\bo{\F}_{\text{i}}\ \bo{\F}_{\text{e}}}
$
where $\text{i}$ denotes the \textit{internal space} and $\text{e}$ denotes the \textit{external space}, we can express the identity on $\mc{F}_n$ as follows.
\begin{align}
  1_n
=
  1_{\text{i}}
+
  1_{\text{e}}
&&
\begin{array}{c@{\ }c@{\ }c@{\ }c@{\ }c}
  1_{\text{i}}
&
\equiv
&
  1|_{\text{i}}
&
=
&
  \kt{\bo{\F}_{\text{i}}}
  \br{\bo{\F}_{\text{i}}}
\\[5pt]
  1_{\text{e}}
&
\equiv
&
  1|_{\text{e}}
&
=
&
  \kt{\bo{\F}_{\text{e}}}
  \br{\bo{\F}_{\text{e}}}
\end{array}
\end{align}
This allows us to decompose the wavefunction as
$
  \Y
=
  \Y_{\text{i}}
+
  \Y_{\text{e}}
$
and the Hamiltonian as
$
  H
=
  H_{\text{ii}}
+
  H_{\text{ie}}
+
  H_{\text{ei}}
+
  H_{\text{ee}}
$,
with
$
  \Y_{\text{x}}
\equiv
  1_{\text{x}}
  \Y
$
and
$
  H_{\text{xy}}
\equiv
  1_{\text{x}}
  H
  1_{\text{y}}
$.\,\footnote{To see this, insert the identity in front of $\Y$ and on either side of $H$.}
This allows us to define the
\textit{L\"owdin resolvent}
$
  R_{\text{ee}}
\equiv
  \left.
  (
    E
  -
    H
  )^{-1}
  \right|_{\text{e}}
$,
which satisfies
\begin{align}
\label{eq:external-wavefunction-resolvent-expansion}
  R_{\text{ee}}
  (
    E
  -
    H
  )
=
-
  R_{\text{ee}}
  H_{\text{ei}}
+
  1_{\text{e}}
&&
  \implies
&&
  \Y_{\text{e}}
=
  R_{\text{ee}}
  H_{\text{ei}}
  \Y_{\text{i}}
\end{align}
where the first equation follows from inserting the identity and the second follows from substituting this result into $R_{\text{ee}}$ times the Schr\"odinger equation,
$
  (
    E
  -
    H
  )
  \Y
=
  0
$.
Projecting the Schr\"odinger equation by $1_{\text{i}}$ and rearranging then yields
\begin{align}
  (
    H_{\text{ii}}
  +
    V_{\text{ii}}
  )
  \Y_{\text{i}}
=
  E
  \Y_{\text{i}}
&&
  V_{\text{ii}}
=
  H_{\text{ie}}
  R_{\text{ee}}
  H_{\text{ei}}
\end{align}
where we have made use of equation~\ref{eq:external-wavefunction-resolvent-expansion}.
This sets up an effective Schr\"odinger equation for the exact energy in the internal space.
If $V_{\text{ii}}$ is treated as a perturbation, then the zeroth order states are eigenfunctions of the Hamiltonian in the basis of internal-space determinants.
Normalizing $\Y_{\text{i}}$ to one, the exact energy is given by the
\textit{L\"owdin functional}
\begin{align}
  E
=
  \ip{\Y_{\text{i}}|H|\Y_{\text{i}}}
+
  \ip{\Y_{\text{i}}|H|\bo{\F}_{\text{e}}}
  \ip{\bo{\F}_{\text{e}}|E - H|\bo{\F}_{\text{e}}}^{-1}
  \ip{\bo{\F}_{\text{e}}|H|\Y_{\text{i}}}
\end{align}
where we have expanded the resolvent in the basis of external-space determinants.
To first order, the energy correction is
% % ERROR
% \begin{align}
%   E
% -
%   E^{\{0\}}
% = \underset{E^{\{1\}}}{\underbrace{
%   \ip{\Psi_{\text{i}}^{\{0\}}|V_{\text{ii}}|\Psi_{\text{i}}^{\{0\}}}
% }}
% +
%   \mc{O}(V_{\text{ii}}^2)
% % ERROR
% &&
%   E^{\{1\}}
% =
%   \ip{\Psi_{\text{i}}^{\{0\}}|H|\bo{\Phi}_{\text{e}}}
%   \ip{\bo{\Phi}_{\text{e}}|E - H|\bo{\Phi}_{\text{e}}}^{-1}
%   \ip{\bo{\Phi}_{\text{e}}|H|\Psi_{\text{i}}^{\{0\}}}
%\end{align}
where curly braces denote orders in $V_{\text{ii}}$.
This gives the leading correction for truncating the wavefunction ansatz.
\end{rmk}

\begin{ex}
If we include all determinants up to $m$-fold substitutions in our internal space, then $H_{\text{ii}}$ is the $\text{CIS}{\cd}m$ Hamiltonian matrix and $\Y_{\text{CIS}{\cd}m}$ is the zeroth order approximation to $\Y_{\text{i}}$.
The L\"owdin partitioning method gives
\begin{align}
  E^{\{1\}}
=
  \ip{\F|(C_{m-1} + C_m)H|\bo{\F}_{m+1}\ \bo{\F}_{m+2}}
  \ip{\bo{\F}_{m+1}\ \bo{\F}_{m+2}|E - H|\bo{\F}_{m+1}\ \bo{\F}_{m+2}}^{-1}
  \ip{\bo{\F}_{m+1}\ \bo{\F}_{m+2}|H(C_{m-1} + C_m)|\F}
\end{align}
where we have used Slater's rules to eliminate matrix elements of $H$ where the determinants differ by more than two orbitals.
Noting that to zeroth order in the fluctuation potential
$
  E
-
  H
=
  E_{\text{c}}
-
  H_{\text{c}}
\approx
-
  H_0
$, we can approximate the L\"owdin resolvent by $R_0$.
This leads to the following correction to the $\text{CIS}{\cd}m$ energy
\begin{align}
  E^{\{1\}}
\approx
  (\tfr{1}{(m+1)!})^2
  \sum_{\substack{a_1\cd a_{m+1}\\i_1\cd i_{m+1}}}
  \fr{
    |\ip{\F_{i_1\cd i_{m+1}}^{a_1\cd a_{m+1}}|V_{\text{c}}\,(C_{m-1} + C_m)|\F}|^2
  }{
    \mc{E}_{a_1\cd a_{m+1}}^{i_1\cd i_{m+1}}
  }
+
  (\tfr{1}{(m+2)!})^2
  \sum_{\substack{a_1\cd a_{m+2}\\i_1\cd i_{m+2}}}
  \fr{
    |\ip{\F_{i_1\cd i_{m+2}}^{a_1\cd a_{m+2}}|V_{\text{c}}\,C_m|\F}|^2
  }{
    \mc{E}_{a_1\cd a_{m+2}}^{i_1\cd i_{m+2}}
  }
\end{align}
which can be viewed as a perturbative correction for $(m+1)$- and $(m+2)$-tuple substitutions.
\end{ex}

\begin{rmk}
Under the TCC similarity transformation, the L\"owdin partitioning correction has the following form.
\begin{align}
  E^{\{1\}}
=
  \ip{\ol{\Y}_{\text{i}}^{\{0\}}|\ol{H}|\bo{\F}_{\text{e}}}
  \ip{\bo{\F}_{\text{e}}|E - \ol{H}|\bo{\F}_{\text{e}}}^{-1}
  \ip{\bo{\F}_{\text{e}}|\ol{H}|\ol{\Y}_{\text{i}}^{\{0\}}}
&&
\begin{array}{r@{\ }l}
  \kt{\ol{\Y}_{\text{i}}^{\{0\}}}
&=
  \text{exp}(-T)\,\kt{\Y_{\text{i}}^{\{0\}}}
\\
  \br{\ol{\Y}_{\text{i}}^{\{0\}}}
&=
  \br{\Y_{\text{i}}^{\{0\}}}\,
  \text{exp}(T)
\end{array}
\end{align}
Using
$
  1_{\text{i}}(E + \ol{H}_0) 1_{\text{e}}
=
  0
$
and
$
  1_{\text{e}}(E + \ol{H}_0)\kt{\F}
=
  0
$
and substituting in the EOM-CCS${\cd}m$ states gives the following.
\begin{align}
  E^{\{1\}}
=
  \ip{\F|(L_{m-1} + L_m)\,(V_{\text{c}}\,\text{exp}(T))_{\text{c}}|\bo{\F}_{\text{e}}}
  \ip{\bo{\F}_{\text{e}}|E - \ol{H}|\bo{\F}_{\text{e}}}^{-1}
  \ip{\bo{\F}_{\text{e}}|(V_{\text{c}}\,\text{exp}(T))_{\text{c}} R|\F}
\end{align}
where we have used the fact that the excitation level of $\bm{\F}_{\text{e}}$ is at least $m+1$ and that of $\ol{V}_{\text{c}}$ is $-2$ or higher to eliminate the contributions to $L$ that cannot form complete contractions.
This gives the first-order L\"owdin partitioning correction for ground and excited state energies obtained with a truncated TCC Ansatz.
\end{rmk}

\begin{ex}
\thmtitle{The $(m+1)_\La$ correction}
Approximating the L\"owdin resolvent by the model resolvent gives
\begin{align}
  E^{\{1\}}
\approx
  \ip{\F|(\La_{m-1} + \La_m)V_{\text{c}}\,\text{exp}(T)|\bo{\F}_{\text{e}}}_{\text{c}}
  \ip{\bo{\F}_{\text{e}}|R_0 V_{\text{c}}\,\text{exp}(T)|\F}_{\text{c}}
\end{align}
for the ground state, which effectively ``dots'' the lambda equations against the amplitude equations for excitation level $m+1$ and higher with $\La$ and $T$ truncated at $m$-fold excitations.
From \cref{rmk:cc-perturbative-analysis}, the leading contribution to the $(m+1)$-tuples amplitude equations  has order $m$.
The vector of order-$m$-truncated $(m+1)$-tuples amplitudes is given by\footnote{$\bm{k}\not\ni 1$ here means that integer compositions containing 1 are excluded.}
\begin{align}
  \bo{t}_{m+1}\bord{m}
=
  \br{\bo{\F}_{m+1}}R_0
    V_{\text{c}}
    (
      T_m
    +
      \sum_{p=2}^4
      \fr{1}{p!}
      \sum_{\bm{k}\not\ni 1}^{\mc{C}_p(m+p-1)}
      T_{k_1}
      \cd
      T_{k_p}
    )
  \kt{\F}_{\text{c}}\,
\end{align}
using equation~\ref{eq:cc-k-tuples-equation}.
The leading contribution to the $(m+1)$-tuples lambda equations comes from $\text{exp}(T)\bord{0}= 1$.
This approximation to $E^{\{1\}}$ defines the
$
  (m+1)_\La
$
correction
which,
using
$
  \kt{\bo{\F}_{\text{m+1}}}\cdot
  \bo{t}_{m+1}\bord{m}
=
  T_{m+1}\bord{m}
$, can be written as follows
\begin{align}
  E_{(m+1)_\La}
=
  \ip{\F|(\La_{m-1} + \La_m) V_{\text{c}} T_{m+1}\bord{m}|\F}\,\,,
\end{align}
forming a well-defined hierarchy of perturbatively-corrected CC methods:
CCSD(T)$_\La$,
CCSDT(Q)$_\La$,
CCSDTQ(P)$_\La$,
etc.
\end{ex}

\begin{ex}
\thmtitle{The $(\text{T})$ correction}
Since the leading contributions to $\La_1$ and $\La_2$ are given by
\begin{align}
  {}\ord{1}\la_{ij}^{ab}
=
  \br{\F}
  V_{\text{c}}
  R_0
  \kt{\F_{ij}^{ab}}
=
  {}\ord{1}t_{ab}^{ij*}
&&
  {}\ord{2}\la_i^a
=
  \br{\F}
  \La_2\ord{1}
  V_{\text{c}}
  R_0
  \kt{\F_i^a}
=
  {}\ord{2}t_a^{i*}\,\,,
\end{align}
the approximation $\La_1\approx T_1\dg, \La_2\approx T_2\dg$ will capture the leading terms in the (T)$_\La$ correction plus many higher-order ones.
The resulting $(\text{T})$ correction augments the [T] correction with an order $5^+$ contribution,
$
  \br{\F}
    T_1\dg
    V_{\text{c}}
    T_3\bord{2}
  \kt{\F}
$.
Though less rigorous than the (T)$_\La$ correction, (T) is computationally advantageous in that it avoids solution of the $\La$ equations.
\begin{align}
  E_{(\text{T})}
=
  \br{\F}
    (
      T_1\dg
    +
      T_2\dg
    )
    V_{\text{c}}
    T_3\bord{2}
  \kt{\F}
=
\diagram{
  \interaction{1}{1t}{(0,+0.5)}{ddot}{overhang};
  \interaction{2}{g}{(1,+0.5)}{ddot}{sawtooth};
  \interaction{3}{3t}{(0,-0.5)}{ddot}{overhang};
  \node[right=2pt of 3t3 ] {[2]};
  \draw[->-,bend left ] (3t1) to (1t1);
  \draw[-<-,bend right] (3t1) to (1t1);
  \draw[->-,bend left ] (3t2) to (g1);
  \draw[-<-,bend right] (3t2) to (g1);
  \draw[->-,bend left ] (3t3) to (g2);
  \draw[-<-,bend right] (3t3) to (g2);
}\hspace{-8pt}
+
\underset{\displaystyle E_{[\text{T}]}}{\underbrace{
\diagram{
  \interaction{2}{2t}{(0,+0.5)}{ddot}{overhang};
  \interaction{3}{3t}{(0,-0.5)}{ddot}{overhang};
  \node[right=2pt of 3t3 ] {[2]};
  \draw[->-,bend left ] (3t1) to (2t1);
  \draw[-<-,bend right] (3t1) to (2t1);
  \draw[->-,bend left ] (3t2) to (2t2);
  \draw[-<-=0.25,-<-=0.75, bend right]
    (3t2)
    to
      node[ddot,midway] (g1) {}
    (2t2);
  \draw (2,0) node[ddot] (g2) {};
  \draw[sawtooth] (g1) to (g2);
  \draw[->-,bend left=40 ] (3t3) to (g2);
  \draw[-<-,bend right=40] (3t3) to (g2);
}\hspace{-8pt}
+
\diagram{
  \interaction{2}{2t}{(0,+0.5)}{ddot}{overhang};
  \interaction{3}{3t}{(0,-0.5)}{ddot}{overhang};
  \node[right=2pt of 3t3 ] {[2]};
  \draw[-<-,bend left ] (3t1) to (2t1);
  \draw[->-,bend right] (3t1) to (2t1);
  \draw[-<-,bend left ] (3t2) to (2t2);
  \draw[->-=0.25,->-=0.75, bend right]
    (3t2)
    to
      node[ddot,midway] (g1) {}
    (2t2);
  \draw (2,0) node[ddot] (g2) {};
  \draw[sawtooth] (g1) to (g2);
  \draw[-<-,bend left=40 ] (3t3) to (g2);
  \draw[->-,bend right=40] (3t3) to (g2);
}
}}
\end{align}
The CCSD(T) method was originally justified on different grounds, but its truly remarkable performance is difficult to understand using ordinary perturbation theory.
Several other fifth-order terms could just as easily be included, and there is no strong \emph{a priori} reason to expect this one to be as magical as it is.
L\"owdin partitioning suggests that $E_{(\text{T})}$ is the leading correction to the error incurred by truncating the configuration space at doubles.
\end{ex}


\section{Background}\label{sec:background}
We briefly explain the concept of edit distance and its relation to the longest common subsequence. We then present the sequential algorithm from Myers, which was the basis for our parallel implementation.

% Give a short, self-contained summary of necessary
% background information. For example, assume you present an
% implementation of sorting algorithms. You could organize into sorting
% definition, algorithms considered, and asymptotic runtime statements. The goal of the
% background section is to make the paper self-contained for an audience
% as large as possible. As in every section
% you start with a very brief overview of the section. Here it could be as follows: In this section
% we formally define the sorting problem we consider and introduce the algorithms we use
% including a cost analysis.

% Explain the algorithm you use including their costs.
% As an aside, don't talk about "the complexity of the algorithm.'' It's incorrect, problems have a complexity, not algorithms.

% \mypar{Longest common subsequence}
% The longest common subsequence problem is the problem of finding the longest sequence that two input sequences have in common. A related problem is finding the longest common substring. However, in that case the solution sequence needs to appear consecutively within the input string.

\mypar{Edit distance}
The edit distance refers to the minimum number of changes required to transform one string into another. In the case where we only consider insertions and deletions, and exclude substitutions, the LCS problem is equivalent to finding the edit distance. All symbols that do not appear in the LCS count towards the edit distance.

To transform the first string into the second, we perform deletions for all symbols in the first sequence that are not part of the LCS and similarly insertions for the second sequence. Those changes are referred to as an edit script. % and the total number of changes is the edit distance.

%\mypar{Diff program}
%In the context of computer science, it is a common problem to compare source files to different versions. In order to visualize changes better, a diff program can display the minimal number of changes by highlighting all symbols that are part of the edit script.

\mypar{Myers' algorithm}
Myers \cite{myers_anond_1986} takes a greedy approach to finding the solution in the edit graph of two sequences. It has an asymptotic runtime of $O(nd)$ where $n$ is the total length of the two sequences and $d$ is the size of the minimum edit script. This algorithm performs well when the sequences are similar and have a small $d$.

For constructing the edit graph, shown in figure \ref{edit_graph}, the two sequences A and B are placed along a grid. The solution for the shortest edit script can be constructed by finding the shortest path from $(0,0)$ to the bottom right corner. A horizontal or vertical segment represents an edit. A diagonal can only be taken if the two input sequences are identical.

\begin{figure}[hbt]\centering
  \includegraphics[width=0.9\linewidth]{images/edit-graph.pdf}
  \caption{Edit graph for comparison of two sequences \cite{edit_graph}. The solution for the shortest edit script is shown in red.
}
  \label{edit_graph}
\end{figure}

% Myers' algorithm pseudocode
\begin{algorithm}
\caption{Myers' LCS algorithm \cite{myers_anond_1986}}
\label{myers_algorithm}
\SetAlgoNoLine
\SetAlgoNoEnd
\DontPrintSemicolon
\scriptsize       % decrease font size

\KwSty{Constant} $MAX \in [0, M+N]$\;
$V:\ \KwSty{Integer}[-MAX\ ..\ MAX]$\;
\;
$V[1]\leftarrow 0$\;
\For{$d\leftarrow 0$ \KwTo $MAX$}{
    \For{$k\leftarrow -d$ \KwTo d in steps of 2}{
        \eIf{$k=-d$ or $k\ne d$ and $V[k-1]<V[k+1]$}{
            $x\leftarrow V[k+1]$\;
        }{
            $x\leftarrow V[k-1]+1$\;
        }
        $y\leftarrow x-k$\;
        \While{$x < N$ and $y < M$ and $a_{x+1} = b_{y+1}$}{$(x,y)\leftarrow (x+1,y+1)$\;}
        $V[k]\leftarrow x$\;
        \If{$x\ge N$ and $y \ge M$}{
            Length of shortest edit script is d\;
            \KwSty{STOP}\;
        }
    }
 }
\end{algorithm}

Myers' algorithm, shown in algorithm \ref{myers_algorithm}, goes through the diagonals shown in figure \ref{edit_graph} with an increasing edit distance and stores the coordinates of the furthest reachable point on each diagonal. The variables $N$ and $M$ represent the lengths of the sequences A and B.\\
To compute an entry on the diagonal $k$ and distance $d$, the previous paths can connect to it either by a horizontal or vertical move from its neighbors on the diagonals $k \pm 1$. Out of those two entries from the table for a distance of $d-1$, it takes the one with the higher x-value and follows the diagonal as long as the two sequences are identical. The new coordinates are then stored in the DP table.

The solution has been found once an entry reaches the coordinates $(N,M)$. The edit distance $d$ for that entry directly tells us the minimum edit distance. But the actual edit script has to be computed recursively.

\begin{figure}[hbt]\centering
  \includegraphics[width=0.95\linewidth]{images/dp_table.pdf}
  \caption{The DP table represents the furthest points on each diagonal that can be reached for a given edit distance. The arrows denote the dependencies of a single entry. The solution is marked in red and has an edit distance of 5.}
  \label{dp_table}
\end{figure}

Every entry depends on at most two entries from the previous row in the DP table (marked as arrows in figure \ref{dp_table}). If we only want the LCS length, it is not required to store the entire table, but only the previous row for the distance $d-1$. Thus the memory consumption is linear and no longer the limiting factor for very large input sequences. Myers presents an approach (``linear refinement'') to compute the solution recursively \cite{myers_anond_1986}. However, we will not go further into detail because it lies outside the scope of this report.
% Additionally, it is not necessary to store both coordinates. If we only store the x-coordinate for an entry, we can compute the intersection with the diagonal $k$ as $y = x - k$.


\problemname{Lucky Sum}
%\illustration{.5}{filename}{Image by \href{url}{Author}}

The lottery company has just launched a new game!
Each lottery ticket now consists of $N$ integers.
Every week the lottery draws a single lucky sum $S$.
The payout of a ticket is the number of integer pairs on the ticket that have a sum of $S$.
To have a better understanding of your chance of winning, you would like to determine the payouts for $Q$ lucky sums.

\section*{Input}

The first line of the input has an integer $T$, the number of test cases.\\
Each case has two integer $N, Q$ on the first line.\\
The next line has $N$ integers, the integers on the lottery ticket.
Note that the lottery ticket integers may have duplicates.
Then follow $Q$ lines, each has a single integer representing one lucky sum for which you are going to determine the payout.

\section*{Output}
For each lucky sum, output the payout on a single line.

\section*{Constraints}
\begin{itemize}
\item $1 \leq T\leq 15$
\item $2 \leq N \leq 1\,000$
\item $1 \leq Q \leq 5\,000$
\item Integers on the lottery ticket and the lucky sums are non-negative and no larger than $10^6$.
\item The lucky sums in each test case are distinct.
\end{itemize}

\section*{Subtasks}
\begin{itemize}
\item $N, Q \leq 50$
\item Original constraints
\end{itemize}


\documentclass[12pt,openright,twoside,headsepline,bibtotoc]{scrbook}
\input{adjustment.tex}

\begin{document}
\selectlanguage{english}

\chapter{Preparation of the ElSA input file from the Dirac output}

\section{The main part}\label{sec:main}

A relativistic atomic wave function $\BRA{n l j m \beta}$ in the Dirac program~\cite{Dirac_program} is expressed as a series of the Cartesian Gaussian basis set functions $Z_{l_x l_y l_z \gamma}(\VEC{r})$:
%
\begin{equation}
\BRA{n l j m \beta} = \sum_{l_x l_y l_z \gamma} S_{n l j m \beta}(l_x, l_y, l_z, \gamma) \cdot Z_{l_x l_y l_z \gamma}(\VEC{r}) \cdot \BRA{\beta},
\label{eq:phi_Dirac}
\end{equation}
where $S_{n l j m \beta}(l_x, l_y, l_z, \gamma)$ are expansion coefficients, $\BRA{\beta}$ -- spin functions, $\{n l j m\}$ -- quantum numbers, and $\{ l_x, l_y, l_z, \gamma \}$ number the basis set functions. The basis set functions in the Dirac program are given as follows~\cite{Dirac:basis_set}:
%
\begin{equation}
\left\{
\begin{aligned}
&Z_{l_x l_y l_z \gamma}(\VEC{r}) = N^\gamma_{l_x l_y l_z} \cdot x^{l_x} y^{l_y} z^{l_z} \cdot e^{-\gamma r^2}
\\
&N^\gamma_{l_x l_y l_z} = \left(2 \sqrt{\gamma} \right)^l \left( \frac{2 \gamma}{\pi} \right)^\frac{3}{4} .
\end{aligned}
\right.
\end{equation}
%
They are normalized~\cite{Dirac:basis_set}:
%
\begin{equation}
\SCP{Z_{l_x l_y l_z \gamma}(\VEC{r})}{Z_{l_x l_y l_z \gamma}(\VEC{r})}_\VEC{r} = F_{l_x l_y l_z} = (2l_x-1)!! \cdot (2l_y-1)!! \cdot (2l_z-1)!!
\end{equation}
%

Since in the ElSA code the same relativistic atomic wave function is written in the different way~\cite{ElSA:site}:
\begin{equation}
\BRA{n l j m \beta} = \frac{P_{n l j}(r)}{r} \cdot C^{j m}_{l (m-\beta) \frac{1}{2} \beta} \cdot Y_{l (m-\beta)}(\Omega) \cdot \BRA{\beta} ,
\label{eq:phi_ElSA}
\end{equation}
%
the following connection between both equations (\ref{eq:phi_Dirac}) and (\ref{eq:phi_ElSA}) may be established:
\begin{equation}
P_{n l j}^{(m \beta)}(r) = \frac{\VEC{r}}{C^{j m}_{l (m-\beta) \frac{1}{2} \beta}} \cdot \sum_{l_x l_y l_z \gamma} S_{n l j m \beta}(l_x, l_y, l_z, \gamma) \cdot \SCP{Y_{l (m-\beta)}(\Omega)}{Z_{l_x l_y l_z \gamma}(\VEC{r})}_\Omega ,
\label{eq:Pmbeta}
\end{equation}
%
where $C^{j m}_{l (m-\beta) \frac{1}{2} \beta}$ are Clebsch-Gordan coefficients~\cite{Varshalovich:75}, $\SCP{}{}_\Omega$ is a scalar product only over angular variables, and $P_{n l j}^{(m \beta)}(r)$ supposes that the radial wave function in the Dirac code depends on the $m$ and $\beta$ quantum numbers as well.

It is convenient to choose another normalization for the Cartesian Gaussians:
%
\begin{equation}
Z_{l_x l_y l_z \gamma}(\VEC{r}) = \frac{N^\gamma_{l_x l_y l_z}}{N(l_x, l_y, l_z, \gamma)} \cdot G_{l_x l_y l_z \gamma}(\VEC{r}) ,
\label{eq:Z}
\end{equation}
%
where new Gaussians $G_{l_x l_y l_z \gamma}(\VEC{r})$ are expressed as follows~\cite{Frisch:95}:
%
\begin{equation}
\left\{
\begin{aligned}
&G_{l_x l_y l_z \gamma}(\VEC{r}) = N(l_x, l_y, l_z, \gamma) \cdot x^{l_x} y^{l_y} z^{l_z} \cdot e^{-\gamma r^2}
\\
&N(l_x, l_y, l_z, \gamma) = 2^l \sqrt{ \frac{ l_x! \cdot l_y! \cdot l_z! \cdot \gamma^{l + \frac{3}{2}}}{(2 l_x)! \cdot (2 l_y)! \cdot (2 l_z)! \cdot  \pi^\frac{3}{2}} } .
\end{aligned}
\right.
\end{equation}
%
They in its turn may be expressed through the spherical Gaussian functions $\tilde G_{l m_l \gamma}(\VEC{r})$(see~\cite{Frisch:95}):
%
\begin{equation}
G_{l_x l_y l_z \gamma}(\VEC{r}) = c^{-1}(l, m_l, l_x, l_y, l_z) \cdot \tilde G_{l m_l \gamma}(\VEC{r}) ,
\label{eq:G}
\end{equation}
%
where
%
\begin{equation}
\left\{
\begin{aligned}
&\tilde G_{l m_l \gamma}(\VEC{r}) = \tilde N(l, \gamma) \cdot r^l \cdot e^{-\gamma r^2} \cdot Y_{l m_l}(\Omega)
\\
&\tilde N(l, \gamma) = \sqrt{ \frac{2^{2l+3} \cdot (l+1)! \cdot \gamma^{l+\frac{3}{2}}}{(2l+2)! \cdot \sqrt{\pi}} } .
\end{aligned}
\right.
\label{eq:tilde_G}
\end{equation}
%
The proportionality factor in eq.~(\ref{eq:G}) is expressed as follows:
%
\begin{equation}
\left\{
\begin{aligned}
&c^{-1}(l, m_l, l_x, l_y, l_z) = \sum_{l_x^\prime + l_y^\prime + l_z^\prime = l} S(l_x, l_y, l_z, l_x^\prime, l_y^\prime, l_z^\prime) \cdot \left\{ c(l, m_l, l_x^\prime, l_y^\prime, l_z^\prime) \right\}^\ast
\\
&l = l_x + l_y + l_z ,
\end{aligned}
\right.
\end{equation}
%
where overlap matrix $S(l_x, l_y, l_z, l_x^\prime, l_y^\prime, l_z^\prime)$ has the form:
%
\begin{multline}
S(l_x, l_y, l_z, l_x^\prime, l_y^\prime, l_z^\prime) =
\\
= \left\{
\begin{aligned}
&\frac{(l_x + l_x^\prime)! \cdot (l_y + l_y^\prime)! \cdot (l_z + l_z^\prime)! }{(\frac{l_x + l_x^\prime}{2})! \cdot (\frac{l_y + l_y^\prime}{2})! \cdot (\frac{l_z + l_z^\prime}{2})!} \cdot \sqrt{ \frac{l_x! \cdot l_y! \cdot l_z! \cdot l_x^\prime! \cdot l_y^\prime! \cdot l_z^\prime!}{(2l_x)! \cdot (2l_y)! \cdot (2l_z)! \cdot (2l_x^\prime)! \cdot (2l_y^\prime)! \cdot (2l_z^\prime)!} }
\\
&0, \qquad \frac{l_x + l_x^\prime}{2} \notin \mathbb{Z}, \quad \frac{l_y + l_y^\prime}{2} \notin \mathbb{Z}, \quad \frac{l_z + l_z^\prime}{2} \notin \mathbb{Z} ,
\end{aligned}
\right.
\end{multline}
%
and the inversed coefficients are:
%
\begin{multline}
c(l, m_l, l_x, l_y, l_z) =
\\
= \left\{
\begin{aligned}
&\frac{1}{2^l \cdot l!} \cdot \sqrt{ \frac{(2l_x)! \cdot (2l_y)! \cdot (2l_z)! \cdot l! \cdot (l - \ABS{m_l})!}{(2l)! \cdot l_x! \cdot l_y! \cdot l_z! \cdot (l + \ABS{m_l})!}} \, \times
\\
&\times \sum_{i=0}^{\frac{l-\ABS{m_l}}{2}} \binom{l}{i} \cdot \binom{i}{j} \cdot \frac{(-1)^i \cdot (2l-2i)!}{(l-\ABS{m_l}-2i)!} \cdot \sum_{k=0}^j \binom{j}{k} \cdot \binom{\ABS{m_l}}{l_x-2k} \cdot (-1)^{\pm \frac{\ABS{m_l}-l_x+2k}{2}}
\\
&\text{``$+$''}, \qquad m_l \geq 0
\\
&\text{``$-$''}, \qquad m_l < 0
\\
&j = \frac{l_x + l_y - \ABS{m_l}}{2}
\\
&0, \qquad j \notin \mathbb{Z} .
\end{aligned}
\right.
\end{multline}
%

It follows from Eqs.~(\ref{eq:Z}),~(\ref{eq:G}),~(\ref{eq:tilde_G}):
%
\begin{equation}
Z_{l_x l_y l_z \gamma}(\VEC{r}) = \frac{N_{l_x l_y l_z}^\gamma \cdot \tilde N(l, \gamma)}{N(l_x, l_y, l_z, \gamma)} \cdot c^{-1}(l, m_l, l_x, l_y, l_z) \cdot r^l \cdot e^{-\gamma r^2} \cdot Y_{l m_l}(\Omega) ,
\end{equation}
%
and, therefore, the scalar product in Eq.~(\ref{eq:Pmbeta}) equals:
%
\begin{multline}
\SCP{Y_{l (m-\beta)}(\Omega)}{Z_{l_x l_y l_z \gamma}(\VEC{r})}_\Omega =
\\
= \frac{N_{l_x l_y l_z}^\gamma \cdot \tilde N(l, \gamma)}{N(l_x, l_y, l_z, \gamma)} \cdot c^{-1}(l, m-\beta, l_x, l_y, l_z) \cdot r^l \cdot e^{-\gamma r^2} \cdot \delta_{l_x+l_y+l_z, l} \cdot \delta_{m-\beta, m_l} .
\label{eq:scalangl}
\end{multline}
%
Substituting Eq.~(\ref{eq:scalangl}) into Eq.~(\ref{eq:Pmbeta}), the radial part of relativistic atomic wave function has the form:
%
\begin{equation}
\left\{
\begin{aligned}
&P_{n l j}^{(m \beta)}(\VEC{r}) = r^{l+1} \sum_{\gamma} N(n, l, j, m, \beta, \gamma) \cdot e^{-\gamma r^2}
\\
&N(n, l, j, m, \beta, \gamma) =
\\
&= \frac{1}{C^{j m}_{l (m-\beta) \frac{1}{2} \beta}} \sum_{l_x+l_y+l_z = l} S_{n l j m \beta}(l_x, l_y, l_z, \gamma) \cdot \frac{N_{l_x l_y l_z}^\gamma \cdot \tilde N(l, \gamma)}{N(l_x, l_y, l_z, \gamma)} \cdot c^{-1}(l, m-\beta, l_x, l_y, l_z) .
\end{aligned}
\right.
\label{eq:radpart}
\end{equation}
%

In order to get rid of spurious dependence of the radial part in Eq.~(\ref{eq:radpart}) on the $m$ and $\beta$ quantum numbers we average over them:
%
\begin{equation}
P_{n l j}(\VEC{r}) = \frac{1}{j+\frac{1}{2}} \sum_m \frac{1}{2} \sum_\beta P_{n l j}^{(m \beta)}(\VEC{r}) .
\end{equation}
%
The final expression looks as follows:
%
\begin{equation}
\left\{
\begin{aligned}
&P_{n l j}(\VEC{r}) = r^{l+1} \sum_{\gamma} M(n, l, j, \gamma) \cdot e^{-\gamma r^2}
\\
&M(n, l, j, \gamma) = \frac{1}{j+\frac{1}{2}} \sum_m \frac{1}{2} \sum_\beta N(n, l, j, m, \beta, \gamma) .
\end{aligned}
\right.
\end{equation}
%
The coefficients $M(n, l, j, \gamma)$ are stored in a file for the following use in the ElSA code.

\section{Approximations}

\subsection{Contribution of the l quantum number}

In relativistic calculations l is a bad quantum number and may be not known. However, we need to guess it from the Dirac output for the calculations done in Sec.~\ref{sec:main}. To do so, we express the norm of the atomic wave function given in the Dirac basis set:
%
\begin{equation}
\left\{
\begin{aligned}
&\BRA{n l j m \beta} = \sum_{l_x l_y l_z \gamma} S_{n l j m \beta}(l_x, l_y, l_z, \gamma) \cdot Z_{l_x l_y l_z \gamma}(\VEC{r}) \cdot \BRA{\beta}
\\
&\SCP{n l j m \beta}{n l j m \beta}_\VEC{r} = \sum_{l_x^\prime l_y^\prime l_z^\prime \gamma^\prime} \sum_{l_x l_y l_z \gamma} S_{n l j m \beta}^\ast(l_x^\prime, l_y^\prime, l_z^\prime, \gamma^\prime) \cdot S_{n l j m \beta}(l_x, l_y, l_z, \gamma) \cdot \SCP{Z_{l_x^\prime l_y^\prime l_z^\prime \gamma^\prime}(\VEC{r})}{Z_{l_x l_y l_z \gamma}(\VEC{r})}_\VEC{r} .
\end{aligned}
\right.
\end{equation}
%
As it may be seen, it does not actually depend on $l$. At the next step, we approximate this expression. We evaluate it only for diagonal elements and consider the contribution to the total norm comes from different $l$ values:
%
\begin{equation}
\SCP{n l j m \beta}{n l j m \beta}_\textrm{Contrib.} \approx \sum_{l_x+l_y+l_z = l} \sum_\gamma \left| S_{n l j m \beta}(l_x, l_y, l_z, \gamma) \right|^2 \cdot F_{l_x l_y l_z} .
\end{equation}
%
The $l$ quantum number giving the largest contribution to the total norm is the orbital quantum number attributed with the atomic orbital under consideration.

\subsection{Deviation of norm}

In the ElSA code we are interested only in the large components of the four-component relativistic atomic wave function. The normalization factor of the large component is changing due to relativistic effect and this change is the larger, the atomic number $Z$ is higher and for the same element is the most prominent for the $1s$ orbitals. Therefore, we approximate the allowed changes in wave function norm as follows:
%
\begin{equation}
\Delta_\textrm{norm} = A \cdot \frac{Z}{n} + B,
\end{equation}
%
where $n$ is a principal quantum number, the constants $A = 0.003$ and $B = 0.015$ are fitted.

\subsection{Separation into active and inactive orbitals}

We are interested only in the core, closed and inactive atomic orbitals. The separation into the valence and core orbitals is actually done in the Dirac input files. Nevertheless, some orbitals which are treated by Dirac as core orbitals still have almost degenerate orbital energies with the orbitals treated as valence states. Such semicore orbitals usually have bad normalization and ill defined $l$ orbital quantum numbers due to the coupling with the true open-shell valence states. Therefore, we introduced the energy threshold to additionally separate such semicore orbitals and not to process them. We attributed to the valence states all orbitals with orbital energies higher than:
%
\begin{equation}
E_\textrm{thresh} = C \cdot Z ,
\end{equation}
%
where the constant $C = -0.09$ hartree has been fitted.

\bibliographystyle{/Users/campic/Papers/Biblio/physrev}
\bibliography{/Users/campic/Papers/Biblio/biblio_eng}
\end{document}


\documentclass[12pt]{article}
\usepackage{amsmath, amsfonts}
\usepackage{hyperref}
\usepackage[font=large,labelfont=bf]{caption}
\usepackage{tikz, pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{positioning, arrows.meta, quotes}
\usetikzlibrary{shapes, snakes}
\usepackage{geometry}
 \geometry{
 a4paper,
 total={170mm,257mm},
 left=30mm,right=30mm,
 top=20mm,
 }
\title{Intuitive Understanding of Newton-Raphson Method}
\author{Xinyu Chen}

\begin{document}
\large
\maketitle

\begin{abstract}
Newton-Raphson method is a classical and powerful algorithm for numerically determining the root of some equations. This post will introduce some simple and intuitive examples for showing how does the Newton-Raphson method work for finding the root of equations.
\end{abstract}

\section{Start with a Quadratic Equation}

Quadratic equation is one of the most classical equation in math, which takes the form of $ax^2+bx+c=0$. If we have a quadratic equation $x^2-4=0$, then as we know, the positive solution is $x=2$.

For graphical convenience, we define a function as $f(x)=x^2-4$. The derivative of the function is $f^\prime(x)=2x$.

\begin{figure}[h]
    \centering
    \input{graphics/example1_s1}
    \caption{{\color{blue}$f(x)=x^2-4$} (blue curve).}
    \label{example1_s1}
\end{figure}

\clearpage

If we use $x_0=4$ as starting point, then $(4,12)$ is the point of intersection.

\begin{figure}[h]
    \centering
    \input{graphics/example1_s2}
    \caption{{\color{blue}$f(x)=x^2-4$} (blue curve); {\color{orange}$x=4$} (dashed orange line); {\color{orange}$(4,12)$} (orange dot).}
    \label{example1_s2}
\end{figure}

For the point $(4,12)$, the tangent line is $f(x)=8x-20$.

\begin{figure}[h]
    \centering
    \input{graphics/example1_s3}
    \caption{{\color{blue}$f(x)=x^2-4$} (blue curve); {\color{orange}$x=4$} (dashed orange line); {\color{orange}$(4,12)$} (orange dot); {\color{red}$y=8x-20$} (red line).}
    \label{example1_s3}
\end{figure}

\clearpage

The point of intersection of tangent line and $x$ axis is $(\frac{5}{2},0)$. If we use $x_1=\frac{5}{2}$ as a new point, then $(\frac{5}{2},\frac{9}{4})$ is the point of intersection.

\begin{figure}[h]
    \centering
    \input{graphics/example1_s4}
    \caption{{\color{blue}$f(x)=x^2-4$} (blue curve); {\color{orange}$x=\frac{5}{2}$} (dashed orange line); {\color{orange}$(\frac{5}{2},\frac{9}{4})$} (orange dot); {\color{red}$y=8x-20$} (red line).}
    \label{example1_s4}
\end{figure}

For the point $(\frac{5}{2},\frac{9}{4})$, the tangent line is $f(x)=5x-\frac{41}{4}$.

\begin{figure}[h]
    \centering
    \input{graphics/example1_s5}
    \caption{{\color{blue}$f(x)=x^2-4$} (blue curve); {\color{orange}$x=\frac{5}{2}$} (dashed orange line); {\color{orange}$(\frac{5}{2},\frac{9}{4})$} (orange dot); {\color{red}$y=5x-\frac{41}{4}$} (red line).}
    \label{example1_s5}
\end{figure}

The point of intersection of tangent line and $x$ axis is $(\frac{41}{20},0)$. As can be seen, the $x$ coordinate $\frac{41}{20}=2.05$ is very close to the solution $x=2$.

\clearpage

\section{Revisit Newton's Motivation}

In the rather early stage, Newton tried to motivate the idea using equation $x^3-2x-5=0$. As we know, the solution is very close to 2. Perhaps, we can try to use $x_0=2$ as starting point.

\begin{figure}[h]
    \centering
    \input{graphics/example2_s1}
    \caption{{\color{blue}$f(x)=x^3-2x-5$} (blue curve).}
    \label{example2_s1}
\end{figure}

Recall that $f^\prime(x)=3x^2-2$.
\begin{enumerate}
\item Use $x_0=2$, then $(x_0,f(x_0))=(2,-1)$ and $f^\prime(x_0)=10$.
\item Tangent line is $f(x)=10x-21$, and the point of intersection of tangent line and $x$ axis is $(2.1,0)$.
\item Use $x_1=2.1$, then $(x_1,f(x_1))=(2.1,0.061)$ and $f^\prime(x_1)=11.23$.
\item Tangent line is $f(x)=11.23x-23.522$, and the point of intersection of tangent line and $x$ axis is $(2.094568,0)$.
\end{enumerate}

Note that $x_2=2.094568$ is very close to the final estimate achieved by Newton, i.e., $x=2.09455148$.

\clearpage

\section{Explain Newton-Raphson Iteration}

For any equation $f(x)=0$, the Newton-Raphson iteration is
\begin{equation*}
x_{n+1}=x_{n}-\frac{f(x_{n})}{f^\prime(x_{n})}
\end{equation*}

Suppose $x^3-2x^2-11x+12=0$, how to use the Newton-Raphson iteration to obtain the solution with the starting point $x_0=2$?

\begin{figure}[h]
    \centering
    \input{graphics/example3_s1}
    \caption{{\color{blue}$f(x)=x^3-2x^2-11x+12$} (blue curve).}
\end{figure}

Note that $f^\prime(x)=3x^2-4x-11$.

If $x_0=2$, then
\begin{equation*}
x_1=x_{0}-\frac{f(x_{0})}{f^\prime(x_{0})}=2-\frac{f(2)}{f^\prime(2)}=0.5714285714285714
\end{equation*}

\begin{figure}[h]
    \centering
    \input{graphics/example3_s2}
    \caption{{\color{blue}$f(x)=x^3-2x^2-11x+12$} (blue curve); {\color{orange}$x_0=2,x_1=0.57143$} (orange line).}
\end{figure}

\clearpage

As $x_1=0.5714285714285714$, then
\begin{equation*}
x_2=x_{1}-\frac{f(x_{1})}{f^\prime(x_{1})}=0.9978678038379531
\end{equation*}

\begin{figure}[h]
    \centering
    \input{graphics/example3_s3}
    \caption{{\color{blue}$f(x)=x^3-2x^2-11x+12$} (blue curve); {\color{orange}$x_0=2,x_1=0.57143,x_2=0.99787$} (orange line).}
\end{figure}

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% DOCUMENT BEGIN %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[usenames,dvipsnames]{beamer}
%
% Choose how your presentation looks.
%
% For more themes, colour themes and font themes, see:
% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
%
\mode<presentation>
{
  \usetheme{Warsaw}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{default} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{color}

\newtheorem{proposition}{Proposition}

% new commands for readability
\newcommand{\C}{\mathbb{C}}
\newcommand{\F}{\mathbb{F}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}

\title[Groups Generated by Reflections]{Groups Generated by Reflections}
\author{Robert Lech}
\institute{Carleton University}
\date{\today}

\begin{document}

\begin{frame}
  \titlepage{}
\end{frame}

% Uncomment these lines for an automatically generated outline.
\begin{frame}{Outline}
 \tableofcontents
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% INTRODUCTION BEGIN %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Introduction}

\subsection{Dihedral Groups}

\begin{frame}{Finite Dihedral Groups Generated by a Reflection and a Rotation}

Recall that finite dihedral groups, $D_n$, are commonly presented in terms of a rotation $r\in D_{n}$ and a
reflection $s\in D_{n}$. This can be seen as $D_{n}=<r,s|r^{n},s^{2},(rs)^{n}>$. This is seen below:

\begin{figure}[h]
    \label{fig:d5_rotations_reflections}
    \centering
    \includegraphics[width=0.70\textwidth]{images/d5_rotations_reflections.png}
    \caption{Rotations and Reflections of $D_5$}
\end{figure}

\end{frame}

\begin{frame}{Finite Dihedral Groups Generated by Reflections}

Also, recall that one can generate a finite dihedral group with two reflections $a,b\in D_n$. This is seen
below:

\pause{}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.50\textwidth]{images/d5_rotations_reflections.png}
    \caption{Rotations and Reflections of $D_5$}
\end{figure}

\end{frame}

\begin{frame}{Infinite Dihedral Groups}

\begin{itemize}
  \item Can we have a dihedral group with infinite elements?
  \pause{}
  \item How could you picture that?
  \pause{}
  \item What interesting things can we say about it?
\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% GROUPS GENERATED BY TWO REFLECTIONS BEGIN %%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Groups Generated by Two Reflections}

\begin{frame}{The Group Generated by 2 Reflections}

Suppose we looked at the Cartesian plane with two reflections defined: \textcolor{red}{$a[(x,y)]=(-x,y)$}
and \textcolor{blue}{$b[(x,y)]=(2-x,y)$}. The next few examples illustrates the orbit of
\textcolor{green}{$e$}.

\begin{figure}[h]
    \centering
    \includegraphics[width=0.50\textwidth]{images/1-01-d_inf.png}
    \caption{The axes of reflections $a$ and $b$.}
\end{figure}

\end{frame}

\begin{frame}{The Group Generated by 2 Reflections}

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/1-02-d_inf_a_b.png}
    \caption{The images of $a[(0.5,0)]$ and $b[(0.5,0)]$.}
\end{figure}

\end{frame}

\begin{frame}{The Group Generated by 2 Reflections}

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/1-04-d_inf_ab_1.png}
    \caption{The images of $ab[(0.5,0)]$ and $ba[(0.5,0)]$.}
\end{figure}

\end{frame}

\begin{frame}{The Group Generated by 2 Reflections}

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/1-05-d_inf_ab_2.png}
    \caption{The images of $abab[(0.5,0)]$ and $baba[(0.5,0)]$.}
\end{figure}

\end{frame}

\begin{frame}{Properties of this Group}

\begin{proposition}

Let $a$ be the reflection that fixes $x=0$ and $b$ the reflection $x=1$, and let $D_\infty$ be the group
generated by $a$ and $b$. Then every element of $D_\infty$ can be expressed as an alternating product of
$a$'s and $b$'s. Furthermore, if $n\in \mathbb{N}$, then the following hold:

\begin{enumerate}
  \item $abab\ldots abab=(ab)^{n}$ is the horizontal translation described by $(x,y)\rightarrow (x-2n,y)$.
  \item $baba\ldots baba=(ba)^{n}$ is the horizontal translation described by $(x,y)\rightarrow (x+2n,y)$.
  \item $baba\ldots bab=(ba)^{n-1}b$ is the reflection that fixes $x=n$.
  \item $abab\ldots aba=(ab)^{n-1}a$ is the reflection that fixes $x=-n$.
\end{enumerate}

\end{proposition}

\end{frame}

\begin{frame}{Infinite Dihedral Groups}

We prove $(1)$ and $(3)$ and observe how similar the other other cases are after the proof. We will prove
the statement $P(k)$ by induction where $P(k)$ states that $(ab)^{k}=(x-2k,y)$ for a fixed $k$. \\~\\

\pause{}

The base case when $k=0$ is pretty straight forward as $e[(x,y)]=(ab)^{0}[(x,y)]=(x,y)=(x-2(0),y)$. \\~\\

\pause{}

We assume the inductive hypothesis and attempt to prove this holds when $k=n+1$. We see that
$(ab)^{n+1}[(x,y)]=(ab)(ab)^{n}[(x,y)]$. Applying the inductive hypothesis gives us that
$(ab)(ab)^{n}[(x,y)]=ab[(x-2n,y)]$. Applying $b$ gives us $ab[(x-2n,y)]=a[(2-(x-2n),y)]$. Applying $a$
gives us $(x-2(n+1),y)$. So $P(n+1)$ holds.

\end{frame}

\begin{frame}{Infinite Dihedral Groups}

To prove $(3)$, we simply look at it algebraically. We note that:

\begin{align*}
(ba)^{n-1}b[(x,y)]
&= (ba)^{n-1}[(2-x,y)] \\
&= ((2-x)+2(n-1),y) \\
&= (2n-x,y)
\end{align*}

We see that $(ba)^{n-1}b[(n,y)]=(n,y)$. This completes the proof of (3) and (4) is identical to this.
\end{frame}

\begin{frame}{Infinite Dihedral Groups}

We can conclude that if translations $w_{1}=(ab)^{n}$ and $w_{2}=(ba)^{n}$ and reflections
$w_{3}=(ba)^{n-1}b$, and $w_{4}=(ab)^{n-1}a$, then for $i\neq j$:

\begin{itemize}
  \item $\Rightarrow w_{i}\neq w_{j}$, and
  \item $w_{i}[(x,y)]\neq w_{j}[(x,y)]$.
\end{itemize}

\end{frame}

\begin{frame}{Tiling of the Plane}

We see that the axes of reflections help us create a tiling of the plane. This can be seen by
``rolling'' a piece of paper that has one edge painted red and the other blue.

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/2-02-Tiling.png}
    \caption{The tiling of the plane caused by $a,b\in D_\infty$.}
\end{figure}

\end{frame}

\begin{frame}{The ``Two Wrongs make a Right'' Property}

The tiling property is not only for decoration. It allows us to compute $w=w_{1}w_{2}\ldots w_{n}$, s.t.
$w_{i}\in {a,b}$ in a different and interesting way. We first see this by example. We can evaluate
$baba[(0,5,0)]$ below ``the right way''.

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/2-03-Computing_baba.png}
    \caption{Computing $baba$ the correct way.}
\end{figure}

\end{frame}

\begin{frame}{The ``Two Wrongs make a Right'' Property}

Now we do it again while making two mistakes below:

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/2-04-Wrong_Way.png}
    \caption{Computing $baba$ when making 2 mistakes.}
\end{figure}

\end{frame}

\begin{frame}{Cayley Graph of $D_\infty$}

Furthermore, we can create our Cayley graph with the following steps:

\begin{enumerate}
  \item Start with a vertex labelled $\varepsilon$
  \item Draw a vertex to the left and right of the vertex labelled $\varepsilon$ and label them $a$ and
  $b$, respectively, while labelling the edges $a$ and $b$, respectively.
  \item Draw a vertex to the left of the vertex labelled $a$ and right of the vertex labelled $b$ and label
  them $ba$ and $ab$, respectively, while labelling the edges $b$ and $a$, respectively.
  \item Repeat forever.
\end{enumerate}

\end{frame}

\begin{frame}{Cayley Graph of $D_\infty$}

It looks like so:

\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/2-01-Cayley_Graph.png}
    \caption{The Cayley graph of $D_\infty$.}
\end{figure}

\end{frame}

\begin{frame}{The Fundamental Domain of $D_\infty$}

Note that a single vertex and its two half edges are all that are needed for the fundamental domain.
\begin{figure}[h]
    \centering
    \includegraphics[width=1\textwidth]{images/2-01-01-Fundamental_Domain.png}
    \caption{The Fundamental Domain of $D_\infty$.}
\end{figure}

\end{frame}

\begin{frame}{Generating a Strict Subgroup $D_\infty$ Isomorphic to $D_\infty$}

We note that $D_\infty$ exhibits some interesting behaviour.

\begin{proposition}

The subgroup $H$ of $D_\infty$ generated by $\{a,bab\}$ is a subgroup of index 2 that is isomorphic to
$D_\infty$.

\end{proposition}

We need to show this in steps:

\begin{enumerate}
  \item Define a map $\varphi:H\rightarrow D_{\infty}$.
  \item Show $\varphi$ is well-defined and a group homomorphism.
  \item Show $\varphi$ is surjective.
  \item Show $\ker(\varphi)={1}$
  \item Show $H$ has index 2.
\end{enumerate}

\end{frame}

\begin{frame}{Generating a Strict Subgroup $D_\infty$ Isomorphic to $D_\infty$}

\textbf{Step 1}: Let's let $\alpha=a$ and $\beta=bab$. Now, define $\varphi$ to be such that
$\varphi(\alpha)=a$, $\varphi(\beta)=b$, and for an arbitrary element $\varphi(x_{1}x_{2}\ldots
x_{n})=\varphi(x_{1})\varphi(x_{2})\ldots \varphi(x_{n})$ where $x_{i}\in {\alpha, \beta}$. \\~\\

\pause{}

\textbf{Step 2}: To see that this map is well-defined, we first recall from the previous proposition that
elements of $D_\infty$ are uniquely described by $a$'s and $b$'s. So it's very clear that $\forall$ words
$w,w'\in H, w=w' \Rightarrow \varphi(w)=\varphi(w')$.

\pause{}

We note that $\varphi$ must be a homomorphism simply from its definition.

\end{frame}

\begin{frame}{Generating a Strict Subgroup $D_\infty$ Isomorphic to $D_\infty$}

\textbf{Step 3}: We want to show $\varphi$ is surjective. However, by our definition of $\varphi$, every
generator ${a,b}$ of $D_\infty$ has some word in $H$ mapping to it. Therefore, $\varphi$ is surjective.
\\~\\

\pause{}

\textbf{Step 4}: We want to show that $\ker(\varphi)={1}$. We first note that $\varphi(\alpha)\neq 1$ and
$\varphi(\beta)\neq 1$.

\pause{}

So assume $x\in H$ such that $x=x_{1}x_{2}\ldots x_{n}$. First, assume $n\geq 1$ is even and starts with
$\alpha$. Then $x=(\alpha\beta)^{n/2}$ and so $\varphi(x)=(ab)^{n/2}\neq 1_{D_\infty}$ by the first
proposition.

\pause{}

Similarly, we see what happens when $n$ is odd. So $\ker(\varphi)={1}$.

\end{frame}

\begin{frame}{Generating a Strict Subgroup $D_\infty$ Isomorphic to $D_\infty$}

We conclude that $H$ and $D_\infty$ are isomorphic to each other. \\~\\

\pause{}

\textbf{Step 5}: We want to show that the index of $H$ is 2. We show this by proving $D_\infty=H\cup bH$.
\pause{} To see this, note that $H=\{ w | w $ has an even amount of $b$'s $\}$. Left multiplying every
element of $H$ by $b$ gives us the remaining elements of $D_\infty$ with no overlap. So $H$ has index 2 in
$D_\infty$.

\end{frame}

\begin{frame}{What comes next}

We've looked at $D_\infty$ and how it's generated by 2 reflections. Next, we'd like to see a group that is
generated by 3 reflections and any interesting different or similar properties that arise.

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% GROUPS GENERATED BY THREE REFLECTIONS BEGIN %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Groups Generated by Three Reflections}

\begin{frame}{Groups Generated by 3 Reflections}

There are many groups that are generated by three reflections. These were studied by Jacques Tits who called them \textit{Coxeter Groups}.

For simplicity, we'll primarily focus on $W_{333}$.

\end{frame}

\begin{frame}{Orbit of $e$ in $W_{333}$}

Suppose we defined three reflections on the Cartesian plane:

\begin{itemize}
  \item \textcolor{red}{$r[(x,y)]=(x,-y)$}
  \item \textcolor{blue}{$b[(x,y)]=(\frac{3-x-\sqrt{3}y}{2},\frac{3-\sqrt{3}x+y}{2})$}
  \item \textcolor{green}{$g[(x,y)]=(\frac{-3-x+\sqrt{3}y}{2},\frac{3+\sqrt{3}x+y}{2})$}
\end{itemize}

Choose \textcolor{orange}{$e$} to be the barycenter/centroid. What's its orbit?

\end{frame}

\begin{frame}{Orbit of $e$ in $W_{333}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.7\textwidth]{images/6-01-rbg-rbg-1.png}
    \caption{The axes of reflections \textcolor{red}{$r$}, \textcolor{blue}{$b$}, \textcolor{green}{g} and the points \textcolor{red}{$r$}, \textcolor{blue}{$b$}, \textcolor{green}{g}.}
\end{figure}

\end{frame}

\begin{frame}{Orbit of $e$ in $W_{333}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=.65\textwidth]{images/6-02-rbg_rbg_2.png}
    \caption{The points \textcolor{red}{$r$}, \textcolor{blue}{$b$}, \textcolor{green}{g}, \textcolor{red}{$rb$}, \textcolor{red}{$rg$}, \textcolor{blue}{$br$}, \textcolor{blue}{$bg$}, \textcolor{green}{gr}, \textcolor{green}{gb}.}
\end{figure}

\end{frame}

\begin{frame}{Orbit of $e$ in $W_{333}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=.7\textwidth]{images/6-03-rbg_rbg_3.png}
    \caption{The points consisting of 0, 1, 2, and 3 reflections.}
\end{figure}

\end{frame}

\begin{frame}{Tiling of the plane under $W_{333}$}

How does the tiling look?

\pause{}

\begin{figure}[h]
    \centering
    \includegraphics[width=.7\textwidth]{images/6-05-rbg_rbg_3-tiling.png}
    \caption{The tiling of the group.}
\end{figure}

\end{frame}

\begin{frame}{Cayley Graph of $W_{3,3,3}$}

Suppose our generating set is $S=\{r,b,g\}$. What's $\Gamma_{W_{3,3,3},S}$

\pause{}

\begin{itemize}
\item $W_{3,3,3}$ acts transitively on the barycenters of each triangle
\item This gives us the orbit of $x$ under $W_{3,3,3}$
\end{itemize}
\end{frame}

\begin{frame}{Cayley Graph of $W_{3,3,3}$}
\begin{figure}[h]
    \centering
    \includegraphics[width=.6\textwidth]{images/6-06-rbg_rbg_3-cayley.png}
    \caption{The Cayley graph of the group looking like a hexagonal tiling.}
\end{figure}

\end{frame}

\begin{frame}{Fundamental Domain of $W_{333}$}

We recall Theorem 1.55 that states $S=\{g\in G | g \ne e$ and $gF \cap F\}$ for a generating set $S$.

\pause{}

\begin{figure}[h]
    \centering
    \includegraphics[width=.55\textwidth]{images/6-07-rbg_rbg_3-fundamental_domain.png}
    \caption{The Fundamental Domain}
\end{figure}

\end{frame}

\begin{frame}{Other Groups Generated by Three Reflections}

\begin{itemize}
  \item $W_{2,4,4}$, the group generated by triangles with interior angles $\{\pi/2,\pi/4,\pi/4\}$
  \item $W_{2,3,6}$, the group generated by triangles with interior angles $\{\pi/2,\pi/3,\pi/6\}$
  \item Similar, but they have their ``quirks''
\end{itemize}

\end{frame}

\begin{frame}{Question 7}

Draw the Cayley Graphs of $W_{2,4,4}$ and $W_{2,3,6}$.

\end{frame}

\begin{frame}{$W_{2,4,4}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=.5\textwidth]{images/7-03-W_244_tiling.png}
    \caption{The tiling generated by triangles with interior angles $\frac{\pi}{2},\frac{\pi}{4},\frac{\pi}{4}$}
\end{figure}

\end{frame}

\begin{frame}{$W_{2,4,4}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=.5\textwidth]{images/7-04-W_244_cayley_graph.png}
    \caption{The Cayley graph of the group $W_{2,4,4}$.}
\end{figure}

\end{frame}

\begin{frame}{$W_{2,3,6}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=.5\textwidth]{images/7-02-W_236_cayley_graph.png}
    \caption{The tiling generated by triangles with interior angles $\frac{\pi}{2},\frac{\pi}{3},\frac{\pi}{6}$}
\end{figure}

\end{frame}

\begin{frame}{$W_{2,3,6}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=.6\textwidth]{images/7-01-W_236_tiling.png}
    \caption{The Cayley graph of the group $W_{2,3,6}$.}
\end{figure}

\end{frame}

\section{Extra Questions}

\begin{frame}{Question 5}

Tile the plane with squares. Let $W$ represent the group generated by the 4 reflections of each side of a
square. Prove that $W\cong D_{\infty} \oplus D_{\infty}$.

Suppose we defined three reflections on the Cartesian plane:

\begin{itemize}
  \item \textcolor{red}{$r[(x,y)]=(-x,y)$}
  \item \textcolor{blue}{$r[(x,y)]=(2-x,y)$}
  \item \textcolor{Fuchsia}{$r[(x,y)]=(x,-y)$}
  \item \textcolor{green}{$r[(x,y)]=(x,2-y)$}
\end{itemize}

Choose \textcolor{orange}{$e$} to be the barycenter/centroid. What's its orbit?

\end{frame}

\begin{frame}{Question 5}

\begin{figure}[h]
    \centering
    \includegraphics[width=.55\textwidth]{images/8-01-Tiling_of_D_infty_D_infty.png}
    \caption{The tiling of the group $W$.}
\end{figure}

\end{frame}

\begin{frame}{Question 5}

Firstly, let's look at an arbitrary point in the tiling, say $w=bcadcabad$. \pause{} We note that vertical
and horizontal actions can be interchanged. That is $\{a,b\}$ commute with $\{c,d\}$. \pause{} So this word
can be rewritten as $w=baabacdcd=w_{h}w_{v}$  where $w_h,w_v$ represent the sequence of horizontal and vertical
actions, respectively. \pause{} Each of these are words in their own instances of $D_\infty$.

\end{frame}

\begin{frame}{Question 5}

More formally, let $D_\infty=<a,b|a^2,b^2>$ and let $\phi:W\rightarrow D_\infty \oplus D_\infty$ such that:

 \pause{}

\begin{itemize}
  \item $\phi(a)=(a,e)$
  \item $\phi(b)=(b,e)$
  \item $\phi(c)=(e,a)$
  \item $\phi(d)=(e,b)$
\end{itemize}

\end{frame}

\begin{frame}{Question 5}

What's left to do here is to show that:

\begin{itemize}
\item $\phi$ is onto
\item $\ker(\phi)$ is trivial
\item Show that this is a valid homomorphism
\end{itemize}

Let $x_1,x_2, \ldots x_n \in W$ and  $y_1,y_2, \ldots y_j\in \{a,b\}$ $z_1,z_2, \ldots z_k\in \{c,d\}$.
Then we can see that:
\begin{align*}
\phi(x_1x_2 \ldots x_n)
&=\phi(y_1y_2 \ldots y_{j}z_{1}z_{2} \ldots z_k)\\
&=\phi(y_1y_2 \ldots y_j)\phi(z_1z_2 \ldots z_k)\\
&=\phi(y_1)\phi(y_2) \ldots \phi(y_j)\phi(z_1)\phi(z_2) \ldots \phi(z_k)\\
&=\phi(x_1)\phi(x_2) \ldots \phi(x_n)
\end{align*}
\end{frame}

\begin{frame}{Question 6}

Prove that $\Z \oplus \Z$ is a subgroup of $W_{3,3,3}$.\\

\pause{}

Let $V=\{w={a_1a_2\ldots a_n} | a_i\in\{(bgr)^2,(bgr)^{-2},brbg,(brbg)^{-1}\}\}$, including the empty word.
Here, $(bgr)^2$ denotes a shift in a horizontal direction and $brbg$ denotes a shift in the vertical
direction. Firstly, we see this is a subgroup of $W_{3,3,3}$.

\end{frame}

\begin{frame}{Tiling of the plane under $W_{333}$}

\begin{figure}[h]
    \centering
    \includegraphics[width=.7\textwidth]{images/6-05-rbg_rbg_3-tiling.png}
    \caption{The tiling of the group.}
\end{figure}

\end{frame}

\begin{frame}{Question 6}

Prove that $\Z \oplus \Z$ is a subgroup of $W_{3,3,3}$.\\

Let $V=\{w={a_1a_2\ldots a_n} | a_i\in\{(bgr)^2,(bgr)^{-2},brbg,(brbg)^{-1}\}\}$, including the empty
word. Here, $(bgr)^2$ denotes a shift in a horizontal direction and $brbg$ denotes a shift in the vertical
direction. Firstly, we see this is a subgroup of $W_{3,3,3}$. Secondly, we see that a mapping
$\phi:V\rightarrow \Z \oplus \Z$ such that $\phi((bgr)^2)=(1,0)$, $\phi((bgr)^{-2})=(-1,0)$,
$\phi(brbg)=(0,1)$, $\phi((brbg)^{-1})=(0,-1)$.

\end{frame}

\begin{frame}{Question 6}

We need to show three things here:

\begin{itemize}
\item $\phi$ is onto
\item $\ker(\phi)$ is trivial
\item The commutator relator in $\Z \oplus \Z$ holds in $W$. That is $wxw^{-1}x^{-1}=1$  in $W$.
\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% BIBLIOGRAPHY BEGIN %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Sources Cited}

\begin{frame}{Bibliography / Sources Cited}

\begin{thebibliography}{9}

\bibitem{d5_rotations_reflections}
The symmetries of a pentagon. (2013, September 17). Retrieved April 03, 2017, from
https://beckytikz.wordpress.com/2013/09/17/the-symmetries-of-a-pentagon/
Image of Symmetries of a Pentagon

\bibitem{chapter_2}
Meier, J. (2008). Groups, Graphs and Trees An Introduction to the Geometry of Infinite Groups. Cambridge:
Cambridge University Press.
Chapter 2

\end{thebibliography}

\end{frame}

\begin{frame}{Bibliography / Sources Cited}

\begin{thebibliography}{9}

\bibitem{reflection}
Rajpoot, \%. C. (2015, May 13). Reflection of a point about a line \& a plane in 2-D \& 3-D
co-ordinate\ldots Retrieved April 03, 2017, from
https://www.slideshare.net/hcr1991/reflection-of-a-point-about-a-line-a-plane-in-2d-3d-space-geometry-by-hcr
Reflection of a point about a line in 2D

\bibitem{30_60_90_tiling}
File:Tile V46b.svg. (n.d.). Retrieved April 03, 2017, from
https://commons.wikimedia.org/wiki/File%3ATile_V46b.svg
Tiling of Plane with 30,60,90 Triangle

\end{thebibliography}

\end{frame}

\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% DOCUMENT END %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Groups Generated by Reflections Paper/paper.tex


% Modified based on Xiaoming Sun's template and https://www.overleaf.com/latex/templates/cs6780-assignment-template/hgjyygbykvrf

\documentclass{scribe}
\usepackage{xfrac}
\usepackage{tikz}

\setCourse{Mathematics for Computer Science (30470023)}
\setSemester{Spring 2020}
\setInstructor{Prof. Andrew C. Yao}
\setLectureID{2}
\setLectureDate{Feb 24, 2020}
\setScribe{Boyang Chen, Jiatu Li, Mengdi Wu}
\newcommand{\prob}[1]{\mathrm{Pr} \left\{ #1 \right\}}

\begin{document}
\notetitle

\section{Overview}
\label{sec:overview}

In the second lecture, we are going to discuss three interesting and important problems as an application of discrete probability. These problems, and even solutions, are not so hard to understand for a person who rarely knows mathematics. But there is deep relationship between these problems and some mathematical theory (like coding theory), which should be considered seriously.

\section{The hat problem}
\label{sec:hats-problem}

\subsection{Problem description}
\label{sec:problem-description}

There are three people standing on the corners of a triangle, wearing hats of \textbf{black} or \textbf{\color{red}red}, which is uniformly randomly determined by the game host. They can not see the color of their own hats, but each of them can see the color of the other's. As soon as the game starts, each peron can either keep silent, or guess the color of his own hat.

The three people wins as a team if (1) at least one person takes a guess, and (2) no one guesses incorrectly. They can discuss before the game started, but after the color configuration is determined, communication of any kind is prohibited. Now they want to know that, what is their best strategy such that the probability to win is maximized.

\subsection{Strategies}
\label{sec:naive-and-clever-strategies}

Firstly we would like to discuss some naive strategies and compute their probability to win. \textit{Strategy 1} is quite simple, in which each person makes random guess. The probability for each person to be correct is $\sfrac{1}{2}$ independently, thus they win with a probability of $\left(\sfrac{1}{2}\right)^3 = \sfrac{1}{8}$. A more clever strategy, \textit{Strategy 2}, is that only one of them makes a random guess, and the other two keep silent. In this case, the probability to win is $\sfrac{1}{2}$, which is much better than \textit{Strategy 1}.

So is \textit{Strategy 2} optimal? No. The real winner is \textit{Strategy 3}, in which each person, w.l.o.g. called $A$, will look at the other two before making a decision. If the they have the same color, $A$ will choose to guess the different color and otherwise, $A$ will keep silent.

Let's consider the probability to win for \textit{Strategy 3}. If the color configuration is \textbf{BBB} or \textbf{\color{red}RRR}, each of them will make an incorrect guess and therefore they fail. Otherwise, if the color configuration is \textbf{BB{\color{red}R}}, \textbf{B{\color{red}R}B}, \textbf{B{\color{red}R}{\color{red}R}}, \textbf{{\color{red}R}BB}, \textbf{{\color{red}R}B{\color{red}R}} or \textbf{{\color{red}R}{\color{red}R}B}, only the minority will make a correct guess and they will win. As a result, the probability to win is $\sfrac{6}{8} = \sfrac{3}{4}$, which is better than $\sfrac{1}{2}$. Clever strategy!

\subsection{Binary string and cube}
\label{sec:color-configuration}

It seems that the colorful represention will confuse us a lot when there are more than three people. Suppose $0$ denotes a \textbf{black} hat and $1$ denotes a \textbf{\color{red}red} hat, then a color configuration can be represented by a binary string of length $3$. If we draw all of the possible configurations on a three-dimensional space, we will have an unit cube (see Figure \ref{unit-cube}).

\begin{figure}[htb]
  \centering
  \begin{tikzpicture}
    \pgfmathsetmacro{\cubex}{2}
    \pgfmathsetmacro{\cubey}{2}
    \pgfmathsetmacro{\cubez}{2}
    \draw (-\cubex, -\cubey, 0) node[below] {$000$};
    \draw (-\cubex, 0, 0) node[below] {$001$};
    \draw (0, -\cubey, 0) node[below] {$100$};
    \draw (0, 0, 0) node[below] {$101$};
    \draw (-\cubex, -\cubey, -\cubez) node[right] {$010$};
    \draw (0, 0, -\cubez) node[right] {$111$};
    \draw (0, -\cubey, -\cubez) node[right] {$110$};
    \draw (-\cubex, 0, -\cubez) node[right] {$011$};
    \draw[] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
    \draw[] (-\cubex, -\cubey, 0) -- (-\cubex, -\cubey, -\cubez) -- (0, -\cubey, -\cubez);
    \draw[] (-\cubex, -\cubey, -\cubez) -- (-\cubex, 0, -\cubez);
  \end{tikzpicture}
  \caption{Unit-cube of all color configurations.}\label{unit-cube}
\end{figure}

Now let's look more deeper at the cube. The corners connected directly by an edge is different in exactly 1 bit. When $A$ looks at the other two, he/she can know that the actual color configuration must fall into one of the two corners $\{u, v\}$ on the cube, that are connected with an edge.

We would like to paint their strategy on the cube, for simplicity, let's focus on deterministic strategies. If $A$ would like to choose $u$ in $\{u, v\}$, we put an arrow from $v$ to $u$, and similarly $u\to v$ if $A$ prefers $v$. If $A$ keeps silent, we will paint nothing. For instance, Figure \ref{strategy-3} shows the cube represention of \textit{Strategy 3}.

\begin{figure}[htb]
  \centering
  \begin{tikzpicture}
    \pgfmathsetmacro{\cubex}{2}
    \pgfmathsetmacro{\cubey}{2}
    \pgfmathsetmacro{\cubez}{2}
    \draw[] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle;
    \draw[] (0,0,0) -- ++(0,0,-\cubez) -- ++(0,-\cubey,0) -- ++(0,0,\cubez) -- cycle;
    \draw[] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,0,-\cubez) -- ++(\cubex,0,0) -- cycle;
    \draw[] (-\cubex, -\cubey, 0) -- (-\cubex, -\cubey, -\cubez) -- (0, -\cubey, -\cubez);
    \draw[] (-\cubex, -\cubey, -\cubez) -- (-\cubex, 0, -\cubez);
    \draw[thick, ->>] (-\cubex, -\cubey, 0) -- (-\cubex, 0, 0);
    \draw[thick, ->>] (-\cubex, -\cubey, 0) -- (0, -\cubey, 0);
    \draw[thick, ->>] (-\cubex, -\cubey, 0) -- (-\cubex, -\cubey, -\cubez);
    \draw[thick, ->>] (0, 0, -\cubez) -- (0, 0, 0);
    \draw[thick, ->>] (0, 0, -\cubez) -- (0, -\cubey, -\cubez);
    \draw[thick, ->>] (0, 0, -\cubez) -- (-\cubex, 0, -\cubez);
  \end{tikzpicture}
  \caption{Cube represention of \textit{Strategy 3}.}\label{strategy-3}
\end{figure}

Intuitively speaking, \textit{Strategy 3} put the errors (source of arrows in Figure \ref{strategy-3}) into a few bad corners, so that it wins in more corners, or color configurations in the hat problem. The precious results are listed as follow.

\begin{lemma}
  \label{lemma:optimal}
  \textit{Strategy 3} is the best deterministic strategy.
\end{lemma}
\begin{proof}
  Exercise.
\end{proof}

\begin{theorem}
  \textit{Strategy 3} is the best strategy, including those strategies with randomness.
\end{theorem}
\begin{proof}
  Exercise.
\end{proof}

\subsection{Error correcting code}
\label{sec:ecc}

Suppose we are transmitting a binary string using a noisy channel, in which at most one bit of the string may be flipped during transmission. To ensure the correctness of transmission, we may encode $0$ into $000$ and $1$ into $111$, thus a single error can always be detected and corrected. This is a kind of \ul{1-error correcting code}.

More preciously, we choose a collection of binary string called \ul{code words} $\mathcal{C}$, such that any pair of distinct code words has disjoint neighborhood, where the neighborhood of a code word $\mathcal{N}(s)$ is defined as the set of possible strings formed by flipping a bit of $s$. In this example, we choose $\mathcal{C} = \{000, 111\}\subseteq\{0, 1\}^3$. We can transmit any binary string of length $\log_2|\mathcal{C}|$ by code words and correct any 1-bit error.

Another exmaple of the 1-error correcting code is \ul{Hamming $(7, 4)$-Code}, which choose $2^4$ code words of length $7$, thus can encode $4$-bit information. More generally, we can prove the following theorem.

\begin{theorem}
  \label{thm:hamming-exists}
  Suppose $n=2^k-1$, it's always possible to choose $2^{n-k}$ code words of length $n$ to form a 1-error correcting code, which is also optimal.
\end{theorem}
\begin{proof}
  Firstly we prove that it's possible to choose $2^{n-k}$ code words. Suppose
  \[
    \mathcal{C} = \left\{a_1a_2\dots a_n\in \{0,1\}^n~\Big|~\bigoplus_{a_i = 1}i = 0\right\},
  \]
  is the set of code words, where $\oplus$ means bitwise xor operation. On the one hand, for all binary string $c = c_1c_2\dots c_n$, suppose $u = \oplus_{c_i=1}i$, we can find a code word
  \[c' = c_1c_2\dots c_{u-1}(1-c_u)c_{u+1}\dots c_n,\]
  such that $c\in \mathcal{N}(c')$, thus the code words and the union of their neighborhood covers all binary strings. On the other hand, it's easy to show that the neighborhoods of distinct code words are disjoint, so the code words and their neighborhoods form a partition of $\{0, 1\}^n$. Since $|\mathcal{N}(s)| = n$ for all $s$, we have
  \[
    |\mathcal{C}| = \frac{2^n}{|\mathcal{N}(s)| + 1} = 2^{n-k}.
  \]
  The proof of optimality is left as exercise.
\end{proof}

\subsection{The corresponding}
\label{sec:corresponding}

Now we are ready for the interesting corresponding between the hat problem and the error correcting code. The code we construct in the proof of Theorem \ref{thm:hamming-exists} is actually called \ul{perfect}, which means the code words and their neighborhood form a partition of $\{0, 1\}^n$, i.e. each binary string that is not a code word belongs to the neighborhood of some code word.

\begin{theorem}
  If there is a perfect error correcting code of length $n$, there is also an optimal strategy for the hat game of $n$ people, whose probability to win is $1-\sfrac{1}{(n+1)}$.
\end{theorem}

\begin{proof}
  Consider the following strategy. For each person $A$, if the possible color configurations (represented by binary strings) $\{u, v\}$ in his point of view does not contain any code word, $A$ will keep silent. Otherwise w.l.o.g. $u$ is a code word, $A$ will guess that the color configuration is $v$. It's not hard to compute the probability to win and prove the optimality.
\end{proof}

\section{Finding your IDs}

\subsection{Problem description}

$n$ students play a game. The IDs of the students are $1,2,\dots,n$, respectively. There are $n$ boxes, each of which contains one of the IDs, and no two boxes contain the same ID. During the game, each student can privately open $\frac{n}{2}$ of the boxes one by one and try to find his/her own ID. The student can discuss a strategy before the game, but no communication is allowed after the beginning of the game. If all of the students find their own IDs, they win --- then they all can avoid a final exam and get As.

\subsection{Solution}

If each student opens $\frac{n}{2}$ boxes at random, the probability of winning is only $2^{-n}$. Let's consider a more clever strategy: number the boxes from $1$ to $n$ randomly; each student first open the box with the same number as his/her ID, then repeatly open the box with the same number as the ID contained by the box he/she has just opened, until his/her ID is found or $\frac{n}{2}$ boxes has been opened.

To determine the probability of winning with this strategy, we first define a probability space $\mathbb{P} = (\mathcal{U}, p)$ by $\mathcal{U}$ being the set of ways of mapping box numbers to student IDs, i.e., the set of permutations, and $p = \frac{1}{\lvert \mathcal{U} \rvert} = \frac{1}{n!}$ since the probability is uniform.

The students win if and only if the permutation has no cycle of length over $\frac{n}{2}$. Therefore we can define the event $T$ by
\begin{align*}
  T = \left\{\sigma \mid \sigma \text{ has no cycle of length over } \frac{n}{2} \right\}.
\end{align*}
To calculate $\lvert T \rvert$, we define more events. Let $T_j$ be the set of permutations which have cycles of length $j$. Then
\begin{align*}
  \overline{T} = \bigcup_{j=\frac{n}{2}+1}^{n} T_j,
\end{align*}
and since a permutation can only have at least one cycle of length over than $\frac{n}{2}$, we have $T_j \cap T_k = \emptyset$ for all $\frac{n}{2} < j < k$. Then,
\begin{align*}
  \lvert \overline{T} \rvert = \sum_{j=\frac{n}{2}+1}^n \lvert T_j \rvert.
\end{align*}
We only need to determine $T_j$ for $j > \frac{n}{2}$. There are $\binom{n}{j}$ ways to choose the elements of the cycle. With these $j$ elements, there are $(j-1)!$ different cycles. Finally, there are $(n-j)!$ ways to arrange the rest elements. Therefore
\begin{align*}
  T_j = \binom{n}{j} (j-1)! (n-j)! = \frac{n!}{j}.
\end{align*}
The probability of winning is then given by
\begin{align*}
  \prob{T} &= 1 - \frac{\lvert \overline{T} \rvert}{\lvert \mathcal{U} \rvert} \\
           &= 1 - \sum_{i=\frac{n}{2}+1}^{n} \frac{\lvert T_j \rvert}{n!} \\
           &= 1 - \sum_{i=\frac{n}{2}+1}^{n} \frac{1}{j} \\
           &\approx 1 - (\ln n - \ln \frac{n}{2}) \\
           &= 1 - \ln 2 \\
           &\approx 30.7\%,
\end{align*}
which is surprisingly high.

\section{The online auction problem}

\subsection{Problem description}

Here is the description of the problem: in an online auction, there are $n$ people and they will offer their bids sequentially. Suppose they offer prices randomly and none of their prices are the same (here random means that the permutation of their price is random). Then the auction goes on and we need to make a decision "to sell the goods to her" or "not to sell the goods to her" and once we reject one price we cannot accept it anymore, just as the word "online" infers. All the information we have about the price is the position of it among the $n$ prices.

The auctioneer wins if he sells the goods with the highest price among the $n$ prices. Then what is the probability he could reach to win?

We can adapt a random strategy: that is, randomly choose a number $k$ among $\{1, 2,\dots, n\}$, and accept the k-th price. We can find that the probability to win is $1/n$, which is too low to satisfy with it.

\end{document}