% $Header: /cvsroot/latex-beamer/latex-beamer/solutions/conference-talks/conference-ornate-20min.en.tex,v 1.6 2004/10/07 20:53:08 tantau Exp $

\documentclass{beamer}

% This file is a solution template for:

% - Talk at a conference/colloquium.
% - Talk length is about 20min.
% - Style is ornate.

% Copyright 2004 by Till Tantau <tantau@users.sourceforge.net>.
%
% In principle, this file can be redistributed and/or modified under
% the terms of the GNU Public License, version 2.
%
% However, this file is supposed to be a template to be modified
% for your own needs. For this reason, if you use this file as a
% template and not specifically distribute it as part of a another
% package/program, I grant the extra permission to freely copy and
% modify this file as you see fit and even to delete this copyright
% notice.

\mode<presentation>
{
%  \usetheme{Warsaw}
%  \usetheme{Boadilla}
%  \usetheme{Goettingen}
%  \usetheme{Hannover}
%  \usetheme{Madrid}
%  \usetheme{Marburg}
%  \usetheme{Montpellier}
%  \usetheme{Pittsburgh}
  \usetheme{Hawke}
  % or ...

  \setbeamercovered{transparent}
  % or whatever (possibly just delete it)
}

\usepackage[english]{babel}
% or whatever

\usepackage[latin1]{inputenc}
% or whatever

\usepackage{times}
\usepackage[T1]{fontenc}
% Or whatever. Note that the encoding and the font should match. If T1
% does not look nice, try deleting the line with the fontenc.

\usepackage{multimedia}

%%%%%%
% My Commands
%%%%%%

\newcommand{\ml}{{\sc matlab}}
\newcommand{\bfm}[1]{{\boldsymbol{#1}}}
\newcommand{\bx}{\bfm{x}}
\newcommand{\bb}{\bfm{b}}

%%%%

\title[Lecture 29] % (optional, use only with long paper titles)
{Lecture 29 - QR Factorisation}

% \subtitle
% {Include Only If Paper Has a Subtitle}

\author[I. Hawke] % (optional, use only with lots of authors)
{I.~Hawke}
% - Give the names in the same order as the appear in the paper.
% - Use the \inst{?} command only if the authors have different
%   affiliation.

\institute[University of Southampton] % (optional, but mostly needed)
{
%  \inst{1}%
  School of Mathematics, \\
  University of Southampton, UK
}
% - Use the \inst command only if there are several affiliations.
% - Keep it simple, no one is interested in your street address.

\date[Semester 1] % (optional, should be abbreviation of conference name)
{MATH3018/6141, Semester 1}
% - Either use conference name or its abbreviation.
% - Not really informative to the audience, more for people (including
%   yourself) who are reading the slides online

\subject{Numerical methods}
% This is only inserted into the PDF information catalog. Can be left
% out.

% If you have a file called "university-logo-filename.xxx", where xxx
% is a graphic format that can be processed by latex or pdflatex,
% resp., then you can add a logo as follows:

\pgfdeclareimage[height=0.5cm]{university-logo}{mathematics_7469}
\logo{\pgfuseimage{university-logo}}

% Delete this, if you do not want the table of contents to pop up at
% the beginning of each subsection:
%  \AtBeginSubsection[]
%  {
%    \begin{frame}<beamer>
%      \frametitle{Outline}
%      \tableofcontents[currentsection,currentsubsection]
%    \end{frame}
%  }
\AtBeginSection[]
{
  \begin{frame}<beamer>
    \frametitle{Outline}
    \tableofcontents[currentsection]
  \end{frame}
}

% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command:

%\beamerdefaultoverlayspecification{<+->}

\begin{document}

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

\section{\texorpdfstring{$QR$ factorisation}{QR factorisation}}

\subsection{\texorpdfstring{$QR$ factorisation}{QR factorisation}}

\begin{frame}
  \frametitle{The full spectrum of a matrix}

  Our aim is to compute the full spectrum of the square $n \times n$
  matrix $A$; that is, we want to find all its eigenvalues. \pause

  \vspace{1ex}

  Method: transform to a simpler problem that is straightforwardly
  solved. E.g.\ transform $A$ to $B$ with same spectrum, but $B$
  triangular: eigenvalues of a triangular matrix are the diagonal
  coefficients. \pause

  \vspace{1ex}

  Schur's theorem shows that every matrix $A$ has a \emph{similar}
  triangular matrix $B$, but is not useful for finding the matrix in
  practice. \pause

  \vspace{1ex}

  The proof of Schur's theorem made repeated use of \emph{Householder
    reflections}; these are generally useful as we shall see later.

\end{frame}

\begin{frame}
  \frametitle{\texorpdfstring{$QR$ factorisation}{QR factorisation}}

  Another decomposition method for a general (not necessarily square)
  matrix: \emph{orthogonal factorisation}. $A$ written as product of
  matrices, some of which are orthogonal (i.e.\ real -- $Q^{\dagger} =
  Q^T$ -- and unitary, $Q^{-1} = Q^{\dagger} = Q^T$).  \pause

  \vspace{1ex}

  Simplest example: \emph{Householder's} $QR$-factorisation
  \begin{equation*}
    A = Q R,
  \end{equation*}
  with $Q$ unitary, $R$ upper triangular. \pause $A$ and $R$ may be $m
  \times n$ matrices, but $Q$ is always square ($m \times m$). \pause

  \vspace{1ex}

  If $A = QR$ with $Q$ unitary then
  \begin{equation*}
    B = R Q = \left( Q^{\dagger} Q \right) R Q = Q^{\dagger} A Q
  \end{equation*}
  which is similar to $A$.

\end{frame}

\begin{frame}
  \frametitle{Householder's factorisation}

  Need factorisation $A = QR$; or construct unitary $Q$ such that
  \begin{equation*}
    Q^{\dagger} A = R
  \end{equation*}
  where $R$ is upper triangular. \pause

  \vspace{1ex}

  Done by iterative process using \emph{Householder transformations}
  \begin{equation*}
    U_k =
    \begin{pmatrix}
      \text{Id}_{k-1} & 0 \\
      0 & \text{Id}_{m-k+1} - \bfm{u}_k \bfm{u}_k^{\dagger}
    \end{pmatrix}.
  \end{equation*} \pause
  Simple generalization of Householder reflections;
  when $k=1$ it \emph{is} a Householder reflection.

\end{frame}

\begin{frame}
  \frametitle{The iterative process}

  To convert original $A$ into upper triangular matrix $R$, at each
  stage construct matrix rotating $k^{\text{th}}$ column of $A$,
  $\bfm{a}_k$, into $\hat{\bfm{e}}_k$ that is zero in all entries
  $>k$. \pause So
  \begin{align*}
    \bfm{e}_1 = \mu_{1,1} \hat{\bfm{e}_1} & = (\mu_{1,1}, 0, \dots, 0)^T. %\\
%    \hat{\bfm{e}}_2 & = (\mu_{2,1}, \mu_{2,2}, 0, \dots, 0)^T
  \end{align*}
  \pause

  At first stage need a Householder reflection to take $\bfm{a}_1$ to
  (a multiple of) $\bfm{e}_1$. The later stages do not care what
  happens to entries ``above'' the diagonal. So they can be multiplied
  by the identity matrix. \pause Thus at each stage a suitable
  Householder transformation
  \begin{equation*}
    U_k =
    \begin{pmatrix}
      \text{Id}_{k-1} & 0 \\
      0 & \text{Id}_{m-k+1} - \bfm{u}_k \bfm{u}_k^{\dagger}
    \end{pmatrix}
  \end{equation*}
  takes column $\bfm{a}_k$ to ``upper triangular'' column $k$ of the
  new matrix, without altering columns $\bfm{a}_l, \,\, l<k$.

\end{frame}

\begin{frame}
  \frametitle{The rotation}

  At each stage rotate (part of) column $\bfm{a}_k$ into ``lower
  triangular'' column $\hat{\bfm{e}}_k$. This gives the vector
  $\bfm{u}$ for the Householder reflection
  \begin{equation*}
    \bfm{u}_k = \frac{\sqrt{2}}{\| \bfm{a}_k - \beta_k \hat{\bfm{e}}_k \|}
    ( \bfm{a}_k - \beta_k \hat{\bfm{e}}_k ),
  \end{equation*} \pause
  where $\beta_k$ is such that
  $\|\bfm{a}_k\| = \beta_k \|\hat{\bfm{e}}_k\|$, so the reflection is a unitary matrix.

  \begin{overlayarea}{\textwidth}{0.4\textheight}
    \only<3|handout:0>{
    \begin{align*}
      U_1A & \,=
      \left(\text{Id}_{m} - \bfm{u}_1 \bfm{u}_1^{\dagger}\right) A
      \\
      &\, = \left(\begin{array}{c|c}
        \beta_1 & *\\
	\hline
	\boldsymbol{0} & W_{m-1}
      \end{array}\right).
    \end{align*}}

    \only<4|handout:0>{
    \begin{align*}
      U_2U_1A & \,=
      \Bigg(\begin{array}{c c}
	\text{Id}_{1} & 0 \\
	0 & \text{Id}_{m-1} - \bfm{u}_2 \bfm{u}_2^{\dagger}
      \end{array}\Bigg)
      \left(\begin{array}{c|c}
        \beta_1 & *\\
	\hline
	\boldsymbol{0} & W_{m-1}
      \end{array}\right)\\
      &\, = \left(\begin{array}{c c|c}
        \beta_1 & * & *\\
	0 & \beta_2 & *\\
	\hline
	\boldsymbol{0} & \boldsymbol{0} & W_{m-2}
      \end{array}\right).
    \end{align*}}

  \only<5|handout:0>{
    \begin{align*}
      U_3U_2U_1A &\,
      = \left(\begin{array}{c c c|c}
        \beta_1 & * & *& *\\
        0 & \beta_2 & * & *\\
        0 & 0 & \beta_3 & * \\
	\hline
	\boldsymbol{0} & \boldsymbol{0} & \boldsymbol{0} & W_{m-3}
      \end{array}\right).
    \end{align*}}

  \only<6>{
    \begin{align*}
      U_4U_3U_2U_1A &\,
      = \left(\begin{array}{c c c c|c}
        \beta_1 & * & *& *& *\\
        0 & \beta_2 & * & *& *\\
        0 & 0 & \beta_3 & *& * \\
        0 & 0 & 0 & \beta_4 & * \\
	\hline
	\boldsymbol{0} & \boldsymbol{0} & \boldsymbol{0} & \boldsymbol{0} & W_{m-4}
      \end{array}\right).
    \end{align*}}
  \end{overlayarea}

\end{frame}

\begin{frame}
  \frametitle{Consequences}

  The result of applying $k$ Householder transforms is
  \begin{equation*}
    U_k U_{k-1} \dots U_2 U_1 A = \left(
      \begin{array}{c|c}
        J & H \\ \hline 0 & W
      \end{array}\right)
  \end{equation*}
  where $J$ is upper triangular. After $n-1$ transforms we have the
  upper triangular matrix $R$ required. \pause

  \vspace{1ex}

  As each $U_i$ is unitary, the product
  \begin{equation*}
    Q^{\dagger} = U_{n-1} U_{n-2} \dots U_2 U_1
  \end{equation*}
  is unitary, and hence
  \begin{equation*}
    Q = U_1 U_2 \dots U_{n-2} U_{n-1}.
  \end{equation*}

\end{frame}

\section{\texorpdfstring{The $QR$ algorithm of Francis}{The QR
    algorithm of Francis}}

\subsection{\texorpdfstring{The $QR$ algorithm of Francis}{The QR
    algorithm of Francis}}

\begin{frame}
  \frametitle{\texorpdfstring{The $QR$ algorithm of Francis}{The QR
      algorithm of Francis}}

  $QR$ algorithm: iterative process that, in the limit, gives upper
  triangular $A_{\infty}$ similar to $A$. \pause Two steps at each
  iteration:
  \begin{enumerate}
  \item Factorize $A_k$ using Householder's algorithm to get
    \begin{equation*}
      A_k = Q_k R_k.
    \end{equation*}
  \item Compute the next guess $A_{k+1}$ using
    \begin{equation*}
      A_{k+1} = R_k Q_k.
    \end{equation*}
  \end{enumerate} \pause

  From the definition
  \begin{equation*}
    A_{k+1}  = R_k Q_k = Q_k^{\dagger} Q_k R_k Q_k = Q_k^{\dagger} A_k Q_k
  \end{equation*}
  so that all members of the sequence are similar. \pause

  \vspace{1ex}

  Start sequence with $A_1 = A$; iterate sequence to produce a
  triangular matrix.% \pause
  If $A_k$ upper triangular then $Q_k = I$: sequence has converged
  \begin{align*}
    A_{k+1} & = A_k .
  \end{align*}

%   We will not prove that this method actually converges to an upper
%   triangular matrix, but we will rely on it.

\end{frame}

% \begin{frame}
%   \frametitle{\texorpdfstring{The $QR$ algorithm of Francis}{The QR
%       algorithm of Francis}}

%   \begin{enumerate}
%   \item Factorize $A_k$ using Householder's algorithm to get
%     \begin{equation*}
%       A_k = Q_k R_k.
%     \end{equation*}
%   \item Compute the next guess $A_{k+1}$ using
%     \begin{equation*}
%       A_{k+1} = R_k Q_k.
%     \end{equation*}
%   \end{enumerate}

%   This gives the itteration scheme
%   \begin{align*}
%     A_{k+1} & = Q_k^{\dagger} A_k Q_k
%   \end{align*}

%   Clearly if $A_k$ is upper triangular then $Q_k = I$ and our sequence has
%   converged
%   \begin{align*}
%     A_{k+1} & = A_k .
%   \end{align*}

% %   We will not prove that this method actually converges to an upper
% %   triangular matrix, but we will rely on it.

% \end{frame}

\begin{frame}
  \frametitle{Example}

  We apply the $QR$ algorithm to
  \begin{equation*}
    A =
    \begin{pmatrix}
      1 & 2 & 3 \\
      4 & 5 & 6 \\
      7 & 8 & 0
    \end{pmatrix}.
  \end{equation*}
  Start from $A_1 = A$, and at each stage we compute the
  $QR$-factorisation, setting $A_{k+1}  = R_k Q_k$. \pause We find
  \begin{overlayarea}{\textwidth}{0.4\textheight}
    \only<2|handout:0>
    {
      \begin{equation*}
        A =
        \begin{pmatrix}
          1 & 2 & 3 \\
          4 & 5 & 6 \\
          7 & 8 & 0
        \end{pmatrix} \rightarrow
        A_2 =
        \begin{pmatrix}
          8.5909 &  -9.2413  &  3.1659\\
          -4.3423 &  -1.0909 &   1.1078\\
          3.1659  &  1.1078 &  -1.5000
        \end{pmatrix}
      \end{equation*}
    }
    \only<3|handout:0>
    {
      \begin{equation*}
        A =
        \begin{pmatrix}
          1 & 2 & 3 \\
          4 & 5 & 6 \\
          7 & 8 & 0
        \end{pmatrix} \rightarrow
        A_3 =
        \begin{pmatrix}
          12.1434 &  -0.1941 &   2.7400 \\
          3.6616 &  -5.8055 &   1.3022 \\
          0.1341 &  -0.2284 &  -0.3379
        \end{pmatrix}
      \end{equation*}
    }
    \only<4|handout:0>
    {
      \begin{equation*}
        A =
        \begin{pmatrix}
          1 & 2 & 3 \\
          4 & 5 & 6 \\
          7 & 8 & 0
        \end{pmatrix} \rightarrow
        A_4 =
        \begin{pmatrix}
          11.6370 &  -5.3339 &  -3.0770\\
          -1.5849 &  -5.2507 &  -0.6576\\
          0.0041  &  0.0146  & -0.3863
        \end{pmatrix}
      \end{equation*}
    }
    \only<5|handout:0>
    {
      \begin{equation*}
        A =
        \begin{pmatrix}
          1 & 2 & 3 \\
          4 & 5 & 6 \\
          7 & 8 & 0
        \end{pmatrix} \rightarrow
        A_5 =
        \begin{pmatrix}
          12.2535 &  -2.9417 &   2.9725\\
          0.7988  & -5.8653  &  1.0822\\
          0.0001  & -0.0011  & -0.3882
        \end{pmatrix}
      \end{equation*}
    }
    \only<6|handout:0>
    {
      \begin{equation*}
        A =
        \begin{pmatrix}
          1 & 2 & 3 \\
          4 & 5 & 6 \\
          7 & 8 & 0
        \end{pmatrix} \rightarrow
        A_6 =
        \begin{pmatrix}
          12.0378 &  -4.1083 &  -3.0373\\
          -0.3683 &  -5.6494 &  -0.8874\\
          0.0000  &  0.0001  & -0.3884
        \end{pmatrix}
      \end{equation*}
    }
    \only<7>
    {
      \begin{equation*}
        A =
        \begin{pmatrix}
          1 & 2 & 3 \\
          4 & 5 & 6 \\
          7 & 8 & 0
        \end{pmatrix} \rightarrow
        A_7 =
        \begin{pmatrix}
          12.1581 &  -3.5634 &   3.0087 \\
          0.1765  & -5.7697  &  0.9800 \\
          0.0000  & -0.0000  & -0.3884
        \end{pmatrix}
      \end{equation*}
    }
  \end{overlayarea}
\end{frame}

\begin{frame}
  \frametitle{Example: 2}

  \begin{columns}
    \begin{column}{0.35\textwidth}
      The matrix
      \begin{equation*}
        A =
        \begin{pmatrix}
          1 & 2 & 3 \\
          4 & 5 & 6 \\
          7 & 8 & 0
        \end{pmatrix}
      \end{equation*}
      has eigenvalues
      \begin{equation*}
        \left\{
          \begin{array}{c}
            12.1229\\ -5.7345\\ -0.3884
          \end{array}\right. .
      \end{equation*}
      The $QR$ algorithm of Francis converges to all eigenvalues linearly.
    \end{column}
    \begin{column}{0.65\textwidth}
      \includegraphics[width=\textwidth]{figures/QRFrancis1}
    \end{column}
  \end{columns}

\end{frame}

\section{\texorpdfstring{$QR$ convergence}{QR convergence}}

\subsection{\texorpdfstring{$QR$ convergence}{QR convergence}}

\begin{frame}
  \frametitle{Comparison with power method}

  Proving that QR algorithm converges not easy. Get some insight from
  comparison with power method.  \pause

  \vspace{1ex}

  Power method: repeated matrix multiplication to find the eigenvector
  of largest eigenvalue.
  %
  \begin{equation*}
    A^k\boldsymbol{x} = \boldsymbol{x}^{(k)} = \lambda_1^k\left[ a_1\boldsymbol{u}_1 +
      \sum_{j=2}^{N}\left(\frac{\lambda_j}{\lambda_1}\right)^ka_j\boldsymbol{u}_j   \right].
  \end{equation*}  \pause
  Obvious extension: apply to multiple vectors
  at the same time.
  \pause

  \vspace{1ex}

  Problem: method will converge to multiple copies of the same
  eigenvector.
\end{frame}

\begin{frame}
  \frametitle{Comparison with power method}

  Overcome problem by \emph{orthonormalising} the vectors at each stage.

  {\centering \includegraphics[width=0.8\textwidth]{figures/QR}}
  \pause

  \vspace{1ex}

  $QR$ algorithm does this by expressing the ``guess'' as an
  orthonormal matrix $Q$ at each stage.  \pause

  \vspace{1ex}

  Method works by removing the dominant eigenvector from the
  basis. \pause Remaining ``guesses''  converge to the
  eigenvector of dominant eigenvalue within the resulting subspace.

\end{frame}

\section{Summary}

\subsection{Summary}

\begin{frame}
  \frametitle{Summary}

  \begin{itemize}
  \item To compute all eigenvalues we use the $QR$ algorithm of Francis.
  \item This algorithm is iterative and converges linearly.
  \item It relies on Householder transformations, a generalization of
    Householder reflections.
  \item Each step in the sequence relies on the $QR$ factorisation of
    the matrix. As $Q$ is unitary, each member of the sequence is
    similar and so the spectrum is unchanged.
  \item Interpreting the algorithm as a generalized power method is
    possible but not straightforward.
  \end{itemize}

\end{frame}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\documentclass[main.tex]{subfiles}
\begin{document}

\section{Sheet 9}

\subsection{Censorship principle justification}

\subsubsection{Boundary condition}

We assume that the Kerr black hole starts off as \emph{critical}:\footnote{I initially thought this could work as well if we assumed the BH was initially subcritical and became critical: this is not the case, the calculation is much worse.} so initially we have \(a = GM\), and that the particle's addition makes it so that \(a' \geq G M'\): this can be written by making the dependence on \(J = aM\) explicit: when we add the particle we get \(J'= J + lm\) and \(M' = M + me\). So the condition reads:
%
\begin{subequations}
\begin{align}
  J' &\geq G M^{\prime 2}  \\
  J + lm &\geq G \qty(M^2 + 2mMe + (me)^2)  \\
  l &\gtrsim 2GM e
  \,,
\end{align}
\end{subequations}
%
where we used the fact that \(J = G M^2\) and we ignored the \(O(m^2)\) term, which is negligible (one could collect a \(M^2\) and get a polynomial in \(m/M\) to consider up to linear order: it is the same thing in the end).
Hereafter, we assume that we have exactly the boundary condition \(l = 2GMe\).

\subsubsection{Effective potential barrier}

We write the potential with respect to the adimensional coordinates \(R = r/2GM\) and \(L= l/2GM = e\), and we  use the fact that \(a = GM\), which implies \(a/2GM = 1/2\). With these substitutions, we find:
%
\begin{subequations}
\begin{align}
  V _{\text{eff}} (R, e, L) &=
  - \frac{1}{2R}
  + \frac{L^2 -  (e^2 - 1) / 4 }{2R^2}
  - \frac{(L - e/2)^2}{2R^3}  \\
  &=   - \frac{1}{2R}
  + \frac{e^2 -  (e^2 - 1) / 4 }{2R^2}
  - \frac{e^2}{8R^3}  \\
  &= e^2 \qty(\frac{3}{8R^2} - \frac{1}{8R^3}) - \frac{1}{2R} + \frac{1}{8R^2}
\,.
\end{align}
\end{subequations}

We want to see, then, whether the potential barrier is as high as \((e^2- 1) /2\). Where is this potential barrier?
The photon is absorbed when it gets inside the event horizon (which then should disappear), and we know that the locations of the horizons are given by \(r_{\pm} = GM \pm \sqrt{(GM)^2 - a^2} = GM\), so in our case they are situated at \(R = 1/2\).

Plugging this into the formula we find
%
\begin{align}
  V _{\text{eff}} = e^2 \qty(\frac{3}{2} - 1) - 1 + \frac{1}{2} = \frac{e^2 -1}{2}
\,,
\end{align}
%
so at \(R = 1/2\) we must have \(\dv*{r}{\tau } = 0\).
This is actually enough for our purposes: it does not reall matter what the rest of the potential looks like, since at at least one point it is as large as the energy. However, it is interesting to see the global shape of the effective potential: it is plotted in figure \ref{fig:residual-potential} for different values of \(e\).

\begin{figure}[ht]
  \centering
  \includegraphics[width=\textwidth]{figures/potential_barrier}
  \caption{Effective potential \(V _{\text{eff}} (R, e) - (e^2 -1) / 2\).}
  \label{fig:residual-potential}
\end{figure}

\subsubsection{Comments on the possibility of undressing a singularity (complement)}

We have shown that the potential barrier will prevent a particle with angular momentum \(l\) with respect to the BH from being absorbed.
There are some things to consider: one of these is the fact that we assumed \(m^2\) is negligible: what if we threw a \emph{really massive} object into our Kerr black hole?
In that case we would have \(L = e + m e^2 / 2M > e\), and since \(\dv*{V}{L} > 0\) everywhere the potential barrier would be even higher. This is not the way to go.

However, we neglected \emph{intrinsic} spin: what if we threw lots of, say, electrons aligned with the rotation axis down on the BH (on a trajectory with \(\theta \equiv 0\))?
They may have angular momentum with respect to the hole which allows them to go in, but increase its angular momentum by a little bit more through their intrinsic spin in order to make the singularity naked\dots

Say we did it with an electron: then we would have a spin of \(j= \hbar /2\) and \(m = m_e\). If its four-velocity while falling in looks like \(u^{\mu } = (u^{t}, u^{r}, 0,0)\) then we have
%
\begin{align}
  e =- g_{t \mu } u^{\mu } =
  \qty(1 - \frac{R}{R^2 + 1/4}) u^{t}
\,,
\end{align}
%
since \(\rho^2 = r^2 + a^2 \) there; it is convenient, in order to minimize the energy imput to the BH, to throw in the electron with asymptotically nonrelativistic velocities: then we will have \(e \sim 1\). So our saturated inequality looks like
%
\begin{align}
  j = \frac{\hbar}{2}= 2GM m_e  \implies M = \frac{\hbar c}{4Gm_e} \sim \SI{e14}{kg}
\,,
\end{align}
%
where in the last equality we reinserted \(c\);
the mass of the black hole needs to be \emph{lower} than this in order for singularity to become naked through absorption of electrons in this manner.
If we substitute in neutrinos for electrons, which also have \(j = \hbar/2\) but mass of at most \(m_\nu \sim \SI{.12}{eV} \sim \SI{2.14e-37}{kg}\), we get \(M _{\text{min}} \sim \SI{e21}{kg}\).

These are quite small masses when compared to those of known black holes, the smallest of which are of the order of the solar mass, \(M_{\odot} \sim \SI{e30}{kg}\).
So we must conclude that throwing massive particles down on the axis of a real black hole is not the way to go.
It seems like the censorship principle is sound.

This is treated more in depth in the wonderfully titled article \emph{Return of the quantum cosmic censor}:\footnote{\url{http://arxiv.org/abs/0810.0079v1}}
there they show that a proper analysis of the interaction of a fermionic field with a (Kerr-Newman: charged and rotating) BH cannot actually over-spin it; the probability of the modes which could to be absorbed is suppressed by a factor \(\exp(- M / M_P)\).

\subsection{Kerr geometry null surfaces}

\subsubsection{Horizon metric}

Let us compute the metric elements at the outer horizon: it is a straight calculation. We just substitute in \(r = r_{+} = GM + \sqrt{(GM)^2 - a^2}\) and \(\rho^2 = \rho^2_{+}\):
%
\begin{subequations}
\begin{align}
  &g_{00}  = - \qty(1 - \frac{2GMr_{+}}{\rho_{+}^2})  \\
  &= \frac{1}{\rho_{+}^2} \qty(2GM \qty(GM + \sqrt{(GM)^2 - a^2}) - r_{+}^2 - a^2 \cos^2\theta )  \\
  &= \frac{1}{\rho_{+}^2} \qty( 2 (GM)^2 + 2GM \sqrt{\dots}- \qty((GM)^2 + (GM)^2 -a^2 + 2GM \sqrt{\dots}) - a^2 \cos^2 \theta )  \\
  &= \frac{a^2}{\rho_{+}^2}  \qty(1 - \cos^2 \theta ) = \frac{a^2 \sin^2\theta}{\rho_{+}^2}
\,,
\end{align}
\end{subequations}
%
where we omitted the argument of the square root for brevity: it is the same on either side, and it simplifies.
For the components \(g_{03}\) and \(g_{22} \) we cannot simplify anything. The  only thing to recall is that the off-diagonal components of the metric when written in component form are half of what they are when written with respect to the differentials, since we usually do not bother to write two separate \(\dd{t} \dd{\varphi }\) and \(\dd{\varphi } \dd{t}\) terms: the diffentials commute, therefore we simply write one of the two combinations with double the value. So we have:
%
\begin{align}
  g_{03} = -\frac{2GMa r_+ \sin^2\theta }{\rho_{+}^2}
\,
\end{align}
and
%
\begin{align}
  g_{22} = \rho_{+}^2
\,.
\end{align}

The computation of the \(g_{33} \) component\footnote{There is a typo in the assignment: this component is denoted as \(g_{03}\) again.} is more interesting: we get
%
\begin{align}
  g_{33} = \qty( r_+^2 + a^2 + \frac{2GMr_{+} a^2 \sin^2\theta }{\rho_{+}^2}) \sin^2 \theta
\,,
\end{align}
%
and we recall the definition of \(\Delta = r^2 + a^2 - 2GM r\): since we are dealing with the case in which \(\Delta = 0\), so we have \(r^2 + a^2 = 2GMr\), which we substitute in and collect:
%
\begin{subequations}
\begin{align}
  g_{33} &= 2GMr_{+} \qty(1 + \frac{a^2 \sin^2\theta }{\rho_{+}^2}) \sin^2\theta \\
  &= 2GMr_{+} \frac{\sin^2 \theta }{\rho_{+}^2} \qty(r_{+}^2 + a^2 \cos^2 \theta + a^2 \sin^2\theta )
\,,
\end{align}
\end{subequations}
%
and then we can notice again the combination \(r_{+}^2 + a^2 = 2GMr_{+}\): so in the end we get
%
\begin{align}
  g_{33} = \qty(\frac{2GMr_{+} \sin \theta }{\rho_{+}})^2
\,.
\end{align}

\subsubsection{Uniqueness of the null vector}

The metric we found for the 3D space \(r \equiv r_{+}\) is:
%
\begin{align}
  \dd{s^2} = \frac{a^2 \sin^2\theta }{\rho_{+}^2} \dd{t^2}
  - \frac{4GM a r_{+} \sin^2\theta }{\rho_{+}^2} \dd{t} \dd{\varphi } + \rho_{+}^2 \dd{\theta^2}
  + \qty(\frac{2GMr_{+} \sin \theta }{\rho_{+}})^2 \dd{\varphi^2}
\,,
\end{align}
%
and now we want to find a vector field \(l^{\mu } = (l^{t}, l^{\theta }, l^{\varphi })\) such that \(l^2 = l^{\mu } g_{\mu \nu } l^{\nu } = 0\).
Since \(\rho_{+}^2 \neq 0\) we can multiply everything by it: we get
%
\begin{align}
  l^2 = a^2 \sin^2\theta (l^{t})^2
  - 4GMar_{+} \sin^2\theta l^{t} l^{\varphi }
  + \rho_{+}^{4} (l^{\theta })^2
  + (2GMr_{+})^2 \sin^2 \theta (l^{\varphi })^2
\,,
\end{align}
%
and we notice that the \(tt\), \(\varphi \varphi \) and \(\varphi t\) terms form a square: we find
%
\begin{align}
  l^2= \qty(a \sin \theta l^{t} - 2GMr_{+} \sin \theta l^{\varphi })^2 + \rho_{+}^4 (l^{\theta })^2
\,,
\end{align}
%
so if we want to set \(l^2 = 0\) we need to have both square terms be separately equal to zero.
This means that \(l^{\theta } = 0\), and that
%
\begin{align}
  a l^{t} = 2GMr_{+} l^{\varphi }
\,,
\end{align}
%
so if we choose a value for one of the components the other one is fixed. Therefore, the vector field only has a scalar degree of freedom: we can rescale it by a scalar field, but its direction is fixed. Specifically, we find that
%
\begin{align}
  \frac{l^{\varphi }}{l^{t}}  = \frac{a}{2GMr_{+}}
\,
\end{align}
%
is the only allowed ratio of these components. If we interpret the vector \(l\) as the 4-velocity of light trapped at the horizon, we have
%
\begin{align}
    \dv{\varphi }{\tau } \dv{\tau }{t} = \dv{\varphi }{t}
    = \frac{a}{2GMr_{+}}
\,.
\end{align}

\subsubsection{A basis for the horizon}

The \(\varphi \varphi \) and \(\theta \theta \) components of the metric are squares of real numbers, so they are positive, so the vectors \(m^{\alpha } = [0,0,1,0]^{\top}\) and \(n^{\alpha } = [0,0,0,1]^{\top}\) are spacelike.

They are orthogonal, since \(m^{\alpha } g_{\alpha \beta } n^{\beta } = g_{23} =0 \).
Let us compare them to the null vector we found earlier, for which we can use the normalization: \(l^{\alpha } = [2GMr_{+}, 0, 0, a]^{\top}\).
We have that \(m^{\alpha } g_{\alpha \beta } l^{\beta } = g_{2 \beta } l^{\beta }=  0\), since the only \(2 \beta \) component of the metric is \(g_{22 }\) but \(l^{2}=0\). On the other hand, we have
%
\begin{subequations}
\begin{align}
  n^{\alpha }g_{\alpha \beta } l^{\beta }
  &= g_{3 \beta } l^{\beta } \\
  &= -\frac{ 2GMar_{+}\sin^2\theta }{\rho_{+}^2} 2GMr_{+}
  + \qty(\frac{2GMr_{+} \sin \theta }{\rho_{+}})^2 a = 0
\,.
\end{align}
\end{subequations}

A basis is defined by linear independence and spanning, which are properties independent of the metric. For an \(n\)-dimensional set of vectors, each of these properties is equivalent to our set being a basis.

So, we prove linear independence: let us consider a combination of these vectors:
%
\begin{align}
  A l^{\mu } + B m^{\mu } + C n^{\mu } = 0
\,,
\end{align}
%
and we need to show that this implies \(A = B = C = 0\).
In order for the \(\mu = 0\) component of the result to be zero we need \(A = 0\). In order for the \(\mu =2\) component to be zero we need \(B = 0\). In order for the \(\mu = 3\) component to be zero we need \(C = 0\), so the result is proven.

\subsection{Solar system Kerr}

\subsubsection{Earth's implausible Kerr description}

We need to estimate the angular momentum of the Earth: for our order of magnitude calculation we will model it as a constant-density sphere, with \(M = \SI{6e+24}{kg}\) and \(r = \SI{6e6}{m}\). The moment of inertia is then given by
%
\begin{align}
  I = \frac{2}{5} M r^{2} \approx \SI{1e38}{kg m^2}
\,.
\end{align}

This is a slight over-estimate: more of the Earth's mass is concentrated around the center, so the actual moment of inertia is about \(20\%\) lower. This is close enough for our purposes.

Then, since the Earth rotates at a revolution per day so with \(\omega = 2\pi / \SI{1}{d}\), we have our estimate for the angular momentum:
%
\begin{align}
  J = I \omega
  \approx \SI{7e+33}{kg m^2 s^{-1}}
\,.
\end{align}

In order to find the length corresponding to the natural-units formula \(a = J/M\) we need to divide by \(c\): so we get
%
\begin{align}
  a = \frac{J}{Mc} \approx \SI{4}{m}
\,,
\end{align}
%
while we have \(GM/c^2 \approx \SI{4e-3}{m}\): their ratio is of the order \num{e3}.

This of course does not mean that there is a naked singularity deep inside the Earth: we'd need all the mass to be concentrated around \(r=0\) for that to be the case, and instead the radius of the Earth is quite larger than \SI{4}{m}.

So we have the quite interesting result that the general-relativistic description of the Earth corresponds to a Kerr metric with \(a \gg GM\). It is not really clear to me what meaning should be drawn from this but it seems to be the case.

\subsubsection{The Sun's Kerr metric}

We can do the same calculation for the Sun, which has \(m \approx \SI{2e30}{kg}\) and \(r \approx \SI{7e8}{m}\); its moment of inertia factor (\(I  / Mr^2\)) is quite badly approximated by \(2/5\): it is around \(0.07\).\footnote{\url{https://web.archive.org/web/20191030204430/https://nssdc.gsfc.nasa.gov/planetary/factsheet/sunfact.html}}
The rotation of the Sun depends on the latitude of the surface since it is a fluid, but its period is on the order of \(\SI{600}{hr}\).
So we have
%
\begin{align}
  J = I \omega \approx \SI{1.7e41}{kg m^2 s^{-1}}
\,,
\end{align}
%
which gives
%
\begin{align}
  a = \frac{JM}{c} \approx \SI{330}{m}
\,,
\end{align}
%
while
%
\begin{align}
  \frac{GM}{c^2} \approx \SI{1500}{m}
\,,
\end{align}
%
therefore the ratio \(a/GM\) is around \num{0.2}.
So the Sun's Kerr metric would have an inner and outer horizon.

\subsubsection{Critical \(\omega \) in general (complement)}

We can compute the value of \(\omega \) for which any object will have \(a = GM\): if the moment of inertia is \(I = \kappa M r^2\) in the end we find
%
\begin{align}
  \omega _{\text{crit}} = \frac{GM}{\kappa r^2 c}
\,,
\end{align}
%
so if we consider objects with a constant density \(\rho \sim M r^{-3}\) the critical angular velocity scales with \(r\): it gets quite low for small objects!
A carousel with \(r \sim \SI{2}{m}\) and \(M \sim \SI{100}{kg}\) (and \(\kappa \sim 0.5\)) will have a critical angular velocity of around \SI{e-17}{rad/s}! It is \emph{really easy} for a small object to have \(a \gg GM\).

\end{document}


\documentclass[12pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{macros}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\pagestyle{empty}
\usepackage{tikz}
\usepackage{filecontents,pgfplots}
\usepackage{enumerate}
\usepackage{nth}
\usepackage{wrapfig}
\usetikzlibrary{scopes}
%\usepackage{natbib}

\begin{document}
\setlength{\unitlength}{1in}
\title{Diffusion and Boltzmann's constant}
\author{Michael G. Lerner}
\date{\today}
\maketitle
%\begin{abstract}
%\end{abstract}

We'll use modern microscopy techniques to measure Boltzmann's constant
by looking at the diffusion of microspheres suspended in fluid and by
looking at the diffusion of quantum dots attached to PE lipids in
supported membranes. We will follow the methodology from
\cite{nakroshis2003measuring}. The paper is pretty good, and we'll do
both types of analysis mentioned in the article, meaning that we'll
want to use both equation (3) and equation (5) from the paper. Here's
where those come from. This treatment is known as Stokes-Einstein
diffusion.
\section{The Langevin Equation}

We've spent a lot of the class so far learning the lesson of
statistical physics: we can determine an enormous amount of physics
related to ``large'' systems by looking at average properties. Here,
we apply the same thinking to dynamics. If we want to describe the
motion of a grain of pollen floating on a pond (or a microsphere in
solution, or a lipid in a membrane), we know that we'll need some sort
of differential equation. The statistical physics trick is that we'll
want a \textit{stochastic} differential equation. That is, we'll want
our differential equation to have a \textit{random} term representing
the interaction of our pollen with the water. The specific type of
differential equation we'll want is called a Langevin equation. Don
Lemons has written a fantastic introduction to stochastic processes
\cite{LemonsStochasticIntro} and MacDonald \cite{MacDonaldNoise} has a
wonderful small book as well if this topic catches your interest. Reif
\cite{ReifStatMech} also has a nice derivation starting in \S15.5 and
we follow it below.

We'll treat a one-dimensional system, and the first goal is to get the
Langevin equation

\begin{equation}
  \label{Langevin}
  m\fd{v}{t} = -\zeta v + \eta(t)
\end{equation}

In looking at (\ref{Langevin}), the two terms on the right hand side
are new to us. The first of these a) slows us down and b) is
proportional to velocity, and so is known as a ``velocity-dependent
drag force'' and $\zeta$ is called the ``drag coefficient''. Although
we won't use it here, the quantity $1/\zeta$ is called the
``mobility'' and is typically written as $\mu$.
The second is our stochastic, or ``noise'' term, a rapidly fluctuating
force due to the environmental water molecules (the Greek letter eta
is chosen because $\eta$ looks like the ``n'' from ``noise'').

In general, we start with Newton's second law:

\begin{equation}
  \label{N2L}
  m\dd{x}{t} = m\fd{v}{t} = F
\end{equation}
and we will try to say some smart things about $F$ that will let us
write (\ref{N2L}) as (\ref{Langevin}).

On the statistical side, if $F$ is the force on our microsphere due to
the surrounding waters, we'd like to consider the average of a large
number $N$ of identically prepared systems, finding the average force
at a specific time $t_1$ on our particle as

\begin{equation}
  \avgb{F(t_1)} \equiv \frac{1}{N}\sum_{n=1}^NF^{(n)}(t_1)
\end{equation}
where $n$ indexes the identically prepared systems. If we assume that
$F(t)$ is rapidly fluctuating, it must then be true that $v$ is also
rapidly fluctuating.

The physical insight here is that we can then break $v$ up into two pieces:

\begin{equation}
  \label{vphysicalinsight}
  v = \avgb{v} + \tilde{v}
\end{equation}
where $\avgb{v}$ is the (slowly varying) ensemble average velocity, and
$\tilde{v}$ a rapidly fluctuating term with mean zero. The key thing
here is that, if we want the long-time behavior of our particle, the
relative \textit{magnitudes} of $\avgb{v}$ and $\tilde{v}$ don't
matter. In fact, the microscopic world is turbulent and extremely
violent. Living in the macroscopic world, we don't usually think about
such things, but the forces bombarding very small objects result in
$\tilde{v}$'s that are typically much larger than $\avgb{v}$'s.

%%%In any case, to get our description of $v$ (\ref{Langevin}), let's
%%%integrate over some time interval $\tau$:
%%%
%%%\begin{equation}
%%%  \label{tauint}
%%%  m\left[ v(t+\tau) - v(t)\right] = \int_t^{t+\tau}F(t')dt'
%%%\end{equation}
%%%
%%%where $t'$ is some dummy variable that disappears after the
%%%integration. We have to be a little careful in choosing $\tau$. A
%%%fuller description may be found in the references, but our physical insight was
%%%that there was a short (microscopic) time scale and a long
%%%time scale (macroscopic). $\tau$ must then be small on the macroscopic
%%%timescale for our description to work, but big enough on the
%%%microscopic time scale that we can use our physical insight equation
%%%(\ref{vphysicalinsight}). In practice, this is easy enough to do because the
%%%timescales are very far apart.
%%%
We can use the same sort of physical insight to the force acting on
the particle:

\begin{equation}
  \label{fphysicalinsight}
  F = \avgb{F} + \tilde{F} \equiv \avgb{F} + \eta
\end{equation}

We're almost done at this point, so take a quick look back at
(\ref{Langevin}) and (\ref{N2L}). We have the rapidly-varying part,
but we need to be a little more detailed in our treatment of the
slowly-varying part. We don't usually talk about force as
a function of velocity, but there's no reason not to. In fact,
%%%(\ref{tauint}) and (\ref{N2L}) make it quite clear that it's
(\ref{N2L}) makes it quite clear that it's
reasonable to do so.

If $\avgb{F}$ is the slowly-varying part of $F$, it must be a function
of the slowly-varying part of $v$, $\avgb{v}$. We know this because,
in equilibrium, if $\avgb{v}$ is zero, must find $\avgb{F}$ = 0. Being
Physicists, we immediately think to expand $\avgb{F(\avgb{v})}$ (for
the next equation, we'll use overbars to represent averages, because
$\avg{F}(\avg{v})$ looks much clearer than $\avgb{F(\avgb{v})}$) in a power series:

\begin{equation}
  \label{fmac}
  \avg{F}(\avg{v}) = \sum_{k=0}^\infty a_0 + a_1\avg{v} + a_2\avg{v}^2 + a_3\avg{v}^3 + ...
\end{equation}

If we assume that our system is unbiased (that is, that the constant
term in (\ref{fmac}) is zero), our first non-zero term is the linear
term. Renaming $a_1$ to be $-\zeta$ where the explicit minus sign
indicates that our environmental forces will tend to slow an object
down, we have our velocity-dependent drag force\footnote{Actually, the
derivation here is sweeping some things under the rug. Langevin's 1908
derivation just \textit{assumed} that one could model the average
force from the environment as a velocity-dependent drag. That's a
perfectly physical reasonable assumption on its own. More rigorously,
one can derive the generalized Langevin equation (GLE, see, for
example, \cite{TuckermanStatMechSim}), and from it
the Langevin equation used here.}:

\begin{equation}
  \label{vddrag}
  \avgb{F} = -\zeta \avgb{v}
\end{equation}
Plugging \ref{vddrag} into the right hand side of
\ref{fphysicalinsight}, and plugging the result into the right hand
side of \ref{N2L}, we get

\begin{equation*}
  m\dd{x}{t} = m\fd{v}{t} = F = \avgb{F} + \eta = -\zeta \avgb{v} + \eta
\end{equation*}
which, looking at the \nth{2} and \nth{5} parts, is the Langevin
equation that we wanted!

In the presence of an external force, this becomes

\begin{equation}
  m\fd{v}{t} = F_{ext} -\zeta v + \eta(t)
\end{equation}

and the slowly-varying part becomes

\begin{equation}
  m\fd{\avgb{v}}{t} = F_{ext} -\zeta \avgb{v}
\end{equation}
\section{Mean-square displacement}

%%The notation in clearer in this section if we use
%%$\avgb{x}$ to denote the average of $x$, rather than $\avgb{x}$.
As with the previous section, this follows \cite{ReifStatMech}
\S15.6.
So, after having derived the equation of motion for our
particle

\begin{equation*}
  m\fd{v}{t} = -\zeta v + \eta(t)
\end{equation*}
what sorts of quantities can we calculate? In absence of an external
force, it seems pretty clear that $\avgb{x} = 0$ in thermal
equilibrium, so
we'd better turn towards higher moments. The most commonly useful of
these is the mean-square displacement, $\avgb{x^2}$.

The key insight we'll need in order to find $\avgb{x^2}$ is that we
already know something about average values! In particular, the
equipartition theorem tells us that the kinetic energy,
$\frac{1}{2}mv^2$, ought to have average value $\frac{1}{2} kT$. If we
write $v$ as $\dot{x}$ and multiply both of those by two, and hope
that for our sanity mass does not fluctuate, we have

\begin{equation}
  \label{equipartition}
  m\avgb{\dot{x}^2} = kT
\end{equation}

If you haven't recently taken a probability/statistics class, two
reminders are in order. First, we need to be careful with averages, as
$\avgb{x}^2 \neq \avgb{x^2}$. Second, we often use the product rule to
do things like multiply both sides of

\begin{equation}
  m\fd{\dot{x}}{t} = -\zeta\dot{x} + \eta(t)
\end{equation}
by $x$ specifically so that we can get an equation involving
$\dot{x}^2$:

\begin{equation}
  \label{msd1}
  mx\fd{\dot{x}}{t}
  =
  m\left[ \fd{}{t}(x\dot{x}) - \dot{x}^2 \right]
  =
  -\zeta x\dot{x} + x\eta(t)
\end{equation}

We're now in a position to take the ensemble average of both sides of
this equation. OK, a third reminder: the ensemble average of the sum
of two quantities is the sum of their respective ensemble averages. If
two quantities are independent, the ensemble average of their product
is the product of their ensemble averages. In particular, looking at
the right hand side of our equation,

\begin{equation}
  \avgb{-\zeta x\dot{x} + x\eta(t)} = \avgb{-\zeta x\dot{x}} + \avgb{x\eta(t)}
  = -\zeta \avgb{x\dot{x}} + \avgb{x}\avgb{\eta(t)}
  = -\zeta \avgb{x\dot{x}}
\end{equation}

where the last equality comes from the fact that the expectation value
of our randomly fluctuating force is, by definition, zero. If we
rearrange (\ref{msd1}) as

\begin{equation}
  \label{msd2}
  m\fd{}{t}(x\dot{x})
  =
  m\dot{x}^2 -\zeta x\dot{x} + x\eta(t)
\end{equation}
we can take ensemble averages and use (\ref{equipartition}) to
write\footnote{OK, fine, a fourth thing to remember: you can commute
  the time derivative inside an ensemble average. To prove this to
  yourself, write the average out as an explicit sum and note that
  taking the derivative of the sum is just taking the sum of the
  derivatives of the individual terms.}

\begin{eqnarray}
  \avgb{m\fd{}{t}(x\dot{x})}
  &=&
  \avgb{m\dot{x}^2 -\zeta x\dot{x} + x\eta(t)} \\
  \nonumber
  m\fd{}{t}\avgb{x\dot{x}}
  &=&
  m\avgb{\dot{x}^2} -\zeta \avgb{x\dot{x}} \\
  \nonumber
  m\fd{}{t}\avgb{x\dot{x}}
  &=&
  kT -\zeta \avgb{x\dot{x}}\\
  \label{msd3}
  \fd{}{t}\avgb{x\dot{x}}
  &=&
  \frac{kT}{m} -\frac{\zeta}{m} \avgb{x\dot{x}}
\end{eqnarray}

That last line may look a little funny, but it's just an ODE in
$\avgb{x\dot{x}}$, which is something we surely know how to
solve:

\begin{equation}
  \label{msd4}
  \avgb{x\dot{x}} = Ce^{-\frac{\zeta}{m} t} + \frac{kT}{m}\frac{m}{\zeta}
  \equiv Ce^{-\frac{1}{\tau} t} + \frac{kT}{\zeta}
\end{equation}
where C is a constant of integration, and $\tau = \frac{m}{\zeta}$ is the
characteristic time. Before we plug in some initial conditions, note
that $\avgb{x\dot{x}}$ isn't a completely foreign quantity:

\begin{equation}
  \label{x2xxd}
  \frac{1}{2}\fd{\avgb{x^2}}{t} = \avgb{x\dot{x}}
\end{equation}
Now, as far as our initial conditions go, we want $\avgb{x^2}$ to be
the mean-square displacement of a particle, so it makes sense to set
$x(t=0) = 0$. Plugging that into (\ref{msd4}) gives

\begin{equation}
  0 = C + \frac{kT}{\zeta}
\end{equation}
so we know $C=-\frac{kT}{\zeta}$ and we can rewrite (\ref{msd4}) as
\begin{equation}
  \label{msd5}
  \avgb{x\dot{x}} = \frac{1}{2}\fd{\avgb{x^2}}{t} = \frac{kT}{\zeta}(1-e^{-\frac{1}{\tau} t})
\end{equation}
and we can finally get an equation for $\avgb{x^2}$ by integrating
once:

\begin{equation}
  \label{msdfull}
  \avgb{x^2} = \frac{2kT}{\zeta}\left[t-\tau(1-e^{-\frac{1}{\tau} t})\right]
\end{equation}

%%\begin{wrapfigure}{l}{6cm}
\begin{tikzpicture}[scale=2]
    \draw[very thin,color=gray] (-0.1,-0.1) grid (2.1,2.1);
    \draw[->] (-0.2,0) -- (2.2,0) node[right] {$t$};
    \draw[->] (0,-0.2) -- (0,2.2) node[left] {$\avgb{x^2}$};
    \draw[domain=0:2] plot (\x,{\x - 0.25*(1-exp(-4*\x))}) node[below right] {};
\end{tikzpicture}
%%\end{wrapfigure}

At short time scales, that looks parabolic, and is called
``ballistic'' diffusion. At long time scales, that looks linear, and
is called ``normal'' diffusion. If we plotted this on a loglog scale,
we would indeed see two linear regions with slopes 2 and 1
respectively.

We can see this explicitly. If $t < \tau$, we can expand

\begin{equation}
  e^{-\frac{1}{\tau} t} = 1 - \frac{1}{\tau} t + \frac{1}{2}\frac{1}{\tau^2}t^2 + ...
\end{equation}
and we make our ``short'' time scale explicit as $t \ll \tau$, where
we can truncate the series as above and (\ref{msdfull}) becomes

\begin{equation}
  \label{msdshort}
  \avgb{x^2} \approx
  \frac{2kT}{\zeta}\left[t-\tau(1- 1 + \frac{1}{\tau} t - \frac{1}{2}\frac{1}{\tau^2}t^2 \right]
  = kT\frac{1}{\tau\zeta} t^2 = \frac{kT}{m}t^2
\end{equation}
We can now see why this regime is called ``ballistic'': the particle
behaves as a free particle with constant velocity
$v=\sqrt{kT/m}$. Meanwhile, on long time scales $t \gg \tau$,
the exponential term in (\ref{msdfull}) tends towards zero, yielding

\begin{equation}
  \label{msdlong}
  \avgb{x^2} = \frac{2kT}{\zeta}\left[t-\tau \right]
  \approx \frac{2kT}{\zeta}t
\end{equation}
From your statistics classes, you should recognize this as the exact
same equation as a particle performing a random walk. Indeed, we
expect a random walker to diffuse with

\begin{equation}
  \avgb{x^2} = 2Dt
\end{equation}
in one dimension, so we've found an equation for our diffusion
constant,

\begin{equation}
  D = \frac{kT}{\zeta}
\end{equation}

The ``Stokes'' part of the picture involves classical
\textit{macroscopic} hydrodynamics showing that, for a sphere of
radius $a$ in a medium of viscosity $\eta$,

\begin{equation}
  \zeta  = 6\pi\eta a
\end{equation}
so we can write (\ref{msdlong}) as

\begin{equation}
  \avgb{x^2} = \frac{kT}{3\pi\eta a} t
\end{equation}
and we're finally ready to analyze some data! We take experimental
data, look at a plot of mean-square displacement vs. time, and extract
the diffusion constant from the slope. Knowing the viscosity of our
media and the temperature of the experiments then allows us to
determine Boltzmann's constant, all from watching grains of pollen
diffuse in water as Perrin did in his famous 1910 work.

\pagebreak
\section{Potential projects}
If this sort of thing strikes your fancy, you could certainly do an
independent project on related matters. Specific topics might include

\begin{itemize}
\item The generalized Langevin equation
\item Fluctuation-dissipation theorems
\item Fokker-Planck equations
\item Green-Kubo functions
\item Einstein's 1905 paper and Langevin's 1908 paper
\item Computer simulations of diffusion
\item Diffusion as a function of probability distributions
\end{itemize}

\section{Thanks}
 This lab is possible due to the
  generous support of Adam Hoppe at South Dakota State University.
\bibliographystyle{alpha}
\bibliography{diffusionbib}

\end{document}


\documentclass[11pt]{article}
\setlength{\parskip}{0.45\baselineskip}%
\setlength{\parindent}{0em}%

%sets margin width and header height
\usepackage[top = 3cm, left=3cm, right=3cm, headheight = 14pt]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsfonts}
% for clever lists item formatting
\usepackage{paralist}
%allows you to easily put properly formatted quotation marks on text.
\usepackage{dirtytalk}

%allows you to make a title page separately (i.e. not in main.tex)
\usepackage{subfiles}

%for includegraphics to work
\usepackage[pdftex]{graphicx}
\usepackage{microtype}
% used in the title
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\newcommand{\C}{\mathsf{C}}
\newcommand{\Obj}{\text{Obj}}
\newcommand{\Hom}[2]{\text{Hom}_{#1}(#2)}

\theoremstyle{definition}
\newtheorem{definition}{Definition}

\begin{document}

\subfile{title/title}
\section{History}
Category theory is a relatively new and still developing mathematical theory.
It was first introduced by mathematicians Samuel Eilenberg and Saunders Mac Lane in a paper titled \say{General Theory of Natural Equivalences} \cite{SamuelEilenberg1945Gton} and was a generalization and abstraction of the techniques and ideas they were employing in their research of topology.
The following is the definition of a category that Eilenberg and Mac Lane's originally gave which varies slightly from the commonly used definition today.

\begin{quote}
    A category $\mathsf{C}$ is an aggregate of abstract elements $A$ called the objects of the category, and abstract elements $\alpha$ are called mappings of the category. A pair of mappings $\alpha_1,\alpha_2$ determine uniquely a product mapping $\alpha_2\alpha_1$ that follows the axioms listed below:

    \begin{enumerate}[\bfseries {C}1.]

        \item The triple product $\alpha_3(\alpha_2\alpha_1)$ is defined if and only if $(\alpha_3\alpha_2)\alpha_1$ is defined. When either is defined, the associative law
        \[\alpha_3(\alpha_2\alpha_1) = (\alpha_3\alpha_2)\alpha_1\]
        is defined.

        \item The triple product $\alpha_3\alpha_2\alpha_1$ is defined whenever both products $\alpha_3\alpha_2$ and $\alpha_2\alpha_1$ are defined.
        \begin{definition}
        A mapping $e$ in $\C$ will be called an identity of $\C$ if and only if the existence of any product $e\alpha$ or $\beta e$ implies that $e\alpha = \alpha$ and $\beta e = \beta$
        \end{definition}

        \item For each mapping $\alpha \in \C$ there is at least one identity $e_1 \in \C$ such that $\alpha e_1$ is defined and at least one identity $e_2 \in \C$ such that $e_2 \alpha$ is defined.

        \item The mapping $e_A$ corresponding to each object $A$ is an identity.

        \item For each identity $e$ of $\C$ there is a unique object $A$ of $\C$ such that $e_A = e$.

    \end{enumerate}
\end{quote}

It is interesting to note that Eilenberg and Mac Lane make the remark that the objects can be omitted from the definition of a category due to the fact that there is a one-to-one correspondence between objects and their identities.
By considering the map that sends an object $A$ to the identity map $e_A$ one can consider the morphism $e_A$ as the object $A$.
However they forgo this option because it would detract from the utility of the definition; it is easier and more appealing to work with objects.

Eilenberg and Mac Lane's key observation, was that it was useful not only to look at an object under a single mapping to itself but it was useful to consider all possible mappings from an object to itself \cite{MarquisJean-Pierre2009FaGP}.
This abstraction is akin to what Felix Klein did when he studied geometry through the perspective of groups of transformations of a set and the invariant properties of that set under those transformations \cite{sep-geometry-19th}.
Eilenberg and Mac Lanes use the example of the the relation between a vector space $V$ over a field $F$ and the set of linear transformations from $V$ to $F$ called the \say{dual space} of $V$ and denoted $\mathcal{L}(V)$.
By considering pointwise addition and pointwise scalar multiplication for any two linear transformations in the dual space, $\mathcal{L}(V)$ is also a vector space. When $V$ is finite dimensional, there is a bijective function between $V$ and $\mathcal{L}(V)$ that preserves the structure of both vector spaces (i.e. they are isomorphic).
However as Eilenberg and Mac Lane point out, demonstrating that such an isomorphism exists requires a choice of basis for $V$.
With category theory, this natural correspondence between a finite dimensional vector space and their dual space can be demonstrated without the need for a choice of basis.

The definition of a category has changed slightly since Eilenberg and Mac Lane's first introduced it.
A more modern definition of a category taken from \cite{aluffi2009algebra} is as follows:

\begin{quote}
\begin{definition}
A category $\C$ is a class of \textit{objects} $\Obj(\C)$, and for every two objects $A$ and $B$ of $\Obj(\C)$ there is a set $\Hom{\C}{A,B}$ subject to the following rules:

\begin{enumerate}
    \item Identity morphism: For every object $A$ of $\C$ there is at least one morphism $1_A \in \Hom{\C}{A,A}$ called the identity on $A$.
    \item Composition of morphisms: If $f \in \Hom{\C}{A,B}$ and $g \in \Hom{\C}{A,B}$ then there is a morphism denoted $gf$ such that $gf \in \Hom{\C}{A,C}$
    \item Composition is associative: if $f \in \Hom{\C}{A,B}$, $g \in \Hom{\C}{B,C}$, $h \in \Hom{\C}{C,D}$ then $(hg)f = h(gf)$.
    \item The identity morphisms acts as an identity with respect to composition: for all $f \in \Hom{\C}{A,B}$, $f1_A =f$ and $1_Bf=f$
\end{enumerate}
\end{definition}

\end{quote}

The following are some examples of categories that arise in mathematics:

\begin{itemize}
    \item The category whose objects are sets and whose morphisms are usual functions.
    \item The category whose objects are topological spaces and whose morphisms are continuous functions.
    \item The category whose objects are vector spaces and whose morphisms are linear maps.
    \item The category whose objects are groups and whose morphisms are group homomorphisms.
\end{itemize}

In general though, morphisms of a category do not have to be structure preserving maps \cite{sep-category-theory}. In fact they do not have to be functions in a set-theoretic sense.
Aluffi \cite{aluffi2009algebra} gives an example of a category whose objects are integers and for any two integers $a$ and $b$, the morphism between them is the set containing the ordered pair $(a,b)$ if $a \leq b$ and is empty otherwise.
Composition of morphisms can then be defined in a way such that the axioms of morphisms are satisfied.
This shows that category theory is very general and that almost any mathematical construction can be looked at through the lens of a category.
As became evident to mathematicians, thinking about mathematics through category theory unifies certain common mathematical ideas.
%Pablo => about line 72, is that a conclusion of line 71? I do not follow the logic but i could be wrong. You may be on to something big though, it's just that I don't see it written. Perhaps this question helps: what did the authors do pointing out the structure and the map between parts of that structure, that previous authors had not done? Or why is it special in their case? Is it  an important pattern  of thinking that you see but not unique? (please clarify your intent here for a more compelling reading.

Notice that in the more modern definition of a category the word \textit{class} is used.
%PA: line #113 it says: "The objects of a category of cannot be a set ..." it should say: "The objects of a category cannot be a set..."
The objects of a category of cannot be a set because we would like to have a concept of a category of all sets whose morphisms are the usual set functions between two sets.
However, because of Russell's paradox one cannot talk about the set of all sets.
Eilenberg and Mac Lane never formally dealt with this foundational issue but they suggested that one could use type theory or extend the Fraenkel-von Neumann-Bernays axioms to formally define a class \cite{MarquisJean-Pierre2009FaGP}.
For them it was simply enough that this generalization of structure and mappings between structure was applicable in their mathematics and it yielded a fruitful paradigm for studying mathematical structures.
In the years that proceeded Eilenberg and Mac Lane's introduction of category theory to study mathematical structures, the theory was used to set foundations of algebraic topology and homological algebra.
Using category theory to study these fields made it easier to find proofs of several results \cite{sep-category-theory}.
The proofs in homological algebra were greatly facilitated by a technique called diagram chasing which is the use of commutative diagrams of morphisms to find equivalent compositions of morphisms.
Without these techniques, it is difficult even to imagine how those results might be proved.

It was not until the 1970's that mathematicians started seeing how useful category theory was to mathematics in general and they started studying category theory itself, especially the role of functors (structure-preserving maps between categories).
This led to an expansion of research in category theory not as a means to an end but as an end itself. \cite{sep-category-theory}

\section{Viability as a Mathematical Foundation}
There are some misgivings for using category theory as a foundation for mathematics. The most evident one is the dubious use of a collection of objects.
If the definition of a category requires the a definition of a collection of objects then how can category theory be taken as a primitive notion?
Marquis \cite{MarquisJean-Pierre2009FaGP} argues that one must distinguish between the epistemic and the logical, making a parallel to transformation groups and geometry.
One can first define an abstract transformation group and proceed to define a geometry from the abstraction even though epistemically, geometry precedes transformation groups.
It is more natural to conceive first of geometry, the study of space, than it is to conceive transformation groups which are an abstract algebraic construction.
In logic though this is often what is done with the study of theories and their models.

Efforts to axiomatize category theory have been undertaken and it was shown by Francis Lawvere that the category of sets can be axiomatized in such a way that the membership relation is not required.
That is, it is possible to axiomatize set theory purely in the language of category theory. \cite{PeruzziA.2006Tmoc}

There is also something to be said for category theory's applicability to other disciplines.
In the past 40 years it has been adopted by other scientific disciplines especially theoretical computer science as a tool to study semantics and logic of programming languages.
At the very least category theory is a rich and powerful paradigm for studying mathematics and a useful tool to use in other fields.
It has recently been used to study cognitive neural networks and to explore quantum field theory in physics \cite{sep-category-theory}.

\section{Relations to Philosophy}
With regards to mathematical structuralism, category theory provides some advantages over set theory as a basis for the foundation of math.%
%PA: line #150: it says "...of an object withing a structure..." it should say "...of an object within a structure..."
Because the core thesis of structuralism is that structures are the basis of mathematical theory and that it is only the position of an object withing a structure that matters, category theory seems to be a more natural way of thinking through the structuralist perspective.
An advantage to using category theory, which was alluded to earlier, is that it does not depend on what specific objects you are looking at.
For example, when you are discussing properties of functions between sets, in a category theoretical perspective, properties such as injectivity and surjectivity of functions are defined in terms of how those functions interact with other functions and not on what they do to specific elements of the sets \cite{PeruzziA.2006Tmoc}.
In this sense, category theory is more focused on the structure than how the functions are specified which is more appealing to the structuralist.

%talk about objections here
Opponents of the idea of using category theory as a foundation for mathematical structuralism argue that category theory is still based on notions from set theory \cite{sep-structuralism-mathematics}.
For example category theory takes the concepts of collections and functions as primitive notions and thus still depends on set theoretical concepts.
In fact even Eilenberg and Mac Lane argued that the axioms of category theory do not capture basic, intuitive truths but are synthetic and structural.

Evidently there is still some debate as to what status category theory has in the foundation of mathematics as well as in the philosophy of mathematics.
There are still applications to explore both inside of mathematics and in other scientific disciplines.
Category theory has found its way also into the philosophy of language and logic, and will continue to be a useful and insightful theory for the future.

\clearpage
\bibliography{biblio/phil567paper.bib}
\bibliographystyle{unsrt}

\end{document}


\newlecture{2}{Text}

\section{Polishing the plain text}
%
%\subsection{UTF-8 encoding}
%
%\begin{frame}[fragile]
%	\frametitle{Use UTF-8 encoding in \LaTeX}
%	UTF-8 encoding is widely used in modern computer applications, so it's useful to include the \structure{inputenc} package and use UTF-8 encoding.
%	\begin{command}
%		\LC{\usepackage[utf-8]{inputenc}}
%	\end{command}
%	\begin{example}
%		café
%	\end{example}
%	However, different operating systems and compiling engines have different support on UTF-8 encoding, some UTF-8 codes that work on your computer may not work on others (though rarely), so it is recommended to use commands (will be introduced later) instead of directly copy and paste the UTF-8 codes from the Internet.
%\end{frame}

\subsection{Special Characters and Accents}

\begin{frame}
	\frametitle{Special Characters}
	Some special symbols can't be directly used since they are reserved by \LaTeX:
	\begin{center}
	\begin{tabular}{llllll}
		\LC|\#| & \# \\
		\samplesymbol{\#}{\#} & \samplesymbol{\$}{\$} & \samplesymbol{\%}{\%} & \samplesymbol{\&}{\&} & \samplesymbol{\~{}}{\~{}} & \samplesymbol{\`{}}{\`{}} \\
		\samplesymbol{\{}{\{} & \samplesymbol{\}}{\}} & \samplesymbol{\_}{\_} &
		\multicolumn{2}{l}{\samplesymbol{textbackslash}{\textbackslash}}
	\end{tabular}
	\end{center}
	Many \LaTeX\ starters are confused with how to correctly print quotes, hyphens and dots.\\
	\`{} prints a left single quote, ' prints a right single quote.\\
	\`{}\`{} prints a left double quote, '' prints a right double quote.\\
	one hyphen (-) print like - \\
	two hyphens ({-}{-}) print like -- \\
	three hyphens ({-}{-}{-}) print like ---\\
	\samplecommand{dots} prints the dots with a correct format (\dots) instead of directly use three dots (...)
\end{frame}

\begin{frame}
	\frametitle{Accent on letters}
	Sometimes you may need an accent form of a letter, here is an example of letter \structure{o}
	\begin{center}
	\begin{tabular}{lllll}
		\sampleaccent{\`{}}{\`}{o} & \sampleaccent{'}{\'}{o} & \sampleaccent{\^{}}{\^}{o} & \sampleaccent{"}{\"}{o} & \sampleaccent{\~{}}{\~}{o} \\
		\sampleaccent{=}{\=}{o} & \sampleaccent{.}{\.}{o} & \sampleaccent{u}{\u}{o} & \sampleaccent{v}{\v}{o} & \sampleaccent{H}{\H}{o}\\
		\sampleaccent{t}{\t}{oo} & \sampleaccent{r}{\r}{o} & \sampleaccent{c}{\c}{o} & \sampleaccent{d}{\d}{o} & \sampleaccent{b}{\b}{o}
	\end{tabular}
	\end{center}
	\begin{block}{Something interesting}
		You may be curious about how to print words like \LaTeX, actually it's defined as a command.
		\begin{itemize}
			\item \samplecommand{TeX} - \TeX
			\item \samplecommand{LaTeX} - \LaTeX
			\item \samplecommand{LaTeXe} - \LaTeXe
		\end{itemize}
	\end{block}
\end{frame}

\begin{frame}
	\frametitle{Deal with unfamiliar symbols}
	Sometimes you may want to deal with symbols you have never seen. In this case, you may refer to \url{http://detexify.kirelabs.org/classify.html} to find out how to output the character.
\end{frame}

\subsection{Fonts}

\begin{frame}
	\frametitle{Basic commands about fonts}
	First, lets start with some commands that transform font types
	\begin{itemize}
		\item \sampletext{bf}{\bf}
		\item \sampletext{it}{\it}
		\item \sampletext{rm}{\rm}
		\item \sampletext{sc}{\sc}
		\item \sampletext{sf}{\sf}
		\item \sampletext{sl}{\sl}
		\item \sampletext{tt}{\tt}
	\end{itemize}
	Note that the commands that transform font types influence the text in the whole scope (\structure{\{...\}}) until another font type is specified. For example, how to use the first command \samplecommand{bf} is shown below\\[0.5em]
	\{\samplecommand{bf} Sample Text\}
\end{frame}

\begin{frame}[fragile]
	Sometimes we don't want to transform  all the font types, instead, we can only change the font type of some specified text.
	\begin{example}
		\begin{minted}{latex}
\textbf{Sample text}
		\end{minted}
	\end{example}
	There are more options for fonts.
	\begin{itemize}
		\item \sampletext{textit}{\textit}
		\item \sampletext{textsc}{\textsc}
	\end{itemize}
	However, in a math environment (will be introduced later), some other commands should be used
	\begin{itemize}
		\item \samplecommand{mathbf} - $\mathbf{Sample\ Text}$
		\item \samplecommand{mathit} - $\mathit{Sample\ Text}$
		\item \samplecommand{mathsf} - $\mathsf{Sample\ Text}$
	\end{itemize}
	Note that the math environment doesn't include all of the font types on the previous page. More information about font types can be found \href{http://www.cnblogs.com/make217/p/6123532.html}{\color{blue}\underline{here}}.
\end{frame}

\begin{frame}
	Font size can also be easily modified
	\begin{itemize}
		\item \sampletext{tiny}{\tiny}
		\item \sampletext{scriptsize}{\scriptsize}
		\item \sampletext{footnotesize}{\footnotesize}
		\item \sampletext{small}{\small}
		\item \sampletext{normalsize}{\normalsize}
		\item \sampletext{large}{\large}
		\item \sampletext{Large}{\Large}
		\item \sampletext{LARGE}{\LARGE}
		\item \sampletext{huge}{\huge}
		\item \sampletext{Huge}{\Huge}
	\end{itemize}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Build a colorful document}
	Changing the color is similar to changing font types. \medskip

	If you want to transform to a color (like transforming to bold with \LC{\bf}), you can use \LC{\color{name}}. \smallskip

	Similarly, you can use \LC{\textcolor{name}} like \LC{\textbf}.\smallskip

	The background color of the whole page can be set using \LC{\pagecolor{name}}.\medskip

	There are some defined color \structure{name} in the \structure{xcolor} package.\medskip

	\begin{tabular}{lllll}
	\samplecolorbox{black}&\samplecolorbox{gray}&\samplecolorbox{olive}&\samplecolorbox{teal}&\samplecolorbox{blue}\\
	\samplecolorbox{green}&\samplecolorbox{orange}&\samplecolorbox{violet}&\samplecolorbox{brown}&\samplecolorbox{lightgray}\\
	\samplecolorbox{pink}&\samplecolorbox{white}&\samplecolorbox{cyan}&\samplecolorbox{lime}&\samplecolorbox{purple}\\
	\samplecolorbox{yellow}&\samplecolorbox{darkgray}&\samplecolorbox{magenta}&\samplecolorbox{red}\\
	\end{tabular}
	\medskip

	You can find more information in the documentation of \structure{xcolor} (\alert{texdoc} \structure{xcolor})
\end{frame}

\subsection{Underline}

\begin{frame}[fragile]
	\frametitle{Ulem package}
	If you want to add some lines on the text, use the \structure{ulem} package.
	\begin{command}
		\begin{minted}{latex}
\usepackage{ulem}
\uline{Sample Text}
		\end{minted}
	\end{command}
	There are different kinds of lines supported:
	\begin{itemize}
		\item \sampletext{uline}{\uline}
		\item \sampletext{uuline}{\uuline}
		\item \sampletext{uwave}{\uwave}
		\item \sampletext{sout}{\sout}
		\item \sampletext{xout}{\xout}
		\item \sampletext{dashuline}{\dashuline}
		\item \sampletext{dotuline}{\dotuline}
	\end{itemize}
\end{frame}

\section{Typesetting}

\subsection{Enumeration}
\begin{frame}[fragile]
	\frametitle{Enumerate}
	When you need to enumerate some items as a list, you may use the \structure{enumerate} package.
	\begin{command}
		\begin{minted}{latex}
\usepackage{enumerate}
\begin{enumerate}[style]
\item % ...
\item % ...
\item % ...
\end{enumerate}
		\end{minted}
	\end{command}
	This will generate a normal list with the serial numbers in the specified \structure{style}, which could be the following (as example)
	\begin{itemize}
		\item \alert{1} - 1, 2, 3, 4, ...
		\item \alert{(i)} - (i), (ii), (iii), (iv), ...
		\item \alert{[1.]} - [1.], [2.], [3.], [4.], ...
	\end{itemize}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Itemize}
	If you want to generate an unordered list, use \structure{itemize} instead of \structure{enumerate}.
	\begin{command}
		\begin{minted}{latex}
\usepackage{enumerate}
\begin{itemize}
\item[style] % ...
\item[style] % ...
\item[style] % ...
\end{itemize}
		\end{minted}
	\end{command}
	In this case, \structure{style} must be added after each item, which is different from that in \structure{enumerate}, and the symbol displayed in the beginning of each item will be exactly same as the \structure{style}. If \structure{style} is not added, a default style will be used.
\end{frame}

\subsection{Alignment}

\begin{frame}[fragile]
	\frametitle{Alignment}
	If you want to align a paragraph of text, use these three environments for left/center/right align.
	\begin{command}
			\begin{minted}{latex}
\begin{flushleft/center/flushright}
% ...
\end{flushleft/center/flushright}
			\end{minted}
	\end{command}
	However, if only a single line needs to be aligned, use these three commands.
	\begin{command}
		\begin{minted}{latex}
\leftline{text}
\centerline{text}
\rightline{text}
		\end{minted}
	\end{command}
\end{frame}

\subsection{Spaces, lines and pages}

\begin{frame}
	\frametitle{Spaces may be confusing}
	There are defined command of spaces in different width and usages.
	\begin{itemize}
		\item \colorbox{yellow}{\ } - the basic space in \LaTeX\ (printed in yellow since it's transparent). Note that any number of spaces or tabs is equal to one space, and the space after a command is ignored. If you want to add an extra space, use \alert{\textbackslash}\colorbox{yellow}{\ } which makes a 1/3\,em space (1 em is approximately the width of an \structure{M} in the current font)
		\item \~{} - If two words can't be separated on two lines, you can tell \LaTeX\ about it using a tie (\~{}), such as Prof.\~{}Hamade (Prof.~Hamade).
		\item  \samplecommand{,} - makes a 1/6\,em space, commonly used before units (notice the space before em on this page)
		\item  \samplecommand{;} - makes a 2/7\,em space
		\item  \samplecommand{quad} - makes a 1\,em space
		\item  \samplecommand{qquad} - makes a 2\,em space
		\item  \samplecommand{phantom}\{\structure{text}\} - makes actually the space of \structure{text}, but \structure{text} will be invisible.
	\end{itemize}
\end{frame}

\begin{frame}
	\frametitle{Separate contents into lines and pages}
	Here are some basic commands about lines and pages in \LaTeX,  you will use them everywhere.
	\begin{itemize}
		\item \samplecommand{newline} - begin a new line
		\item \alert{\textbackslash\textbackslash} - begin a new line (not recommended\footnotemark[1])
		\item \samplecommand{par} - begin a new paragraph (a new line with indent)
		\item \alert{\textbackslash\textbackslash [}\structure{offset}\alert{]} - begin a new line with an vertical offset, \structure{offset} is the size of needed space  (not recommended, using  \LC{\vspace} instead.)
		%\item \samplecommand{linebreak} - begin a new line with the words discrete
		\item \samplecommand{newpage} - begin a new page
		\item \alert{\%} - begin a line comment
	\end{itemize}
	\footnotetext[1]{According to Manuel Charlemagne, \alert{\textbackslash\textbackslash} should only be used for a force break (where \samplecommand{newline} doesn't work).}
\end{frame}

\begin{frame}[fragile]
	\frametitle{Spacing}
	When trying to separate two paragraphs by a certain space, many new learners of \LaTeX\ may use multiple empty lines and linebreaks, which is a very dirty fix and is not so accurate. Actually, \LaTeX\ provides a precise spacing mechanism.
	\begin{command}
		\LC{\vspace{space}}\\
		\LC{\vspace*{space}}
	\end{command}
	When trying to show the next paragraph or sentence precisely at the bottom of the current page, we can use
	\begin{command}
		\LC{\vfill}
	\end{command}
	between the contents of two paragraphs to separate them.
\end{frame}

\begin{frame}[fragile]
	\frametitle{Predefined skipping}

	More often\footnotemark[1], we don't need to think about the skipping space, we can use the predefined skipping commands to achieve a small, medium or big skip. They are actually particular cases of \LC{\vspace}

	\begin{command}
		\LC{\smallskip}\smallskip

		\LC{\medskip}\medskip

		\LC{\bigskip}\bigskip
	\end{command}

	You may note that the effects are these skipping commands have been already shown above.
	\footnotetext[1]{According to Manuel Charlemagne, you should always use these skipping commands if possible instead of using \alert{\textbackslash\textbackslash} (as in many online tutorials).}
\end{frame}

\begin{frame}
	\frametitle{Spacing units}
	The \structure{space} can be anything representing a size, such as \structure{1cm}, \structure{2em} and \structure{10pt}. In \LaTeX, spacing units can be
	\begin{itemize}
		\item \structure{cm}
		\item \structure{mm}
		\item \structure{in} - inch, 1 inch = 2.54 cm
		\item \structure{pt} - 72 pt = 1 inch, the smallest unit in \LaTeX
		\item \structure{em} - 1em equals to the width of letter M
		\item \structure{ex} - 1ex equals to the width of letter x
		\item \LC{\linewidth} - the width of current line in the container
		\item \LC{\pagewidth} - the width of the page
		\item \LC{\pageheight} - the height of the page
		\item \LC{\textwidth} - the normal width of text on the page
		\item \LC{\textheight} - the normal height of text on the page
	\end{itemize}
\end{frame}

\subsection{Minipage and Multicolumn}

\begin{frame}[fragile]
	\frametitle{Minipage}
	\structure{minipage} is a very useful environment for dividing pages into a grid.
	\begin{example}
		\begin{multicols}{2}
			\inputminted[xleftmargin=1.5em]{latex}{../examples/minipage.tex}
		\end{multicols}
	\end{example}
\end{frame}

\begin{frame}
	The code above generate six minipages in a grid of 3 columns $\times$ 2 rows. Don't try to add up the width of minipages in a line for more than about \LC{0.98\linewidth} (since a minipage have a small margin on each side), or the last minipage may be on a new line. \\[0.5em]
	For each minipage, it can be seem as an independent \LaTeX\ document, where text, formulas, graphics, tables and etc. can be inserted, and most importantly, they won't affect each other. What's more, you can even use minipages in a minipage to form a multi-level nesting. \\
\end{frame}

\begin{frame}[fragile]
	\frametitle{The multicol package}
	When typesetting contents with small line width and many lines (for example, source code), the \structure{multicol} package is recommended.
	\begin{command}
		\begin{minted}{latex}
\usepackage{multicol}
\begin{multicols}{cols}
    % contents on column one
    \breakcolumn % break the current column here
    % contents on column two
\end{multicols}
		\end{minted}
	\end{command}
	Here \structure{cols} is the number of columns, it must be specified. If \LC{\breakcolumn} is not used, the \structure{multicol} package will automatically balance the length of each column.
\end{frame}

\section{Learn more - multi languages and scope in \LaTeX}

\subsection{Multiple Languages}

\begin{frame}[fragile]
	\frametitle{Spelling languages}
	If you want to use a spelling language with characters similar to English, package \structure{babel} can be used (exactly the same name as \href{http://babeljs.io/}{babel}).
	\begin{command}
		\LC{\usepackage[languages]{babel}}
		\footnotesize
		\begin{itemize}
			\item \structure{languages} - a list of languages, the last one to be the default language
		\end{itemize}
	\end{command}
	\begin{example}
		\LC{\usepackage[greek,english]{babel}} \\
		\LC{\textgreek{abcdefgABCDEFG}}
	\end{example}
	Then \LaTeX\ will print \textgreek{abcdefgABCDEFG} \\
	Of course, you can use some simple commands to print these greek letters directly, such as \LC{\alpha}, \LC{\beta} and etc, which is more convenient only when few of them are needed.
\end{frame}

\begin{frame}[fragile]
	\frametitle{Chinese}
	The Chinese TeX Community maintains a package called \structure{ctex} for inputing Chinese in \LaTeX. Note that it is only a package, which is shipped with most modern \TeX\ Suites, not the \structure{CTEX} Suite. I don't think it's a good choice to use the \structure{CTEX} Suite directly.
	\begin{command}
		\LC{\usepackage{ctex}}
	\end{command}
	The default \LaTeX\ compiler \structure{pdflatex} doesn't have support on Chinese input with \structure{ctex} package, \structure{xelatex} is a recommended modern \LaTeX\ compiler as a replacement. \\

	However, the \structure{ctex} package is too heavy and it can slow down the total compilation speed seriously.
\end{frame}

\subsection{Scope}

\begin{frame}[fragile]
	\frametitle{Usage of scope in \LaTeX}
	First, you should realize the meaning of ``scope'' in programming. Let's start with a simple example in C/C++ (assuming you know that):
	\inputminted{c++}{../examples/scope.cpp}
\end{frame}

\begin{frame}[fragile]
	In the example of C/C++, we use brackets \structure{\{\}} to define a scope, which is just the same in \LaTeX. In addition, notice that an environment or a command also defines a scope.

	\begin{example}
	\begin{multicols}{2}
		\inputminted{latex}{../examples/scope.tex}
		\columnbreak
		\input{../examples/scope.tex}
	\end{multicols}
	\end{example}

	With the usage of scopes, you can flexibly change the color, font or anything else you wish in a self-defined range of the document.

\end{frame}


%% Digital Systems
%% Continuous System Equivalence
\def\FileDate{10/01/21}
\def\FileVersion{1.0}
% ----------------------------------------------------------------
% Notes pages *********************************************************
% ----------------------------------------------------------------

\begin{slide}
	\heading{Purpose of this Lecture}
	To describe the basic tools for the design of a control system to be implemented using a computer or microcomputer.

	\textbf{Contents}
	\begin{itemize}
		\item Typical architecture
		\item Relationship between $s$ and $z$
		\item Continuous design followed by Discretization
		\item Direct digital design
	\end{itemize}
\end{slide}

\section*{Typical Architecture of a Digital Control System}

\begin{slide}
	\heading{Typical Architecture}
	\begin{center}
	\resizebox{300pt}{!}{\includegraphics{pictures/digicon.pdf}}
\end{center}
\end{slide}

\section*{Relationship between $s$ and $z$}

We have already seen (SLIDE~2, lecture 12) that
\ifslidesonly
\begin{slide}
\heading{Relationship between $s$ and $z$}
We have already seen (see last lecture) that
\input{chunk01}
\end{slide}
\fi
\input{chunk01}

We can use Equation~\ref{eq:l12e1a} to define a mapping between the $s$ and $z$ planes as summarised in SLIDES~\ref{slide:l12s2} and \sref{slide:l12s3}.
\begin{slide}\label{slide:l12s2}
  \heading{Mapping between between $s$ and $z$}
  Since $z=e^{sT}$ we can define a `mapping' from the $s$-plane to the $z$-plane. Various properties of the $z$-plane follow.
\begin{itemize}
  \item s-plane stability boundary $s=j\omega$ maps to the unit circle $|z|=1$ in the z-plane.
  \item Maximum frequency is half the sampling frequency $\omega_s/2$ (a consequence of Nyquist's sampling theorem) and is mapped to the negative real axis in the z-plane.
\end{itemize}
For proofs, see the problems in the self-directed learning exercises.
\end{slide}

\begin{slide}\label{slide:l12s3}
  \heading{Stability in the z-plane}
\begin{itemize}
  \item Because the stability boundary is a unit circle, Routh-Hurwitz and Nyquist stability tests no longer work.
  \item The Jury test is a similar test to the Routh-Hurwitz test but it is more involved.
  \item The design curves for constant natural frequency $\omega_n$, damping ratio $\zeta$, $\sigma_d$ and $\omega_d$ are also distorted by the mapping.
  \item Use the Matlab function \emph{zgrid} to see the mapping.
\end{itemize}
\end{slide}

\begin{slide}\label{slide:l12s4}
  \heading{z-plane Design Curves}
  \begin{center}
    \scalebox{0.3}{\includegraphics{pictures/zgrid.png}}
  \end{center}
\end{slide}

\section*{Continuous Design}

Assumption -- we have designed a compensator using root-locus or frequency response and now need to implement it with digital hardware, e.g. a digital micro-controller or digital signal processor (DSP).

We will recall the Discretization methods discussed in the last lecture, give a comparison of their frequency response behaviour and the applicability of the continuous design approach. We conclude with an example.

\subsection*{Discretization Procedure}

The idea is that given a continuous compensator transfer function $D(s)$ we need to find the best equivalent $D(z)$. As illustrated in \sref{slides:l12s6}, there is no exact solution since the whole time history is available to $D(s)$ whereas only samples are available to $D(z)$ so different discretization approximation methods make different assumptions about what happens to $e(t)$ between sampling instants.

\begin{slide}\label{slides:l12s6}
	\heading{Discretization Procedure}
	Given a continuous $D(s)$ find best equivalent $D(z)$.
	\begin{center}
		\resizebox{200pt}{!}{\includegraphics{pictures/digitization.pdf}}
	\end{center}
\end{slide}

\begin{slide}
	\heading{Discretization with Matlab}
	Take a transfer function (here $D(s)=p/(s+p)$) and return an equivalent $D(z)$
\begin{verbatim}
p = 5; % rad/s
ds = tf([p], [1 p])
Fs = (20*p)/(2*pi); % Hz
Ts = 1/Fs;
dz = c2d(ds, Ts, method)
step(ds,'-',dz,'--')
\end{verbatim}
\end{slide}

\begin{slide}
	\heading{Summary of Discretization Methods}
	See Lecture 11 for mathematical derivations.
	\begin{center}
		\begin{tabular}{|l|l|l|}
			\hline
			\textbf{Method} & \textbf{Transform} & \textbf{c2d method} \\
			\hline
			Zero-order hold & $(1-z^{-1})\mathcal{Z}(D(s)/s)$ & \verb|'zoh'| \\
			\hline
			Tustin (bilinear transform) & $s = (2/T)(1-z^{-1})/(1+z^{-1})$ & \verb|'tustin'| \\
			\hline
			Matched pole-zero & map poles/zeros using $z=e^{sT}$ & \verb|'matched'| \\
			\hline
			First-order hold & See Matlab documentation & \verb|'foh'| \\
			\hline
			Impulse-invariant & See Matlab documentation & \verb|'imp'| \\
			\hline
			Tustin with pre-warp & See Matlab documentation & \verb|'prewarp'| \\
			\hline
		\end{tabular}
	\end{center}
\end{slide}

\subsection*{Comparison of approximations}

\ifslidesonly
\begin{slide}
\heading{Comparison of approximations}
Run script \emph{comparison.m} that you will find on Blackboard.
\end{slide}
\fi
Run script \emph{comparison.m} that you will find on Blackboard.
You should note that the approximations are good for frequencies below about $\omega_s/4$.
If $\omega_s$ is sufficiently high, then break frequencies are accurately reproduced.
MPZ and Tustin show a notch at $\omega_s/2$ because of the zero term at $1+z^{-1}$.
Apart from the large difference at $\omega_s/2$, which is typically outside the
working frequency, all methods have similar performance. Since MPZ is easier to
calculate by hand, it is often to be preferred. However, if you have access to
Matlab and the control system toolbox function \emph{c2d}, there is no need to
use anything other than ZOH (which is the default) or the Tustin method.

\ifslidesonly
\begin{slide}
\heading{Plan for the live session}
In the session we will:
\begin{itemize}
\item design a continous compensator for a plant and discretize it by MPZ method
\item see how the digital compensator would be implemented
\item discuss the limitations of "continuous design"
\item redesign the compensator using a digital-design approach.
\end{itemize}
\end{slide}
\fi

\begin{slide}
	\heading{Design Example}\label{slides:ex1-1}
	\resizebox{300pt}{!}{\includegraphics{pictures/ex1-1.pdf}}
\end{slide}

\subsection*{Design Example}

Let us consider the lead compensation of the double integrator system shown in \sref{slides:ex1-1}. Let us further assume that we want to have the dominant closed-loop poles with ideal damping $\zeta=1/\sqrt{2}$ and natural frequency $\omega_n = 2\sqrt{2}$ rad/s. Furthermore, let us assume that the zero will be placed at $s=-1$ so that the compensator $D(s) = K(s+1)/(s+p)$. The root-locus design parameters will then be obtained from the pole-zero map shown in \sref{slides:ex1-2}.

$$\theta_z = \tan^{-1} 2/1 = 116.57^\circ$$

\begin{eqnarray*}
	-\theta_p + 116.57 -270 & = & -180 \\
	-\theta_p & = & -180 - 153.43 \\
	\theta_p & = & 26.57^\circ
\end{eqnarray*}

\begin{eqnarray*}
	-\tan 26.57 & = & \frac{2}{x} \\
	x & = & 2/\tan 26.57 = 4 \\
	p & = & -6
\end{eqnarray*}

\begin{slide}\label{slides:ex1-2}
	\heading{Root Locus Design Parameters}
	\resizebox{300pt}{!}{\includegraphics{pictures/ex1-2.pdf}}
\end{slide}

To calculate the gain, we need to know that $l_1=2\sqrt{2}$, $l_2=\sqrt{5}$, $l_3=\sqrt{20}$.

$$K = \frac{(2\sqrt{2})^2\times \sqrt{20}}{\sqrt{5}} = \frac{8\times 2\sqrt{5}}{\sqrt{5}} = 16.$$

$$D(s) = \frac{16(s+1)}{(s+6)}.$$

To convert to $D(z)$ let the sampling frequency $\omega_s=20\times \omega_n = 40\sqrt{2}=56.67$ rad/s. Thus $f_s=\omega_s/2\pi = 9$~Hz so sampling period $T = 1/f_s \approx 0.1$~s.

Let's pretend that we are solving this problem in a context where we only have a calculator so we'll use matched-pole zero.

$$D(z)=k\frac{1-e^{-aT}z^{-1}}{1-e^{-bT}z^{-1}}$$

where $k$ is determined by matching the DC gain of the two compensators. For the continuous compensator $D(s)|_{s=0} = 16/6$. For the digital compensator $D(z)|_{z=1} = k(1-e^{-aT})/(1-e^{-bT})$, so

$$k=\frac{16}{6}\times\frac{1-e^{-bT}}{1-e^{-aT}}$$

For our design, $T=0.1$, $a=1$ and $b=6$ so
\begin{eqnarray*}
	k & = & \frac{16}{6}\times\frac{1-e^{-0.6}}{1-e^{-0.1}} \\
	&= & \frac{16}{6}\times\frac{1-0.5488}{1-0.9048} = \frac{16}{6}\times\frac{0.4512}{0.0952}  \\
	k & = & 12.64
\end{eqnarray*}

So $$D(z) = \frac{12.64(1-0.9048z^{-1})}{(1-0.5488z^{-1})}$$

\ifslidesonly
\begin{slide}
\heading{Implementation of design}
\input{chunk02}
\end{slide}
\fi
\input{chunk02}

\ifslidesonly
\begin{slide}
\heading{Implementation of design - pseudocode}
\input{chunk03}
\end{slide}
\fi
\input{chunk03}

\ifslidesonly
\begin{slide}
\heading{Limitations of Continuous Design Approach}
\begin{itemize}
\item Limitations on sampling rate
\item Lag effect of ZOH at low-sampling rates
\end{itemize}
See notes for more detail.
\end{slide}
\fi
\subsection*{Limits of Continuous Design Approach}

If an exact discrete analysis or a simulation of a system were performed and
discretization determined for a large range of sampling rates the digitised
system would be unstable for rates slower than approximately $5\omega_n$
(where $\omega_n$ is the natural frequency of the system dominant poles)
and damping would be degraded for rates slower than $10\omega_n$.
At sampling rates higher than $20\omega_n$ (or $20\times \omega_{BW}$ for
more complex systems) then all methods yield reasonable results and can be used
with confidence at rates of $30\times \omega_{BW}$ or higher.

Errors come about because the approximations ignore the phase lag effect of the
zero-order-hold (ZOH). The ZOH can be approximated by $$G_{zoh}(s)\approx
\frac{2/T}{s+(2/T)}$$ which is based on the idea that, on average, the ZOH delays
the signal by about $T/2$ seconds and this transfer function is a first-order
lag with time constant $T/2$ and DC gain of 1. If this was added to the plant
transfer function then a more accurate model of the delayed plant wiould be
obtained and a more stable design for $D(s)$.

However, the advantage of continuous design is that $T$ is not chosen until
after $D(s)$ is designed and the appearance of $T$ so early invalidates this
assumption.

\ifslidesonly
\begin{slide}
\heading{Direct Digital Design}
\begin{itemize}
\item Used when limitations on sampling would be breached.
\item Stability boundary is unit circle which adds complications not present for
continous time systems
\item Additional complexity added because of distorting effect of the mapping $z=e^{sT}$
\end{itemize}
We will illustrate with an example.
\end{slide}
\fi
\section*{Direct Digital Design}

Direct digital design may be used if the zero-order hold is to be taken into
account or if the sample time is somehow constrained. The discrete transfer
function for the plant, hold and compensator are used throughout and the root
locus method\footnote{Frequency response methods can be used, but are complicated
by the fact that the stability boundary is the unit circle. We leave the methods,
which are well covered in Franklin, Powell and Workman, as a topic for further
research.} is used in the $z$-domain.

In this presentation, we will consider how the plant is digitized and how the
compensator can be designed using the root locus technique in the $z$-domain.

\subsection*{Analysis Tools}

\begin{slide}\label{slides:l12s11}
	\heading{Assumed architecture}
	\resizebox{300pt}{!}{\includegraphics{pictures/digisys.pdf}}
\end{slide}

\begin{slide}\label{slides:l12s12}
	\heading{Discrete equivalent}
	\resizebox{300pt}{!}{\includegraphics{pictures/digequiv.pdf}}
\end{slide}

The zero-order hold (ZOH) precisely defines what happens to the continuous system between samples for there is a unique solution for the combination of the transfer functions of the ZOH and G(s). The transfer function for ZOH  (see Lecture 11) is $(1-e^{-sT})/s$ so for hold followed by plant we can use the mathematical development show in \sref{slides:l12s13} to determine $G(z)$. As we showed in Lecture 11 (see SLIDE~4), the $1/s$ term is present because the output of ZOH is a piecewise constant function of time, and $1-z^{-1}$ represents a step followed by a negative step delayed by one sample period.

\begin{slide}\label{slides:l12s13}
	\heading{Hold Plus Plant}

	\begin{eqnarray*}
		\left(\frac{1-e^{-sT}}{s}\right)G(s) & = & (1-e^{-sT})\frac{G(s)}{s} \\
		\mathcal{Z}\left\{(1-e^{-sT})\frac{G(s)}{s}\right\} & = & \mathcal{Z}\{1-e^{-sT}\}\mathcal{Z}\left\{\frac{G(s)}{s}\right\} \\
		G(z) & = & (1-z^{-1}) \mathcal{Z}\left\{\frac{G(s)}{s}\right\}
	\end{eqnarray*}
\end{slide}

For the discrete equivalent system of \sref{slides:l12s12}

$$\frac{C(z)}{D(z)} = \frac{DG(z)}{1+DG(z)}$$ and the closed-loop characteristic equation (CLCE) is $$1+DG(z)=0.$$ The root-locus plotting rules still apply but the interpretation is different.

\subsubsection*{Example}

$$G(s)=\frac{a}{s+a}$$

\begin{eqnarray*}
	G(z) & = & (1-z^{-1})\mathcal{Z}\left\{\frac{a}{s(s+a)}\right\} \\
	     & = & (1-z^{-1})\mathcal{Z}\left\{\frac{1}{s}-\frac{1}{s+a}\right\} \\
	     & = & (1-z^{-1})\left\{\frac{z}{z-1}-\frac{z}{z+e^{-aT}}\right\} \\
		 & = & \left(\frac{z-1}{z}\right)\left\{\frac{z(z-e^{-aT})-z(z-1)}{(z-1)(z+e^{-aT})}\right\} \\
\end{eqnarray*}
$$G(z) = \frac{1-e^{-aT}}{z-e^{-aT}}.$$
So $G(z)=(1-\alpha)/(z-\alpha)$ where $\alpha=e^{-aT}$. The implications of this result is assessed in SLIDES~\ref{slides:l12s14} and \ref{slides:l12s15}.
\begin{slide}\label{slides:l12s14}
	\heading{Root locus of plant $G(s)=a/(s+a)$}
	\begin{center}
		\resizebox{220pt}{!}{\includegraphics{pictures/slocus.pdf}}
	\end{center}
	This is stable for all open-loop gain $K$.
\end{slide}
\begin{slide}\label{slides:l12s15}
	\heading{Root locus of hold-equivalent plant $G(z)=(1-\alpha)/(z+\alpha)$}
	\begin{center}
		\resizebox{200pt}{!}{\includegraphics{pictures/zlocus.pdf}}
	\end{center}
	This is unstable for some gain $K$ because of the time delay introduced by ZOH.
\end{slide}

\begin{slide}\label{slides:l12s16}
	\heading{Discrete Three Term Compensators}
	\begin{tabular}{|l|l|l|}
	\hline
	\textbf{Type} & \textbf{Implementation} & \textbf{Transfer function} \\
	\hline
	Proportional & $u(n) = K_Pe(n)$ & $D(z)=K_P$ \\
	\hline
	Derivative & $u(n) = K_D(e(n)-e(n-1)$ & $D(z)=K_D(1-z^{-1})$ \\
	\hline
	Integral & $u(n) = u(n-1) + K_Ie(n)$ & $D(z)=K_I/(1-z^{-1})$\\
	\hline
	\end{tabular}
\end{slide}

Of course, these can be combined to give P+D and PID. There are also equivalents of lead, lag and lead-lag.

\subsection*{Design example repeated}

\begin{slide}\label{slides:l12s17}
	\heading{Example: Double-integrator plant again}
	$$G(s)=\frac{1}{s^2}$$
	Hold equivalent is
	$$G(z)=\frac{T^2}{2}\frac{(z+1)}{(z-1)^2}$$
	Let $T = 0.1$ seconds then
	$$G(z)=\frac{1}{200}\frac{(z+1)}{(z-1)^2}$$
\end{slide}

\begin{slide}\label{slides:l12s18}
	\heading{Root locus}
	\begin{center}
		\resizebox{200pt}{!}{\includegraphics{pictures/zdi.pdf}}
	\end{center}
	Note, root-locus is outside unit circle so system is unstable for all $K_P$.
\end{slide}

We introduce proportional plus derivative compensation to bring the root locus inside the unit circle. Thus, from the table in \sref{slides:l12s16} $$U(z)=K_PE(z)+K_D(1-z^{-1})E(z)$$ Hence
\begin{eqnarray*}
	D(z) = \frac{U(z)}{E(z)} & = & K_P + K_D - K_D z^{-1} \\
	& = & \frac{(K_P+K_D)z - K_D}{z} \\
	& = & (K_P+K_D)\left(\frac{z-(K_D/(K_P+K_D))}{z}\right) \\
	& = & K_c\left(\frac{z-\gamma}{z}\right)
\end{eqnarray*}
We note that $$DG(z)=\frac{K_c}{200}\left(\frac{z-\gamma}{z}\right)\frac{(z+1)}{(z-1)^2}$$ and hence the root-locus gain $K_o=K_c/200$. The compensator adds a pole at $z=0$ and a zero at $z=\gamma$.

As before, we would like the system to have ideal damping and a natural frequency of $2\sqrt{2}$. But as we are now working in the $z$-plane, we also need to map the desired closed-loop poles by the mapping $s=e^{sT}$.

Since $s=-2\pm j2$ and $z=e^{sT}$ then $z=e^{-2T}e^{\pm j2T} = e^{-0.2}(\cos0.2\pm j\sin0.2) = 0.8024\pm j0.1627$. Given this location for the desired closed-loop dominant poles, it is a matter of trigonometry to determine that $\gamma=0.8532$ and the root locus gain $K_o=0.0465$. Now since $K_c=200 K_o = 9.31$ it is easy to show that $K_D=7.9367$ and $K_P=1.3703.$ The proof is left as an exercise.

%----------------------------------------------------------------
% The end of notes
% ----------------------------------------------------------------
\endinput

% Local Variables:
% TeX-master: "lecture03"
% End:


\documentclass{sig-alternate-05-2015}

\usepackage{svg}
\usepackage{pstricks}
\begin{document}

\title{Backtracking Sudoku}
\newcommand{\sep}{\vspace{1cm}}

\numberofauthors{1} %  in this sample file, there are a *total*
% of EIGHT authors. SIX appear on the 'first-page' (for formatting
% reasons) and the remaining two appear in the \additionalauthors section.
%
\author{
\alignauthor
Joshua Rahm\\
       \affaddr{University of Colorado}\\
       \email{joshua.rahm@colorado.edu}
}
\date{\today}
% Just remember to make sure that the TOTAL number of authors
% is the number that will appear on the first page PLUS the
% number that will appear in the \additionalauthors section.

\newcommand\citationneeded{${}^{\text{<citation\_needed>}}$}

\maketitle
\begin{abstract}
    This paper analyzes the runtime and the semantics of
    a backtracking Sudoku solver. To better undestand
    and analyze this algorithm, I have implemented
    a version of the backtracking sudoku solver in
    Haskell. This will be the base implementation from
    which the analysis will stem from.
\end{abstract}

\section{Introduction}

Sudoku is a very popular class of logic puzzles where the goal of the player is
to place numbers in cells in a grid adhering to certain constraints. The puzzle
consists of a grid, partially filled with numbers.  The grid is sized to be
$n^2\times n^2$ where $n$ is an integer. The grid is then divided up into $n$
$n\times n$ sub grids, as well as $n^2$ rows and columns. The goal of the
puzzle is to place numbers such that each row, column and sub-grid has every
number on the interval $[1, n^2]$.

For example, following is a valid solution for $n=3$ ($9\times 9$ grid)

\begin{figure}
    \begin{center}
        \sep
        \def\arraystretch{1.5}
        \begin{tabular}{| c c c | c c c | c c c |}
            \hline
            3&7&6&1&4&2&9&5&8 \\
            5&8&4&6&7&9&2&1&3 \\
            9&1&2&8&3&5&4&7&6 \\
            \hline
            6&9&1&2&5&4&3&8&7 \\
            8&4&5&3&6&7&1&9&2 \\
            2&3&7&9&1&8&5&6&4 \\
            \hline
            4&6&9&5&8&3&7&2&1 \\
            7&2&8&4&9&1&6&3&5 \\
            1&5&3&7&2&6&8&4&9 \\
            \hline
        \end{tabular}
        \sep
    \end{center}

    \caption{Example Complete Sudoku Board}
    \label{fig:example}
\end{figure}

As you can see in the example above, all boxes, rows and columns contain all
the numbers from 1 to 9.

\section{Algorithm}

The backtracking algorithm I implemented is fairly simple in concept. Sudoku is
a game where each row, column and block have a set of numbers from 1 to $n^2$
associated with that block. The first step in the algorithm is to initialize
the $SudokuPossibilities$, this is a data structure that keeps track of all
the unused numbers for each row, column and block.

The following pseudocode describes how the algroithm is implement.

\section{Analysis}

\subsection{Correctness}

The correctness of this Sudoku solving algorithm is in tow steps. % BAD!!!
First, I need to show that the solution the algorithm finds are actually
correct solutions. This means tow things. First, it means that the original
hints are in fact still in the solution! (The solver is not allowed to ignore
the hints and return just any valid board.) In addition, the board state must
be valid. This means that all rows, columns, and blocks must have unique
numbers from $0..n$.

This algorithm is designed such that doing any to the contrary is impossible.

\subsection{Run Time}

The general runtime for backtracking Sudoku is $O(N^H)$ where $H$ is the number
of hints given. \citationneeded.

\subsection{Empirical Results}

To gather information on the runtime based on the factors identified in the section
above. The results were generated as such; for $N=2,3,4$, and $H=0.2N,0.4N,0.6N,0.8N$.
Each configuration of the problem had $1000$ runs where each run was a randomly
generated Sudoku game for that configuration.

In the interest of time, the runtime was capped at 10 minutes, so this will have
skewed the results for the $N=4$ cases.

\begin{figure*}
    \begin{center}
        \resizebox{\textwidth}{!}{%
        \input{../runs/output.pdf_tex}}
        \caption{Measured Results}
        \label{fig:measured}
    \end{center}
\end{figure*}

Figure \ref{fig:measured} is an in-depth look at the runtime for different configurations of
Sudoku. The results clearly show a correlation between runtime and both factors. Each run
is displayed as a semi-transparent circle, this represents a histogram. Where the line is darker,
there are more runs that took that amount of time.

The lines indicate the mean and median of the runtimes for each $N$, showing the relationship
between $H$ and the runtime. The teal line indicates the median runtime for each $N$. This, shows
an super-exponential relationship between $N$ and the runtime.

Interestingly enough, there seems to be little consistency in the relationship
for $H$ and $T$. In the $N=2$ and $N=4$ cases, $H=0.4N$ is the worst case, whereas,
$H=0.2N$ is the worst case for $N=3$. This could be a result of the timeout not being
high enough. There is a possibility that the timeout has skewed these results and
the $N=4$ case does indeed look like the $N=3$ case, but considering the distributions
of the unskewed data, this is probably not the case.

\subsection{Space Usage}

\section{Pathological Cases}

\end{document}