\chapter{Asymptotics for Prior Elicitation}

This chapter is a self-contained paper submitted for publication at NeurIPS.

\section{Statistical Elicitation}

% Background summary
% basics, typical terminologies etc
Elicitation is the process of forming a probability distribution from a person's knowledge and beliefs.
We will focus on the case of elicitation to obtain a prior that will be used in a subsequent machine learning task. Although most of the results will be applicable to other motivations for elicitation, narrowing the language will simplify our discussion. %to be used a prior in modeling

Classically, elicitation is a human-centered process with multiple roles:
The \emph{modeler} will ultimately do the modeling, with the elicited prior.
The \emph{facilitator} has a strategy and asks questions to gather information to use for inference.
The \emph{expert} has the knowledge that the facilitator will use.
A \emph{statistician} will train the expert on probability and provide feedback.

An individual may fill multiple roles; for example, a single individual commonly fills both the statistician and facilitator roles.
The expert may also be the modeler who will ultimately use the elicited prior.

Elicitation is a multi-stage process, typified by the following steps.  The modeler and the statistician will determine the target value in collaboration in the structuring and decomposition step. Then, during the elicitation phase there is further iteration over three steps: 1. elicit summaries, 2. fit a distribution, and 3. assess adequacy.
The elicitation process is our focus for the presented work, as the fitting and assessment steps are the primary role of the automated tool.

In higher dimensions, summaries are less intuitive and even cumbersome to communicate.  Therefore, we will, in our automated facilitator-statistican discussion, shift from eliciting summaries to eliciting samples.
Sample based elicitation has been applied in an experimental setting successfully for fitting beta distributions.

\textit{NEED TO ADD REFERENCES TO SOME SPECIFIC EXPERIMENTS}

Literature on elicitation focuses on making inferences from the type of information provided by elicitation and the related psychological literature. The psychology of elicitation relates to how people characterize uncertainty (not consistently) to what information is actually needed in order to make inferences about uncertainty that are themselves useful for further inferences.

In the Human Computer Interactive and Viszualization communities, elicitation has been studied in amazon turkers either to eval \textit{REST OF SENTENCE? -  NEED REFERENCES}

Toward the study of Bayesian modeling in a broad sense, HCI researchers have built tools for eliciting specific forms of priors. \textit{REFERENCES}

Observing how statisticians set priors revealed that the choice of visualization can impact how experienced Bayesian statisticians choose to set a prior. In designing a more general prior elicitation tool, it will be important to understand what forms of information will facilitate good inferences and to balance these forms with what pscyhological insights exist regarding how experts choose matching interfaces. Further research has examined what information experts are able to express reliably, and how visualization impact the broad strategies of the expert. \textit{REFERENCES} In this work, we consider the learnability of classes of priors from different forms of evidence toward making tool design choices.

% We may represent uncertainty in many ways: probabilities, percentages, relative frequencies, odds, or natural frequencies.
% Mathematically, these are equivalent, but research has shown that these are not always equivalent when filtered through a human mind.
% Frequencies seem to provide less biased estimates than probabilities. % get cite
% A facilitator may ask for information from the expert directly or indirectly.
% Examples of direct techniques include direct estimation, response scales and probability wheels.
% Bets are an example of an indirect format to get the information from an expert.
% Rooted in the psychological literature, there are standard techniques for debiasing judgements.
% While understanding how to elicit the probability of an event is helpful in some cases, in a more general sense, we want to elicit a whole prior distribution.
% We might be interested in different things from an expert, in particular the literature considers two main cases: eliciting the probability of a specific event and eliciting a distribution.

\section{Sample Based Elicitation}

Prior work using sample-based elicitation used a method of moments technique with weighted samples. We propose a similar elicitation procedure, but consider a distinct inference technique. Moving to a least squares based approach with a stated objective function for the prior enables cases where the moments do not exist.
% Moments do not always exist

In order to build a general automated elicitation tool, we need to consider how the tool will learn from the expert. In the end, this learning will be an online process which learns from each sample sequentially and then presents the updated model to the user for feedback.
% As a first consideration of the learnability of this objective function we consider the case of learning from i.i.d. samples in batch.
While in general, learning from correlated samples can degrade performance relative to i.i.d samples, learning from coresets constructed with a diverse sampling strategy has been shown improve learning rates \textit{REFERENCE}. In elicitation, the examples will be provided by a human expert along with given instructions. For our work, we assume this will result in samples that are more diverse than a sample directly from the distribution for two reasons. First, an expert is unlikely to give an example that is very close to a previous sample, which leads to the generation of a representative sample that explains the range of their belief. Second, the instructions can prompt the user to provide examples that are both likely and unlikely. Therefore, by examining the i.i.d case, we are obtaining a worst-case estimate of the learnability of the problem.

In this section, we present our main analytical results.
First, we will introduce our least squares based objective function.
Next, we will consider the large sample behavior of the proposed estimator
% to ensure that our proposed elicitation process is viable in a broad sense. Generally, we
by evaluating the consistency of the estimator, and we will show the conditions under which we achieve asymptotic normality. Third, we present a finite sample result.

\section*{A Least-Squares Based Approach to Elicitation}

\subsection*{Proposed Objective Function}

Assume that we elicit i.i.d. observations $x_i$ with corresponding sample likelihoods $z_i$ for $i=1,\ldots,n$. Assuming we have a parametric model class, our proposed method of estimating $\theta$ involves minimizing an objective function, which we illustrate below.

Let $Q((\vec{x},\vec{z}),\theta)=\sum_i \left( l(x_i,\theta)-z_i \right)^2$

Our proposed optimization problem is $$
\hat{\theta} = \arg \min_{\theta} \sum_i \left( l(x_i,\theta)-z_i \right)^2 = \arg \min_{\theta} Q((\vec{x},\vec{z}), \theta),$$

where $x_i,z_i$ is the $i$th sample and likelihood.

$$\frac{dQ}{d\theta} = 2 \sum_i \left( (l(x_i,\theta)-z_i) \frac{\partial}{\partial \theta}l(x_i,\theta)\right) $$

and let $\psi((x_i,z_i),\theta)=l(x_i,\theta)-z_i.$

$\hat{\theta}$ is a solution to $$\sum_i \left( (l(x_i,\theta)-z_i) \frac{\partial}{\partial \theta}l(x_i,\theta)\right) = 0$$

and

$\theta_0$ solves $$\E_{\theta_0}\left[(l(x_i,\theta)-z_i) \frac{\partial}{\partial \theta}l(x_i,\theta)\right]=0$$

\section*{Asymptotic Analysis}

Let $\Omega$ be the parameter space with an open set $\omega$ such that $\theta_0$, the true parameter value, is an interior point.

\subsection*{Consistency}

Then if $\left( (l(x_i,\theta)-z_i) \frac{\partial}{\partial \theta}l(x_i,\theta)\right)$ is monotone in $\theta$, continuous in a neighborhood of $\theta_0$, and $\theta_0$ is an isolated root, $\hat{\theta} \xrightarrow{\mathcal{P}}\ \theta_0$.

\subsection*{Asymptotic Normality}

$$\frac{\partial}{\partial \theta} \psi((x,z),\theta) = \left[ \frac{\partial}{\partial \theta}l(x,\theta) \right]^2  + (l(x,\theta)-z) \frac{\partial^2}{\partial \theta^2}l(x,\theta)$$

If $$\E_{\theta_0} \left[ \left[ \frac{\partial}{\partial \theta}l(x,\theta) \right]^2  + (l(x,\theta)-z) \frac{\partial^2}{\partial \theta^2}l(x,\theta) \right] $$ is finite and nonzero and

$$
\E_{\theta_0} \left[ \left\lbrace \left[ \frac{\partial}{\partial \theta}l(x,\theta) \right]^2  + (l(x,\theta)-z) \frac{\partial^2}{\partial \theta^2}l(x,\theta)\right\rbrace^2 \right] < \infty
$$,

then $$\sqrt{n}(\hat{\theta}-\theta_0) \xrightarrow{\mathcal{L}}\ \mathcal{N}(0,\sigma_{\hat{\theta}}^2)$$

where $$\sigma_{\hat{\theta}}^2 = \frac{\E_{\theta_0}[\psi^2((X,Z),\theta_0)]}{(\E_{\theta_0} [\frac{\partial}{\partial \theta} \psi((X,Z),\theta)|_{\theta=\theta_0}])^2}$$

\subsection{Finite Sample}

To do an elicitation, we will need to obtain a finite number of samples from an expert. While the large sample results give confidence in the general tractability of the problem, the finite sample results are important to understanding the realistic feasibility of implementing an automated elicitation tool.

For the finite sample result, the assumptions are the following \cite{Pinelis2017}:

Let $\theta_{0}\in \Theta$ be the expert's target value of the parameter $\theta$, such that
\begin{center}
	$[\theta_{0}-\delta,\ \theta_{0}+\delta]\subseteq \theta^{\circ}$
\end{center}
for some real $\delta>0$, where $\theta^{\circ}$ denotes the interior of the subset $\Theta$ of $\mathbb{R}$.

For brevity, we will use $\mathrm{P}$ and $\mathrm{E}$ throughout defined as $\mathrm{P} :=\mathrm{P}_{\theta_{0}}$ and $\mathrm{E} :=\mathrm{E}_{\theta_{0}}.$

For $x\in \mathcal{X}$ and $\theta\in \theta$, consider the function
$$
\ell_{X,Z}(\theta)=- (\ell_x(\theta)-z)^2
$$

\begin{enumerate}
	\item The set $\mathcal{X}_{>0} :=\{x\in \mathcal{X}:p_{\theta}(x)>0\}$ is the same for all $\theta\in [\theta_{0}-\delta,\ \theta_{0}+\delta],$ and for each $x\in \mathcal{X}_{>0}$ the likelihood $l_{x}(\theta)$ are thrice differentiable in $\theta$ at each point $\theta\in [\theta_{0}-\delta,\ \theta_{0}+\delta].$
	\item $\mathrm{E}\ell_{X,Z}^{'}(\theta_{0})^{2}=I_1(\theta_0)$ and $-\mathrm{E}\ell_{X,Z}^{''}(\theta_{0})=I_2(\theta_{0})\in (0,\infty)$.
	\item $\mathrm{E}|\ell_{X,Z}'(\theta_{0})|^{3}+\mathrm{E}|\ell_{X,Z}^{''}(\theta_{0})|^{3}<\infty.$
	\item $\mathrm{E} \sup |\ell_{X,Z}^{'''}(\theta)|^{3}<\infty.$
	$$
	\theta\in [\theta_0-\delta,\theta_0+\delta]
	$$
\end{enumerate}

% \subsection{Main Result}
Suppose that the above conditions hold and that $\ell_{X,Z}(\theta)$ is concave in $\theta\in \Theta$, for each $x,z\in \mathcal{X}\times \mathcal{Z}$.

Then

$$|\mathrm{P}\left(\sqrt{n \frac{I_2(\theta_{0})^2}{I_1(\theta_0)}}(\hat{\theta}-\theta_{0})\leq z\right)-\Phi(z)|\leq\frac{C}{\sqrt{n}}$$

for all real $z$, and

$$|\mathrm{P}(\sqrt{n\frac{I_2(\theta_{0})^2}{I_1(\theta_0)}}(\hat{\theta}-\theta_{0})\leq z)-\Phi(z)|\leq\frac{C_{\omega}}{z^3 \sqrt{n}}$$

for $z\in (0,\omega \sqrt{n}]$ for any $\omega\in (0,\infty)$. $C_{\omega}$ is a finite expression that depends on $\omega$ and neither $C$ and $C_{\omega}$ depend on $n$ or $z$.

\section{Experiments}

To validate our learnability results, we performed experiments using synthetic data. Throughout, we simulate the batch data that would be obtained from an elicitation by sampling a ``target" distribution and then computing the likelihood. Next, we use these data to learn the parameters of the proposed distribution class. We assess the quality of the elicitation with the $L2$ error of the learned parameters and the KL divergence for the learned distribution. Last, we generate a number of batches of data each of a fixed size and then attempt to learn from that.

\subsection{Validating the estimator and the learning rate}

First, we use exact samples without noise. We generate sample, likelihood pairs from the target distribution in fixed sizes and multiple batches. We used a batch size of 20. Then, we ran the optimization process to see how well can we learn the true distribution from these samples as we increase the number of samples in those batches.

We varied the number of samples from 2 to 40 and had 20 batches. We wanted to see for how many batches out of 20 are we able to learn the true distribution. We saw that the rate of success of elicitation was directly related to the sample size as shown below. Second, we added noise the likelihoods, assuming that our expert can give realistic samples, but may be variably good.

\section*{Proof of Theoretical Bound}
Here, we provide a theoretical proof of the main asymptotic result. This follows the technique introduced in \cite{Pinelis2017} for maximum likelihood estimators. Pinelis briefly states that his result could be extended to M-estimators, and in the following, we fully exposit the proof for the general class of M-estimators, which requires adjustments to the assumptions in \cite{Pinelis2017}.

This proof is organized as follows.

\begin{enumerate}
	\item We describe the general problem setting and assumptions required.
	\item We demonstrate tight bracketing of our M-estimator between two functions of the sum of independent random vectors.
	\item We present uniform and nonuniform optimal-order bounds on the convergence rate in the multivariate delta method \cite{Pinelis2016}.
	\item We apply the general bounds in the multivariate delta method such that we can make bracketing work.
	\item We bound the remainder and show this is asymptotically negligible under certain conditions.
\end{enumerate}

\subsection*{Setting and Assumptions}

Let $X, X_1, X_2, \ldots$ be random variables mapping from $(\Omega, \mathcal{A})$ to $(\mathcal{X},\mathcal{B})$ and let $(P_{\theta})_{\theta\in \Theta}$ be a parametric family of probability measures such that $X, X_1, X_2, \ldots$ are i.i.d. with respect to each of the measures $P_{\theta}$ with $\theta \in \Theta$. Importantly, $\Theta\subseteq \mathbb{R}$, i.e. the parameter space $\Theta$ is a subset of the real line.

Let $E_{\theta}$ be the expectation with respect to $P_{\theta}$. For each $\theta\in \Theta$, $P_{\theta} X^{-1}$ of $X$ has a density $p_{\theta}$ with respect to a measure $\mu$ on $\mathcal{B}$.

Because the extended real line $[-\infty,\infty]$ is compact, for each $n\in \mathbb{N}$ and point $x=x_n=(x_1,\ldots,x_n)\in \mathcal{X}^n$, the function $\Theta\ni \theta\mapsto \ell_{X,Z}(\theta) = \sum_{i=1}^n -(l_{x_i}(\theta)-z_i)^2 $ has at least one generalized maximizer $\hat{\theta}_n(x)$ in the closure of $\Theta$.

Let $\theta_{0}\in \Theta$ be the expert's target value of the parameter $\theta$, such that
\begin{center}
	$[\theta_{0}-\delta,\ \theta_{0}+\delta]\subseteq \theta^{\circ}$
\end{center}
for some real $\delta>0$, where $\theta^{\circ}$ denotes the interior of the subset $\Theta$ of $\mathbb{R}$.

For convenience, we provide the assumptions for $\ell$ again below.

\begin{enumerate}
	\item The set $\mathcal{X}_{>0} :=\{x\in \mathcal{X}:p_{\theta}(x)>0\}$ is the same for all $\theta\in [\theta_{0}-\delta,\ \theta_{0}+\delta],$ and for each $x\in \mathcal{X}_{>0}$ $\ell_{x}(\theta)$ is thrice differentiable in $\theta$ at each point $\theta\in [\theta_{0}-\delta,\ \theta_{0}+\delta].$
	\item $\mathrm{E}\ell_{X,Z}^{'}(\theta_{0})^{2}=I_1(\theta_0)$ and $-\mathrm{E}\ell_{X,Z}^{''}(\theta_{0})=I_2(\theta_{0})\in (0,\infty)$.
	\item $\mathrm{E}|\ell_{X,Z}'(\theta_{0})|^{3}+\mathrm{E}|\ell_{X,Z}^{''}(\theta_{0})|^{3}<\infty.$
	\item $\mathrm{E} \sup |\ell_{X,Z}^{'''}(\theta)|^{3}<\infty.$
\end{enumerate}

\medskip

\subsection*{Tight Bracketing}

Without loss of generality (w.l.o.g.), $\mathcal{X}_{>0}=\mathcal{X}$. Then on the event
\begin{equation}\label{eqn:goodevent}
	G:=\{\hat{\theta}\in[\theta_{0}-\delta,\ \theta_{0}+\delta]\}
\end{equation}
($G$ for ``good event," one must have

\begin{equation}\label{eqn:taylor}
	0 =\ell_{\mathrm{x}}'(\displaystyle \hat{\theta})=\ell_{\mathrm{x}}'(\theta_{0})+(\hat{\theta}-\theta_{0})\ell_{\mathrm{x}}''(\theta_{0})+\frac{(\hat{\theta}-\theta_{0})^{2}}{2}\ell_{\mathrm{x}}'''(\theta_{0}+\xi(\hat{\theta}-\theta_{0}))
\end{equation}

\begin{equation}\label{eqn:taylor2}
	=n(\overline{Z}-(\hat{\theta}-\theta_{0})\overline{U}+\frac{(\hat{\theta}-\theta_{0})^{2}}{2}\overline{R})
\end{equation}

for some $\xi\in (0,1)$ as a function of the $X_i$'s, where $\overline{Z}=\frac{1}{n}\sum_{i=1}^n Z_i,\, \overline{U}=\frac{1}{n}\sum_{i=1}^{n}U_{i},\, \overline{R}:=\frac{1}{n}\sum_{i=1}^{n}R_{i},\,
\overline{R^{*}}:=\sum_{i=1}^{n}R_{i}^{*},$

\begin{equation}\label{eqn:Z}
	Z_i = \ell'_{X_i}(\theta_0),\quad U_i=-\ell''_{X_i}(\theta_0)
\end{equation}

\begin{equation}\label{eqn:R}
	R_i = \ell''_{X_i}(\theta_0 + \xi(\hat{\theta}-\theta_0))\in [-R_i^{*},R_i^{*}], \quad R_i^{*}=\sup_{\theta\in [\theta_0-\delta,\theta_0+\delta]} \abs{\ell'''_{X_i}(\theta)}.
\end{equation}

Looking at \eqref{eqn:taylor} and \eqref{eqn:taylor2}, one has a quadratic equation for $\hat{\theta}$.

On the event $G$ one has
\begin{align*}
	\hat{\theta}-\theta_{0}=\frac{\overline{Z}}{\overline{U}} &\textrm{ if } \overline{R}=0\, \&\, \overline{U}\neq 0, \\
	\hat{\theta}-\theta_{0}\in\{d_{+},\ d_{-}\} &\textrm{ if } \overline{R}\neq 0,
\end{align*}

where
$$
d_{\pm}:=\frac{\overline{U}\pm\sqrt{\overline{U}^{2}-2\overline{Z}\overline{R}}}{\overline{R}}.
$$

One defines a ``bad event" by letting

$B :=B_{1}\cup B_{2}$, where

$B_{1} :=\{\overline{R}\neq 0,\hat{\theta}-\theta_{0}=d_{+}\}\cup\{\overline{U}\leq 0\}$ and $B_{2} :=\{\overline{U}^{2}\leq 2|\overline{Z}|\overline{R^{*}}\}.$

On the event $B_1 \cap \{\overline{U}>0\}$, one sees $|\hat{\theta}-\theta_{0}|=|d_{+}|\geq \overline{U}/|\overline{R}|\geq\overline{U}/\overline{R^{*}}$

By \eqref{eqn:goodevent},
\begin{equation}\label{eqn:bound_intersection}
	\Prob(G\cap B_{1})\leq \Prob(\overline{U}\leq 0 \textrm{ or } \frac{\overline{U}}{\overline{R^{*}}}\leq \delta) =\Prob( \frac{\overline{U}}{\overline{R^{*}}}\leq \delta)=\Prob(\sum_{i=1}^{n}(U_{i}-\delta R_{i}^{*})\leq 0).
\end{equation}

And by the assumptions for $\ell$ and the definitions for $Z_i$, $U_i$, $R_i$, and $R^{*}_i$,

\[
\mathrm{E}U_{1}>0,\, \mathrm{E}|Z_{1}|^{3}<\infty,\, \mathrm{E}|U_{1}|^{3}<\infty,\, \mathrm{E}(R_{1}^{*})^{3}<\infty.
\]

Therefore, $\mathrm{E}R_{1}^{*}<\infty$. Choose $\delta>0$ to be small enough such that
$$
\delta_{1}:=\mathrm{E}(U_{i}-\delta R_{i}^{*})>0.
$$
Then, letting $Y_{i} :=(U_{i}-\delta R_{i}^{*})-\mathrm{E}(U_{i}-\delta R_{i}^{*})$, we use \eqref{eqn:bound_intersection} with Markov's inequality to have

\begin{align*}
	\mathrm{P}(G\cap B_{1})\leq \mathrm{P}(\sum_{i=1}^{n}Y_{i}\leq-n\delta_{1})&\leq\frac{1}{(n\delta_{1})^{3}}\mathrm{E}|\sum_{i=1}^{n}Y_{i}|^{3}
	\\
	&\leq\frac{n\mathrm{E}|Y_{1}|^{3}+\sqrt{8/\pi}(n\mathrm{E}Y_{1}^{2})^{3/2}}{(n\delta_{1})^{3}}\leq\frac{\mathrm{C}}{n^{3/2}}
\end{align*}

where $\mathrm{C}:=(\mathrm{E}|Y_{1}|^{3}+\sqrt{8}/\pi(\mathrm{E}Y_{1}^{2})^{3/2})/\delta_{1}^{3}$, which depends on $\delta_{1}>0, \mathrm{E}Y_{1}^{2}<\infty,$ and $\mathrm{E}|Y_{1}|^{3}<\infty$. However, this does not depend on $n$.

Now, one notices $B_{2}$ implies at least one of the following events:
\begin{align*}
	B_{21} &=\displaystyle\{\overline{U}\leq\frac{1}{2}\mathrm{E}U_{1}\} \\
	B_{22} &=\{\overline{R^{*}}\geq 1+\mathrm{E}R_{1}^{*}\}, \textrm{ or}\\
	B_{23} &= \displaystyle \{|\overline{Z}|\geq\frac{1}{8}(\mathrm{E}U_{1})^{2}/(1+\mathrm{E}R_{1}^{*})\}.
\end{align*}

So,
\begin{equation}
	\Prob(B_{2})\leq \Prob(B_{21})+\Prob(B_{22})+\Prob(B_{23}).
\end{equation}

The bounding of each of the probabilities $\mathrm{P}(B_{21})$, $\mathrm{P}(B_{22})$ , $\mathrm{P}(B_{23})$ is quite similar to the bounding of $\mathrm{P}(G\cap B_{1})$ -- because

\begin{align*}
	\Prob(B_{21})&=\Prob(\sum_{i=1}^{n}Y_{i,21}\leq-n\delta_{21}), \\
	\Prob(B_{22})&=\Prob(\sum_{i=1}^{n}Y_{i,22}\geq n\delta_{22}) \textrm{ ,and } \\
	\Prob(B_{23})&= \Prob(\sum_{i=1}^{n}|Y_{i,23}|\geq n\delta_{23}).
\end{align*}

It follows that

\begin{equation}\label{GandB}
	\mathrm{P}(G\cap B)\leq \mathrm{P}(G\cap B_{1})+\mathrm{P}(B_{2})\leq\frac{\mathrm{C}}{n^{3/2}},
\end{equation}
where $\mathrm{C}$ depends on $\ell$, the measure $\mu$, and the choice of $\theta_{0}-$ but not on $n.$

On the other hand, if $\overline{R}\neq 0$ and $\overline{U}>0$, then $d_{-}=\displaystyle \frac{2\overline{Z}}{\overline{},U+\sqrt{\overline{U}^{2}-2\overline{Z}\overline{R}}}$. Here, the condition $\overline{U}>0$ is so the denominator of the latter ratio is nonzero. Thus, on the event $G\backslash B$ one has
\begin{equation}\label{inclusionrelation}
	\overline{U}>0 \textrm{ and } \displaystyle \hat{\theta}-\theta_{0}=\frac{2\overline{Z}}{\overline{U}+\sqrt{\overline{U}^{2}-2\overline{Z}\overline{R}}}\in[T_{-},\ T_{+}]
\end{equation}
where
\begin{equation}\label{Tpm}
	T_{\pm}\ :=\frac{2\overline{Z}}{\overline{U}+\sqrt{\overline{U}^{2}\mp 2|\overline{Z}|\overline{R^{*}}}
	}.
\end{equation}

\medskip

\subsection*{General uniform and nonuniform bounds on the rate of convergence to normality for smooth nonlinear functions of sums of independent random vectors}

Denote the standard normal distribution function (d.f.) by $\Phi$. For any $\mathbb{R}^{d}$-valued random vector $\zeta$,

\[
\Vert\zeta\Vert_{p} :=(\mathrm{E}\Vert\zeta\Vert^{p})^{1/p} \textrm{ for any real } p\geq 1,
\]

where $\Vert$ . $\Vert$ denotes the Euclidean norm on $\mathbb{R}^{d}.$

Take any Borel-measurable functional $f:\mathbb{R}^{d}\rightarrow \mathbb{R}$ satisfying the following smoothness condition: there exist $\epsilon\in(0,\ \infty), M_{\epsilon}\in(0,\ \infty)$ , and a linear functional $L:\mathbb{R}^{d}\rightarrow \mathbb{R}$ such that

\begin{theorem}[Smoothness Condition]
	\begin{equation}\label{eqn:smoothness}
		|f(\displaystyle \mathrm{x})-L(\mathrm{x})|\leq\frac{M_{\epsilon}}{2}\Vert \mathrm{x}\Vert^{2} \textrm{ for all } \mathrm{x}\in \mathbb{R}^{d} \textrm{ with } \Vert \mathrm{x}\Vert\leq\epsilon .
	\end{equation}

\end{theorem}

Thus, $f(0)=0$ and $L$ necessarily coincides with the first Fr\'{e}chet derivative, $f'(0)$ , of the function $f$ at $0$. Moreover, for the smoothness condition to hold, it is enough that

\[
M_{\epsilon}\geq M_{\epsilon}^{*} :=\displaystyle \sup\{\frac{1}{\Vert \mathrm{x}\Vert^{2}}|\frac{\mathrm{d}^{2}}{\mathrm{d}t^{2}}f(\mathrm{x}+t\mathrm{x})|_{t=0}|\ :\ \mathrm{x}\in \mathbb{R}^{d},\ 0<\Vert \mathrm{x}\Vert\leq\epsilon\}.
\]

Notice that $f$ does not need to be twice differentiable at $0$. One example is if $d=1$ and $f(x)= \displaystyle \frac{x}{1+|x|} \textrm{ for } x\in \mathbb{R}.$

Let $V, V_{1}$, . . . , $V_{n}$ be i.i.d. random vectors in $\mathbb{R}^{d}$, with $\E V=0$ and
$$
\overline{V}:=\frac{1}{n}\sum_{i=1}^{n}V_{i}.
$$
And let
\begin{equation}\label{sigmatilde}
	\tilde{\sigma} :=\Vert L(V)\Vert_{2}, v_{3} :=\Vert V\Vert_{3}, \textrm{ and } \varsigma_{3} :=\displaystyle \frac{\Vert L(V)\Vert_{3}}{\tilde{\sigma}}.
\end{equation}

\begin{theorem}\label{berryesseen}
	Suppose that the smoothness condition holds and that $\tilde{\sigma}>0$ and $v_{3}<\infty$. Then for all $z\in \mathbb{R}$
	\begin{equation}\label{berryesseen1}
		|\displaystyle \mathrm{P}(\frac{f(\overline{V})}{\tilde{\sigma}/\sqrt{n}}\leq z)-\Phi(z)|\leq\frac{\mathrm{C}}{\sqrt{n}},
	\end{equation}
	where $\mathrm{C}$ is a finite positive expression that depends only on the function $f$ and the moments $\tilde{\sigma}$, $\varsigma_{3}$, and $v_{3}$. Moreover, for any $\omega\in(0,\ \infty)$ and for all
	\begin{equation}\label{omega}
		z\in(0,\ \omega\sqrt{n}],
	\end{equation}

	one has

	\begin{equation}\label{berryesseen2}
		|\mathrm{P}(\frac{f(\overline{V})}{\tilde{\sigma}/\sqrt{n}}\leq z)-\Phi(z)|\leq\frac{\mathrm{C}_{\omega}}{z^{3}\sqrt{n}}
	\end{equation}

	where $C_{\omega}$ is a positive, finite, and only depends on $f$ through the smoothness condition, the moments $\tilde{\sigma}$, $\varsigma_{3}$, and $v_3$, and $\omega$.
\end{theorem}

\subsection*{Applying bracketing}

Now let $d=3$ and then let

$$\mathcal{D} :=\{\mathrm{x}=(x_{1},\ x_{2},\ x_{3})\in \mathbb{R}^{d}=\mathbb{R}^{3}\ :\ x_{2}+\mathrm{E}U_{1}>0,\ (x_{2}+\mathrm{E}U_{1})^{2}>2|x_{1}||x_{3}+\mathrm{E}R_{1}^{*}|\}.$$

By \eqref{eqn:R} and assumptions 2 and 4 for $\ell$ , $\mathrm{E}U_{1}=I_2(\theta_{0})\in(0,\ \infty)$ and $\mathrm{E}R_{1}^{*}\in[0,\ \infty$). So, for some real $\epsilon>0$, the set $\mathcal{D}$ contains the $\epsilon$-neighborhood of the origin $0$ of $\mathbb{R}^{3}.$

Define functions $f\pm:\mathbb{R}^{3}\rightarrow \mathbb{R}$ by the formula

\begin{equation}\label{definef}
	f_{\pm}(\displaystyle \mathrm{x})=f_{\pm}(x_{1},\ x_{2},\ x_{3})=\frac{2x_{1}}{x_{2}+\mathrm{E}U_{1}+\sqrt{(x_{2}+\mathrm{E}U_{1})^{2}\mp 2|x_{1}||x_{3}+\mathrm{E}R_{1}^{*}|}}
\end{equation}

for $\mathrm{x}=(x_{1},\ x_{2},\ x_{3})\in \mathcal{D}$, and let $f(\mathrm{x}) :=0$ if $\mathrm{x}\in \mathbb{R}^{3}\backslash \mathcal{D}$.

Clearly, $f_{\pm}(0)=0,$
\begin{equation}\label{Lplusminus}
	L_{\pm}(\displaystyle \mathrm{x}):=f_{\pm}'(0)(\mathrm{x})=\frac{x_{1}}{\mathrm{E}U_{1}}=\frac{x_{1}}{I_2(\theta_{0})}
\end{equation}
for $\mathrm{x}=(x_{1},\ x_{2},\ x_{3})\in \mathbb{R}^{3}$, and the smoothness condition \eqref{eqn:smoothness} holds for some $\epsilon$ and $M_{\epsilon}$ in $(0,\ \infty)$ --because, as was noted above, $\mathrm{E}U_{1}=I_2(\theta_{0})\in(0,\ \infty)$ and $\mathrm{E}R_{1}^{*}\in[0,\ \infty$), and hence the denominator of the ratio in \eqref{definef} is bounded away from $0$ for $\mathrm{x}=(x_{1},\ x_{2},\ x_{3})$ in a neighborhood of $0.$

Next, let
\begin{equation}\label{Vi}
	V_{i}:=(Z_{i},\ U_{i}-\mathrm{E}U_{i},\ R_{i}^{*}-\mathrm{E}R_{i}^{*})
\end{equation}
for $i=1,\ldots,n$, with $Z_{i}, U_{i}, R_{i}^{*}$ as defined in \eqref{eqn:R} and \eqref{eqn:Z} . Then, by \eqref{sigmatilde}, \eqref{Lplusminus} , and condition 2 , for $f=f\pm,$
\begin{equation}\label{sigmatilde1}
	\tilde{\sigma} = \sqrt{\frac{\mathrm{E}Z_{1}^{2}}{I_2(\theta_{0})^{2}}}=\frac{\sqrt{I_1(\theta_0)}}{I_2(\theta_{0})}>0
\end{equation}

and $ v_{3}^{3}=\mathrm{E}\Vert V\Vert^{3}<\infty$ by the third and fourth conditions. This shows that all the required conditions for \eqref{berryesseen} are satisfied for $ f=f\pm\cdot$.

Moreover, by \eqref{Vi}, \eqref{definef}, and \eqref{Tpm},
$$
T_{\pm}=f_{\pm}(\overline{V})
$$
on the event $G\backslash B$. So, by the inclusion relation in \eqref{inclusionrelation} (which holds on the event $G\backslash B=(G^{\mathrm{c}}\cup B)^{\mathrm{c}}$, where $\mathrm{c}$ denotes the complement) and \eqref{sigmatilde1} , inequality \eqref{berryesseen1} in \ref{berryesseen} implies
$$
\mathrm{P}(\sqrt{n/I_1(\theta_{0})}I_2(\theta_0)(\hat{\theta}-\theta_{0})\leq z)\leq \mathrm{P}(\sqrt{n/I_1(\theta_{0})}I_2(\theta_0)f_{-}(\overline{V})\leq z)+\mathrm{P}(G^{\mathrm{c}}\cup B)
$$
$$
\leq\Phi(z)+\frac{\mathrm{C}}{\sqrt{n}}+\mathrm{P}(G^{\mathrm{c}}\cup B)
$$
and, quite similarly,
$$
\mathrm{P}(\sqrt{n/I_1(\theta_{0})}I_2(\theta_0)(\hat{\theta}-\theta_{0})\leq z)\geq \mathrm{P}(\sqrt{n/I_1(\theta_{0})}I_2(\theta_0)f_{+}(\overline{V})\leq z)-\mathrm{P}(G^{\mathrm{c}}\cup B)
$$
$$
\geq\Phi(z)-\frac{\mathrm{C}}{\sqrt{n}}-\mathrm{P}(G^{\mathrm{c}}\cup B)\ ,
$$
for all real $z$. Note that $\mathrm{P}(G^{\mathrm{c}}\cup B)=\mathrm{P}(G^{\mathrm{c}})+\mathrm{P}(G\cap B)$ . It follows now by \eqref{eqn:goodevent} and \eqref{GandB} that
\begin{equation}
	|\displaystyle \mathrm{P}(\sqrt{n/I_1(\theta_{0})}I_2(\theta_0)(\hat{\theta}-\theta_{0})\leq z)-\Phi(z)|\leq\frac{\mathrm{C}}{\sqrt{n}}+\mathrm{P}(|\hat{\theta}-\theta_{0}|>\delta)
\end{equation}
for all real $z$. Quite similarly, but using \eqref{berryesseen2} instead of \eqref{berryesseen1} , one has
\begin{equation}
	|\displaystyle \mathrm{P}(\sqrt{n/I_1(\theta_{0})}I_2(\theta_0)(\hat{\theta}-\theta_{0})\leq z)-\Phi(z)|\leq\frac{\mathrm{C}}{z^{3}\sqrt{n}}+\mathrm{P}(|\hat{\theta}-\theta_{0}|>\delta)
\end{equation}
for $z$ as in \eqref{omega}.

Given rather standard regularity conditions, the remainder term $\mathrm{P}(|\theta-\theta_{0}|>\delta)$ typically decreases exponentially fast in $n$ and thus is negligible as compared with the (''error'' term $\displaystyle \frac{\mathrm{c}}{\sqrt{n}}$, and even with the (''error'' term $\displaystyle \frac{\mathrm{c}}{z^{3}\sqrt{n}}-$ under condition \eqref{omega} . Some details on this can be found in the following section.

\subsection*{Bounding the remainder}

Before we proceed, we use the following assumptions:

\begin{enumerate}
	\item $\ell_{x,z}(\theta)$ is concave in $\theta\in\theta$, for each $x\in \mathcal{X}$ and $z\in \mathcal{Z}$
	\item $$
	\mathrm{E}\frac{\exp(\ell_{X,Z}(\theta_{0}\pm h))}{\exp(\ell_{X,Z}(\theta_{0}))} < 1.$$
\end{enumerate}

Suppose that the $\ell_{x,z}(\theta)$ is concave in $\theta\in\theta$, for each $x\in \mathcal{X}$ and $z\in \mathcal{Z}$. By assumption 2 , $\mathrm{E}\ell_{X}''(\theta_{0})\neq 0$. Hence, $\mathrm{P}(\ell_{X,Z}(\theta_{0}+h)\neq\ell_{X,Z}(\theta_{0}))>0$ for some $h\in(0,\ \delta)$ . The concavity of $\ell_{x,z}(\theta)$ in $\theta$ implies that of $\ell_{X,Z}(\theta)$ . So, if $\hat{\theta}>\theta_{0}+\delta$, then $\ell_{X,Z}(\theta_{0}+h)\geq\ell_{X,Z}(\theta_{0})$ .

Therefore,
$$
\mathrm{P}(\hat{\theta}>\theta_{0}+\delta)\leq \mathrm{P}(\ell_{X,Z}(\theta_{0}+h)\geq\ell_{X,Z}(\theta_{0}))=\mathrm{P}(\prod_{i=1}^{n}\sqrt{\frac{\exp(\ell_{X_i,Z_i}(\theta_{0}+h))}{\exp(\ell_{X_i,Z_i}(\theta_{0})}}\geq 1)
$$

$$
\leq \mathrm{E}\prod_{i=1}^{n}\sqrt{\frac{\exp(\ell_{X_i,Z_i}(\theta_{0}+h))}{\exp(\ell_{X_i,Z_i}(\theta_{0})}}=\lambda_{+}^{n},
$$
where
$$
\lambda_{+}:=\mathrm{E}\sqrt{\frac{\exp(\ell_{X,Z}(\theta_{0}+h))}{\exp(\ell_{X,Z}(\theta_{0})}}<\sqrt{\mathrm{E}\frac{\exp(\ell_{X,Z}(\theta_{0}+h))}{\exp(\ell_{X,Z}(\theta_{0}))}} < 1;$$
the inequality here is an instance of a strict version of the Cauchy-Schwarz inequality, which holds because $\mathrm{P}(\ell_{X,Z}(\theta_{0}+h)\neq\ell_{X,Z}(\theta_{0}))>0$. Similarly, $\mathrm{P}(\hat{\theta}<\theta_{0}-\delta)\leq\lambda_{-}^{n}$ for some $\lambda_{-}\in[0,1$), and so,
\begin{center}
	$\mathrm{P}(|\hat{\theta}-\theta_{0}|>\delta)\leq 2\lambda^{n}$   (6.1)
\end{center}
for $\lambda :=\displaystyle \max(\lambda_{+},\ \lambda_{-})\in[0,1)$ .


\documentclass[Physics.tex]{subfiles}
\begin{document}
\chapter{Electromagnetism}
A \sldef{magnetic field} is a region of space in which a moving charge or a current-carrying conductor will experience a magnetic force when placed in the field.

The force on a moving charge in a magnetic field is \begin{equation}\mathbf{F} = q\mathbf{v} \times \mathbf{B}\end{equation} From this, the force on a current-carrying conductor with length \(\mathbf{l}\) in the direction of the conventional current \(I\) can be derived to be \begin{equation}\mathbf{F} = I\mathbf{l}\times\mathbf{B}\end{equation}

From this, it can be seen that a charge moving in a magnetic field will experience a force perpendicular to both velocity and the field, which can be predicted using Fleming's left-hand rule (or the direction of the right-handed cross product).

The \sldef{magnetic flux density} is the force acting per unit current per unit length of a conductor placed at right angles to the magnetic field i.e. \begin{equation}\mathbf{B} = \frac{\mathbf{F}}{I\mathbf{l}}\end{equation}

Magnetic flux density has units tesla (\si{\tesla}), which is defined equivalently; one \sldef{tesla} is the magnetic flux density of a uniform magnetic field in which a straight wire carrying a current of \SI{1}{\ampere} placed perpendicular to the field experiences a force per unit length of \SI{1}{\newton\per\meter} in a direction at right angles to both the field and the current.

The force on a current-carrying conductor can be used to measure the magnetic flux density, through a current balance. A wire frame balanced on a pivot with a current through it is placed such that one side is in the magnetic field and experiences a magnetic force; a weight is then placed on the opposite side to balance the frame. With needed lengths, the current, and the mass of the weight, flux density can be found.

A magnetic field will never do any work on a moving charge as the force on the charge is always perpendicular to its movement. Charges moving in a magnetic field will undergo circular motion. If there is an electric field parallel to the magnetic field, charges will move in a spiral.

If an electric field and a magnetic field perpendicular to the electric field are combined, only charges moving with a particular velocity through the fields will move through the field undeflected. This can be used as a ``velocity selector'' of sorts.
\section {Magnetic fields caused by currents}
The magnetic field caused by a long straight wire is circular with its direction predicted by the right-hand grip rule (fingers representing the field). The field lines are concentric circles centred at the wire.

The magnetic field caused by a single circular loop is similar to that of an infinitesimally short bar magnet.

A \sldef{solenoid} is a long cylindrical coil of wire. The magnetic field due to a solenoid is similar to that of a bar magnet, and is also predicted by the right-hand grip rule (fingers representing the current).

When a ferrous core is placed within a current-carrying solenoid, it becomes temporarily magnetised as the magnetic field of the solenoid concentrates within the iron bar. The solenoid and the iron bar together produce a very strong magnetic field, stronger than produced by the solenoid alone, thus forming an electromagnet.

When two parallel conductors carry a current in the same direction, they will experience forces toward the other conductor. When two parallel conductors carry a current in the opposite direction, they will experience forces away from the other conductor. This can be predicted from first principles, using the right-hand grip rule. The force per unit length on each wire \begin{equation}\frac{F}{l} = \frac{\mu_0I_1I_2}{2\pi d}\end{equation}

The \sldef{ampere} is defined based on the above result -- one ampere is the constant current which, if maintained in two straight parallel conductors of infinite length placed \SI{1}{\metre} in vacuum, would produce a force per unit length of \SI{2E-7}{\newton\per\meter} between the conductors.
\end{document}


\chapter{Struct, Type and Arrays}

\section{Struct}
\label{sec:struct}

PEARL structs may be mapped to C++ structs.
The C++ operators like \verb|=| (assignment), \verb|.| (dot) and
\verb|->| (follow) will work.

One problem arises when structs are multiply defined
in PEARL. All struct with the same internal structures as
taken to be identical. C and C++ structs as not compatible
if multiply defined.

The struct statement should be mapped to a named C++ struct and the identifier
of the struct is derived from the struct components.
The C++ standard states that a C++ compiler should support at least 1024
characters for identifiers. The g++ has no limit for the length of identifiers.

Each possible data type for a struct component is mapped to a letter.
The length has a maximum length of 64 for FIXED, FLOAT and BIT. CHAR
variables may have a length of up to 32767 characters.
 C++ provides only 63 different
 characters for the use in identifiers. So we use 1-5 digits
for the length.

If the component is an array, the number of dimensions and the
 limits are
passed as \verb|_| (underscore) separated list of decimal integers
to the type.

Mapping of data types to letters:

\begin{tabular}{|l|c|c|}
\hline
Datatype & letter & REF \\
\hline
FIXED & A &a\\
FLOAT & B &b\\
BIT  & C &c\\
CHARACTER & D &d \\
CLOCK  & E &e \\
DURATION & F&f \\
TASK & & g \\
PROC  & & h \\
SEMA & I & i \\
BOLT & J & j \\
\hline
STRUCT & S &s\\
\hline
\end{tabular}

\paragraph{Note:} Semaphores and Bolts variables are not allowed in structs,
but the encoding mapping is also used for the inter module checker.

Structs are mapped to the key 'S' followed by an integer
indicating the length of the struct components.
E.g.

Example:
\begin{PEARLCode}
... STRUCT [
    x FIXED(15);
    y FLOAT(53);
    ]
...
\end{PEARLCode}

The component x ist translated into A15 and y into B53.
The struct consists of these two elements with a length of
the type string of 3 digits each. Thus the content
of the struct is described by the string "'A15B53"'.
This is prefixed with "'S"' and the length of the component
descriptor leading to S6A15B53.

\begin{CppCode}
struct S6A15B53 {
   pearlrt::Fixed<15> _x;
   pearlrt::Float<53> _y;
};
\end{CppCode}

In case of combination of arrays in structs and array of structs we get:

\begin{PEARLCode}
DCL x STRUCT [
   a FIXED(7);
   b(1:3,3:10) FLOAT(24);
   c(2) STRUCT [
     c1(19) FIXED(15);
     c2 BIT(5);
     ];
  ];
\end{PEARLCode}

The name of the struct results into:

$S37\underbrace{\underbrace{A7}_{FIXED(7)}}_{a}\underbrace{\underbrace{B24}_{Float(24)}\underbrace{\_2\_1\_3\_3\_10}_{(1:3,3:10)}}_{b(1:3,3:10)}\underbrace{\underbrace{S12\underbrace{A15\_1\_1\_19}_{c1(19) FIXED(15)}\underbrace{C5}_{c2 BIT(5)}}_{STRUCT ..}\underbrace{\_1\_1\_2}_{(2)}}_{c(2)}$

\begin{CppCode}
struct S37A7B24_2_1_3_3_10S12A15_1_1_19C5_1_1_2 {
   pearlrt::Fixed<7> _a;
   pearlrt::Float<24> data_a[32];
   struct S13A15_1_1_19C5 {
     pearlrt::Fixed<15> data_c1[19];
     pearlrt::BitString<5>  _c2;
   } data_c[2];
};

// for array descriptors see corresponding section
DCLARRAY(ad_2_1_3_3_10,2,LIMITS{{1,3,6},{3,10,1}};
DCLARRAY(ad_1_1_19,1,LIMITS{{1,19,1}}};
DCLARRAY(ad_1_1_2,1,LIMITS{{1,2,1}}};
\end{CppCode}

\section{TYPE}
The type statement must we resolved by the compiler.
When used in STRUCTs, it is recommended that they are replaced by the
native elements.
%should be mapped on \verb|typedef| with a suitable prefix
%(here \verb|type_|). For details about struct nameing see next section.

Example:
\begin{PEARLCode}
TYPE complex STRUCT [
     real FLOAT(53);
     imaginary FLOAT(53);
];
\end{PEARLCode}

\begin{CppCode}
struct _SB53B53 {
   pearlrt::Float<53> _real;
   pearlrt::Float<53> _imaginary;
};

\end{CppCode}
%

\section{Array}

PEARL supports multidemensional arrays with individual index
boundaries. Different arrays may be passed to procedures if the
number of dimensions are identical.
Arrays may be part of data structures.

\subsection{Array Data}
The data storage for the array elements may be defined as a plain
linear data array. The access of array elements is done via the
{\em array descriptor}. It is recommended to name the array
descriptor like the according the user element and make
a decoration for the data storage.
The calculation of the required number of data elements must be
done in the PEARL$\rightarrow$C++ compiler.

\subsection{Array Descriptor}
The operations of arrays are done with the {\em array descriptor}
and the pointer to the first element of the data storage.
The descriptor is of the type \verb|Array *|.

\begin{classSummary}
 Class & \verb|Array| \\
 Specification & Array.h \\
 Namespace & pearlrt \\
 Implementation & Array.cc \\
 \verb|offset(...)|      & returns the linear index
       			to the specified array element \\
 \verb|upb(Fixed<31> idx)| & return upper bound of the
			 specified index; index starts counting at 1\\
 \verb|lwb(Fixed<31> idx)| & return lower bound of the
			 specified index; index starts counting at 1 \\
\end{classSummary}

The definition of the array descriptor is done via a C-macro.
The methods \verb|offset|, \verb|upb| and \verb|lwb|
will throw \verb|ArrayIndexOutOfBoundsSignal|
if the index is out of the bounds.

\paragraph{Note:} The DCLARRAY macro may be compressed into a single statement.
The separate statements are for clearance.
The elements should become static to avoid conflicts, if more than
one module is used. A simple way of inter module reuse is not known up to now.

\begin{verbatim}
#define DCLARRAY(name,dimensions,limits) \
   pearlrt::ArrayDescriptor<dimensions> a_##name = { dimensions, limits }; \
   pearlrt::Array b_##name((pearlrt::ArrayDescriptor<0>*)&a_##name); \
   pearlrt::Array * name = &(b_##name);
\end{verbatim}

The parameters are:
\begin{description}
\item[name] a compiler generated identifier, which will become
    the name  of the array descriptor. The descriptors should be
    named according the array structure. One descriptor for all
    arrays with the same structure is sufficient, independent of
    the contained data type.
\item [dimensions] is a C integer constant with the number of
   array dimensions. This must be larger than 0.
\item[limits] is a initializer list for the limits data structure.
   The elements of the limits structure are also C integers
   \begin{enumerate}
   \item start index as integer
   \item end index as integer
   \item number of elements in next sub array. This value is 1 for the
     last index. It is the product of all index ranges of all subarrays.
     E.g. a(3,4,5) $\rightarrow$ LIMITS(3,\{1,3,4*5*1\},\{1,4,5*1\},\{1,5,1\}\}
     \\
     LIMITS is implemented as a macro.
   \end{enumerate}
\end{description}

The access to the array elements is done via the method \verb|offset|,
with gets a variadic parameter list with all array indices.

Used prefix decoration scheme:

\begin{tabular}{|l|l|}
\hline
data & data storage as linear array \\
\hline
a & array descriptor object \\
\hline
b & array object which stores the pointer of the array descriptor \\
\hline
\end{tabular}

\subsection{Example}

\begin{PEARLCode}
DCL testValue FIXED(31);
DCL x(10:20) FIXED(31);
DCL y(1,10,10:20) FLOAT(24);
TYPE MyStruct STRUCT [
           dummy FIXED(31);
           array1 (0:9,9:9) FIXED(31);
           dummy2 FIXED(31);
           ];
DCL s(0:19) MyStruct;
...
x(10) := x(15);
y(10,10) := 0.0;
testValue := s(2).array1(0,1);
\end{PEARLCode}

\begin{CppCode}
// DCL x(10:20) FIXED(31);
static Fixed<31> data_x[11]; // 11 data elements
                             // identifier with decoration
DCLARRAY(ad_1_10_20, 1, LIMITS{{10,20,1}});
// - - - - - -
// DCL y(1,10,10:20) FLOAT(24);
 // 10*11 data elements
 // identifier with decoration
static pearlrt::Float<24> data_y[110];
DCLARRAY(ad_2_1_10_10_20, 2, LIMITS{{1,10,11},{10,20,1}});

// - - - - - -
   struct S17A31A31_1_1_100A31 {
      pearlrt::Fixed<31> _dummy1;
      pearlrt::Fixed<31> _array1[100];
         // arrayData Fixed(0:9,0:9);
      pearlrt::Fixed<31> _dummy2;
   } ;
   S17A31A31A31_1_1_100A31 _s[20];

                        // indices 0..19;
                        //multiply with 1
                        // since no subarray present
   DCLARRAY(ad_1_0_19, 1, LIMITS({{0,19,1}}));
   DCLARRAY(ad_2_0_9_0_9, 2, LIMITS({{0,9,10},{0,9,1}}));

...
   *(_x+ad_1_10_20->offset(pearlrt::Fixed<31>(10))) =
             *(x_data+ad_1_10_20->offset(pearlrt::Fixed<31>(15)));
   *(_y+ad_2_1_10_10_20->offset(pearlrt::Fixed<31>(10),
            pearlrt::Fixed<31>(10)) =
                          pearlrt::Float<24>(0.0);
...
   pearlrt::Fixed<31> testValue;

   testValue =
        *((*(_s+ad_1_1_2->offset(pearlrt::Fixed<31>(2))) )._array1)+
             ad_2_0_9_0_9->offset(pearlrt::Fixed<31>(0),pearlrt::Fixed<31>(1)
        );

\end{CppCode}

\subsection{Usage as Parameter}
The array descriptor is a pointer, which must be passed as an additional parameter
to procedures.
Passing arrays of structs containing some array may lead to the requirement
to pass more than one array descriptor in addition to the pointer to the
reals data object.
By convention the array descriptors should be passed after the pointer to the
data storage in the order of declaration of the array descriptors (DCLARRAY).

\begin{PEARLCode}
DCL x(10:20) FIXED(31);
TYPE MyStruct STRUCT [
           dummy FIXED(31);
           array1 (0:9,9:9) FIXED(31);
           dummy2 FIXED(31);
           ];
DCL s(0:19) MyStruct;
...
CALL anyFunc(x);
CALL otherAnyFunc(s);
...
anyFunc(a() FIXED(31) IDENT)
   a(LWB a) := 0;  // clear first element
END;
\end{PEARLCode}

\begin{CppCode}
// DCL x(10:20) FIXED(31);
 // 11 data elements
 // identifier with decoration
static pearlrt::Fixed<31> _x[11];
DCLARRAY(ad_1_10_20, 1, LIMITS{{10,20,1}});

// - - - - - -
   struct S19A31A31_2_0_9_0_9A31 {
      pearlrt::Fixed<31> _dummy1;
                       // arrayData Fixed(0:9,0:9);
      pearlrt::Fixed<31> _array1[100];
      pearlrt::Fixed<31> _dummy2;
   };

   struct S19A31A31_2_0_9_0_9A31  _s[20];
   DCLARRAY(ad_1_1_20, 1, LIMITS({{0,19,1}}));
   DCLARRAY(ad_2_0_9_0_9, 2, LIMITS({{0,9,10},{0,9,1}}));

...
   anyFunc(_x, ad_1_10_20);
   otherAnyFunc(_s, as_2_0_9_0_9);
...
void anyFunc(pearlrt::Fixed<31> * _a,
             pearlrt::Array * ad_a) {
  *(_a+ad_a->offet(ad_a->lwb(1))) =
          (pearlrt::Fixed<31>)(0)
}
\end{CppCode}

If a complete array should be written to a DATION with e.g. WRITE,
the address of the first array element must be used.


\section{Elliptic curves}


\section{Regression trees}


\section{Identically Independently Distributed variables (IID)}


\chapter{{\tt testWrapperMPI.c} --- A MPI Driver Program}
\label{chapter:MPI_driver}

\begin{verbatim}
/*  testWrapperMPI.c  */

#include "../BridgeMPI.h"

/*--------------------------------------------------------------------*/
int
main ( int argc, char *argv[] ) {
/*
   -----------------------------------------------------------
   purpose -- main driver program to solve a linear system
      where the matrix and rhs are read in from files and
      the solution is written to a file.
      NOTE: MPI version

   created -- 98sep25, cca and pjs
   -----------------------------------------------------------
*/
BridgeMPI   *bridge ;
char        *mtxFileName, *rhsFileName, *solFileName ;
double      nfactorops ;
FILE        *msgFile ;
InpMtx      *mtxA ;
int         error, msglvl, myid, neqns, nfent, nfind, nfront,
            nproc, nrhs, nrow, nsolveops, permuteflag, rc, seed,
            symmetryflag, type ;
int         tstats[6] ;
DenseMtx    *mtxX, *mtxY ;
/*--------------------------------------------------------------------*/
/*
   ---------------------------------------------------------------
   find out the identity of this process and the number of process
   ---------------------------------------------------------------
*/
MPI_Init(&argc, &argv) ;
MPI_Comm_rank(MPI_COMM_WORLD, &myid) ;
MPI_Comm_size(MPI_COMM_WORLD, &nproc) ;
/*--------------------------------------------------------------------*/
/*
    --------------------
    get input parameters
    --------------------
*/
if ( argc != 10 ) {
   fprintf(stdout,
           "\n\n usage : %s msglvl msgFile neqns type symmetryflag"
           "\n         mtxFile rhsFile solFile seed"
           "\n   msglvl  -- message level"
           "\n      0 -- no output"
           "\n      1 -- timings and statistics"
           "\n      2 and greater -- lots of output"
           "\n   msgFile -- message file"
           "\n   neqns   -- # of equations"
           "\n   type    -- type of entries"
           "\n      1 -- real"
           "\n      2 -- complex"
           "\n   symmetryflag -- symmetry flag"
           "\n      0 -- symmetric"
           "\n      1 -- hermitian"
           "\n      2 -- nonsymmetric"
           "\n   mtxFile -- input file for A matrix InpMtx object"
           "\n      must be *.inpmtxf or *.inpmtxb"
           "\n   rhsFile -- input file for Y DenseMtx object"
           "\n      must be *.densemtxf or *.densemtxb"
           "\n   solFile -- output file for X DenseMtx object"
           "\n      must be none, *.densemtxf or *.densemtxb"
           "\n   seed -- random number seed"
           "\n",
        argv[0]) ;
   return(0) ;
}
msglvl = atoi(argv[1]) ;
if ( strcmp(argv[2], "stdout") == 0 ) {
   msgFile = stdout ;
} else {
   int    length = strlen(argv[2]) + 1 + 4 ;
   char   *buffer = CVinit(length, '\0') ;
   sprintf(buffer, "%s.%d", argv[2], myid) ;
   if ( (msgFile = fopen(buffer, "w")) == NULL ) {
      fprintf(stderr, "\n fatal error in %s"
              "\n unable to open file %s\n",
              argv[0], argv[2]) ;
      MPI_Finalize() ;
      return(0) ;
   }
   CVfree(buffer) ;
}
neqns        = atoi(argv[3]) ;
type         = atoi(argv[4]) ;
symmetryflag = atoi(argv[5]) ;
mtxFileName  = argv[6] ;
rhsFileName  = argv[7] ;
solFileName  = argv[8] ;
seed         = atoi(argv[9]) ;
fprintf(msgFile,
        "\n\n %s input :"
        "\n msglvl       = %d"
        "\n msgFile      = %s"
        "\n neqns        = %d"
        "\n type         = %d"
        "\n symmetryflag = %d"
        "\n mtxFile      = %s"
        "\n rhsFile      = %s"
        "\n solFile      = %s"
        "\n",
        argv[0], msglvl, argv[2], neqns, type, symmetryflag,
        mtxFileName, rhsFileName, solFileName) ;
/*--------------------------------------------------------------------*/
/*
   -----------------------------------
   processor zero reads in the matrix.
   if an error is found,
   all processors exit cleanly
   -----------------------------------
*/
if ( myid != 0 ) {
   mtxA = NULL ;
} else {
/*
   ----------------------------------------------------
   open the file, read in the matrix and close the file
   ----------------------------------------------------
*/
   mtxA = InpMtx_new() ;
   rc = InpMtx_readFromFile(mtxA, mtxFileName) ;
   if ( rc != 1 ) {
      fprintf(msgFile,
              "\n fatal error reading mtxA from file %s, rc = %d",
              mtxFileName, rc) ;
      fflush(msgFile) ;
   }
}
/*
   ---------------------------------------------------------------
   processor 0 broadcasts the error return to the other processors
   ---------------------------------------------------------------
*/
MPI_Bcast((void *) &rc, 1, MPI_INT, 0, MPI_COMM_WORLD) ;
if ( rc != 1 ) {
   MPI_Finalize() ;
   return(-1) ;
}
/*--------------------------------------------------------------------*/
/*
   ---------------------------------------------------
   processor zero reads in the right hand side matrix.
   if an error is found, all processors exit cleanly
   ---------------------------------------------------
*/
if ( myid != 0 ) {
   mtxY = NULL ;
} else {
/*
   ----------------------------------
   read in the right hand side matrix
   ----------------------------------
*/
   mtxY = DenseMtx_new() ;
   rc = DenseMtx_readFromFile(mtxY, rhsFileName) ;
   if ( rc != 1 ) {
      fprintf(msgFile,
              "\n fatal error reading mtxY from file %s, rc = %d",
              rhsFileName, rc) ;
      fflush(msgFile) ;
   } else {
      DenseMtx_dimensions(mtxY, &nrow, &nrhs) ;
   }
}
/*
   ---------------------------------------------------------------
   processor 0 broadcasts the error return to the other processors
   ---------------------------------------------------------------
*/
MPI_Bcast((void *) &rc, 1, MPI_INT, 0, MPI_COMM_WORLD) ;
if ( rc != 1 ) {
   MPI_Finalize() ;
   return(-1) ;
}
/*--------------------------------------------------------------------*/
/*
   ------------------------------------------
   create and setup a BridgeMPI object
   set the MPI, matrix and message parameters
   ------------------------------------------
*/
bridge = BridgeMPI_new() ;
BridgeMPI_setMPIparams(bridge, nproc, myid, MPI_COMM_WORLD) ;
BridgeMPI_setMatrixParams(bridge, neqns, type, symmetryflag) ;
BridgeMPI_setMessageInfo(bridge, msglvl, msgFile) ;
/*
   -----------------
   setup the problem
   -----------------
*/
rc = BridgeMPI_setup(bridge, mtxA) ;
fprintf(msgFile,
        "\n\n ----- SETUP -----\n"
        "\n    CPU %8.3f : time to construct Graph"
        "\n    CPU %8.3f : time to compress Graph"
        "\n    CPU %8.3f : time to order Graph"
        "\n    CPU %8.3f : time for symbolic factorization"
        "\n    CPU %8.3f : time to broadcast front tree"
        "\n    CPU %8.3f : time to broadcast symbolic factorization"
        "\n CPU %8.3f : total setup time\n",
        bridge->cpus[0], bridge->cpus[1], bridge->cpus[2],
        bridge->cpus[3], bridge->cpus[4], bridge->cpus[5],
        bridge->cpus[6]) ;
rc = BridgeMPI_factorStats(bridge, type, symmetryflag, &nfront,
                           &nfind, &nfent, &nsolveops, &nfactorops) ;
if ( rc != 1 ) {
   fprintf(stderr,
           "\n error return %d from BridgeMPI_factorStats()", rc) ;
   MPI_Finalize() ;
   exit(-1) ;
}
fprintf(msgFile,
        "\n\n factor matrix statistics"
        "\n %d fronts, %d indices, %d entries"
        "\n %d solve operations, %12.4e factor operations",
        nfront, nfind, nfent, nsolveops, nfactorops) ;
fflush(msgFile) ;
/*--------------------------------------------------------------------*/
/*
   --------------------------------
   setup the parallel factorization
   --------------------------------
*/
rc = BridgeMPI_factorSetup(bridge, 0, 0.0) ;
if ( rc != 1 ) {
   fprintf(stderr,
           "\n error return %d from BridgeMPI_factorSetup()", rc) ;
   MPI_Finalize() ;
   exit(-1) ;
}
fprintf(msgFile, "\n\n ----- PARALLEL FACTOR SETUP -----\n") ;
fprintf(msgFile,
        "\n    CPU %8.3f : time to setup parallel factorization",
        bridge->cpus[7]) ;
if ( msglvl > 0 ) {
   fprintf(msgFile, "\n total factor operations = %.0f"
           "\n upper bound on speedup due to load balance = %.2f",
           DV_sum(bridge->cumopsDV),
           DV_sum(bridge->cumopsDV)/DV_max(bridge->cumopsDV)) ;
   fprintf(msgFile, "\n operations distributions over processors") ;
   DV_writeForHumanEye(bridge->cumopsDV, msgFile) ;
   fflush(msgFile) ;
}
/*--------------------------------------------------------------------*/
/*
   ------------------------------------------------------
   set the factorization parameters and factor the matrix
   ------------------------------------------------------
*/
permuteflag = 1 ;
rc = BridgeMPI_factor(bridge, mtxA, permuteflag, &error) ;
fprintf(msgFile, "\n\n ----- FACTORIZATION -----\n") ;
if ( rc == 1 ) {
   fprintf(msgFile, "\n\n factorization completed successfully\n") ;
} else {
   fprintf(msgFile, "\n"
           "\n return code from factorization = %d\n"
           "\n error code                     = %d\n",
           rc, error) ;
   MPI_Finalize() ;
   exit(-1) ;
}
fprintf(msgFile,
        "\n    CPU %8.3f : time to permute original matrix"
        "\n    CPU %8.3f : time to distribute original matrix"
        "\n    CPU %8.3f : time to initialize factor matrix"
        "\n    CPU %8.3f : time to compute factorization"
        "\n    CPU %8.3f : time to post-process factorization"
        "\n CPU %8.3f : total factorization time\n",
        bridge->cpus[8], bridge->cpus[9], bridge->cpus[10],
        bridge->cpus[11], bridge->cpus[12], bridge->cpus[13]) ;
IVzero(6, tstats) ;
MPI_Reduce((void *) bridge->stats, (void *) tstats, 6, MPI_INT,
           MPI_SUM, 0, bridge->comm) ;
fprintf(msgFile,
        "\n\n   factorization statistics"
        "\n   %d pivots, %d pivot tests, %d delayed vertices"
        "\n   %d entries in D, %d entries in L, %d entries in U",
        tstats[0], tstats[1], tstats[2],
        tstats[3], tstats[4], tstats[5]) ;
fprintf(msgFile,
        "\n\n   factorization: raw mflops %8.3f, overall mflops %8.3f",
        1.e-6*nfactorops/bridge->cpus[11],
        1.e-6*nfactorops/bridge->cpus[13]) ;
fflush(msgFile) ;
/*--------------------------------------------------------------------*/
/*
   ------------------------
   setup the parallel solve
   ------------------------
*/
rc = BridgeMPI_solveSetup(bridge) ;
fprintf(msgFile, "\n\n ----- PARALLEL SOLVE SETUP -----\n"
        "\n    CPU %8.3f : time to setup parallel solve",
        bridge->cpus[14]) ;
if ( rc != 1 ) {
   fprintf(stderr,
           "\n error return %d from BridgeMPI_solveSetup()", rc) ;
   MPI_Finalize() ;
   exit(-1) ;
}
/*--------------------------------------------------------------------*/
/*
   -----------------------------------------
   processor 0 initializes a DenseMtx object
   to hold the global solution matrix
   -----------------------------------------
*/
if ( myid == 0 ) {
   mtxX = DenseMtx_new() ;
   DenseMtx_init(mtxX, type, 0, 0, neqns, nrhs, 1, neqns) ;
   DenseMtx_zero(mtxX) ;
} else {
   mtxX = NULL ;
}
/*
   ---------------------------------------------
   the processors solve the system cooperatively
   ---------------------------------------------
*/
permuteflag = 1 ;
rc = BridgeMPI_solve(bridge, permuteflag, mtxX, mtxY) ;
if ( rc == 1 ) {
   fprintf(msgFile, "\n\n solve complete successfully\n") ;
} else {
   fprintf(msgFile, "\n" " return code from solve = %d\n", rc) ;
}
fprintf(msgFile, "\n\n ----- SOLVE -----\n"
        "\n    CPU %8.3f : time to permute rhs into new ordering"
        "\n    CPU %8.3f : time to distribute rhs "
        "\n    CPU %8.3f : time to initialize solution matrix "
        "\n    CPU %8.3f : time to solve linear system"
        "\n    CPU %8.3f : time to gather solution "
        "\n    CPU %8.3f : time to permute solution into old ordering"
        "\n CPU %8.3f : total solve time"
        "\n\n solve: raw mflops %8.3f, overall mflops %8.3f",
        bridge->cpus[15], bridge->cpus[16], bridge->cpus[17],
        bridge->cpus[18], bridge->cpus[19], bridge->cpus[20],
        bridge->cpus[21],
        1.e-6*nsolveops/bridge->cpus[18],
        1.e-6*nsolveops/bridge->cpus[21]) ;
fflush(msgFile) ;
if ( myid == 0 ) {
   if ( msglvl > 0 ) {
      fprintf(msgFile, "\n\n solution matrix in original ordering") ;
      DenseMtx_writeForHumanEye(mtxX, msgFile) ;
      fflush(msgFile) ;
   }
}
/*--------------------------------------------------------------------*/
/*
   ---------------------
   free the working data
   ---------------------
*/
if ( myid == 0 ) {
   InpMtx_free(mtxA) ;
   DenseMtx_free(mtxX) ;
   DenseMtx_free(mtxY) ;
}
BridgeMPI_free(bridge) ;

/*--------------------------------------------------------------------*/

MPI_Finalize() ;

return(1) ; }

/*--------------------------------------------------------------------*/
\end{verbatim}


\section{Quantum Dimer Model}
Each site is involved in no more than one dimer.

Complete dimer covering each site involved in exactly 1 dimer.
Different dimer configurations are assumed orthogonal states.
This is not the case in real systems,
but is assumed in the dimer model.

Then we considered a square lattice,
with a Hamiltonian that has a hopping term where the configurations get flipped
plus a potential energy term.
\begin{align}
    H_{qdm} &=
    \sum -t \left( \ket{||}\bra{=} + \mathrm{h.c.} \right)
    +
    V\left(
    \ket{||} \bra{||} + \ket{=}\bra{=}
    \right)
\end{align}

Last time we considered hot topological sectors.
We have a non-bipartite lattice.
Fix reference line count parity of dimer crossings $n_c\mod 2$.
And $n_c\mod 2$ is invariant under logical dimer moves.

This winding number $n_c$,
the reference line matters.
If you choose a different reference line,
this number does change,
so to define the topological sector you must fix the reference line first.
You can see this if you draw a triangular lattice.
Because each site is connected to exactly one dimer,
if I change my reference line to cross a particular site near it,
I will always cross an extra dimer when I deform the line like this.
Because each site is part of 1 dimer,
$n_c\mod 2$ depends on the reference.
Once we fix our reference looks and do this counting,
the result is going to be an invariant of these local moves.
On a torus,
we can consider two reference loops corresponding to non-contractible cycles of
the torus and we get the 2 non-contractible sectors.

On a bipartite lattice,
we pick 2 reference lines and nay integer associated with 2 reference lines.

\subsection{Topological Excitations}
\begin{align}
    \ket{g.s}
    &=
    \sum_c A_c \ket{c}
\end{align}
Then we talked about topological excitations.
It's probably better to call them topological defects.
Depending on what phase you're in,
they may or may not be deconfined excitations.
We talked about visons,

Say you have a vison at $i$ and a vison at $j$.
Suppose that you had a ground state which was the sum over some dimer
configurations with some amplitudes.
Then you can introduce the visons by picking some reference line.
And $i$ and $j$ are the endpoints of the line.
So a vison $i$ and vison at $j$ connected by this line would be the same sum
with configurations
but a $(-1)^{n_c}$.
\begin{align}
    \ket\left\{ V_i V_j \right\}
    &=
    \sum_c
    A_c \left( -1 \right)^{n_c} \ket{c}
\end{align}
Think of it as a $\mathbb{Z}_2$ vortex,
because it's like a branch cut,
and along the branch cut,
we change the state depending on how many dimers are crossing it.
So $-1$ associated with branch cuts.

Then you can break them into 2 monomers,
and you allow the monomers to move around.
The local moves only break the dimers.
If I had a dimer on some particular link,
then that creates two monomers or vice versa.
\begin{align}
    \left( \ket{:}\bra{|} + \mathbb{h.c.} \right)
\end{align}
A single monomer requires some string of moves to break and move far apart.
A single monomer is thus a topological excitation
because it cannot be created by any local operator.

Let's rephrase some notation.
Let's call the reference line $\gamma$,
and the number of crossings along it $n(\gamma)$.
Then
\begin{align}
    \ket\left\{ V_i V_j \right\}
    &=
    \sum_c
    A_c
    \left( -1 \right)^{n_c\left( \gamma \right)}
    \ket{c}
\end{align}
If you fix $\gamma$,
this will have multiple configurations,
but I haven't told you they are all related by local moves.
This $\gamma$ here is just a line segment.
The number of line crossings is not topologically protected.
It could be topologically protected if it were a closed loop though.
But here the $\gamma$ is a line segment that starts at $i$ and ends at
$j$.

\begin{question}
    Different dimer coverings could ave different $n_c(\gamma)$'s?
\end{question}
Yes that's right.
If $\gamma$ is a non-contractible loop,
then local moves will not change $n_c\left( \gamma \right)$.

\begin{question}
    Are monomers topological excitations?
\end{question}
There's no operator that creates a single monomer.
The only way is to break a dimer,
get 2 monomers and move one far away.
This has become important recently,
because last year in Harvard,
in a Rydberg atom array,
they managed to create the quantum dimer model,
and a particular ground state that corresponds to a $\mathbb{Z}_2$ spin liquid.

\begin{question}
    Dimer models can be defined even without translational symmetry
    on arbitrary tribulations?
\end{question}
Yes it's more general.

\begin{question}
    If you have a square lattice,
    and or have a dislocation,
    it will become non-bipartite.
\end{question}
We can do it on bipartite or non-bipartite lattices.

\subsection{Square Lattice Dimer Model}
There is a particular point in the parameter space where you set $V=t$.
This point is called the RK point, which stands for Rocksta-GUilson.
When you set $V=t$,
then you can write the Hamiltonian as
\begin{align}
    H &=
    V\sum
    \left(
    \ket{||}
    -\ket{=}
    \right)
    \left(
    \bra{||}
    -
    \bra{=}
    \right)\\
    &= V \sum_{\square} P_{\square}
\end{align}
And the point here is that this is actually a sum of projectors,
so you can define a projector on each plaquette,
so you're just summing over plaquettes.
Projector means if you square it you get the same thing.
\begin{align}
    P_{\square}^2 = P_{\square}
\end{align}

The nice thing is that the ground state is the state that is annihilated by
every projector.

\begin{question}
    Is that always possible?
\end{question}
You don't know it's always possible,
but here it is.
You can have projects that are weird.
Here it will be possible.

A generic wave function that is annihilated by projectors takes the form
of a sum over configurations $c$.
\begin{align}
    \ket{\Phi} &= \sum_{c} A_c \ket{c}
\end{align}
If the configurations $c$ and $c'$ differ by some flipped plaquette,
then $A_c = A_{c'}$.
So you can write a ground state as a uniform superposition over all coverings,
but a restricted sum over all configurations that can be obtained by local flip
moves.
\begin{align}
    \ket{\Psi_0}
    &=
    \sum_{c} \ket{c}
\end{align}
This is a uniform superposition over dimer coverings related by flipping terms.

This RK point is nice because we have a nice understanding of the wavefunction
as just a uniform superposition over dimer coverings related by these local
flips.
But the actual properties of the state,
like what phase of matter it corresponds to depends sensitively on what
dimension you're in and the specific geometry of the lattice.
Here we're on a square lattice,
but it could be triangular.
What phase and what properties depends sensitively on lattice geometry and
dimension.

Depending on lattice geometry and dimension,
RK point has different physics.
If you're on a 2D bipartite lattice,
for example a square or honeycomb lattice,
the RK point is actually a critical point
between 2 different ordered phases.
On the other hand,
if you're on a non-bipartite lattice,
then the RK point is just one point in a larger phase that corresponds to a
$\mathbb{Z}_2$ short
range RVB phase,
sometimes called a $\mathbb{Z}_2$ spin liquid.
I think the RK point in 3D is part of really interesting gapless phase of spin
liquid.
To figure this out,
you in general need to do complicated numerics,
but writing the Hamiltonian and doing numerics to diagnose what phase you're
in,
and perturb the Hamiltonian to see what the properties are.
It's generally not something to be understood analytically.

\begin{question}
    The ground state is a uniform superposition over states related by local
    moves,
    but with different topology sectors,
    we have different ground state for each sector?
    Also, the classification depends on which reference loop we choose?
\end{question}
That might affect how you label the states,
but not that they are different states.

So that's what happens when $V=t$,
but what about other limits?

What if $V/t \to \infty$?

One phase is called the \emph{columnar phase},
where you have dimers just along columns like this.
This breaks translation symmetry,
and it breaks rotation symmetry.
Here this would happen in the limit $t>0$ and $V\to -\infty$.
You want to satisfy that second term in the Hamiltonian,
which really likes plaquettes which look like this,
so it has the maximum number of flippable plaquettes.

On the other hand,
if $t>0$ and we take $V\to +\infty$,
then we want to minimize the number of flippable plaquettes.
If you really want to violate that second term in the Hamiltonian,
you would have a staggered configuration.
No plaquette looks like that second term.
These are different kinds of ordered phases that break translational and rotating
symmetry.

Spin liquid type phases on the critical point are particularly interesting
because they are described by gauge theories.

This quantum dimer model so far,
may look familiar to you,
they arise in the context of gauge theory,
like $U(1)$ and $\mathbb{Z}_2$ gauge theory.
There's in fact a mapping from quantum dimer model to gauge theory.
And this RK point will correspond to some gapless U(1) gauge theory,
and iff you're non-bipartite,
the RK point corresponds to the deconfined phase of a $\mathbb{Z}_2$ gague
theorey.

\begin{question}
    In the 2D non-bipartite phase,
    is there a more complciated orderd phase?
\end{question}
There's generally huge different kinds of orderd phasess.
You essentially break the symmetyr into any subgroup of that.
If you write down a paritcular Hamiltnoian on the tringaulr lattice,
it's a complicated story you need to do mnumerics to figure out.

\begin{question}
    How does this relate to the original system without orthogonal states?
\end{question}
You could try to hink of the Dimer model on its own and try to realise that,
like the Rydberg atom array.
So physiical models on themselves.

You can think of this quantum dimer model,
imagine on each link htere is a particle with occupation number 0 or 1,
so you can map this quantum dimer model to some kind of model of bosons defined
on links.
The fact that dimer coverings will be orthognal,
but there will be a dimer constraint,
so no two sites will have 2 paricles,
so each site will have 1 boson.
So you map it to a model of bosons,
where you forbid any link that talks to a different site.

each dimer maps to the occupation number of a boson.
The constraint that each site is connected to 1 dimer becomes a constraint that
the sum of the occupation number of the bosons for each link,
\begin{align}
    \sum_{l \in +} n_{b, l} = 1
\end{align}
for any link that's conected to a star site has to equal 1.
You can map the dimer model to a boson hopping and make the constraint an
energetic constraint,
so the Hamiltonani is bosons hopping on a link,
plus a sum over all sites and sum over all links with some coefficietn $K$
infinitely large.
\begin{align}
    H &=
    -t \sum\left( b_i^\dagger b_i + \mathbb{h.c.}\right)
    - K
    \sum_s
    \left(
    \sum_{l \in +}
    n_{b,l} - 1
    \right)^2
\end{align}
If you start with the trignaulr lattice,
you get the Kagome lattice,
which is the balanced Fisher-Girven mdoel,
a model of bosons hopping on a Kagome lattice,
with dimer constraints made energetic.

Just think of the dimer mdoel as some constarinted boson model,
or just think of it as inspirational from the original spin-singlet problem.
Both perspectives are used.

\section{Quantum Lattice Gauge Theory}
But first,
let's talk about lattice gauge theory.

Let's start with U(1) lattice gauge theory on a square lattice.
We have gauge fields defined on links.
I'm going to call it $a_{ij}$,
which is a $U(1)$ gauge field defined on links.
And then $a_{ij}$ is actually an angle $a_{ij}\in [0,2\pi)$.
Furthermore,
if we have some gauge field defined on some link,
we should think of the link as being directed.
When I say $a_{ij}$,
I really mean them link is directed from $i$ to $j$,
and if it's the other away around,
\begin{align}
    a_{ij} &= -a_{ji}
\end{align}
In addition  to the gauge field,
we have some matter fields which are defined on site vertices,
$c_i$ which could be a boson or fermion operator,
agnostic for now.
It carries charge 1 under this $U(1)$ gauge field,
which means under a gauge transformation
\begin{align}
    c_i &\to e^{i\theta_i} c_i\\
    a_{ij} &\to a_{ij} + \theta_i - \theta_j
\end{align}

\begin{question}
    How are the links directed?
\end{question}
There's no constraint?
You just pick everything in the same direction.

A generic Hamiltonian will have nearest-neighbour hopping terms
and a magnetic field and electric field term.
\begin{align}
    H_{U(1)}
    &=
    -\sum_{\langle ij \rangle}
    t c_i^\dagger c_j e^{ia_{ij}} + \mathbf{h.c.}
    - K
    \sum_{\square}
    \cos\left( b_{\square} \right)
    +
    J
    \suM_{\langle ij \rangle} e_{ij}^2
\end{align}
where $b$ is a magnetic field associated with each plaquette.
Each $b_{\square} =
a_{ij} + a_{jk} + a_{kl} + a_{li}$
can be thought of as a holomony term.
You could think of $a_{ij}$ as the phase of some rotor variable,
so a phase on a $U(1)$ rotor,
and $e_{ij}$ would be its corresponding angular momentum.

So $e_{ij}$ would have integer eigenvalues.
And canonical commutation relations between them are
\begin{align}
    \left[ e_{l}, a_{l'} \right] &=
    i \delta_{ll'}
\end{align}
Equivalently,
this is just saying $e^{ia}$ acts like a raising operator for the electric field
\begin{align}
    \left[ e_{l}, e^{ia_{l'}} \right]
    &=
    e^{ia_{l'}}
    \delta_{ll'}
\end{align}
So $e^{ia}$ is the raising operator for $e$.
So it's like having rotor degrees for freedom where $e$ is the angular
momentum and $a$ is the phase.
But there is an important gauge redundancy,
which is the same as saying that we need to have a Gauss law,
$\nablea\cdot e = n$
where $n$ is charge density.
But here this is a lattice divergence.
To be specific,
suppose I have a site $i$,
and I have links directed inwards $l_1, l_2, l_3, l_4$.
What that means is that I add up electric field coming in from these links and
that should be equal to the density on that site.
\begin{align}
    e_{l_1} + e_{l_2} + e_{l_3} + e_{l_4} &= n_i
\end{align}
Thus the Gauss law \emph{generates}
the gauge transformation,
which means that suppose you had some state $\ket{\left\{ a_{ij}, n_i \right\}}$
then
\begin{align}
    e^{i\sum_j \left( \nabla\cdot e - n_j \right) \theta_j}
    \ket{}\left\{ a_{ij}, n_i \right\}
    &=
    \ket{\left\{
    a_{ij} + \theta_j - \theta_j
    ,
    n_i
    \right\}}
\end{align}
The first term,
you can integrate by parts,
and what a single $e$ does is that $e^{ie\theta}$ shifts $a$ by $\theta$.
This is just the same as the gauge transformation I wrote down before for $c_i$
and $a_{ij}$.
The gauge transformation changes the phase of the state by this amount.
Because
$e^{i\sum_j \left( \nabla\cdot e - n_j \right) \theta_j}=1$,
it means that
\begin{align}
    \ket{\left\{ a_{ij}, n_i\right\} }
    =
    e^{-i\sum _j n_j \theta_j}
    \ket\left\{ a_{ij} + \theta_j - \theta_i , n_i\right\}}
\end{align}
This is the gauge redundancy in our description.
Let's write it down explicitly.
For the second term,
\begin{align}
    e^{-in_j \theta_j} \ket{n_j}
\end{align}
is equivalent to
$c_i \to e^{i\theta_i} c_n$.
For the first term,
\begin{align}
    e^{e_{ij\left( \theta_j - \theta_i \right)}}\ket{a_{ij}}
    &=
    \ket{a_{ij} + \theta_j - \theta_i}
\end{align}
In the continuum limit,
this becomes a continuum $U(1)$ gauge field coupled to matter.
\begin{align}
    H &=
    \int d^2 r
    \left[
    c^\dagger (r)
    \frac{\left( i\partial - a \right)^2}{2m}
    c(r)
    -
    \tilde{K} \cos b
    - \tilde{J} e^2
    \right]
\end{align}
And remember pure maxwell theory has a Hamiltonian that is proportional to $E^2
- B^2$ with
\begin{align}
    H_{\text{Maxwell}}
    \propto e^2 - b^2
\end{align}
Here,
the coefficients for the $e^2$ and $b^2$ terms are not the same,
and remember the reason they're the same in Maxwell is because of Lorentz
invariance,
but there is no Lorentz invariance in the lattice gauge theory,
so there's no reason why $\tilde{K}$ and $\tilde{J}$ would be related to each
other.
So we have no special relationship between $\tilde{K}$ and $\tilde{J}$.

In the Hamiltonian framework,
$e$ is the canonicmal momentum relative to $a$.
But $b$ would be the curl of $a$.
In the continuum,
you would have
\begin{align}
    b &= \nabla\times a
\end{align}
while $e$ and $a$ are canonically conjugate.

\subsection{$\ZZ_2$ gauge theory}
So $\mathbb{Z}_2$ gauge theory is just breaking the $U(1)$ down to
$\mathbb{Z}_2$.
Can understand by ``spontaneous gauge symmetry breaking''
It will spontaneously obtain an expectation value.
You pick an operator with charge 2,
so something like $\langle C^2 \rangle$.
Then you calculate the expectation value of $C^2$,
and if it's non-zero,
then that's gauge symmetry breaking.
The transition where this happens is sometimes called the Anderson-Higgs
transition,
but colloquially we sometimes call it ``Higgsing''.
Higgs is a verb now.

More formally,
we can define $\mathbb{Z}_2$ gauge theory as follows.
Again we have this square lattice,
which has gauge fields on links,
and matter fields on sites.
Here our $\ZZ_2$ gauge fields are $\sigma_{ij}^z= \pm 1$ Pauli $Z$ operators.
Then $\ZZ_2$ charged matter defined on sites.
I'm going to take the matter fields to be Ising spin variables,
so there's a basis where its eigenvalues are $+1$ or $-1$.
So we have a spin operator defined on sites $S_{i}^{x}$
which takes $-1$ to $+1$.
Though in general the matter can be either bosonic or fermionic.
To make a connection to $U(1)$ gauge theory,
you could think
\begin{align}
    \sigma_{ij}^{z} &7=
    e^{ia_{ij}\pi}
\end{align}
and then
\begin{align}
    \sigma_{ij}^{x}
    &=
    e^{i e_{ij} \pi}
\end{align}
can be thought of as an electric field.
Here $a_{ij}$ and $e_{ij}$ have eigenvalues 0 or 1 mod 2.
Then the gauge transformation is
\begin{align}
    \sigma_{ij}^z \to \lambda_i \lambda_j \sigma_{ij}^z
\end{align}
for $\lambda_i = \pm 1$,
while
\begin{align}
    a_{ij} \to a_{ij} + \theta_j + \theta_i \mod 2
\end{align}
and
\begin{align}
    S_i^x \to \lambda_i S_i^x
\end{align}

For simplicity,
consider nearest-neighbour hopping.
Remember these $S^x$ are boson creation and annihilation operators,
but because it's mod 2,
creation and annihilation are the same thing.
\begin{align}
    H &=
    -\sum_{\langle ij \rangle}
    t
    S_i^x S_j^x \sigma_{ij}^Z
    - K
    \sum_{\square}
    \prod_{\langle ij\rangle \in \square}
    \sigma_{ij}^z
    - h
    \sum_{\langle ij \rangle}
    \sigma_{Ij}^x
\end{align}
And this is the thing that minimizes the magnetic fields at the plaquettes.
This is what you would call $\mathbb{Z}_2$ lattice gauge theory
coupled to matter.
Although in this specific example,
the matter itself is an Ising spin.

One last thing we haven't done is the Gauss law,
which we did in the U(1) case but no the $\ZZ_2$ case.
Before we had a charge on each site,
but now we need a $\ZZ_2$ charge on each site.
So let us define a $\ZZ_2$ charge on each site.
Call our $\ZZ_2$ charge $n_i = 0 \mod 2 $ in some basis.
And so
\begin{align}
    \left( -1 \right)^{n_i}
    \ket{S_i^z} = s_i^z \ket{s_i^z}
\end{align}
The matter field is an Ising spin that is pointing in up or down direction,
but if it's up we say it's $\ZZ_2$ charge even,
and odd if down.
If I start with $\ZZ_2$ charge even on two neighbouring sites,
then that's going to create $\ZZ_2$ charge odd on the neighbouring sites.

Let $\sigma^x = \ZZ_2$ be the electric field and then
\begin{align}
    \left( \nabla\cdot e \right) - n_i = 0 \mod 2
\end{align}

\begin{question}
    Is there a generalization to higher neighbours?
\end{question}
Yes.
Consider a term like
\begin{align}
    \sum_{ij}
    c_{i_1}^\dagger c_{i_n}
    e^{i\left(
    a_{i_1 i_2}
    + a_{i_2 i_3}
    + \cdots +
    a_{i_{n-1} i_n}
    \right)}
\end{align}

\begin{question}
    What's the classical analogue?
\end{question}
There's multiple things you could say.
First you could ignore the magnetic term,
and it's purely classical,
this is the 2D classical $\ZZ_2$ gauge theory coupled to matter.
If you think fo the path integral or partition function of this quantum model,
spacetime is 3D,
youcauld map that to a classical 2D Ising model.

If I draw some site $i$ and consider its neighbouring links $l_1,l_2,l_3,l_4$,
then what the Gauss law is saying si that
\begin{align}
    \sigma_{l_1}^x
    \sigma_{l_2}^x
    \sigma_{l_3}^x
    \sigma_{l_4}^x
    &=
    s_i^z
\end{align}
And this means that
\begin{align}
    \left(
    \prod_{l\in +} \sigma^x
    \right)
    S_i^z
    = +1
\end{align}
which is the Gauss law constraint.

The cleeer thing:
Inseead of thinking it as a hard constrain on the Hilbert space,
you cna think of it as an energetic constraint you add as an extra term in the
Hamiltonian.
\begin{align}
    H &=
    -\sum_{\langle ij \rnagle}
    t S_i^x S_j^x \sigma_{ij}^z
    -
    K \sum_{\square} \prod_{\langle ij \rangle} \sigma_{ij}^z
    - h \sum_{\langle ij \rangle} \sigma_{ij}^x
    - J \sum_i
    \left(
    \prod_{l \in +} \sigma_l^x
    \right)
    S_i^z
\end{align}
with $J\to\infty$.

Now let's assume $S$ forms a trivial paramagnet.
\begin{align}
    \langle S_i^x \rangle &= 0\\
    \langle S_i^z \rangle &= 1
\end{align}
Then we can do a mean field approximation
\begin{align}
    H_{mf} &=
    - K \sum_{\square} \prod_{l\in\square} \sigma_l^z
    - J\sum_{+} \prod_{l \in +} \sigma_l^x
    - h\usm_{\langle ij\rangle} \sigma_{ij}^x
\end{align}
THis is pure $\ZZ_2$ lattice gauge theory because there are no matter fields,
but it's a pure $\ZZ_2$ lattice gague theory iwthteh Gaus law treated
energetically.

If you set $h=0$,
you get the famous Kitaev toric code Hamiltonian.
IT's really just $\ZZ_2$ latice gauge theory wher you treat Gauss law as an
energetic cosntraitn.
This was fundanetmally a conseptaionlly umpotatn thing to  do.
Rather than not treating the Gauss law as a fundmenatl Hilbert space constrat,
was not a trivia step.
Befoer the Hilbert space had a hard constarin,
adn we canont factor.
Now instead,
the Hilbert space is much bigger,
but it does factorize.
Before when you implmeent the constraint it was not a spin model.
Here we havea spin mdoel that reproduces the gauge field.
Kitaev became famous for making this 1 important step.
everything was knonwn since the 1907s,
but hte new insight was to make the Gauss law constraint energetic.


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx} % Allows including images
\usepackage{subcaption}
\usepackage{amsmath}
\newcommand{\pluseq}{\mathrel{+}=}

\title{Weekly Report}
\author{Junior Team }
\date{August 2020}

\begin{document}

\maketitle

\section*{Introduction}
After presenting, we began to incorporate some of the ideas and feedback received from the group. We also began to prepare for out meeting with Nima scheduled next week.

\section{Un-Normalized Error}
One common question in response to our different plots is are these trends simply due to normalization? For example, in figure \ref{fig:originalPlot}, it is possible that this trend is simply due to the amplification of errors due to the small denominators when in the normalization step. If we plot the un-normalized error however, we still see the same trend (Fig \ref{fig:newerPlot}), showing that this can't be due to normalization.

\begin{figure}[h!]
    \centering
    \begin{subfigure}[b]{0.45\linewidth}
        \includegraphics[scale=0.125]{changeInOmegaEllipse.jpg}
        \caption{Normalized Error}
        \label{fig:originalPlot}
    \end{subfigure}
    \quad
    \begin{subfigure}[b]{0.45\linewidth}
       \includegraphics[scale=0.125]{newPlot.jpg}
        \caption{Ellipse Data Set}
        \label{fig:newerPlot}
    \end{subfigure}
    \caption{Examining the Effect of Normalization on this Trend}
\end{figure}

\noindent In addition to looking at the change in angular velocity, we can simply take the magnitude of post impact angular velocity and get the same trend (Fig. \ref{fig:3DPlot}). We see that usually if the impact leads to a lot of rotation, the IRB model has a better prediction than if it has low amounts of rotation after impact. Adding the total norm of Post impact velocity on the third axis further cements that this trend is not due to normalization. \\

\begin{figure}[h!]
    \centering
    \includegraphics[scale = 0.25]{3DPlot.jpg}
    \caption{Investigating Error and Magnitude of Post Impact Angular Velocity}
    \label{fig:3DPlot}
\end{figure}

\noindent This is a rather counter intuitive finding, saying that when an object has a softer impact (lower velocity impact) and lower levels of rotations post impact, the IRB model tends to give worse predictions. Perhaps this can be explained by something mentioned later in the report or perhaps this is something that needs to be revisited starting with the fundamental physics of the problem. This trend is something we will continue to discuss and consider as we move forwards.

\newpage
\section{Improving Square Data Set}

\subsection{Removing Bad Data}
One nice benefit of plotting non-normalized error was the ability to spot data trials that had been marked as "good" but actually had issues like missing frames or a was double impact. After plotting all of the cases, we saved a list of all the trials that we above a certain error threshold and ran them all through the visualizer for manual inspection. Through this process, over twenty five impacts were eliminated and our total number of impacts in our data set was now a little under 300. This of course led to lower means for error in both the normalized and un-normalized cases.

\subsection{Improving Velocity Fitting Methods}
As Matt pointed out in our presentation, the linear fitting method for extracting velocities should really be different for the y case. Since the object is in free fall, we do not expect the position curve to be linear, but rather to follow a parabolic trajectory. To factor this in, we subtracted the effect of gravity on the position, then performed a linear fit. The method can be explained via this series of steps:

\begin{align*}
    \mbox{Position Vector: } y = [y_0,\ y_1,\ ...,\ y_n] \\
    \mbox{Time Vector: } t = [t_0,\ t_1,\ ...,\ t_n] \\
    \mbox{Filter Position Vector:  } y_* = y +\frac{1}{2}g(t-t_0)^2 \\
    \mbox{Apply a  Linear Fit: } polyfit(t, y_*),\ y_* = mt+ b \\
    \mbox{Rewrite Position Vector: } y = mt + b - \frac{1}{2}g(t-t_0)^2 \\
    \mbox{Calculate Velocity: } v(t_n)  = m - g (t_n - t_0)
\end{align*}

\subsection{Improving Jacobian Calculations}
After our presentation, we were hearing a lot of suggestions with respect to the way we involve angular velocity. The idea of including the angular velocity component when calculating our contact Jacobian was something we found interesting, so we decided to focus some of our time on that. As we mentioned before, we were calculating the contact Jacobian as shown:

\begin{equation}
n =
\begin{bmatrix}
 0 \\
 1 \\
 x_{COM}-x_{contact}
\end{bmatrix}
\end{equation}

\begin{equation}
d =
\begin{bmatrix}
 1 \\
 0 \\
 y_{COM}-y_{contact}
\end{bmatrix}
\end{equation}

\noindent However, we wanted to improve the accuracy of these calculations by including angular velocity when detecting/simulating an impact. The way we did this was by first examining when the y-velocity of the square changed signs from negative to positive. Initially, we would then take the data from a frame before to begin simulating the square's trajectory with minuscule time steps ($\Delta t = 10^{-7}  s$), but we were finding that going back only one frame gave us inconclusive results. We found that making our beginning frame (time $t = 0$) two frames back would yield conclusive solutions within our specified tolerance. We began at time $t = 0$ and iterated through, simulating the square's trajectory and positioning with the following assumptions:

% \begin{align*}
%     \mbox{Constant x Velocity : } x = \dot{x} t + x_0 \\
%     \mbox{Constant y Acceleration (Freefall) : }  y = \frac{-1}{2} gt^{2} + \dot{y} t + y_0 \\
%     \mbox{Constant y Acceleration (Freefall) : } \dot{y} = -gt + \dot{y_0}

% \end{align*}

\begin{equation}
    \mbox{Constant x velocity: } x = \dot{x} t + x_0
\end{equation}
\begin{equation}
    \mbox{Constant Angular Velocity : } \theta = \omega t + \theta_0
\end{equation}
\begin{equation}
     \mbox{Freefall: }y = \frac{-1}{2} gt^{2} + \dot{y} t + y_0
\end{equation}
\begin{equation}
    \mbox{Freefall: }\dot{y} = -gt + \dot{y_0}
\end{equation}

\end{document}

Weekly Reports/Weekly Report 809/main.tex


\chapter{Space charge resonances and instabilites} \label{app-B}

In Chapter \ref{chap-1}, it was mentioned that space charge can be divided into two categories: incoherent effects involving the motion of single particles, and coherent effects involving the self-consistent motion of the entire beam. Here, these effects are explored by carrying out several of the numerical experiments in \cite{Hofmann2017Book} using the PyORBIT code.

\section*{Incoherent space charge resonances}

We first assume that the beam is matched — i.e., oscillates with the same periodicity as the external focusing — and track a particle in the field of the matched beam. In Chapter \ref{chap-1}, we stated that the primary concern in circular accelerators is that the shifted single-particle tunes cross low-order machine resonance lines. But it is also possible for the beam's electric field to drive single-particle resonances \cite{Holmes1999, Jeon1999, Li2014, Kojima2019, Asvesta2020}. For suppose the transverse electric field is expanded in powers of $x$ and $y$: these so-called ``psuedo-multipoles" can then be treated in a similar way to the magnetic multipoles in Appendix \ref{app-A}. For illustration, we reproduce a numerical study from \cite{Hofmann2017Book} using PyORBIT. Fig.~\ref{fig:incoherent_instability} shows a simulation of a truncated Gaussian distribution in a FODO lattice as the zero-current tune is decreased from 100\degree to 90\degree over 500 cells. The initial distribution has equal emittances in both planes and is matched to the lattice with a depressed tune of 92\degree.
%
\begin{figure}[!p]
    \centering
    \vspace*{2cm}
    \begin{subfigure}{\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/incoherent_resonance_fourth_order.png}
        \label{fig:incoherent_instability_a}
        \caption{}
    \end{subfigure}
    \vfill
    \vspace*{1cm}
    \vfill
    \begin{subfigure}{0.5\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/incoherent_resonance_fourth_order_emittance.png}
        \label{fig:incoherent_instability_b}
        \caption{}
    \end{subfigure}
    \caption{Simulation of a truncated Gaussian distribution in a FODO lattice. The zero-current tune is decreased from 100\degree to 90\degree over 500 cells. (a) $x$-$x'$ distribution. (b) RMS horizontal emittance. (Reproduced from \cite{Hofmann2017Book}.)}
    \label{fig:incoherent_instability}
    \vspace*{2cm}
\end{figure}
%
A fourth-order resonance is excited as the depressed tune approaches 90 degrees. The smooth emittance growth during most of the simulation shows that the core of the beam remains matched, justifying the use of ``incoherent" describe the resonance. Higher-order resonances can also occur for different combinations of beam intensity and focusing strength.

\section*{Coherent instabilities}

In \cite{Hofmann1983}, Hofmann et al. analytically studied perturbations of a round ($\varepsilon_x = \varepsilon_y$) KV distribution using the Vlasov equation in one of the simplest time-dependent cases: a FODO lattice with equal horizontal and vertical tunes. The result is shown in Fig.~\ref{fig:stopbands}, which plots the depressed tune as a function of beam intensity. Each thin line represents a different zero-current tune, and the thick lines represent regions of instability.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=\textwidth]{Images/chapter1/stopbands_hor.png}
    \caption{Instability stopbands obtained from perturbations of a KV distribution with equal emittances in a FODO lattice. (From \cite{Hofmann1983}).}
    \label{fig:stopbands}
\end{figure}
%

The second-order instabilities involve linear forces only, so they should appear in the KV envelope equations. We use a FODO cell with a zero-current tune of $100\degree$ corresponding to the second-to-bottom line on the left-most plot in Fig.~\ref{fig:stopbands}. The initial distribution is first matched to the lattice, then tracked for 500 cells by integrating the KV envelope equations. Fig.~\ref{fig:envelope_instability} shows the horizontal and vertical envelopes as the depressed KV tune is decreased from $90\degree$ to $71\degree$, crossing the stopband. This is known as the envelope instability.
%
\begin{figure}[!p]
    \centering
    \includegraphics[width=\textwidth]{Images/chapter1/envelope_instability.png}
    \caption{Integrated KV envelope equations in a FODO lattice as the depressed KV tune $\nu_x$ is decreased. The zero-current tune is 100\degree.} \label{fig:envelope_instability}
\end{figure}
%

Observation of the higher-order stopbands requires PIC simulation. We choose a zero-current tune of 90\degree; according to Fig.~\ref{fig:stopbands}, a third-order and fourth-order instability should occur at a depressed tune of 45\degree and 30\degree, respectively. Fig.~\ref{fig:coherent_instabilities} shows the simulated evolution in PyORBIT for three different distributions: KV, Waterbag, and Gaussian. (Note that while the simulations in \cite{Hofmann2017Book} used a bunched beam, coasting beams were used in this simulation.)
%
\begin{figure}[!p]
    \begin{subfigure}[b]{0.47\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/coherent_instability_fourth_order.png}
        \label{fig:coherent_instabilities_a}
    \end{subfigure}
    \hfill
    \begin{subfigure}[b]{0.47\textwidth}
        \includegraphics[width=\textwidth]{Images/chapter1/coherent_instability_third_order.png}
        \label{fig:f2}
    \end{subfigure}
    \vfill
    \begin{subfigure}[b]{\textwidth}
        \centering
        \includegraphics[width=\textwidth]{Images/chapter1/coherent_instability_emittances.png}
        \label{fig:coherent_instabilities_b}
    \end{subfigure}
    \caption{Simulated Gaussian, Waterbag, and KV distributions in a FODO lattice with a zero-current tune of 90\degree and depressed KV tunes of $\nu_x$ = 45\degree (top left) and 30\degree (top right).}
    \label{fig:coherent_instabilities}
\end{figure}
%
The instabilities violently affect the KV distribution, but their effect is less pronounced in the other distributions. Thus, it is assumed that high-order coherent instabilities, while interesting, are not important in typical beams with large tune spreads.

The Danilov distribution and/or other self-consistent distributions may exhibit similar coherent instabilities. Lund, Kikuchi, and Davidson noted this in 2009 \cite{Lund2009}:
\begin{quote}
    \textit{Although the low-order properties of the KV distribution are appealing physically, the full four-dimensional structure corresponds to a singular, hyperellipsoidal shell in phase space. For strong space charge, this singular structure drives unphysical, higher-order instabilities which limit practical use of the KV distribution for initializing simulations. The KV distribution is the only exact Vlasov equilibrium known that is a function of linear-field Courant-Snyder invariants. Danilov et al. \cite{Danilov2003} investigate alternative classes of exact kinetic equilibrium distributions for linear forces. These distributions are highly singular, and based on elementary plasma physics considerations, can be expected to be unstable (similar to the KV distribution) in regimes of high space-charge intensity.}
\end{quote}