\section{Value-Based}
\label{section:value-based}
Value-based methods typically aim at finding $Q^*$ first, which then gives the optimal policy $\pi^*(s) = \argmax_a Q^*(s,a)$. For this, they require finite action spaces.
% Like other model-free approaches, the agent needs to interact with the environment to learn.

\subsection{Tabular environments}
In the case of tabular environments (i.e. $S$ is finite as well), $Q^\pi$ can actually be represented by a matrix.

\paragraph{Tabular Q-learning}
Starting from a random value-action function $Q$, tabular Q-learning consists in interacting with the environment and applying equation \ref{eq:bellman-q*} to converge to $Q^*$ (algorithm \ref{algo:tabular-q-learning}). Q-learning is an \emph{off-policy} method, i.e. learns the value of the optimal policy independently of the agent's actions, and $\pi$ can be any policy as long as all state-action pairs are visited enough.

\begin{algorithm}[H]
\DontPrintSemicolon
\For{a number of episodes}{
    initialize $s_0$ \;
    \While{episode not done}{
        take action $a_t \sim \pi(s_t)$, observe $r_t$ and $s_{t+1}$ \;
        $Q(s_t,a_t) \leftarrow Q(s_t,a_t) + \alpha \left[ r_t + \gamma \max_a Q(s_{t+1}, a) \right]$ \;
    }
}
\caption{Tabular Q-learning}
\label{algo:tabular-q-learning}
\end{algorithm}

\paragraph{SARSA} The SARSA algorithm is the \emph{on-policy} equivalent of Q-learning as it learns the value of the current agent's policy $\pi$. Instead of using Bellman equation \ref{eq:bellman-q*}, it uses equation \ref{eq:bellman-q} for the update step, and converges to the optimal policy $\pi^*$ as long as policy $\pi$ becomes greedy in the limit.

\paragraph{Exploration strategies} \label{paragraph:exploration-strategies} Used by value-based algorithms (SARSA, Q-learning) to balance between exploration and exploitation when interacting with the environment.
\begin{itemize}
    \item \emph{$\epsilon$-greedy strategy}
        \[
          \pi(s)=\begin{cases}
            \argmax_a Q(s,a) & \text{be greedy with probability $\epsilon$}\\
            \textit{a random action}, & \text{otherwise}
          \end{cases}
        \]
    \item \emph{Boltzmann selection}
        \[
          \pi(a\mid s) = \frac{\exp(Q(s,a)/\tau)}{\sum_{a'} \exp(Q(s,a')/\tau)}
        \]
    \item Others: UCB-1, pursuit strategy. Comparison in \cite{tijsma2016comparing} (for stochastic mazes).
\end{itemize}

\paragraph{Temporal Difference (TD) learning} TD methods combine Monte-Carlo (MC) sampling \footnote{Since we don't know the MDP, we have to approximate the expectation using trajectory samples} with the \emph{bootstrapping} of DP methods \footnote{Bootstrapping: using our current approximation of $V^{\pi}(s')$ to estimate $V^{\pi}(s)$}, and are used to learn $V^\pi$ or $Q^\pi$. The following quantity
\[
    \delta_t = r_{t+1} + \gamma V(s_{t+1}) - V(s_t)
\]
is called the \emph{TD-error}.

\begin{itemize}
    \item \emph{TD(0) learning} is the most straightforward method. After acting according to $\pi$, the value function is updated with:
    \[
        V(s_t) \leftarrow V(s_t) + \alpha [r_t + \gamma V(s_{t+1}) - V(s_t)]
    \]
    Since $\E[r_t + \gamma V^\pi(s_{t+1})] = V^\pi(s_t)$, $V$ will eventually converge to $V^\pi$.
    % todo: understand the difference with TD(1)

    \item \emph{Multi-steps learning}. When the reward is delayed and is observed several steps after the decisive action, TD(0) is slow since values only propagate from one state to the previous one. With:
    \[
        G_t^{(n)} = r_t + \gamma r_{t+1} + \dots + \gamma^{n-1} r_{t+n} + \gamma^n V^\pi(s_{t+n})
    \]
    the \emph{$n$-step return}, it is also true that $\E[G_t^{(n)}] = V^\pi(s_t)$. Therefore, the update steps becomes:
    \[
        V(s_t) \leftarrow V(s_t) + \alpha [G_t^{(n)} - V(s_t)]
    \]
    Multi-steps learning can converge faster depending on the problem. As $n \rightarrow \infty$, $G_t^{(n)}$ approaches the unbiased MC estimate of $V^\pi$, at the cost of higher variance.

    \item \emph{TD($\lambda$) learning}. Instead of choosing the right $n$, a better way to navigate between TD(0) and MC updates is to average all $n$-step returns with a decay $\lambda$. For $\lambda \in [0,1)$, the \emph{$\lambda$-return} is defined as
    \[
        G_t^\lambda = (1-\lambda) \sum_{n=1}^\infty \lambda^{n-1} G_t^{(n)}
    \]
    and also verifies $\E[G_t^\lambda] = V^\pi(s_t)$, therefore can be used in the update step. Choosing $\lambda=0$ is equivalent to TD(0) updates, and $\lambda \rightarrow 1$ approaches MC updates.
\end{itemize}

% todo: TD learning algo ? (forward view)

\paragraph{Eligibility traces} Eligibility traces $e_t$ are an equivalent but more convenient way of implementing TD($\lambda$) learning. Updates are done online (\emph{backward view}) instead of having to wait the end of the trajectory (\emph{forward view}).
% todo: check
% Note: these are actually accumulating traces, but other versions exist (https://www.cs.utexas.edu/~pstone/Courses/394Rfall16/resources/week6-sutton.pdf):
% - dutch traces, equivalent to TD(lambda) and with a sound background (better than accumulating traces?), but can only be implemented with tabular env (?) cf sutton
% - replace traces, a crude approximation to dutch traces

\begin{algorithm}[H]
\DontPrintSemicolon
\For{a number of episodes}{
    initialize $s_0$ and set $e_0(s)=0, \forall s$\;
    \While{episode not done}{
        take action $a_t=\pi(s_t)$, observe $r_t$ and $s_{t+1}$ \;
        \For{all $s$}{
          $e_t(s) \leftarrow \lambda \gamma e_{t-1}(s) + \mathbbm{1}_{s_t=s}$ \tcp*{this leads to $e_t(s) = \sum_{k=0}^t(\lambda \gamma)^{t-k} \mathbbm{1}_{s_k=s}$}
          $V(s_t) \leftarrow V(s_t) + \alpha e_t(s) \delta_t$ \;
        }
    }
}
\caption{Eligibility traces, also called online TD($\lambda$), tabular version}
\label{algo:eligibility-traces}
\end{algorithm}

% todo: version with weights

\begin{figure}[H]
    \centering
    \begin{subfigure}{0.3\textwidth}
        \includegraphics[width=\linewidth]{figures/backup-td.png}
        \caption{TD(0) Learning (sampling and bootstrapping)}
        \label{fig:backup-td}
    \end{subfigure}
    \begin{subfigure}{0.3\textwidth}
        \includegraphics[width=\linewidth]{figures/backup-mc.png}
        \caption{Monte-Carlo (sampling, no bootstrapping)}
        \label{fig:backup-mc}
    \end{subfigure}
    \begin{subfigure}{0.3\textwidth}
        \includegraphics[width=\linewidth]{figures/backup-dp.png}
        \caption{Dynamic Programming (bootstrapping, no sampling)}
        \label{fig:backup-dp}
    \end{subfigure}
    \caption{Different approaches to learning value functions. By using an estimate in the update, bootstrapping methods do not need to go as deep and can be faster, although they introduce bias. Unless the MDP is known, sampling is necessary. Figures taken from David Silver notes \cite{silver2015}, lecture 4 on Model-Free prediction.}
\end{figure}

\subsection{Approximate Q-learning}
Tabular learning approaches have trouble learning in large environments since there is no generalization between similar situations, and storing Q or V can even be an issue. Approximate approaches allow working with large finite environments and even with continuous state space $S$, by considering
\[
    Q(s,a) \approx Q_\theta(\phi(s),a)
\]
with $\phi(s) \in \mathbb{R}^d$ a vector of features. Features $\phi$ can be hand-crafted, but in Deep Reinforcement Learning (DRL) they are typically learned using neural networks and we simply note $Q(s,a) \approx Q_\theta(s,a)$.

\paragraph{Deep Q-Network (DQN) \cite{mnih2013playing}\cite{mnih2015human}} DQN was the first successful attempt at applying DRL on high-dimensional state spaces, and uses 2D convolutions with an MLP to extract features. It overcomes stability issues thanks to:
\begin{itemize}
    \item \emph{Experience-replay}. Within a trajectory, transitions are strongly correlated but gradient descent algorithms typically assume independent samples, otherwise gradient estimates might be biased. Storing transitions and sampling from a memory buffer $D$ reduces correlation, and even allows mini-batch optimization to speed up training. Re-using past transitions also limits the risk of catastrophic forgetting.
    \item \emph{Target network}. Based on eq. \ref{eq:bellman-q*}, values $Q_\theta(s,a)$ can be learned by minimizing the error\footnote{This can be the mean square error, or Huber loss for more stability} to the target $r + \gamma \max_{a'}Q_\theta(s',a')$. In this case, $\theta$ is continuously updated and we are chasing a non-stationary target. Learning can be stabilized by using a separate network $Q_{\theta^-}$ called the target network, with weights $\theta^-$ updated every $k$ steps to match $\theta$.
\end{itemize}

\begin{algorithm}[H]
\DontPrintSemicolon
\SetKwInput{Init}{Init}
\Init{replay memory $D$ with capacity $M$, $Q_\theta$ with random weights, $\theta^- = \theta$}
\For{a number of episodes}{
    initialize $s_0$ \;
    \While{episode not done}{
        take action $a_t \sim \pi(s_t)$, observe $r_t$ and $s_{t+1}$ \tcp*{$\pi$ can be $\epsilon$-greedy for instance}
        store transition $(s_t, a_t, r_t, s_{t+1})$ in $D$ \;
        sample random mini-batch of transitions $\left((s_j, a_j, r_j, s_{j+1})\right)_{j=1,\dots,N}$ from $D$ \;
        set $y_j=\begin{cases}
            r_j & \text{if $s_{j+1}$ is a terminal state}\\
            r_j + \gamma \max_{a'} Q_{\theta^-}(s_{j+1},a') & \text{otherwise}
          \end{cases}$ \;
        $\theta \leftarrow \theta - \alpha \nabla_\theta \frac{1}{N} \sum_{j=1}^N (y_j - Q_\theta(s_j,a_j))^2$ \;
        every $k$ steps, update $\theta^- = \theta$ \;
    }
}
\caption{Deep Q-learning with experience replay and target network (DQN)}
\label{algo:DQN}
\end{algorithm}

\paragraph{Prioritized Experience Replay (PER) \cite{schaul2015prioritized}}
Improve experience replay: rather than sampling transitions $t_i$ uniformly from the memory buffer, prioritize the ones that are the most informative, i.e. with the largest error.
\[
i \sim P(i) = \frac{p_i^\alpha}{\sum_k p_k^\alpha}
\quad \text{with} \quad
p_i = |\delta_i| + \epsilon
\]
And $\delta_t = r_t + \gamma \max_a Q(s_{t+1},a) - Q(s_t, a_t)$ the TD-error again. In practice when implementing PER, errors $\delta_i$ are stored in memory with their associated transition $t_i$ and are only updated with current $Q_\theta$ when $t_i$ is sampled. A SumTree structure can be used to efficiently sample from $P(i)$, in $O(\log |D|)$. Since PER introduces a bias\footnote{This \href{https://danieltakeshi.github.io/2019/07/14/per/}{blog post} goes into more details}, authors use \emph{importance sampling} and correct the loss with a term $w_i = 1 / (N P(i))^\beta$.

\paragraph{Double DQN \cite{van2016deep}}
Because it is using the same value function $Q_\theta$ for both action selection and evaluation in the target $y_t = r_t + \gamma \max_a Q_\theta(s_{t+1}, a)$, Q-learning tends to overestimate action values as soon as there is any estimation error. This is particularly the case when the action space is large (figure \ref{fig:double-dqn}). Double Q-learning \cite{hasselt2010double} decouples action selection and evaluation using 2 parallel networks $Q_\theta$ and $Q_{\theta'}$. Double DQN \cite{van2016deep} improves DQN performance and stability by doing it simply with the online network $Q_\theta$ and target network $Q_{\theta^-}$:
\[
    y_t = r_t + \gamma Q_{\theta^-}(s_{t+1}, \argmax_a Q_\theta(s_{t+1}, a))
\]

\begin{figure}[H]
    \centering
    \includegraphics[width=0.5\linewidth]{figures/double-dqn.png}
    \caption{Red bars (resp. blue bars) show the bias in a single Q-learning update (resp. double Q learning update) when considering i.i.d. Gaussian noise. Figure taken from \cite{van2016deep}}
    \label{fig:double-dqn}
\end{figure}

\paragraph{Rainbow \cite{hessel2018rainbow}}
Rainbow studies and combines a number of improvements to the DQN algorithm: multi-steps returns, prioritized experience replay, Double Q-learning, as well as dueling networks (using a value function $V_\theta(s)$ and an advantage function $A_\theta(s,a)$ to estimate $Q(s,a)$), noisy nets (adaptive exploration by adding noise to the parameters of the last layer, instead of being $\epsilon$-greedy) and distributional RL (approximate the distribution of returns instead of the expected return).

\paragraph{Deep Recurrent Q-Network \cite{hausknecht2015deep}}
By using a RNN to learn the features (e.g. after the convolutional layers), DQRN keeps in memory a representation of the world according to previous observations. This makes it possible to go beyond the Markov property and work with POMDPs, but it can be harder to train.


\chapter{\Pelectron \Ppositron annihilation}
The annihilation process \HepProcess{\Pelectron \Ppositron \to \Pmuon \APmuon} is related to the scattering process \HepProcess{\Pelectron \Pmuon \to \Pelectron \Pmuon} as can be seen by comparing their diagrams. The diagram for the annihilation process is
\begin{figure}[th]
\centering
\include{figures/annihilate}
\caption{Diagram for the s-channel electron annihilation process to positrons.}
\end{figure}
which is the same as for t-channel elastic scattering, only rotated by $90^\circ$. The rotation is equivalent to exchanging $k^\prime$ with $-p$. The consequence of this transformation is simply that the roles of $s$ and $t$ are swapped in the probability $\abs{T_{fi}}^2$, so the differential cross section for the annihilation process is
\begin{equation}\boxed{
\dv{\sigma}{\Omega} = \frac{e^4}{32\pi^2s} \frac{t^2+u^2}{s^2}
}\end{equation}

\section{Total cross section}
We wish to integrate the differential cross section in the limit where the masses of the particles involved become zero.

Write the kinematic Mandelstam variables in term of energies:
\begin{align}
s = (k + p)^2 &\approx 2k \cdot p \nonumber \\
&= 2 \mqty(E_{\Pelectron} \\ E_{\Pelectron}) \cdot \mqty(E_{\Ppositron} \\ -E_{\Ppositron}) \nonumber \\
&= 4E_{\Pelectron} E_{\Ppositron}
\end{align}
\begin{align}
t = (k - k^\prime)^2 &\approx -2k\cdot k^\prime \nonumber \\
&= -2 \mqty(E_{\Pelectron} \\ E_{\Pelectron}) \cdot \mqty(E_{\Pmuon} \\ E_{\Pmuon} \cdot \cos\theta) \nonumber \\
&= -2 E_{\Pelectron}E_{\Pmuon}(1-\cos\theta)
\end{align}
\begin{align}
u = (k-p^\prime)^2 &\approx -2k\cdot p^\prime \nonumber \\
&= -2 \mqty(E_{\Pelectron} \\ E_{\Pelectron}) \cdot \mqty(E_{\APmuon} \\ -E_{\APmuon}\cdot \cos\theta) \nonumber \\
&= -2 E_{\Pelectron}E_{\APmuon} (1+\cos\theta)
\end{align}

Then the differential cross section becomes
\begin{align}
\dv{\sigma}{\Omega} &= \frac{e^4}{32\pi^2s} \frac{4E_{\Pmuon}^2(1-\cos\theta)^2 + 4E_{\APmuon}^2(1+\cos\theta)^2}{16 E_{\Ppositron}^2} \nonumber \\
&= \frac{e^4}{128\pi^2s} \frac{E_{\Pmuon}^2(1-\cos\theta)^2 + E_{\APmuon}^2(1+\cos\theta)^2}{E_{\Ppositron}^2}
\end{align}

Now we choose the centre of momentum frame where $E_{\Pelectron} = E_{\Pmuon} = E_{\APelectron} = E_{\APmuon}$ for massless particles. Then the differential cross section becomes
\begin{equation}
\dv{\sigma}{\Omega} = \frac{e^4}{64\pi^2s} \left( 1 + \cos^2\theta \right)
\end{equation}

which can be easily integrated:
\begin{align}
\sigma &= \frac{e^4}{64\pi^2s}\int(1+\cos^2\theta) \, \dd{\Omega} \nonumber \\
&= \frac{e^4}{64\pi^2s} \left( 4\pi + 2\pi\int\limits_{-1}^1 \cos^2\theta \, \dd(\cos{\theta}) \right) \nonumber \\
&= \frac{e^4}{64\pi^2s} \left( 4\pi + \frac{4\pi}{3} \right) \nonumber \\
&= \frac{e^4}{12\pi s}.
\end{align}

Finally we use that the fine structure constant $\alpha = \frac{e^2}{4\pi}$ (see \eqref{eq:fineStructure}) to get
\begin{equation}\boxed{
\sigma = \frac{4\pi\alpha^2}{3s}.
}\end{equation}

\section{$R$ at \Pelectron \Ppositron colliders}
The process $\HepProcess{\Pelectron\Ppositron \to \Pmuon\APmuon}$ may be generalised to include other allowed particles in the final state, shown in Figure~\ref{fig:generalAnnihilation}.
\begin{figure}[th]
\centering
\include{figures/generalAnnihilation}
\caption{The diagram for general $s$-channel \Pelectron \Ppositron annihilation with final state fermions in QED.\label{fig:generalAnnihilation}}
\end{figure}
The process is exclusively $s$-channel except in the case for final-state electrons, where $t$- and $u$- channels contribute, and in fact dominate at low energies. Also, muons are simpler to detect. For these reasons, we use the process with final-state muons as a `standard candle' and define the ratio $R$,
\begin{equation}\boxed{
R = \frac{\sigma( \Pelectron\Ppositron \to \Pquark\APquark )}{\sigma ( \Pelectron\Ppositron \to \Pmuon\APmuon )}.
}\end{equation}

At low energies, only \Pup and \Pdown quarks are accessible in the final state. They instantly hadronise into pions or $\rho$ mesons, for example. The cross section is proportional to the square of the quark charge and we simply add the cross sections for distinguishable final states,
\begin{equation}
R_{\Pup\Pdown} = \left[\left(\frac{2}{3}\right)^2 + \left(\frac{-1}{3}\right)^2 \right] \times 3 = \frac{5}{3}
\end{equation}
where the factor of 3 is due to colour multiplicity of the quark states. In this simple treatment, $R$ increases in steps to $\frac{6}{3}$, $\frac{10}{3}$, $\frac{11}{3}$ up to the CM energy $\sqrt{s} = 2m_{\Pbottom} \simeq \SI{9.3}{\giga\electronvolt}$. When the final state quarks combine to form resonances (e.g.~\Prho: \SI{770}{\mega\electronvolt}, \PJpsi: \SI{3.1}{\giga\electronvolt}, \PUpsilonFourS: \SI{10.6}{\giga\electronvolt}) $R$ increases above these predictions due to the enhanced cross section.

The Barbar \Pelectron \Ppositron collider operated at the \PUpsilonFourS resonance, allowing measurement of $R$ at about 3.84 (expected 3.67). The higher measured value can be accounted for by QCD higher order $O(\alpha_S)$ QCD corrections due to gluon radiation.

Similarly, the LEP collider operated at the $\PZ$ resonance $\sqrt{s} = \SI{91}{\giga\electronvolt}$. An analogous quantity $R_Z$ is defined
\begin{equation}
R = \frac{\sigma( \PZ \to \Pquark\APquark )}{\sigma ( \PZ \to \Pmuon\APmuon )}.
\end{equation}
To lowest order, $P_Z = 20.09$ and it is measured to be $20.79 \pm 0.04$. The $3.5\%$ discrepancy is fully explained by higher order QCD corrections involving gluons.
\begin{figure}[hb]
\centering
\include{figures/Zgluonrad}
\caption{$\PZ$ decay into quark final states with gluon radiation. This diagram contributes to the $O(\alpha_S)$ QCD correction to $R_Z$.\label{fig:Zgluonrad}}
\end{figure}

\section{Helicity conservation at high energies}
Recall the chiral projection operators from Section \ref{sec:gammaMatrix},
\begin{equation*}
P_R = \frac{1}{2}\left( 1 + \gamma^5 \right), \quad P_L = \frac{1}{2}\left( 1 - \gamma^5 \right).
\end{equation*}
As discussed above, in the limit where $m \rightarrow 0$, helicity and chirality have the same eigenstates. The left-handed chiral state is given, for example, by $U_L = P_L U$.

Using the fact that $\gamma^5$ -- and hence $P_L$ and $P_R$ -- is Hermitian and $\gamma^\mu \gamma^5 = -\gamma^5 \gamma^\mu$, we see that $P_L\gamma^\mu = \gamma^\mu P_R$ and therefore
\begin{equation}
\overline{U}_L = (P_L U)^\dagger \gamma^0 = U^\dagger P_L \gamma^0 = U^\dagger \gamma_0 P_R = \overline{U} P_R.
\end{equation}
Similarly, $\overline{U}_R = \overline{U}P_L$.

Now consider the QED current
\begin{equation}
\overline{U}\gamma^\mu{U} = (\overline{U}_L + \overline{U}_R)\gamma^\mu(U_L + U_R)
\end{equation}
and look at a cross-term specifically,
\begin{align}
\overline{U}_L \gamma^\mu U_R &= \overline{U} P_R \gamma^\mu P_R U \nonumber \\
&= \overline{U} \gamma^\mu P_L P_R U \nonumber \\
&= 0\end{align}
because $P_LP_R=0$. This means there are no chirality-changing currents in QED and hence QED conserved chirality, or equivalently helicity in the high energy limit.


\documentclass[12pt]{article}
\input{physics1}
\begin{document}

\section*{NYU Physics I---the spacetime interval}

\paragraph{\theproblem}\refstepcounter{problem}%
Draw a spacetime diagram showing the four events
$A=(c\,t_A,x_A)=0\,\m,0\,\m)$, $B=(1\,\m,1\,\m)$, $C=(1\,\m,0\,\m)$,
and $D=(0\,\m,1\,\m)$,

\paragraph{\theproblem}\refstepcounter{problem}%
Compute all six spacetime intervals between all pairs of events.

\paragraph{\theproblem}\refstepcounter{problem}%
Now Lorentz Transform these events to a new frame using the Lorentz
Transformation
\begin{eqnarray}\displaystyle
c\,t' & = & \gamma\,c\,t - \beta\,\gamma\,   x \nonumber\\
   x' & = & \gamma\,   x - \beta\,\gamma\,c\,t \quad ,
\end{eqnarray}
with $\beta=(3/5)$.

\paragraph{\theproblem}\refstepcounter{problem}%
Draw a spacetime diagram of the four events in the new frame.

\paragraph{\theproblem}\refstepcounter{problem}%
Re-compute all six spacetime intervals in this new frame.  Which are
null, which are spacelike, and which are timelike?

\paragraph{\theproblem}\refstepcounter{problem}%
Now Lorentz Transform the events again using the opposite velocity, or
\begin{eqnarray}\displaystyle
c\,t'' & = & \gamma\,c\,t' + \beta\,\gamma\,   x' \nonumber\\
   x'' & = & \gamma\,   x' + \beta\,\gamma\,c\,t' \quad .
\end{eqnarray}
Is everything okay?

\end{document}


\chapter{Total boundness of reloids}

\section{Thick binary relations}
\begin{defn}
\index{alpha-thick@$\alpha$-thick}I will call \emph{$\alpha$-thick} and denote $\thick_{\alpha}(E)$
a $\mathbf{Rel}$-endomorphism $E$ when there exists a finite cover $S$
of $\Ob E$ such that $\forall A\in S:A\times A\subseteq\GR E$.
\end{defn}

\begin{defn}
$\CS(S)=\bigcup\setcond{A\times A}{A\in S}$ for a collection $S$
of sets.\end{defn}
\begin{rem}
$\CS$ means ``Cartesian squares''.\end{rem}
\begin{obvious}
A $\mathbf{Rel}$-endomorphism is $\alpha$-thick iff there exists
a finite cover $S$ of $\Ob E$ such that $\CS(S)\subseteq\GR E$.\end{obvious}
\begin{defn}
\index{beta
-thick@$\beta$-thick}I will call \emph{$\beta$-thick} and denote $\thick_{\beta}(E)$
a $\mathbf{Rel}$-endomorphism $E$ when there exists a finite set
$B$ such that $\rsupfun{\GR E}B=\Ob E$.\end{defn}
\begin{prop}
$\thick_{\alpha}(E)\Rightarrow\thick_{\beta}(E)$.\end{prop}
\begin{proof}
Let $\thick_{\alpha}(E)$. Then there exists a finite cover $S$ of
the set $\Ob E$ such that $\forall A\in S:A\times A\subseteq\GR E$.
Without loss of generality assume $A\ne\emptyset$ for every $A\in S$.
So $A\subseteq\rsupfun{\GR E}\{x_{A}\}$ for some $x_{A}$ for every
$A\in S$. So
\[
\rsupfun{\GR E}\setcond{x_{A}}{A\in S}=\bigcup\setcond{\rsupfun{\GR E}\{x_{A}\}}{A\in S}=\Ob E
\]
and thus $E$ is $\beta$-thick.\end{proof}
\begin{obvious}
Let $X$ be a set, $A$ and $B$ be $\mathbf{Rel}$-endomorphisms
on $X$ and $B\sqsupseteq A$. Then:
\begin{itemize}
\item $\thick_{\alpha}(A)\Rightarrow\thick_{\alpha}(B)$;
\item $\thick_{\beta}(A)\Rightarrow\thick_{\beta}(B)$.
\end{itemize}
\end{obvious}
\begin{example}
There is a $\beta$-thick Rel-morphism which is not $\alpha$-thick.\end{example}
\begin{proof}
Consider the $\mathbf{Rel}$-morphism on $[0;1]$ with the graph on
figure~\ref{fig:thick-counterexample}:
\[
\Gamma=\setcond{(x,x)}{x\in[0;1]}\cup\setcond{(x,0)}{x\in[0;1]}\cup\setcond{(0,x)}{x\in[0;1]}.
\]
\begin{figure}[ht]
\begin{tikzpicture}
\draw[thin,gray,text=black,<->] (0,1.4) node[left] {$y$}
|- (1.4,0) node[below] {$x\vphantom{1}$};
\draw[densely dotted,gray] (1,0) |- (0,1);
\draw[thick] (0,1) node[left] {$1$}
-- (0,0) node[below left] {$0$}
-- (1,0) node[below] {$1$}
(0,0) -- (1,1);
\end{tikzpicture}

\caption{\label{fig:thick-counterexample}Thickness counterexample graph}
\end{figure}

$\Gamma$ is $\beta$-thick because $\rsupfun{\Gamma}\{0\}=[0;1]$.

To prove that $\Gamma$ is not $\alpha$-thick it's enough to prove
that every set $A$ such that $A\times A\subseteq\Gamma$ is finite.

Suppose for the contrary that $A$ is infinite. Then $A$ contains
more than one non-zero points $y$, $z$ ($y\ne z$). Without loss
of generality $y<z$. So we have that $(y,z)$ is not of the form
$(y,y)$ nor $(0,y)$ nor $(y,0)$. Therefore $A\times A$ isn't a
subset of $\Gamma$.
\end{proof}

\section{Totally bounded endoreloids}

The below is a straightforward generalization of the customary definition
of totally bounded sets on uniform spaces (it's proved below that
for uniform spaces the below definitions are equivalent).
\begin{defn}
\index{alpha
-totally bounded@$\alpha$-totally bounded}An endoreloid $f$ is \emph{$\alpha$-totally bounded} ($\totBound_{\alpha}(f)$)
if every~$E\in\up f$ is $\alpha$-thick.
\end{defn}

\begin{defn}
\index{beta
-totally bounded@$\beta$-totally bounded}An endoreloid $f$ is \emph{$\beta$-totally bounded} ($\totBound_{\beta}(f)$)
if every~$E\in\up f$ is $\beta$-thick.\end{defn}
\begin{rem}
We could rewrite the above definitions in a more algebraic way like
$\up f\subseteq\thick_{\alpha}$ (with $\thick_{\alpha}$ would be
defined as a set rather than as a predicate), but we don't really
need this simplification.\end{rem}
\begin{prop}
If an endoreloid is $\alpha$-totally bounded then it is $\beta$-totally
bounded.\end{prop}
\begin{proof}
Because $\thick_{\alpha}(E)\Rightarrow\thick_{\beta}(E)$.\end{proof}
\begin{prop}
If an endoreloid $f$ is reflexive and $\Ob f$ is finite then $f$
is both $\alpha$-totally bounded and $\beta$-totally bounded.\end{prop}
\begin{proof}
It enough to prove that $f$ is $\alpha$-totally bounded. Really,
every $E\in\up f$ is reflexive. Thus $\{x\}\times\{x\}\subseteq\GR E$
for $x\in\Ob f$ and thus $\setcond{\{x\}}{x\in\Ob f}$ is a sought
for finite cover of $\Ob f$.\end{proof}
\begin{obvious}
~
\begin{itemize}
\item A principal endoreloid induced by a $\mathbf{Rel}$-morphism $E$ is
$\alpha$-totally bounded iff $E$ is $\alpha$-thick.
\item A principal endoreloid induced by a $\mathbf{Rel}$-morphism $E$ is
$\beta$-totally bounded iff $E$ is $\beta$-thick.
\end{itemize}
\end{obvious}
\begin{example}
There is a $\beta$-totally bounded endoreloid which is not $\alpha$-totally
bounded.\end{example}
\begin{proof}
It follows from the example above and properties of principal endoreloids.
\end{proof}

\section{Special case of uniform spaces}

Remember that \emph{uniform space} is essentially the same as symmetric,
reflexive and transitive endoreloid.
\begin{thm}
Let $f$ be such an endoreloid that $f\circ f^{-1}\sqsubseteq f$.
Then $f$ is $\alpha$-totally bounded iff it is $\beta$-totally
bounded.\end{thm}
\begin{proof}
~
\begin{description}
\item [{$\Rightarrow$}] Proved above.
\item [{$\Leftarrow$}] For every $\epsilon\in\up f$ we have that $\rsupfun{\GR\epsilon}\{c_{0}\},\dots,\rsupfun{\GR\epsilon}\{c_{n}\}$
covers the space. $\rsupfun{\GR\epsilon}\{c_{i}\}\times\rsupfun{\GR\epsilon}\{c_{i}\}\subseteq\GR(\epsilon\circ\epsilon^{-1})$
because for $x\in\rsupfun{\GR\epsilon}\{c_{i}\}$ (the same as $c_{i}\in\rsupfun{\GR\epsilon}\{x\}$)
we have
\[
\rsupfun{\rsupfun{\GR\epsilon}\{c_{i}\}\times\rsupfun{\GR\epsilon}\{c_{i}\}}\{x\}=\rsupfun{\GR\epsilon}\{c_{i}\}\subseteq\rsupfun{\GR\epsilon}\rsupfun{\GR\epsilon^{-1}}\{x\}=\rsupfun{\GR(\epsilon\circ\epsilon^{-1})}\{x\}.
\]
For every $\epsilon'\in\up f$ exists $\epsilon\in\up f$ such that
$\epsilon\circ\epsilon^{-1}\sqsubseteq\epsilon'$ because $f\circ f^{-1}\sqsubseteq f$.
Thus for every $\epsilon'$ we have $\rsupfun{\GR\epsilon}\{c_{i}\}\times\rsupfun{\GR\epsilon}\{c_{i}\}\subseteq\GR\epsilon'$
and so $\rsupfun{\GR\epsilon}\{c_{0}\},\dots,\rsupfun{\GR\epsilon}\{c_{n}\}$
is a sought for finite cover.
\end{description}
\end{proof}
\begin{cor}
A uniform space is $\alpha$-totally bounded iff it is $\beta$-totally
bounded.\end{cor}
\begin{proof}
From the theorem and the definition of uniform spaces.
\end{proof}
Thus we can say about just \emph{totally bounded} uniform spaces (without
specifying whether it is $\alpha$ or $\beta$).

\section{Relationships with other properties}
\begin{thm}
Let $\mu$ and $\nu$ be endoreloids. Let $f$ be a principal $\continuous'(\mu,\nu)$
continuous, monovalued, surjective reloid. Then if $\mu$ is $\beta$-totally
bounded then $\nu$ is also $\beta$-totally bounded.\end{thm}
\begin{proof}
Let $\varphi$ be the monovalued, surjective function, which induces
the reloid~$f$.

We have $\mu\sqsubseteq f^{-1}\circ\nu\circ f$.

Let $F\in\up\nu$. Then there exists $E\in\up\mu$ such that $E\subseteq\varphi^{-1}\circ F\circ\varphi$.

Since $\mu$ is $\beta$-totally bounded, there exists a finite typed
subset $A$ of $\Ob\mu$ such that $\rsupfun{\GR E}A=\Ob\mu$.

We claim $\rsupfun{\GR F}\rsupfun{\varphi}A=\Ob\nu$.

Indeed let $y\in\Ob\nu$ be an arbitrary point. Since $\varphi$ is
surjective, there exists $x\in\Ob\mu$ such that $\varphi x=y$. Since
$\rsupfun{\GR E}A=\Ob\mu$ there exists $a\in A$ such that $a\mathrel{(\GR E)}x$
and thus $a\mathrel{(\varphi^{-1}\circ F\circ\varphi)}x$. So $(\varphi a,y)=(\varphi a,\varphi x)\in\GR F$.
Therefore $y\in\rsupfun{\GR F}\rsupfun{\varphi}A$.\end{proof}
\begin{thm}
Let $\mu$ and $\nu$ be endoreloids. Let $f$ be a principal $\continuous''(\mu,\nu)$
continuous, surjective reloid. Then if $\mu$ is $\alpha$-totally
bounded then $\nu$ is also $\alpha$-totally bounded.\end{thm}
\begin{proof}
Let $\varphi$ be the surjective binary relation which induces the
reloid $f$.

We have $f\circ\mu\circ f^{-1}\sqsubseteq\nu$.

Let $F\in\up\nu$. Then there exists $E\in\up\mu$ such that $\varphi\circ E\circ\varphi^{-1}\subseteq F$.

There exists a finite cover $S$ of $\Ob\mu$ such that $\bigcup\setcond{A\times A}{A\in S}\subseteq\GR E$.

Thus $\varphi\circ\left(\bigcup\setcond{A\times A}{A\in S}\right)\circ\varphi^{-1}\subseteq\GR F$
that is $\bigcup\setcond{\rsupfun{\varphi}A\times\rsupfun{\varphi}A}{A\in S}\subseteq\GR F$.

It remains to prove that $\setcond{\rsupfun{\varphi}A}{A\in S}$ is
a cover of $\Ob\nu$. It is true because $\varphi$ is a surjection
and $S$ is a cover of $\Ob\mu$.
\end{proof}
A stronger statement (principality requirement removed):
\begin{conjecture}
The image of a uniformly continuous entirely defined monovalued surjective
reloid from a ($\alpha$-, $\beta$-)totally bounded endoreloid is
also ($\alpha$-, $\beta$-)totally bounded.
\end{conjecture}
Can we remove the requirement to be entirely defined from the above
conjecture?
\begin{question}
Under which conditions it's true that join of ($\alpha$-, $\beta$-)
totally bounded reloids is also totally bounded?
\end{question}

\section{Additional predicates}

We may consider also the following predicates expressing different
kinds of what is intuitively is understood as boundness. Their usefulness
is unclear, but I present them for completeness.
\begin{itemize}
\item $\totBound_{\alpha}(f)$
\item $\totBound_{\beta}(f)$
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\alpha}(E^{n})$
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\beta}(E^{n})$
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\alpha}(E^{0}\sqcup\ldots\sqcup E^{n})$
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\beta}(E^{0}\sqcup\ldots\sqcup E^{n})$
\item $\exists n\in\mathbb{N}:\totBound_{\alpha}(f^{n})$
\item $\exists n\in\mathbb{N}:\totBound_{\beta}(f^{n})$
\item $\exists n\in\mathbb{N}:\totBound_{\alpha}(f^{0}\sqcup\ldots\sqcup f^{n})$
\item $\exists n\in\mathbb{N}:\totBound_{\beta}(f^{0}\sqcup\ldots\sqcup f^{n})$
\item $\totBound_{\alpha}(S(f))$
\item $\totBound_{\beta}(S(f))$
\end{itemize}
Some of the above defined predicates are equivalent:
\begin{prop}
~
\begin{itemize}
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\alpha}(E^{n})\Leftrightarrow\exists n\in\mathbb{N}:\totBound_{\alpha}(f^{n})$.
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\beta}(E^{n})\Leftrightarrow\exists n\in\mathbb{N}:\totBound_{\beta}(f^{n})$.
\end{itemize}
\end{prop}
\begin{proof}
Because for every $E\in\up f$ some $F\in\up f^{n}$ is a subset of $E^{n}$, we have
\[\forall E\in\up f:\thick_{\alpha}(E^{n})\Leftrightarrow\forall F\in\up f^n:\thick_{\alpha}(F)\]
and likewise for $\thick_{\beta}$.\end{proof}
\begin{prop}
~
\begin{itemize}
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\alpha}(E^{0}\sqcup\ldots\sqcup E^{n})\Leftrightarrow\exists n\in\mathbb{N}:\totBound_{\alpha}(f^{0}\sqcup\ldots\sqcup f^{n})$
\item $\exists n\in\mathbb{N}\forall E\in\up f:\thick_{\beta}(E^{0}\sqcup\ldots\sqcup E^{n})\Leftrightarrow\exists n\in\mathbb{N}:\totBound_{\beta}(f^{0}\sqcup\ldots\sqcup f^{n})$
\end{itemize}
\end{prop}
\begin{proof}
It's enough to prove
\begin{align}
\label{thk-1}&\forall E\in\up f\exists F\in\up(f^0\sqcup\dots\sqcup f^n):F\sqsubseteq E^{0}\sqcup\ldots\sqcup E^{n} \text{ and}\\
\label{thk-2}&\forall F\in\up(f^0\sqcup\dots\sqcup f^n)\exists E\in\up f:E^{0}\sqcup\ldots\sqcup E^{n}\sqsubseteq F.
\end{align}

For the formula~\eqref{thk-1} take $F=E^0\sqcup\dots\sqcup E^n$.

Let's prove~\eqref{thk-2}. Let $F\in\up(f^0\sqcup\dots\sqcup f^n)$. Using the fact that $F\in\up f^i$ take
$E_i\in\up f$ for $i=0,\dots,n$ such that $E_i^i\sqsubseteq F$ (exercise~\ref{rld-fn} and properties of generalized filter bases) and then $E=E_{0}\sqcap\dots\sqcap E_{n}\in\up f$. We have
$E^{0}\sqcup\ldots\sqcup E^{n}\sqsubseteq F$.
\end{proof}
\begin{prop}
All predicates in the above list are pairwise equivalent in the case
if $f$ is a uniform space.\end{prop}
\begin{proof}
Because $f\circ f=f$
and thus $f^n=f^0\sqcup\dots\sqcup f^n=S(f)=f$.\end{proof}


\subsection{Physical system and governing equations}

We consider a thin layer of fluid over a flat bottom and with a free
surface.
%
Under the assumption that the characteristic horizontal scale of the
flow $L$ is much larger than the mean layer thickness $H_0$, it can be
shown that the pressure is only a function of the local layer
thickness $H(x, y)$, i.e.\ that the flow is hydrostatic.
%
Further assuming that the horizontal flow is vertically invariant, it
can be shown that the shallow-water system is governed by the
Saint-Venant equations \cite[see for example][]{VallisLIVRE2006}
\begin{eqnarray}
(\p_t + \uu\cdot \bnabla ) \uu
&=& - c^2 \bnabla h - f \eez \wedge \uu + \nu \bnabla^2 \uu,   \label{eq_uu}\\
\p_t   h    &=& - \bnabla \cdot (h \uu).  \label{eq_h}
\end{eqnarray}
where $\uu$ is the horizontal velocity, %
$h = H/H_0$ the normalized layer thickness, %
$\bnabla$ the horizontal gradient, %
$\nu$ the kinetic viscosity, %
$f$ the Coriolis parameter %
and %
$c = \sqrt{gH_0}$, with $g$ the gravitational acceleration.
%
In the following, the Coriolis parameter is assumed to be spatially
homogeneous.

\subsection{Eigenmodes of the linearized equations}

\label{subsection_eigen}

Neglecting the non-linear and the dissipative terms, the governing
equations can be rewritten as
\begin{equation}
\p_t q = 0, \mbox{\hspace{1cm}}
\p_t d = a \mbox{\hspace{6mm} and \hspace{6mm}}
\p_t a = - c^2\varkappa^2 d,
\end{equation}
where $q = \zeta - f\eta$ is the linear Charney potential vorticity, %
$d = \bnabla \cdot \uu$ the horizontal divergence, %
$a = -c^2\bnabla^2 \eta + f\zeta$ an ageostrophic variable and %
$\varkappa^2 = {k_d}^2 - \bnabla^2$ the Helmholtz operator, %
with $k_d = f/c$ the deformation wave number. %
Here, $\eta = h-1$ is the normalized surface displacement and %
$\zeta = \eez \cdot (\bnabla \wedge \uu)$ is the vertical component of
the vorticity.
%
The dispersion relation is $\omega^2 = {\omega_l}^2$, where
\begin{equation}
 \omega_l(\kk) \equiv c  \sqrt{ {k_d}^2 + |\kk|^2 } = \sqrt{ f^2 + c^2|\kk|^2 },
\end{equation}
which implies that in the non-rotating case the waves are
non-dispersive.
%
The eigenfunctions of the linear operator are the prograde and
retrograde linear waves with positive and negative frequencies,
respectivelly.
%
Denoting the prograde quantities by the index $+$, the retrograde
quantities by the index $-$ and the temporal and spatial Fourier
transform by a tilde, we have by definition %
$a = a_+ + a_-$, $d = d_+ + d_-$, %
$\widetilde{\p_t a_\pm} = \mp i \omega_l \tilde a_\pm$ and %
$\widetilde{\p_t d_\pm} = \mp i \omega_l \tilde d_\pm$.
%
The linearized governing equations for the waves can be rewritten as %
$i \tilde a_\pm = \pm \omega_l \tilde d_\pm$, which gives %
$ \tilde a_\pm = \tilde a /2 \pm \omega_l \tilde d /(2i) .$

\subsection{Conserved quantities}

The non-dissipative one-layer shallow-water equations conserve a local
quantity along the trajectories of the fluid particles, the Ertel
potential vorticity $\ErtelPV = \zeta_a/h$, where $\zeta_a = \zeta +
f$ is the absolute vorticity.
%
Note that since the lagrangian derivative of the Ertel potential
vorticity is $\D_t \ErtelPV = 0$, the space-averaged Ertel potential
vorticity is not conserved $\p_t \meanx{\ErtelPV} = \meanx{d \ErtelPV}
\neq 0 $, where the brackets $\meanx{}$ denote the space average.
%
In the case of two-dimensional turbulence, it can be shown that the
energy can not cascade towards small scales due to the
constraints that the enstrophy $\meanx{ \zeta^2/2 }$ is conserved and
that the spectra of energy and enstrophy are proportional
\cite[]{Kraichnan1967}.
%
This result was further extended by \cite{Charney1971} to the case of
quasi-geostrophic turbulence using the analogy between the
enstrophy and the Charney linear potential enstrophy $\meanx{ q^2/2
}$, where $q$ is the linear potential vorticity equal in the shallow
water case to $q = \zeta - f \eta$.
%
Note, however, that the analogy does not hold for the nonlinear Ertel
potential vorticity $\ErtelPV$ and that the local conservation of
$\ErtelPV$ is a much weaker constraint for the dynamics of the flows.

The non-dissipative one-layer shallow-water equations also conserve
some space-averaged quantities.
%
For example, since
\begin{equation}
(\D_t+d) \zeta_a = 0 \Rightarrow \p_t \meanx{\zeta_a} = 0 ,
\end{equation}
the space-averaged absolute vorticity $\meanx{\zeta_a }$ is conserved.
Since the governing equation for the thickness $h$ and the mass flux
$\JJ = h \uu$ are
\begin{eqnarray}
(\D_t+d) h
&=& 0, \label{eq_h_2}\\
(\D_t+d) \JJ
&=& - \bnabla E_P - f \eez \wedge \JJ, \label{eq_JJ}
\end{eqnarray}
where $E_P = c^2 h^2/2$ is the total potential energy, the
space-averaged thickness $\meanx{ h }$ is conserved and the kinetic
momentum $\meanx{ \JJ }$ is conserved in the absolute not-rotating
reference frame.
%
Note that in contrast to the case of the Navier-Stokes equations,
the dissipative shallow-water equations do not conserve $\meanx{ \JJ }$,
even with a Newtonian viscous operator.

The non-dissipative one-layer shallow-water equations also conserve
the space-averaged total energy, the local energy being the sum of the
local potential energy (PE), $E_P = c^2 h^2/2$, and the local kinetic
energy (KE), $E_K = \JJ\cdot\uu/2$.  Using (\ref{eq_uu}),
(\ref{eq_h_2}) and (\ref{eq_JJ}), it is straightforward to show that
\begin{eqnarray}
(\D_t + d) E_K
&=&
- \uu \cdot \bnabla E_P, \\
(\D_t + d) E_P
&=&
- E_P \bnabla \cdot \uu.
\end{eqnarray}
%
The space-averaged conversion from potential energy to kinetic energy
is equal to $C = -\meanx{ \uu \cdot \bnabla E_P } = \meanx{ E_P
\bnabla \cdot \uu }$.
%
The total potential energy can be split in three parts
\begin{equation}
E_P = c^2/2 + c^2\eta+ c^2 \eta^2/2.
\end{equation}
The first term corresponds the potential energy of the state with null
surface displacement.  The second term is a contribution to the
potential energy which is zero in average.  We call the third term
$E_A = c^2\eta^2/2$ the available potential energy (APE).  Its
space-average is indeed equal to the space-averaged APE.


\documentclass{article}
    % General document formatting
    \usepackage[margin=0.7in]{geometry}
    \usepackage[parfill]{parskip}
    \usepackage[utf8]{inputenc}
    \usepackage{mathrsfs}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage{tikz}
    \usepackage{fancyhdr}
    \usepackage{multicol}

    \usetikzlibrary{positioning}

\pagestyle{fancy}
\fancyhf{}
\rhead{Edgar Jacob Rivera Rios - A01184125}

\begin{document}
\section*{2.5.3. Linear Temporal Logic (LTL)}
Prove $\models \neg \diamond \neg p \rightarrow \Box p$ (the converse direction (the sufficiency) of Theorem 13.14 in Ben-Ari, M.).
\begin{align*}
    \models \neg \diamond \neg p &\rightarrow \Box p\\
    \neg \diamond \neg p &= True\\
    \diamond \neg p &= False\\
    \forall s \in S&,\ \forall S_{i} \in \mathscr{I}(s)\\
    S_{i}(P) &= True \equiv \Box p
\end{align*}
\begin{center}
    \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
      \node {$\neg(\neg \diamond \neg p \rightarrow \Box p)$}
        child {node {$\neg \diamond \neg p, \neg \Box p$}
          child {node {$\exists s \in S,\ S_{i} \in \mathscr{I}(j)$}
            child {node {$p, \neg p$\\$\times$}
            edge from parent [solid] node [right] {}}
          edge from parent [dashed] node [right] {instantiation}}
        edge from parent node [right] {$\alpha$}};
    \end{tikzpicture}
\end{center}
By contradiction of the inverse, it's proved true

\section*{Exercise 2.5.4. Linear Temporal Logic (LTL)}
Prove Theorem 13.15 from Ben-Ari, M.:  $\models \Box (p \rightarrow q) \rightarrow (\Box p \rightarrow \Box q)$.
\begin{align*}
    \models \Box (p \rightarrow q) \rightarrow (\Box p \rightarrow \Box q)\\
    \Box (p \rightarrow q) = True\\
    \forall s \in S,\ \forall S_{i} \in \mathscr{P}(s)
\end{align*}
\begin{center}
    \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
      \node {$\neg(\Box (p \rightarrow q) \rightarrow (\Box p \rightarrow \Box q))$}
        child { node {$\Box (p \rightarrow q), \neg (\Box p \rightarrow \Box q)$}
          child {node {$\Box (p \rightarrow q), \Box p, \neg \Box q$}
            child {node {$\exists s \in S,\ S_{i} \in \mathscr{I}(j)$}
              child {node {$\neg p, p, \neg q$\\$\times$}
              edge from parent [solid] node [right] {}}
              child {node {$q, p, \neg q$\\$\times$}
              edge from parent [solid] node [right] {}}
            edge from parent [dashed] node [right] {instantiation}}
          edge from parent node [right] {$\alpha$}}
        edge from parent node [right] {$\alpha$}};
    \end{tikzpicture}
\end{center}
By contradiction of the inverse, it's proved true
\end{document}


\documentclass{standalone}

\begin{document}

	\chapter{Series}

	\section{Sequences}

	Consider the following set of numbers:
	\begin{center}
		$2,4,6,8,...$\\
		$1,2,4,8,16,...$\\
		$4,9,16,25,...$\\
	\end{center}
	In each of the above cases, the numbers are written in a particular order and there is a clear rule for obtaining the next number and as many numbers in the list.\\

	The above are all examples of sequences where a sequence is a set of terms in a defined order with a rule for obtaining the terms.

	\section{Summation Series}

	When the terms of a sequence are added, a summation series is formed:

	\begin{multicols}{2}
		\begin{center}
			$2+4+6+8+10+...$\\
			$1+2+4+8+16+...$\\
			$4+9+16+25+36+...$\\
		\end{center}
		\begin{center}
			~\\
			are all examples of series.
			~\\
		\end{center}
	\end{multicols}
	A series can be finite or infinite, where a finite series consists of a fixed number of terms, whereas an infinite series has an infinite number of terms.\\

	Considering the follwing series, \[1+\frac{1}{2}+ \frac{1}{4}+\frac{1}{8}+\frac{1}{16}+...\] we can notice that the general term of this series is $\frac{1}{2^r}$. The general term of a series is not unique, it depends on the initial value of $r$. Thus, the general term $\frac{1}{2^{r-1}}$ also corresponds to the above series but we take the initial value of $r$ to be 1.\\

	A summation series can be defined in a concise way using the Greek letter $\Sigma$ denoting the \textit{summation of terms}. The above series may be expressed as \[\sum_{r=0}^\infty \frac{1}{2^r}\] which is equivalent to \[\sum_{r=1}^\infty \frac{1}{2^{r-1}} \quad r \in \mathbb{Z}\]

	\section{Arithmetic Progressions}
	\subsection{Definition}
	An arithmetic progression is a sequence of numbers starting with term $a$, in which successive terms are obtained by adding the same constant, denoted by $d$, reffered to as the \textbf{common difference}.\\

	\subsection{General term}
	Let us consider the general A.P with first term $a$ and common difference $d\colon$ \[a+(a+d)+(a+2d)+(a+3d)+(a+4d)+(a+5d)+...\] By observing the coefficient of $d$ and the position of the term, we can conclude that the general term can be obtained by the equation: \[T_n = a+(n-1)d\]
	\subsection{Sum of the first n terms}
	Considering an A.P. with $n$ terms, let the first term be $a$, the common difference to be $d$	and the last term to be $l$

	\begin{align*}
				S_n &= a+(a+d)+(a+2d)+(a+3d)+(a+4d)+(a+5d)+...+(l-d)+l\\
\implies	S_n &= l+(l-d)+(l-2d)+(l-3d)+(l-4d)+(l-5d)+...+(a+d)+a\\
	\implies	2S_n &= n(2a+l)\\
 \implies   S_n  &= \frac n2 (2a+l)\\
	   		&= \frac n2 (2a +(n-1)d)
	\end{align*}
	\newpage
	\section{Geometric progressions}
	\subsection{Definition}
	A geometric progression is a sequence of numbers starting with term $a$, in which successive terms are obtained by multiplying the same constant, denoted by $r$, reffered to as the \textbf{common ratio}.\\

	\subsection{General term}

	Let us consider a general G.P. with first tirm $a$ and a common ratio $r$: \[a+ar+ar^2+ar^3+ar^4+ar^5+...+ar^n-1+\ldots\]
	By observing the exponent of $r$ and the position of the term we can conclude that the general term can be obtained by the equation: \[\mathrm{T_n} = ar^{n-1}\]

	\subsection{Sum of the first n terms}
	Considering a G.P. with first term $a$, common ratio $d$ and it's sum denoted by $S_n$:

	\begin{align*}
		S_n = a+&ar+ar^2+ar^3+ar^4+ar^5+\ldots+ar^{n-1}+\ldots\\
		rS_n = \phantom{a+}&ar+ar^2+ar^3+ar^4+ar^5+\ldots+ar^n+\ldots\\
		S_n - rS_n =\phantom{a+}& a-ar^n\\
		(1-r)S_n = \phantom{a+}&a(1-r^n)\\
		S_n = \phantom{a+}&  \frac{a(1-r^n)}{1-r} \qed
		\end{align*}

	\section{Convergence of a series}

	For any\footnote{A.P's by definition \textbf{do not} converge.} given G.P., we can always add infinitely many times more terms to the end of the series, but what hapens to it's sum? Given that $\abs r = 1$, the sum will always get infinitesimally closer to a definite number.\\

	Considering the G.P. $\frac 12 + \frac 14 + \frac 18 + \frac 1 {16} + \ldots$ we can observe that if you keep on adding terms and summing them, the sum will approach 1. In mathematical language we say \[\text{as } n \rightarrow \infty\,,\,S_n = 1\] or \[\lim_{n\to\infty}S_n = 1\]

	\section{Binomial theorem}

	The binomial theorem states that \[(x+y)^n = \sum_{k=0}^n\begin{pmatrix}n\\k\end{pmatrix} x^ky^{n-k}	\]

	\section{Maclaurin Series}
	\subsection{Derivation}
	Let $f(x)$ be nay function of $ x $ and suppose that $ f(x) $ can be expanded as a series of ascending powers of $ x $ and that this series can be differentiated $ w.r.t. x $
	\begin{center}
		$	f(x) \equiv a_0   + a_{1}x  + a_{2}x^2 + a_{3}x^3 + a_{4}x^4 + ... +	 a_{r}x^r$\\
		\text{where $a_n$ are constants to be found}
	\end{center}
	Thus, inputting $0$ into $f(x)$ returns:
	$$\boxed{f(0) = a_{0}}$$\\
	Differentiating  $f(x)$ $w.r.t.x\colon$
	$$f'(x) \equiv a_{1} + 2a_{2}x + 3a_{3}x^2 + 4a_4x^3 + \cdots + ra_{r}x^{r-1} + \cdots$$
	Inputting $0$ into $f'(x)\colon$
	$$\boxed{f'(0) = a_1}$$\\
	Differentiating $f'(x)$ $w.r.t.x\colon$
	$$f''(x) \equiv 2a_{2} + 6a_{3}x + 12a_4x^2 + \cdots + (r-1)(r)a_{r}x^{r-2} + \cdots$$
	Inputting $0$ into $f''(x)\colon$
	$$\boxed{f''(0) = 2a_2}$$\\
	Differentiating $f''(x)$ $w.r.t.x\colon$
	$$f'''(x) \equiv 6a_{3} +24a_4x + \cdots + (r-2)(r-1)(r)a_{r}x^{r-3}+ \cdots$$
	Inputting $0$ into $f'''(x)\colon$
	$$\boxed{f'''(0) = (2)(3)a_3}$$
	$$\vdots$$
	\newpage
	By the above calculation we can conclude that:
	$$\boxed{a_r = \frac{f^r(x)}{r!}}$$
	Considering all of the above:

	\tcbset{
		enhanced,
		colback=red!5!white,
		boxrule=0.1pt,
		colframe=black!75!black,
		fonttitle=\bfseries
	}
	\begin{center}
		\begin{tcolorbox}[center title,hbox,    %%<<---- here
			lifted shadow={1mm}{-2mm}{3mm}{0.1mm}%
			{black!50!white}]
			\begin{varwidth}{\textwidth}
				\begin{center}
					$f(x) \equiv f(0) + f'(0)x + \dfrac{f''(0)x^2}{2!} + \dfrac{f'''(0)x^3}{3!} + \cdots + \dfrac{f^r(0)x^r}{r!} + \cdots$\\
					\bigskip
					$\displaystyle \therefore \quad f(x) \equiv \sum_{r=1}^{\infty} \dfrac{f^r(x)}{r!}$
				\end{center}
			\end{varwidth}
		\end{tcolorbox}
	\end{center}

	This is known as Maclaurin's Theorem, and can be obtained if and only if $f^r(0) \in \mathbb{R}$. In the following examples we use Maclaurin's Theorem to obtain the series expansion of some standard equations. The range of validity of each expansion is left as an exercise to the reader.
	\subsection{Examples}
	\begin{example}
		\emph{Express} $e^x$ \emph{as a series expansion using the Maclaurin theorem.}
	\end{example}
	Let $f(x) = e^x$
	\begin{alignat*}{5}
		&   & f(x)    & = & e^x \quad & \Rightarrow\quad & f(0) = 1    \\
		&   & f'(x)   & = & e^x \quad & \Rightarrow\quad & f'(0) = 1   \\
		&   & f''(x)  & = & e^x \quad & \Rightarrow\quad & f''(0) = 1  \\
		&   & f'''(x) & = & e^x \quad & \Rightarrow\quad & f'''(0) = 1
	\end{alignat*}

	$$\therefore \quad e^x  = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} +\ldots + \frac{x^r}{r!} + \ldots $$
	\hrulefill
	\begin{example}
		\emph{Express} $\cos x$ \emph{as a series expansion using the Maclaurin theorem.}
	\end{example}
	\begin{alignat*}{5}
		&   & f(x)    & =           & \cos (x) \quad & \Rightarrow\quad & f(0) = 1    \\
		&   & f'(x)   & = \text{ -} & \sin (x) \quad & \Rightarrow\quad & f'(0) = 1   \\
		&   & f''(x)  & = \text{ -} & \cos(x) \quad  & \Rightarrow\quad & f''(0) = 1  \\
		&   & f'''(x) & =           & \sin (x) \quad & \Rightarrow\quad & f'''(0) = 1
	\end{alignat*}
	$$\therefore \quad \cos (x)  = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} -\frac{x^6}{6!}+\ldots + (-1)^r\times\frac{x^{2r}}{2r!} + \ldots $$\\
	The above expansion justifies the fact that when $x$ is very small and thus high powers of $x$ may be neglected, then: \boxed{\cos x \approx 1- \frac{x^2}{2}}\\
	\begin{example}
		\emph{Express} $\ln(1+x)$ \emph{as a series expansion using the Maclaurin theorem.}
	\end{example}

	\begin{alignat*}{5}
		&   & f(x)    & = & \ln(1+x)      \quad & \Rightarrow  \quad & f(0)    & = 0  \\
		&   & f'(x)   & = & (x+1)^{-1} \quad    & \Rightarrow  \quad & f'(0)   & = 1  \\
		&   & f''(x)  & = & -(1+x)^{-2}  \quad  & \Rightarrow \quad  & f''(0)  & = -1 \\
		&   & f'''(x) & = & 2(1+x)^{-3} \quad   & \Rightarrow  \quad & f'''(0) & = 2
	\end{alignat*}
	$$\therefore \quad \ln(1+x)  = x - \frac{x^2}{2} + \frac{x^3}{3} - \ldots + (-1)^{r+1}\times\frac{x^r}{r} + \ldots $$\\
	\hrulefill

	\begin{example}
		\emph{Expand} $\arcsin(x)$ \emph{up to the term in $x^3$. By putting $x=\frac{1}{2}$, find an approximate value for $\pi$}
	\end{example}

	\begin{alignat*}{5}
		& f(x)    & = & \arcsin(x)      \quad                                   & \Rightarrow  \quad & f(0)    & = 0 \\
		& f'(x)   & = & (1-x^2)^{\frac{-1}{2}} \quad                            & \Rightarrow  \quad & f'(0)   & = 1 \\
		& f''(x)  & = & x(1-x^2)^{\frac{-3}{2}}\quad                            & \Rightarrow \quad  & f''(0)  & = 0 \\
		& f'''(x) & = & 3x(1-x^2)^{\frac{-5}{2}} + (1-x^2)^{\frac{-3}{2}} \quad & \Rightarrow  \quad & f'''(0) & = 1
	\end{alignat*}
	$$\therefore \quad \arcsin(x)   = x + \frac{x^3}{3!} + \ldots $$\\
	Putting $x = \frac{1}{2}$\\
	\begin{alignat*}{2}
		&          & f\left(\frac{1}{2}\right) & = \frac{\pi}{6}                                \\
		& \implies & \pi                       & \approx 6\left(\frac{1}{2}+\frac{1}{81}\right) \\
		& \implies & \pi                       & \approx \frac{83}{27}
	\end{alignat*}
	\newpage
	\subsection{Expanding compound functions using standard functions}
	\begin{example}
		Expand $a)\quad \dfrac{e^{2x}+ e^{-3x}}{e^x}\quad b)\quad \ln\left( \dfrac{1-2x}{(1+2x)^2}\right)  $as series of ascending powers of $x$ up to the term in $x^4$. Give the general term in each case and the range of values of $x$ for which each expansion is valid.
	\end{example}
	\begin{alignat*}{2}
		a) &                  & e^x                                    & = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} +\ldots                                                                                \\
		&                  & e^{-3x}                                & = 1 + (-3)x + \frac{(-3x)^2}{2!} + \frac{(-3x)^3}{3!} + \frac{(-3x)^4}{4!} +\ldots                                                                                \\
		& \therefore \quad & e^{x} + e^{-3x}                        & = \left (1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!}\right ) + \left (1 + (-3)x + \frac{(-3x)^2}{2!} + \frac{(-3x)^3}{3!} + \frac{(-3x)^4}{4!}\right ) \\
		&                  &                                        & = 2 -2x + \frac{10x^2}{2!} - \frac{26x^3}{3!} + \frac{89x^4}{4!}                                                                                \\
		\bigskip\\
		b) &                  & \ln\left(\dfrac{1-2x}{(1+2x)^2}\right) & = \ln(1-2x) -2\left (\ln(1+2x)\right)
		\intertext{\emph{Consider $\ln(1-2x)\colon$}}
		&                  & \ln\left(1+(-2x)\right)                & = -2x + -2x^2-\frac{8x^3}{3}-4x^4 + \ldots + \frac{(-1)^{r-1}(-2x)^r}{r}+ \ldots                                                                                \\
		\intertext{\emph{Consider $\ln(1+2x)\colon$}}
		&                  & \ln\left(1+2x\right)                   & = 2x + -2x^2+\frac{8x^3}{3}-4x^4 +\ldots + \frac{-2(-1)^{r-1}(2x)^r}{r} + \ldots                                                                                \\
		& \therefore       & \ln\left(\dfrac{1-2x}{(1+2x)^2}\right) & = \left( -2x + -2x^2-\frac{8x^3}{3}-4x^4\right) -2\left(2x + -2x^2+\frac{8x^3}{3}-4x^4\right)                                                                       \\
		&                  &                                        & = -6x+2x^2-8x^3	+4x^{4}                                                                                \\
	\end{alignat*}
	\text{Range of Validity:}
	\begin{multicols}{2}
		\begin{center}
			$$	\quad\frac{(-1)^{r-1}(-2x)^r}{r} - \frac{2(-1)^{r-1}(2x)^r}{r}$$\\
			$$  =\frac{(-1)^{r-1}(-1)^r(2x)^r+2(-1)^r(2x)^r}{r}$$\\
			$$	=\frac{(-1)^{2r-1}(2x)+2(-1)^r(2x)^r}{r}$$\\
			$$	=\frac{\left( (-1)^{2r-1}+2(-1)^r\right) (2x)^r}{r}$$\\
			$$  =\frac{ \left(-1+2(-1)^r\right(2x)^r)}{r}$$
			$$ =\frac{2^r(2(-1)^r -1)x^r}{r}$$
		\end{center}
	\end{multicols}

	\begin{example}
		Expand  $\ln\left(\frac{x+1}{x}\right)\quad$as series of ascending powers of $x$ up to the term in $x^4$. Give the general term in each case and the range of values of $x$ for which each expansion is valid.
	\end{example}

	$$f(x) \ln\left(\frac{x+1}{x}\right)  = \ln\left(1+\frac{1}{x}\right ) $$

	\begin{alignat*}{5}
		&   & f(x)    & = & \ln(1+\frac{1}{x})    \quad & \Rightarrow  \quad & f(0)    & = 0  \\
		&   & f'(x)   & = & (x+1)^{-1} \quad            & \Rightarrow  \quad & f'(0)   & = 1  \\
		&   & f''(x)  & = & -(1+x)^{-2}  \quad          & \Rightarrow \quad  & f''(0)  & = -1 \\
		&   & f'''(x) & = & 2(1+x)^{-3} \quad           & \Rightarrow  \quad & f'''(0) & = 2
	\end{alignat*}

	\begin{center}
		$=\frac{1}{x} - \frac{1}{2x^2} + \frac{1}{3x^3} - \frac{1}{4x^4} + \ldots + \frac{(-1)^{r+1}}{r} $
	\end{center}
	\hrulefill
	\begin{example}
		Expand $\sin^2{x}$ using Maclaurin's series up to $x^4$
	\end{example}
	\bigskip
	$$sin^2(x)\equiv\frac{1-\cos(2x)}{2}$$
	\begin{alignat*}{2}
		\intertext{\emph{Consider} $\cos(2x)\colon$} &                 &           & =1-\frac{(2x)^{2}}{2!} + \frac{(2x)^4}{4!}  - \cdots + \frac{(-1)^r(2x)^{2r}}{(2r)!}+\cdots           \\
		&                 &           & =1-2x^2+\frac{2x^4}{3}-\cdots+\frac{(-1)^r(2x)^{2r}}{(2r)!}+\cdots                                    \\
		& \therefore\quad & \sin^2(x) & \equiv \frac{1}{2}\left( 1-(1-2x^2+\frac{2x^4}{3}-\cdots+\frac{(-1)^r(2x)^{2r}}{(2r)!}+\cdots)\right) \\
		&                 &           & =\frac{1}{2}\left(1-1+2x^2 - \frac{2x^4}{3} +\cdots+\frac{(-1)^r(2x)^{2r}}{(2r)!}+\cdots\right)       \\
		&                 &           & =x^2-\frac{x^4}{3} +\cdots+\frac{(-1)^{r+1}(2x)^{2r}}{(2r)!}+\cdots
	\end{alignat*}
	\newpage
	\begin{example}
		Given $e^{2x}\cdot \ln{1+ax}$ find possible values for $p$ and $q$.
	\end{example}
	\begin{alignat*}{2}
		\intertext{\emph{Consider} $e^{2x}\colon$}
		&                 & e^{2x}                & = 1+2x + \frac{(2x)^2}{2!} + \frac{(2x)^{3}}{3!} +\cdots +  \frac{x^r}{r!} + \cdots           \\
		\intertext{\emph{Consider} $\ln(1+ax)\colon$}
		&                 & \ln(1+ax)             & = ax - \frac{(ax)^2}{2} + \frac{(ax)^3}{3} - \cdots + \frac{(-1)^{r+1}x^r}{r} + \cdots        \\
		& \therefore\quad & e^{2x}\cdot \ln(1+ax) & = \left(1+2x+2x^2+\frac{4x^3}{3}\right) \left(ax - \frac{a^2x^2}{2} + \frac{a^3x^3}{3}\right) \\
		&                 &                       & =ax-\frac{a^2x^2}{2}+\frac{a^3x^3}{3}+2ax^2-2a^2x^3                                           \\
		&                 &                       & =ax-\left(\frac{a^2}{2}+2a\right) x^2+\left( \frac{a^3}{3}-2a^2\right) x^3
	\end{alignat*}
	~\\
	\begin{equation*}
		\therefore\left.
		\begin{alignedat}{2}
			\hspace{0.5 in}	&&p&=a\\
			&&	\frac{a^2}{2}+2a&=\frac{-3}{2}\\
			&&	\frac{a^3}{3}-2a^2&=q
		\end{alignedat}	\right\}
	\end{equation*}

	\begin{center}
		$$ p = -3,-1 $$
		$$ q= -27, -\dfrac{7}{3}$$
	\end{center}
	\hrulefill
	\newpage
	\section{Summation of Series}
	\subsection{Method 1: Generating differences}

	\begin{example}
		Simplify $f(r)-f(r+1)$, when $f(x) = \frac{1}{r^2}$. Hence, find the sum up to $n$ terms of:\\ $$\sigma_1 = \frac{3}{1^2\cdot 2^2} + \frac{5}{2^2\cdot 3^2} + \frac{7}{3^2\cdot 4^2} + \ldots$$
	\end{example}
	~\\
	Simplifying $f(r) - f(r+1)\colon$
	\begin{alignat*}{2}
		&   & f(r)-f(r+1) & = \frac{1}{r^{2}} - \frac{1}{(r+1)^{2}} \\
		&   &             & =\frac{(r+1)^{2}-r^2}{r^2(r+1)^{2}}     \\
		&   &             & =\frac{2r+1}{r^2(r+1)^2}
	\end{alignat*}
	\textit{Generating series and adding}\\
	\textit{quantitatively equivalent terms:}
	\begin{center}
		$	\frac{1}{1^2} - \cancel{\frac{1}{2^2}}$
		$$	\cancel{\frac{1}{2^2}} - \cancel{\frac{1}{3^2}}$$
		$$	\cancel{\frac{1}{3^2}} - \cancel{\frac{1}{4^2}}$$
		$$\vdots$$
		$$\cancel{\frac{1}{n^2}} - \frac{1}{n+1^2}$$
		~\\
		$$\boxed{\therefore \quad \sigma_1 = 1 - \frac{1}{n+1^2}}$$
	\end{center}
	\hrulefill
	\begin{example}
		If $f(r) = r(r+1)!$ simplify $f(r) - f(r-1)$. Hence sum the series:\\
	\end{example}
	\begin{center}
		$\sigma_1 = 5\cdot 2! + 10\cdot 3! + 17\cdot 4! +  ... + (n^2=1)n!$\\
	\end{center}
	\hrulefill
	\begin{alignat*}{2}
		&   & f(r)-f(r-1) & =r(r+1)! - (r-1)r!  \\
		&   &             & =r(r+1)r! - (r-1)r! \\
		&   &             & =r!(r^2+r-r+1)      \\
		&   &             & =r!(r^2+1)
	\end{alignat*}
	\newpage
	\textit{Generating series and adding}\\
	\textit{quantitatively equivalent terms:}
	\begin{center}
		$\bcancel{f(2)} - f(1)$
		$$\bcancel{f(3)} - \bcancel{f(2)}$$
		$$\bcancel{f(4}) - \bcancel{f(3)}	$$
		$$\vdots$$
		$$\bcancel{f(n-1)} - \bcancel{f(n-2)}$$
		$$f(n) - \bcancel{f(n-1)}$$\\
	\end{center}
	\begin{example}
		If $f(r) = \cos2r\theta$, simplify $f(r) - f(r+1)$. Hence find $\sin3\theta + \sin5\theta + \sin7\theta$
		\hrulefill
	\end{example}
	\begin{alignat*}{2}
		&   & f(r)-f(r+1) & =\cos(2r\theta)- \cos(2(r+1)\theta)                                                                            \\
		&   &             & =-2\sin\left(\frac{2r\theta + (2r+2)\theta}{2}\right)\cdot \sin\left(\frac{ 2r\theta - 2(r+1)\theta}{2}\right) \\
		&   &             & =-2\sin(2r\theta+ \theta)\sin(-\theta)                                                                         \\
		&   &             & =2\sin(\theta[2r+1])\sin\theta
	\end{alignat*}
	\textit{Generating series and adding}\\
	\textit{quantitatively equivalent terms:}\\
	\begin{center}

		\begin{tabular}{ccccc}
			$r=1$    &   & $2\sin(3\theta)\sin(\theta)$ & $=$ & $f(1)\cancel{-f(2)}$          \\
			$r=2$    &   & $2\sin(5\theta)\sin(\theta)$ & $=$ & $\cancel{f(2)}\cancel{-f(3)}$ \\
			$r=3$    &   & $2\sin(7\theta)\sin(\theta)$ & $=$ & $\cancel{f(3)}\cancel{-f(4)}$ \\
			$\vdots$ &   & $\vdots$                     & $=$ & $\vdots$                      \\
			$r=n$    &   & $2\sin(2n+1)\sin(\theta)$    & $=$ & $\cancel{f(n)}-f(n+1)$
		\end{tabular}\\
		~\\
		\begin{alignat*}{2}
			&   & f(1) - f(n+1) & = 2\sin(\theta)\sin(2n+1)                                \\
			&   &               & =\frac{\cos(2\theta)- \cos(2\theta(n+1))}{2\sin(\theta)} \\
			&   &               & =\frac{2\sin(\theta(2r+1))\sin\theta}{2\sin(\theta)}     \\
			&   &               & =\frac{sin((n=1)\theta)\sin(n\theta)}{\sin(\theta)}
		\end{alignat*}
	\end{center}

	\subsection{Method 2: Using partial fractions}
	A special case of the previous method can happen to imply a partial fraction decomposition.

	\begin{example}
		Decompose $\frac{1}{r(r+1)}$. Hence find the sum of $$\sigma_1 = \frac{1}{1\cdot 2} + \frac{1}{2\cdot 3} + \frac{1}{3\cdot 4} + \cdots$$
	\end{example}~\\
	\textit{Decomposing:}
	$$\frac{1}{r(r+1)} \equiv \frac{1}{r} - \frac{1}{r-1}$$
	{Generating series and adding}\\
	{quantitatively equivalent terms:}\\
	\begin{center}
		\begin{tabular}{ccccc}
			$r=1$    &   & $\frac{1}{1}$          & $-$ & $\cancel{\frac{1}{2}}$\linebreak \\
			&&&\\
			$r=2$    &   & $\cancel{\frac{1}{2}}$ & $-$ & $\cancel{\frac{1}{3}}$           \\
			&&&\\
			$r=3$    &   & $\cancel{\frac{1}{3}}$ & $-$ & $\cancel{\frac{1}{4}}$           \\
			&&&\\
			$\vdots$ &   & $\cancel{\vdots}$      & $-$ & $\cancel{\vdots}$                \\
			&&&\\
			$r=n$    &   & $\cancel{\frac{1}{n}}$ & $-$ & $\frac{1}{n+1}$                  \\
		\end{tabular}\\
	\end{center}
	\begin{alignat*}{2}
		& \therefore \quad & \sigma_1 & = 1 - \frac{1}{n+1}                                  \\
		\intertext{Finding convergent value: }
		&                  & 1        & =\lim_{x \to \infty} \left( 1 - \frac{1}{n+1}\right)
	\end{alignat*}
	\hrulefill
	\newpage
	\begin{example}
		Find $\quad \sum_{r=3}^n \frac{2}{(r-1)(r+1)}$
	\end{example}
	\begin{alignat*}{2}
		\intertext{Consider $\frac{2}{(r-1)(r+1)}\colon$}
		&   & \frac{2}{(r-1)(r+1)}                                      & \equiv \frac{1}{r-1} - \frac{1}{r+1}                           \\
		&   & \therefore \quad \sum_{r=3}^n \dfrac{2}{(r-1)(r+1)} \quad & \equiv \quad  \sum_{r=3}^n \dfrac{1}{(r-1)} - \dfrac{1}{(r+1)} \\
	\end{alignat*}
	{Generating series and adding}\\
	{quantitatively equivalent terms:}\\
	\subsection{Method 3: Using standard results}

	\subsection{Method 4: Comparing to standard results}

\end{document}e


\section{Concluding Locality! and CW-complexes}
Again recall what $\sca$-small covers, etc. are. We want to prove that:
\begin{theorem}
$S^\sca_\ast(X)\hookrightarrow S_\ast(X)$ is a quasi-isomorphism, i.e., an isomorphism on homology.
\end{theorem}
We developed the subdivision operator $\$^k:S_\ast(X)\to S_\ast(X)$, and proved that it's a chain map. We showed that $T_k:\$^k\sim 1$.
\begin{proof}[Proof of locality]
We want to prove surjectivity of $ H_n(S^\sca_\ast(X))\to H_n(S_\ast(X))= H_n(X)$. Let $c\in Z_n(C_\bullet)(X)$. We want to find an $\sca$-small $n$-cycle that is homologous to $c$. There's only one thing to do. Pick $k$ such that $\$^k c$ is $\sca$-small. This is a cycle because $d\$^k c=\$^k dc=0$ because $\$^k$ is a chain map. I want to compare this new cycle with $c$. Consider the chain homotopy $T_k$; then: $dT_k c+T_kdc=\$^kc-c$. But $dc=0$, so $\$^k c - c=dT_k c$, so they differ by a boundary, and they're homologous.

Now for injectivity. Suppose $c\in S^\sca_n(X)$ with $dc=0$. Suppose that $c=db$ for some $b\in S_{n+1}(X)$, not necessarily $\sca$-small. We want $c$ to be a boundary of an $\sca$-small chain. Well:
\begin{align*}
& dT_kb+T_kdb=\$^k b-b\\
\Rightarrow& dT_kb+T_kc=\$^k b-b\\
\Rightarrow& d(dT_kb+T_kc)=\$^kb-b=dT_kc=d\$^k b-c\\
\Rightarrow& c=d\$^kb-dT_kc=d(\$^k b-T_kc)
\end{align*}
Now, $\$^k$ is $\sca$-small. Is $T_kc$ also $\sca$-small? I claim that it is. Why? It is enough to show that $T_k\sigma$ is $\sca$-small if $\sigma$ is. We know that $\sigma=\sigma_\ast\iota_n$. Because $\sigma$ is $\sca$-small, we know that $\sigma:\Delta^n\to X$ is the composition $i_\ast\overline{\sigma}$ where $\overline{\sigma}:\Delta^n\to A$ and $i:A\to X$ is the inclusion for some $A\in\sca$. This means that $T_k\sigma=T_ki_\ast\overline{\sigma}=i_\ast T_k\overline{\sigma}$, which certainly is $\sca$-small.
\end{proof}
``Are you happy? You should be very happy, because we've finished our first portion of this course. We now have a whole package of homology.''
\subsection{CW-complexes}
Simplicial complexes are rigid and combinatorial. But manifolds are smooth. In between, you have CW-complexes. (A lot of advertisement for this.) We want to ``glue'' things. This is the pushout construction. Namely, if you have $i:A\hookrightarrow B$ and $f:A\to X$, then you define $X\cup_f B$ (or $X\cup_A B$) via:
\begin{equation*}
\xymatrix{A\ar[r]^f\ar@{^(->}[d]_i & X\ar[d]\\
B\ar[r] & X\cup_f B}
\end{equation*}
defined by $X\cup_f B=X\sqcup B/\sim$ where $\forall a\in A$, $f(a)\sim a$. This is $X$ with $B$ attached along $f$. There are two kinds of equivalence classes, namely elements of $B-A$, because anything not in $A$ is just a singleton. The other is $\{x\}\cup f^{-1}(x)$ for $x\in X$, because anything that's not in $\img f$ is a singleton, but if something is in $\img f$, you identify it with its preimage. This is what it is as a set. It has a universal property. Suppose you have another space $Y$.
\begin{equation*}
\xymatrix{A\ar[r]^f\ar@{^(->}[d]_i & X\ar[d]^j\ar[ddr]^{\overline{j}} & \\
B\ar[r]\ar[drr]_{\overline{g}} & X\cup_f B\ar@{-->}[dr] & \\
 & & Y}
\end{equation*}
such that $\overline{j}f=\overline{g}i$. The topology is right too because that's what the quotient topology does for you. As I wrote before, this is called a \emph{pushout} of the following diagram:
\begin{equation*}
\xymatrix{A\ar[r]^f\ar@{^(->}[d]_i & X\\
B &}
\end{equation*}
\begin{example}
Let $X=\ast$. Then you have a pushout:
\begin{equation*}
\xymatrix{A\ar[r]^f\ar@{^(->}[d]_i & \ast\ar[d]\\
B\ar[r] & \ast\cup_f B}
\end{equation*}
So then $\ast\cup_f B=B/A$.
\end{example}
\begin{example}
\begin{equation*}
\xymatrix{\emptyset\ar[r]^f\ar@{^(->}[d]_i & X\ar[d]\\
B\ar[r] & X\cup_f B}
\end{equation*}
It's then clear that this is exactly $X\sqcup B$.
\end{example}
\begin{example}
If both:
\begin{equation*}
\xymatrix{\emptyset\ar[r]^f\ar@{^(->}[d]_i & \ast\ar[d]\\
B\ar[r] & \ast\cup_f B}
\end{equation*}
So $B/\emptyset=\ast\sqcup B$. For example, $\emptyset/\emptyset=\ast$. This is ``creation from nothing''. ``We won't get into the religious ramifications.''
\end{example}
\begin{example}[Attaching a cell, the most important]
Consider:
\begin{equation*}
\xymatrix{S^{n-1}\ar[r]^f\ar@{^(->}[d]_i & X\ar[d]\\
D^n\ar[r] & X\cup_f D^n}
\end{equation*}
This is called attaching a ``cell''. The $D^n$ is what's called a cell. You're attaching a contractible space. You might want to generalize this a little bit:
\begin{equation*}
\xymatrix{\coprod_{\alpha\in A}S^{n-1}_\alpha\ar[r]^f\ar@{^(->}[d]_i & X\ar[d]\\
\coprod_{\alpha\in A}D^n_\alpha\ar[r] & X\cup_f \coprod_{\alpha\in A}D^n_\alpha}
\end{equation*}
\end{example}
What are some examples? When $n=0$, the declaration is that $S^{-1}=\emptyset$, so this is:
\begin{equation*}
\xymatrix{\emptyset\ar[r]^f\ar@{^(->}[d]_i & X\ar[d]\\
\coprod_{\alpha\in A}\ast\ar[r] & X\cup_f \coprod_{\alpha\in A}\ast}
\end{equation*}
You're just adding a bunch of points to $X$. This is a little more interesting. What about:
\begin{equation*}
\xymatrix{S^0\sqcup S^0\ar[r]^f\ar@{^(->}[d]_i & \ast\ar[d]\\
D^1\sqcup D^1\ar[r] & \ast\cup_f (D^1\sqcup D^1)}
\end{equation*}
Then $\ast\cup_f(D^1\sqcup D^1)$ is a figure $8$, because you have two $1$-disks, where you identify the four boundary points together. If we consider $(X,\ast),(Y,\ast)$, then $X\vee Y:= X\sqcup Y/\ast\sim \ast$. So $\ast\cup_f(D^1\sqcup D^1)=S^1\vee S^1$. More interestingly:
\begin{equation*}
\xymatrix{S^1\ar[r]^{aba^{-1}b^{-1}}\ar@{^(->}[d]_i & S^1\vee S^1\ar[d]\\
D^2\ar[r] & (S^1\vee S^1)\cup_f D^2}
\end{equation*}
This is exactly the torus, i.e., $(S^1\vee S^1)\cup_f D^2=T^2$.
\begin{definition}
A \emph{CW-complex} is a space $X$ with a sequence of subspaces $\emptyset=X_{-1}\subseteq X_0\subseteq X_1\subseteq\cdots\subseteq X$ (could be an infinite sequence) such that for all $n$, there is a pushout diagram like this:
\begin{equation*}
\xymatrix{\coprod_{\alpha\in A_n}S^{n-1}_\alpha\ar[r]^f\ar@{^(->}[d]_i & X_{n-1}\ar[d]\\
\coprod_{\alpha\in A_n}D^n_\alpha\ar[r] & X_{n}}
\end{equation*}
And $X=\bigcup X_n$, topologically (i.e. $A\subseteq X$ is open if and only if $A\cap X_n$ is open for all $n$). Often, $X_n=\mathrm{Sk}_n(X)$, called the $n$-skeleton, in honor of Halloween (coming right up!), of $X$.
\end{definition}
\begin{example}
The torus is $\emptyset\subseteq T^2_0\subseteq T^2_1\subseteq T^2$. Here, $T^2_0=\ast$ and $T^2_1=S^1\vee S^1$.
\end{example}
\begin{definition}
A CW-complex is \emph{finite-dimensional} if $X_n=X$ for some $n$. Say that $X$ is of \emph{finite type} if each $A_n$ is finite, i.e., finitely many cell in each dimension. Say that $X$ is \emph{finite} if it's finite-dimensional and of finite type.
\end{definition}
In CW, the C is for cell, and the W is for weak, because of the topology on a CW-complex. This definition is due to J. H. C. Whitehead. Some people say that the ``CW'' comes from his name.
\begin{theorem}
\begin{enumerate}
\item Any CW-complex is Hausdorff, and it's compact if and only if it's finite.
\item Any compact smooth manifold admits a CW structure.
\end{enumerate}
\end{theorem}
\begin{proof}
Not going to do this.
\end{proof}
Note that there could be multiple CW-structures on something.


\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\usepackage{listings}
\usepackage{soul}
\usepackage{tcolorbox}

\title{Problem Set 3: Free probability}

\date{Depth First Learning Week 4}

\begin{document}
\maketitle

\section*{Problem 1: Why we need free probability}

Relevant readings: Livan textbook, chapter 17: \emph{Born to Be Free}

In the upcoming lectures, we will encounter the concept of free independence of random matrices.  As a reminder, in standard probability theory (of scalar-valued random variables), two random variables $X$ and $Y$ are said to be independent if their joint pdf is simply the product of the individual marginals, i.e.
\begin{equation}
    p_{X,Y}(x,y) = p_X(x) p_Y(x)
\end{equation}
When we have independent scalar random variables $X$ and $Y$, then in principle it is possible to calculate the distribution of any function of these variables, say the sum $X + Y$ or the product $XY$.

When it comes to random matrices, we are often interested in calculating the spectral density (the probability density of eigenvalues) of the sum or product of random matrices.  In the \emph{Resurrecting the Sigmoid} paper, for example, we will calculate the spectral density of the network's input-output Jacobian, which is the product of several matrices for each layer.  So we need an analogue of independent variables for matrices (this condition is known as \emph{free independence}), such that if we know the spectral densities of each one, we can calculate spectral densities of sums and products.

The simplest condition we might imagine under which two matrix-valued random variables (or, equivalently, two matrix ensembles) being freely independent is that all of the entries of each matrix are mutually independent.  However, it turns out that this condition is not good enough! In other words, independent entries sometimes are not enough to destroy all possible angular correlations between the eigenbases of two matrices. Instead, the property that generalizes statistical independence to random matrices is stronger and known as \textit{freeness}.

 In this problem, we will see a concrete example of matrix ensembles with mutually independent entries, yet knowing the eigenvalue spectral density of each ensemble is not enough to determine the eigenvalue spectral density of the sum.

Define three different ensembles of 2 by 2 matrices:

\begin{itemize}
    \item \textbf{Ensemble 1:} To sample a matrix from ensemble 1, sample a standard Gaussian scalar random variable $z$ and multiply it by each element in the matrix $\sigma_z$, where
    \begin{equation}
        \sigma_z = \left( \begin{array}{cc} 1 & 0 \\ 0 & -1 \end{array} \right)
    \end{equation}
    Thus the sampled matrix will be $z \sigma_z$.
    \item \textbf{Ensemble 2:} To sample a matrix from ensemble 2, sample a standard Gaussian  scalar random variable $z$ and multiply it by each element in the matrix $\sigma_x$, where
    \begin{equation}
        \sigma_x = \left( \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right)
    \end{equation}
    Thus the sampled matrix will be $z \sigma_x$.
\end{itemize}

\begin{enumerate}[label=(\alph*)]
\item What is the spectral density $\rho_1(x)$ of eigenvalues of matrices sampled from ensemble 1?

\begin{tcolorbox}
\textbf{Solution:}
The eigenvalues of $\sigma_z$ are $\pm 1$,  so the spectral density $\rho_1(x)$ will be identical to the probability density of $z$ except for a factor of $2$ (because it has to integrate to $2$, the number of eigenvalues, instead of $1$) namely
\begin{equation}
    \rho_1(x) = \frac{\sqrt{2}}{\sqrt{\pi}} e^{-x^2/2}
\end{equation}
\end{tcolorbox}

\item What is the spectral density $\rho_2(x)$ of eigenvalues of matrices sampled from ensemble 2?

\begin{tcolorbox}
\textbf{Solution:}
The eigenvalues of $\sigma_x$ are exactly the same as those of $\sigma_z$, namely $\pm 1$,  so the spectral density $\rho_2(x)$ is the same as $\rho_1(x)$:
\begin{equation}
    \rho_2(x) = \frac{\sqrt{2}}{\sqrt{\pi}} e^{-x^2/2}
\end{equation}
\end{tcolorbox}

You should have found above that the spectral densities of both ensembles are the same.  However, we will see now that simply knowing the spectral density is not enough to determine the spectral density of the sum.
\item Let $A$ and $B$ be two matrices independently sampled from ensemble 1.  Calculate \emph{analytically} the spectral density of the sum, $A + B$.
\begin{tcolorbox}
\textbf{Solution:}
We can write this matrix as $(z_1 + z_2)\sigma_z$, where $z_1$ and $z_2$ are standard normal variables.  The eigenvalues are thus $\pm (z_1 + z_2)$.  Since $z_1$ and $z_2$ are independent, their sum will be a zero-mean Gaussian with variance $2$.  So the spectral density of eigenvalues will be twice that of such a Gaussian, namely:
\begin{equation}
    \rho_{A+B}(\lambda) = \frac{1}{\sqrt{\pi}} e^{-\lambda^2/4}
\end{equation}

\end{tcolorbox}

\item Now let $C$ be a matrix sampled from ensemble 2.  In the next part, you will calculate the spectral density of the sum $A + C$, where $A$ is drawn from ensemble 1 and $C$ is drawn from ensemble 2.  However, to see immediately that the distributions of $A+B$ and $A+C$ will be different, consider the behavior of the spectral density of $A+C$ at zero.  Based on your knowledge of avoided crossings from the previous problem set, \textbf{describe the spectral density of $A+C$ at $\lambda =0$ and contrast this to the spectral density of $A+B$}.

\begin{tcolorbox}
\textbf{Solution:}
Notice that the matrix $A+C$ will have the same form as the matrix considered in the previous problem set, and we found that for such a matrix the presence of the off-diagonal term caused their to be a level repulsion.  So, the eigenvalue spectral density should go to zero as $\lambda$ approaches zero, for the matrix $A+C$.  However, in the above part, we calculated that for matrices $A+B$, there is no avoided crossing and the pdf is finite at $\lambda = 0$.
\end{tcolorbox}

\item Now let $C$ be a matrix sampled from ensemble 2.  Calculate the spectral density of the sum, $A + C$.  Make sure this is consistent with what you argued above about the behavior at $\lambda = 0$.

\begin{tcolorbox}
\textbf{Solution:}
Writing $z_1$ and $z_2$ as standard independent Gaussian random variables, the matrix we are after is $z_1 \sigma_z + z_2\sigma_x$, or
\begin{equation}
    \left( \begin{array}{cc} z_1 & z_2 \\ z_2 & -z_1 \end{array} \right)
\end{equation}
Diagonalizing, we get $\lambda = \pm \sqrt{z_1^2 + z_2^2}$.  Then we can find the pdf of $\lambda$ using:
\begin{equation}
    p_{|\Lambda|}(\lambda) = \frac{1}{2\pi} \int~dz_1 ~\int~dz_2 e^{-z_1^2/2}e^{-z_2^2/2} \delta \left(\lambda - \sqrt{z_1^2 + z_2^2}\right)
\end{equation}
Convert this to polar coordinates:
\begin{equation}
    p_{|\Lambda|}(\lambda) = \frac{1}{2\pi} \int_0^\infty ~2\pi r ~dr~ e^{-r^2/2}\delta(\lambda - r)
\end{equation}
So $p_{|\Lambda|}(\lambda) = \lambda e^{-\lambda^2/2}$.  That was for the positive eigenvalue, and since they come in pairs we get
\begin{equation}
    p_\Lambda(\lambda) = \frac{1}{2}|\lambda| e^{-\lambda^2/2}.
\end{equation}

As expected, this has a zero at $\lambda=0$, and is markedly different from the Gaussian pdf we got previously.
\end{tcolorbox}

Notice that the answers you got in the previous two parts were different, even though the underlying matrices that were being added had the same spectral density and independent entries.

\end{enumerate}

\section*{Problem 2: Using the tools of free probability theory}

Relevant readings: Livan textbook, chapter 17: \emph{Born to Be Free}

From the last problem, you learned that if you're given two different random matrix ensembles, and you know the spectral density of the eigenvalues of each one, that might not be enough to determine the eigenvalue distribution of the sum (or product) of the two random matrices, \emph{even if all of the entries of the two matrices are mutually independent!}   As we mentioned in the last problem, the (stronger) condition that we are after is known as \emph{free independence}.  In general, proving that two matrix ensembles are ``free" (freely independent) is quite tough, so we will not do that here.  Instead, we will look at the tools we use to do calculations \emph{assuming} we have random matrix ensembles which are freely independent.

Specifically, we will show that the sum of two freely independent random matrices, each of whose spectral density is given by a semicircle, is also described by the semicircle distribution.

\begin{enumerate}[label=(\alph*)]
\item Recall that the spectral density of the Gaussian orthogonal ensemble (in the large $N$ limit) is given by the semicircle law:
\begin{equation}
    \rho_{sc}(x) = \frac{1}{\pi}\sqrt{2-x^2}
\end{equation}
(sometimes you see this  with a $4$ or $8$ in the square root and a different factor accompanying $\pi$ in the denominator.  This is just a matter of choosing which Gaussian ensemble---orthogonal, unitary, or symplectic---to use, and doesn't really matter for this problem)

In a previous problem set, you calculated the Stieltjes transform associated with the spectral density for the Gaussian \emph{unitary} ensemble.  Recall that the Stieltjes transform, $G(z)$, is defined via the relation
\begin{equation}
     G(z) = \int_\mathbb{R}~dt \frac{\rho(t)}{z - t}
\end{equation}

(In the previous problem set, this was called $s_{\mu_N}(z)$.  In literature you often see the $G(z)$ notation, since the Stieltjes transform is also known as the \emph{resolvent} or \emph{Green's function}.)

You should have calculated in the last problem set that under the Stieltjes transform,
\begin{equation}
    \frac{1}{2\pi}\sqrt{4-x^2} \mapsto \frac{z - \sqrt{z^2 - 4}}{2}
\end{equation}

\textbf{Use the above fact to calculate the Stieltjes transform of the GOE semicircle given at the beginning of this problem (part (a)).  This is the first step to calculating the spectral density of the sum.}

\begin{tcolorbox}
\textbf{Solution}:
Define
\begin{eqnarray}
    f(x) &=& \frac{1}{2\pi}\sqrt{4 - x^2} \\
    g(x) &=& \frac{1}{\pi}\sqrt{2 - x^2}
\end{eqnarray}
Notice that
\begin{equation}
    g(x) = \sqrt{2} f(x\sqrt{2}).
\end{equation}
If we define $G_g(z)$ and $G_f(z)$ as the Green's functions corresponding to $g(x)$ and $f(x)$, respectively, then we can get a relation between the two:
\begin{eqnarray}
    G_g(z) &=& \int~dt~\frac{g(t)}{z - t} \\
    &=& \sqrt{2}\int~dt~\frac{f(t\sqrt{2})}{z - t} \\
    &=& \sqrt{2}\int~\frac{dy}{\sqrt{2}} \frac{f(y)}{z - y/\sqrt{2}} \\
    &=& \sqrt{2}\int~dy~\frac{f(y)}{z\sqrt{2} - y} \\
    &=& \sqrt{2}G_f(z\sqrt{2}).
\end{eqnarray}
Since we have previously calculated that
\begin{equation}
    G_f(z) = \frac{z - \sqrt{z^2 - 4}}{2},
\end{equation}
this immediately gives us that
\begin{equation}
    G_g(z) = z - \sqrt{z^2 - 2}.
\end{equation}
\end{tcolorbox}

\item  We have calculated the Stieltjes transform or Green's function of the semicircle.  Now we proceed to calculate the so-called Blue's function, which is just defined as the functional inverse of the Green's function.  That is, the Green's function $G(z)$ and the Blue's function $B(z)$ satisfy
\begin{equation}
    G(B(z)) = B(G(z)) = z.
\end{equation}
\textbf{Calculate the Blue's function corresponding to the semicircle Green's function you derived above.}

\begin{tcolorbox}
\textbf{Solution:}
The inverse function is defined by the relation
\begin{equation}
    z = B - \sqrt{B^2 - 2}.
\end{equation}
Then
\begin{eqnarray}
    \sqrt{B^2 - 2} &=& B - z \\
    B^2 - 2 &=& B^2 - 2Bz + z^2 \\
    2Bz &=& z^2 + 2 \\
    B &=& \frac{z}{2} + \frac{1}{z}
\end{eqnarray}
\end{tcolorbox}

\item You should have noticed that the Blue's function you calculated had a singularity at the origin, that is, a term given by $1/z$.  The $R$-transform is defined as the Blue's function minus that singularity; that is,
\begin{equation}
    R(z) = B(z) - \frac{1}{z}.
\end{equation}
\textbf{What is the $R$-transform of the GOE semicircle?}

\begin{tcolorbox}
Since
\begin{equation}
    B = \frac{z}{2} + \frac{1}{z},
\end{equation}
we can immediately write
\begin{equation}
    R(z) = \frac{z}{2}
\end{equation}
\end{tcolorbox}

\item Finally we come to the law of addition of freely independent random matrices:  If we are given freely independent random matrices $X$ and $Y$, whose $R$-transforms are $R_X(z)$ and $R_Y(z)$, respectively, then the $R$-transform of the sum (or more precisely, the $R$-transform of the spectral density of the sum $X + Y$) is simply given by $R_X(z) + R_Y(z)$.

Assume that two standard GOE matrices, say $H_1$ and $H_2$, are freely independent. \textbf{What is the $R$-transform of the spectral density of the sum $H_+ = pH_1 + (1 - p) H_2$?}

\begin{tcolorbox}
\textbf{Solution:}
$R_{H_+}(z) = z$
\end{tcolorbox}

\item \textbf{Using the results above, argue that the sum of two freely-independent ensembles described by the semicircular law is also described by the semicircular law.}

\begin{tcolorbox}
\textbf{Solution:}

The $R$-transform of the sum ($z$) has the same functional form as the individual $R$-transforms ($z/2$), so it seems plausible that this means that when we invert it, we get a semicircle.  Let's make sure of this fact.

We should first figure out how the scaling of the $R$-transform affects the scaling of the matrix it is describing.  We can guess that this amounts to a simple scaling of the matrix itself.  Under the scaling of a general matrix $H \mapsto cH$, the eigenvalue distribution goes from $\rho(\lambda) \mapsto \rho(\lambda/c) /c $.  Then, by the same logic we used in part (a) of this problem, the Green's function goes $G \mapsto G(z/c)/c$ (in part (a), $c$ was $\sqrt{2}$).  To figure out the change in the Blue's function, we can write:
\begin{eqnarray}
    G_{pH}(B_{pH}(z)) = \frac{1}{p} G_{H}(B_{H}(z)/p) = z \\
     G_{H}(B_{H}(z)/p) = pz \\
     B_{pH}(z) = p B_H(pz) \\
\end{eqnarray}
And finally we can get the scaling of the $R$-transform:
\begin{eqnarray}
    R_{pH}(z) &=& pB_H(pz) - \frac{1}{z} \\
    &=& p\left( R_H(pz) + \frac{1}{pz} \right) - \frac{1}{z} \\
    &=& p R_H(pz)
\end{eqnarray}
With this result, we know that if we multiply the GOE matrix by $\sqrt{2}$, the $R$-transform goes from $z/2$ to $z$.  This means that the spectral density of a sum of two GOE matrices is still semicircular, just with a $\sqrt{2}$ scaling.  Another way of saying this is that the semicircular law is stable under free addition.
\end{tcolorbox}

\end{enumerate}

\section*{Problem 3: Another toy example of free addition}

Relevant readings: Partial freeness of random matrices, section 1.3

Though proving that two random matrices are freely independent is tough (and only strictly defined in the limit that the matrix dimension goes to infinity), as the reading suggests, we can approximate two matrices as freely independent if their eigenbases are oriented uniformly randomly with respect to each other.  In this problem, we'll see a toy example of such a situation, and get more experience using the tools of free probability.

\begin{enumerate}[label=(\alph*)]

\item Take random matrix $A$ to be the following:
\begin{equation}
    A(t) = U(t) \sigma_z U(-t),
\end{equation}
where $\sigma_z$ was defined in problem 1 above and $U(t)$ is a rotation matrix given by
\begin{equation}
        U(t) = \left( \begin{array}{cc} \cos{t} & \sin{t} \\ -\sin{t} & \cos{t} \end{array} \right).
\end{equation}
The randomness here comes from $t$, which is sampled uniformly from the interval $\left[0, 2\pi\right)$.

\textbf{What is the spectral density of eigenvalues $\rho(x)$ of this random matrix ensemble?}

\begin{tcolorbox}
\textbf{Solution:}
As described in problem 1, the matrix $\sigma_z$ has eigenvalues $\pm 1$, and we know that conjugation by a unitary operator does not change the eigenvalues.  So the eigenvalue spectral density is given by
$$\rho(x) = \delta(x - 1) + \delta(x + 1)$$,
with $\delta(x)$ denoting the Dirac delta function.
\end{tcolorbox}

\item Take `random' matrix $B$ to be the following: \begin{equation}
    B(t) = \sigma_z,
\end{equation}
with the same definitions as above.

\textbf{What is the spectral density of eigenvalues $\rho(x)$ of this random matrix ensemble?}

\begin{tcolorbox}
\textbf{Solution:}
Since the matrix is deterministic and has eigenvalues at $\pm 1$, we can immediately write
$$\rho(x) = \delta(x - 1) + \delta(x + 1)$$
\end{tcolorbox}

\item If we sample from $A$, calculate the eigenbasis of the sampled matrix, then sample from $B$, and again calculate the eigenbasis of the sampled matrix, we can define the angle between the eigenbases of the two matrices by the angle which would be required to rotate one eigenbasis into the other. Equivalently, we can call it the angle of the rotation matrix required to transform one matrix into the other \textbf{For matrix ensembles $A$ and $B$, what is the distribution of the angle between their eigenbases?}

\begin{tcolorbox}
\textbf{Solution:}
The angle of $B$ is always fixed (since the eigenvectors of $\sigma_z$ are always the constant vectors $(1 ~ 0)^T$ and $(0 ~  1)^T$), so let's call it zero.  The angle of $A$ is $t$, which is uniformly distributed along  $\left[0, 2\pi\right)$.  So this is also the distribution of the difference in angles.
\end{tcolorbox}

\item You should have found that the spectral densities of both ensembles $A$ and $B$ are identical and that the distribution of angles between their eigenbases is Uniform($(0,2\pi])$. Remember, according to the readings, we can call $A$ and $B$ freely independent if their eigenbases are oriented uniformly randomly with respect to each other.

Now we imagine adding the random variables $A$ and $B$.  In part (c), you found that the eigenbases of $A$ and $B$ are rotated uniformly randomly with respect to each other. As per the readings, we can now treat $A$ and $B$ as if they are freely independent and consequently use the property of freely independent random matrices that their $R$-transforms add under free addition.

(i) \textbf{Go through the same steps as in the previous problem to calculate the $R$-transform corresponding to that spectral density.} As a reminder, here's the recipe:
    \begin{itemize}
        \item Calculate Green's function via
        \begin{equation}
         G(z) = \int_\mathbb{R}~dt \frac{\rho(t)}{z - t}
        \end{equation}

        \item Calculate the Blue's function via the relation
        \begin{equation}
            G(B(z)) = B(G(z)) = z.
        \end{equation}

        \item Check that the Blue's function has a $1/z$ singularity at the origin, and subtract it to get the $R$-transform:
        \begin{equation}
            R(z) = B(z) - 1/z.
        \end{equation}
    \end{itemize}

\begin{tcolorbox}
\textbf{Solution:}
Since $\rho(x) = \frac{1}{2}(\delta(x+1) + \delta(x-1))$\footnote{For the Green's functions we use spectral densities normalized as if they were a probability distribution, i.e. which integrate to unity}, we have that
\begin{eqnarray}
G(z) &=& \frac{0.5}{z-1} + \frac{0.5}{z+1} \\
&=& \frac{z}{z^2 - 1}
\end{eqnarray}
Since the blue and Green functions are inverses of each other, this means
\begin{equation}
    z = \frac{B(z)}{B^2(z)-1},
\end{equation}
or
\begin{equation}
    -z + zB^2 - B = 0.
\end{equation}
Using quadratic formula gives
\begin{equation}
    B = \frac{1 \pm \sqrt{1 + 4 z^2}}{2z}.
\end{equation}

Knowing that we need the blue function to have a $1/z$ singularity at the origin tells us that we need to take the positive root, so
\begin{equation}
    B(z) = \frac{1 + \sqrt{1 + 4 z^2}}{2z}.
\end{equation}
This makes the $R$-transform
\begin{equation}
    R(z) = \frac{-1 + \sqrt{1 + 4 z^2}}{2z}.
\end{equation}

\end{tcolorbox}

(ii) Let's find the spectral density of the sum $A$ + $B$. \textbf{Calculate the $R$-transform of the sum of $A$ and $B$}.
\begin{tcolorbox}
The $R$-transform of the sum's spectral density is sum of the individual $R$-transforms, namely
\begin{equation}
    R(z) = \frac{-1 + \sqrt{1 + 4 z^2}}{z}.
\end{equation}

\end{tcolorbox}

(iii) We can now reverse the steps you did in part (d) to get the spectral density of the sum.  That is, from the $R$-transform you just calculated, you can calculate the Blue's function, then the Green's function, and finally the spectral density.  You will need the formula for going from the Green's function to the spectral density, given in chapter 8 of Livan's book:
\begin{equation}
\rho(x) = \frac{1}{\pi}\lim_{\epsilon\rightarrow 0^+} \mathrm{Im}~ G(x-i\epsilon)
\end{equation}
\textbf{Calculate the spectral density of the sum of the random matrices $A$ and $B$}

\begin{tcolorbox}
We add $1/z$ to the $R$-transform to get the blue function:
\begin{equation}
    B(z) = \frac{\sqrt{1 + 4 z^2}}{z}.
\end{equation}
Now we invert to get the Green's function:
\begin{equation}
    z = \frac{\sqrt{1 + 4 G^2}}{G}.
\end{equation}
\begin{equation}
    (z^2 - 4) G^2 = 1.
\end{equation}
\begin{equation}
    G = \pm\frac{1}{\sqrt{z^2 - 4}}
\end{equation}
To get the correct sign, we look for the $1/z$ behavior at infinity, so we take the plus sign.
Thus
\begin{equation}
    G(z) = \frac{1}{\sqrt{z^2 - 4}}
\end{equation}
To get the spectral density, let $z = x - i\epsilon$. Then
\begin{eqnarray}
    G(z) &=& \frac{1}{\sqrt{(x - i\epsilon)^2 - 4}} \\
    &=& \frac{1}{\sqrt{x^2 - 2ix\epsilon - \epsilon^2 - 4}}.
\end{eqnarray}
In the limit that $\epsilon$ goes to zero, the imaginary part will only be non-zero when $|x|$ is less than 2.  We thus arrive at
\begin{equation}
    \rho(x) = \frac{1}{\pi\sqrt{4-x^2}}
\end{equation}
\end{tcolorbox}

\item The spectral density of $A+B$ you caculated in closed form in exercise (d) part (iii) assumes $A$ and $B$ are freely independent, a fact which we attributed to the uniformly-random angle between their eigenbases. \textbf{Verify using simulations that the spectral density you calculated does in fact describe the sum $A$ + $B$.}

What does this result tell you about the free independence or partial free independence of $A$ and $B$?

\begin{tcolorbox}
\textbf{Solution:}

The following code will work:

\begin{lstlisting}
import numpy as np
import matplotlib.pyplot as plt
from functools import reduce

def sample_ensemble(n_samples):
    samples = []
    sigma_z = np.diag([1, -1])

    for i in range(n_samples):
        theta = np.random.uniform(low=0., high=2*np.pi)

        rot_theta = np.array([[np.cos(theta), -np.sin(theta)],
                              [np.sin(theta), np.cos(theta)]])

        rot_theta_dag = np.array([[np.cos(theta), np.sin(theta)],
                              [-np.sin(theta), np.cos(theta)]])

        sample = reduce(np.dot, [rot_theta, sigma_z, rot_theta_dag])
                            + sigma_z

        evals = np.linalg.eigvals(sample)
        samples.append(evals)

    return np.array(samples)

n_samples = 100000
ensemble_samples = sample_ensemble(n_samples)

empirical_density, bins = np.histogram(ensemble_samples,
                                       density=True,
                                       bins=50);
bin_centers = (bins[:-1] + bins[1:])/2.

theoretical_density = 1./(np.pi*np.sqrt(4-np.power(bin_centers, 2)))

plt.scatter(bin_centers, empirical_density)
plt.plot(bin_centers, theoretical_density)

plt.title('Spectral density')
plt.xlabel('Eigenvalue')
plt.ylabel('Density')
\end{lstlisting}

Running this code (or equivalent) should confirm that the distribution calculated for the matrices $A$ + $B$ is accurate.  This result is evidence of the connection between the uniformly random rotation between the eigenbases of $A$ and $B$, and their free independence.
\end{tcolorbox}

\item You just saw that the matrices $A$ and $B$ were freely independent, and we attributed this to the fact that in the coordinate system defined by the eigenbasis of one of the matrices, the eigenvectors of the other were uniformly distributed across the circle.  \textbf{Use this fact to argue that two matrices sampled from the Gaussian Orthogonal Ensemble or Gaussian Unitary Ensemble are freely independent.}

\begin{tcolorbox}
\textbf{Solution:}
One of the defining properties of the two listed ensembles is that they are rotationally invariant, meaning that the probability of any eigenvector is uniform.  This means that the rotation matrix between eigenvectors of two different realizations of (say) GOE matrices will also be uniformly distributed (this is known as being Haar-random, if you've seen the term before).  Thus we should expect matrices sampled independently (i.e. with all entries mutually independent) from any of these ensembles should be freely independent.
\end{tcolorbox}

\end{enumerate}

\end{document}


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{September 3, 2014}
\maketitle
\section*{$\epsilon \Delta$ definition of limit}
let $\{a_n\}_{n=1}^{\infty}$ be a sequence of real numbers. We say that L is the limit of the sequence $\{a_n\}_{n=1}^{\infty}$ if $\forall\epsilon>0$ $\exists N\in\mathbb{N}$ such that $\left\lvert a_n-L\right\rvert < \epsilon \forall n\ge N$
\subsection*{example 1}
$a_n=\frac{1}{n},n\in\mathbb{N}$

prove that
\[\lim_{n\to\infty}\frac{1}{n}=0\]
by the definition
fix $\epsilon>0$. we need to find $N$ such that $\left\lvert \frac{1}{n}-0\right\rvert<\epsilon$  if $n\ge N$. find $N$ such that $1\le\epsilon n,\forall n\ge N$.

\subsubsection*{archimedean property}
given $x>0, y\in\mathbb{R}, \exists N\in\mathbb{N},N>0$ such that $Nx>y$.

apply this to $x=\epsilon, y=1$, $\exists N$ such that $N\epsilon>1$ if $n\ge N, n\epsilon\ge N\epsilon>1$ so the archimediean property gives us the $N$ for the given $\epsilon$

\subsection*{example 2}
find
\begin{align*}
\lim_{n\to\infty}\left(\sqrt{n+1}-\sqrt{n}\right)&=
\lim_{n\to\infty}\left(\frac{\sqrt{n+1}-\sqrt{n}}{\sqrt{n+1}+\sqrt{n}}\sqrt{n+1}+\sqrt{n}\right)\\
&=\lim_{n\to\infty}\left(\frac{(n+1)-(n)}{\sqrt{n+1}+\sqrt{n}}\right)\\
&=\lim_{n\to\infty}\left(\frac{1}{\sqrt{n+1}+\sqrt{n}}\right)\\
&=0
\end{align*}
given $\epsilon>0$ we need to find $N$ such that $\left\lvert (\sqrt{n+1}-\sqrt{n}-0\right\rvert<\epsilon\forall n\ge N\rightarrow\frac{1}{\sqrt{n+1}+\sqrt{n}}<\epsilon\forall n\ge N$.

enough to find N such that $\frac{1}{2\sqrt{n}}<\epsilon\forall n\ge N$

given $\epsilon$ and $\frac{1}{2}$$\exists N\in\mathbb{N}$ such that $\frac{1}{2}<N\epsilon$. for any $n\in N$ such that $\sqrt{n}>N$ (or $n>N^2$). $\frac{1}{2}<\sqrt{n}\epsilon\rightarrow\frac{1}{2\sqrt{n}}<\epsilon\forall n>N^2$

\subsection*{example 3}
not convergent
let $a_n=2^n$.
\subsubsection*{proof}
assum $\exists L\in \mathbb{N}$ such that $\forall \epsilon>0\exists N\in\mathbb{N}$ such that $\left\lvert 2^n-L\right\rvert<\epsilon\forall n\ge N$. Take any $n>m>1, n,m\in\mathbb{N}$
\begin{align*}
  \left\lvert2^n-2^m\right\rvert&=2^m\left(2^{n-m}-1\right)>1\text{ or }2
\end{align*}
consider $\left\lvert a_n-L\right\rvert+\left\lvert a_m-L\right\rvert\ge\left\lvert(a_n-L)+(L-a_m)\right\rvert$ (triangle inequality) leads to $\left\lvert a_n-a_m\right\rvert>1$. so either $\left\lvert a_n-L\right\rvert>\frac{1}{2}$ or $\left\lvert a_m-L\right\rvert>\frac{1}{2}$ (pigeonhole). take $\epsilon>\frac{1}{2}$. Since $n,m$ are arbitrary natural numbers, we cannot find $N$ such that $\left\lvert a_n-L\right\rvert<\epsilon\forall n\ge N,$ and hence the sequence does not converge.

can use this argument with $\left\lvert a_n-a_m\right\rvert>\alpha, \alpha>0$

\section*{squeeze theorem (2.4.6)}
let $\{a_n\}_{n=1}^\infty,\{b_n\}_{n=1}^\infty,\{c_n\}_{n=1}^\infty$ be sequences of reals such that $a_n\le b_n\le c_n$ for each $n\in\mathbb{N}$. Assume
\[\lim_{n\to\infty}a_n=L=\lim_{n\to\infty}c_n\]
Then
\[\lim_{n\to\infty}b_n=L\]
\subsection*{proof}
Given $\epsilon>0$ we need to find $N\mathbb{N}$ such that $\left\lvert b_n-L\right\rvert<\epsilon\forall n\ge N$

have: an $\epsilon>0$. hopothesis: $\lim a_n=L, \lim c_n=L$

since we have $\epsilon>0$ and $\lim a_n=L$, aby definition of limit $\exists N_1$ such that $\forall n\ge N_1$, $\left\lvert L-a_n\right\rvert<\epsilon$ for the same $\epsilon>0, \exists N_2$ such that $\forall n\ge N_2$ $\left\lvert L-c_n\right\rvert<\epsilon$
\begin{align*}
  L-\epsilon&< a_n<L+\epsilon\\
  L-\epsilon&< c_n<L+\epsilon\\
  L-\epsilon&< a_n\le b_n\le c_n<L+\epsilon\\
\end{align*}

if $n\ge\max\{N_1,N_2\}$. hence if $n\ge\tilde N=\max{N_1,N_2}, \left\lvert b_n-L\right\rvert<\epsilon$

\subsection*{example 2.4.7}
variation of squeeze theorem. read it please

\section*{properties of limits}
assume $\lim_{n\to\infty}a_n,\lim_{n\to\infty}b_n$ exist
\begin{enumerate}
\item
\begin{align*}
  \lim_{n\to\infty}(a_n+b_n)=\lim a_n+\lim b_n\\
  \lim ra_n=r\lim a_n\forall r\in\mathbb{R}\\
  \lim a_nb_n=\lim a_n \lim b_n
  \lim \frac{a_n}{b_n}=\frac{\lim a_n}{\lim a_n}
\end{align*}

\end{enumerate}
let A be limit of $a_n$ B be limit of $b_n$ given $\epsilon>0$ we need to find $N\in \mathbb{N}$ such that $\forall n\ge N$ $\left\lvert a_nb_n-AB\right\rvert<\epsilon$. for this given $\epsilon$

$\exists N_1$ such that $\left\lvert a_n-A\right\rvert<\epsilon$ if $n\ge N$

$\exists N_2$ such that $\left\lvert b_n-B\right\rvert<\epsilon$ if $n\ge N$

$\left\lvert a_nb_n-AB\right\rvert=\left\lvert a_nb_n-a_nB+a_nB-AB\right\rvert\le|a_n||b_n-B|+|a_n-A||B|<\epsilon\{\max\{|A+1|,|A-1|\}+|B|\}$ provided $n\ge\max\{N_1,N_2,M\}$
\end{document}


\subsection{Text classification using Naive Bayes}

\subsubsection{Naive Bayes and text classification}

Naive Bayes can be used to classify text documents. The \(x\) variables can be appearances of each word, and \(y\) can be the document classification.