% Created: Enze Chen, August 2017
% Updated: Aaron Lindenberg, 2018
% Last edited: Enze Chen, February 2018
%
% Chapter 7 of the MSE 142 coursereader.

% Uncomment the following three lines and last line to individually compile this chapter
%\documentclass[12pt, english]{book}
%\usepackage{142crstyle}
%\begin{document}

\chapter{Quantum Field Theory} \label{ch:qft}
%{ \doublespacing
One of the greatest challenges facing scientists of the 20th century was using quantum mechanics to accurately model the behavior of subatomic particles, which usually involved painstakingly reconciling quantum mechanics with special relativity. Eventually, they developed the framework of quantum field theory (QFT), which treats particles as excited states (quanta) of the underlying \emph{field} (hence the name).\footnote{For an interesting explanation with helpful diagrams, see \href{https://www.ribbonfarm.com/2015/08/20/qft/}{this post} from Brian Skinner.} We can think of a field as a network of interconnected balls and springs and the strength of the field can be measured by the amount of displacement from rest. In this chapter, we will only scratch the surface of QFT as we explore some of its most surprising and most important results. \par

\section{Second quantization}
So far, all of the systems we have analyzed fall into the category of \textbf{first quantization}, where we describe a quantum mechanical system by its wave function and we describe its surroundings (e.g. the potential well) using classical mechanics. While this formulation is well-defined for a single-particle system, many of its expressions grow combinatorially unwieldy for many-particle systems. In QFT, we are less concerned with the behavior of individual particles (``Which state is particle $i$ in?'') and we're more interested in the overall distribution (``How many particles are in state $\alpha$?''). This calls for \textbf{second quantization}, which places a QHO at each point in space such that the strength of the field is quantized. \par

\subsection{Occupation number operator}
Recall that for single particles, we used bra-ket notation to represent the quantum state as $\ket{\alpha}$, where $\alpha = 0,\ 1,\ 2,\ \dots$. Now we will define the \textbf{occupation number operator} $\hat{n}_{\alpha}$ to be the number of particles in the single-particle state $\ket{\alpha}$. These occupation numbers label the basis state, which is represented as

\begin{tcolorbox} [title=Basis vector] \vspace{-2ex}
	\begin{equation}
		\ket{\Psi} = \ket{\hat{n}_0,\ \hat{n}_1,\ \hat{n}_2,\ \dots,\ \hat{n}_{\alpha},\ \dots} \label{eq:fock}
	\end{equation}
\end{tcolorbox}

For bosons, $\hat{n}_{\alpha}$ can be any non-negative integer, while for fermions $\hat{n}_{\alpha}$ must be 0 or 1.\footnote{Bosons are a class of subatomic particles that have integer spins (e.g. photons, gluons, and other force carriers), while fermions are another class of subatomic particles that have non-integer spins (e.g. electrons) and obey the Pauli exclusion principle.} This formalism allows us to treat the quantum system as an ensemble of indistinguishable particles. The total number of particles is then
\begin{equation}
	\hat{N} = \sum_{\alpha} \hat{n}_{\alpha}
\end{equation}
which sums all the particles in all the states. \par

To get a better understanding of the basis vectors, let's consider some special cases. First, there is a \textbf{vacuum state} with no particles represented as
\begin{equation}
	\ket{0} = \ket{0,\ 0,\ 0,\ \dots}
\end{equation}

The single-particle state that we've previously encountered can be written as
\begin{equation}
	\ket{1_{\alpha}} = \ket{0,\ 0,\ \dots, 1_{\alpha},\ \dots} = \psi_{\alpha}
\end{equation}

From this point, many-particle, many-state bases can be easily deduced, and we'll leave it as an exercise to the reader to find the proper normalization coefficient. \par

Noticeably, the basis vector we defined in Equation~\ref{eq:fock} does not have a fixed particle number. This allows us to introduce and take away particles from our quantum mechanical system, which is conveniently handled by the creation and annihilation operators. \par

\subsection{Creation and annihilation operators}

In the previous chapter, we used the creation and annihilation operators to arrive at different energy states of the quantum harmonic oscillator. Here, since we are dealing with an ensemble of many particles in many states, we will have a different $\ad_{\alpha}$ and $a_{\alpha}$ for each state $\ket{\alpha}$. Furthermore, the definition of the operators has changed, and now the creation operator acts as if it's truly ``creating'' another particle and adding it to the system. Formally, we have
\begin{equation}
	\ad_{\alpha} \ket{\hat{n}_1,\ \hat{n}_2,\ \dots,\ \hat{n}_{\alpha},\ \dots} = \sqrt{\hat{n}_{\alpha}+1}\ket{\hat{n}_1,\ \hat{n}_2,\ \dots,\ \hat{n}_{\alpha}+1,\ \dots}
\end{equation}

Similarly, we define the annihilation operator as
\begin{equation}
a_{\alpha} \ket{\hat{n}_1,\ \hat{n}_2,\ \dots,\ \hat{n}_{\alpha},\ \dots} = \sqrt{\hat{n}_{\alpha}}\ket{\hat{n}_1,\ \hat{n}_2,\ \dots,\ \hat{n}_{\alpha}-1,\ \dots}
\end{equation}

A simple demonstration of the creation operator would be to apply it to the vacuum state to obtain the single-particle state
\begin{equation}
	\ad_{\alpha} \ket{0} = \ket{1_{\alpha}}
\end{equation}

Likewise, if we apply the annihilation operator to the vacuum state, or any basis vector with zero particles in the particular state, we get zero.
\begin{equation}
	a_{\alpha} \ket{0} = 0, \qquad a_{\alpha} \ket{\hat{n}_1,\ \dots,\ \hat{n}_{\alpha}=0,\ \hat{n}_{\beta},\ \dots} = 0
\end{equation}

If we apply the annihilation operator and creation operator in succession, we obtain
\begin{equation*}
\ad_{\alpha} a_{\alpha} \ket{\hat{n}_1,\ \hat{n}_2,\ \dots,\ \hat{n}_{\alpha},\ \dots} = \hat{n}_{\alpha}\ket{\hat{n}_1,\ \hat{n}_2,\ \dots,\ \hat{n}_{\alpha},\ \dots}
\end{equation*}

which gives the relation
\begin{equation}
	\hat{n}_{\alpha} = \ad_{\alpha}a_{\alpha}
\end{equation}

This is similar to what we saw with the QHO and is another definition for the number operator. We will also state the commutation relations here without proof. Note that these are the same commutation relations as the QHO, and it's perfectly valid in QFT to consider bosons as energy quanta of an underlying field of quantum oscillators.
\begin{equation}
	\left[\ad_{\alpha},\ad_{\beta}\right] = \left[a_{\alpha},a_{\beta}\right] = 0, \qquad \left[a_{\alpha}, \ad_{\beta}\right] = \delta_{\alpha,\beta}
\end{equation}

With the formal definitions of second quantization out of the way, we can proceed to a more interesting analysis. Since we have an operator that gives the number of particles of each state in our system, we can find the total energy of all the particles by a simple sum. The expression for the Hamiltonian becomes
\begin{equation}
	\hat{H} = \sum_{\alpha} \hbar\omega_{\alpha} \left(\hat{n}_{\alpha} + \frac{1}{2} \right) = \sum_{\alpha} \hbar\omega_{\alpha} \left(\ad_{\alpha}a_{\alpha} + \frac{1}{2}\right)
\end{equation}

Here we give each quantum state its individual frequency $\omega_{\alpha}$. Now, as we showed in the last chapter, the Hamiltonian is a Hermitian operator, which means it should return a sensible value for the expectation. If we find the expected total energy of the vacuum state, we get the following:
\begin{align*}
	\mel{0}{\hat{H}}{0} &= \sum_{\alpha} \hbar\omega_{\alpha} \cancelto{0}{\mel{0}{\ad_{\alpha}a_{\alpha}}{0}} + \sum_{\alpha}\hbar\omega_{\alpha}\left(\frac{1}{2}\right) \\
	&= \sum_{\alpha} \frac{\hbar\omega_{\alpha}}{2} \rightarrow \infty
\end{align*}

In the second line, the summation of zero-point energies over an unbounded number of possible states seemingly gives infinite energy from vacuum fluctuations alone. Crazy! One of the early results of QFT was that the underlying field is in constant flux and it has physically relevant consequences. We'll see in the next section how we might resolve this ``infinite energy'' to make it physically interpretable.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Quantum electrodynamics}
One of the crowning achievements of QFT is the construction of \textbf{quantum electrodynamics} (QED), which describes how light and matter interact in the quantized electromagnetic field.\footnote{For a great introduction to QED in layman terms, see R. P. Feynman, \href{https://en.wikipedia.org/wiki/QED:_The_Strange_Theory_of_Light_and_Matter}{\emph{QED: The Strange Theory of Light and Matter}}. 1st ed., Princeton, NJ, Princeton University Press, 1985.} QED was the first theory to reconcile quantum mechanics and special relativity, and it led to extremely accurate calculations for the Lamb shift,\footnote{A good description of the Lamb shift is provided by \href{http://hyperphysics.phy-astr.gsu.edu/hbase/quantum/lamb.html}{Rod Nave}.} spontaneous emission (discussed in the next chapter), and a mysterious phenomenon called the Casimir effect, which we will discuss here. As it turns out, all of these phenomenon can be easily explained by the vacuum fluctuation energy and the way it interacts with matter.

%\subsection{Renormalization}

\begin{figure}[!h]
	\centering
	\subfloat[]{\includegraphics[width=0.5\linewidth]{casimir} \label{casimir-fig}} \hspace{2ex}
	\subfloat[]{\includegraphics[width=0.45\linewidth]{casimir-exp} \label{casimir-exp}}
	\caption{\protect\subref{casimir-fig} A schematic of the Casimir effect observed between two metal plates. The boundary conditions at the plates allow a limited number of standing waves to exist in the middle region, which is fewer than the amount of vacuum fluctuations outside the plates. This creates a pressure difference that forces the plates together. \protect\subref{casimir-exp} An experimental measurement using an atomic force microscope of the Casimir force between an Al-coated sphere and an Al-coated surface. Reproduced from U. Mohideen and A. Roy, \href{https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.81.4549}{\emph{Phys. Rev. Lett.}} \textbf{81}, 4549 (1998).}
	\label{fig:casimir}
\end{figure}

\subsection{Casimir effect}
In 1948, Dutch physicist Hendrik Casimir predicted that the zero-point energy in the QED vacuum could cause a physical force between two neutral conducting plates.\footnote{H. B. G. Casimir, \href{http://www.dwc.knaw.nl/DL/publications/PU00018547.pdf}{\emph{Proc. Kon. Ned. Akad. Wetensch.}} \textbf{51}, 793 (1948)} This phenomenon became known as the \textbf{Casimir effect} (Figure~\ref{fig:casimir}) and can be explained using QED and second quantization. Although there are infinite vacuum fluctuations in the space outside of the plates, the reflective surface of the plates actually exclude virtual photons (manifestations of the underlying field) with wavelengths longer than the interplanar distance. Essentially you can think of the plates as nodes for the wave-like photons, so only wavelengths that line up perfectly will remain in the middle region. This reduces the energy density between the two plates, and much like normal pressure, the Casimir force pushes the two plates closer together. \par

Since we should not be merely satisfied with a description, let's try to find an analytical argument and really derive the strength of this Casimir force. Since we are working with the QED vacuum, we have to first establish the \textbf{dispersion relation} for photons, which gives the relationship between the frequency and the wave number. Mathematically, this is written as
\begin{tcolorbox}[title=Dispersion relation] \vspace{-2ex}
	\begin{equation}
		\omega_n = ck_n \label{eq:dispersion}
	\end{equation}
\end{tcolorbox}

where $c$ is the speed of light and $k_n = n\pi/d$. We also make use of the subscript $n$ here to index individual solutions, just like we did with the particle in a box. \par

\subsection{Regularization and renormalization}

Now we will try to find the amount of energy in between the two plates and subtract that quantity from the energy on the outside, and that should give us quantitative information about the Casimir force (its derivative will, anyways). Inside the two conducting plates, we have the following expression for the total energy:
\begin{align*}
	E_{\text{in}} &= \sum_{\alpha} \frac{\hbar\omega_{\alpha}}{2} \\
	&= \sum_{n=0}^{\infty} \frac{\hbar c k_n}{2} \\
	&= \frac{\hbar \pi c}{2d} \sum_{n=1}^{\infty} n \numberthis \label{eq:casimir-in}
\end{align*}

We use a discrete sum for the discrete energy levels of the bound photons, and just like before, we see that the total energy approaches infinity. Now, those of you that have taken complex analysis might see the summation and realize where this is headed---and yes indeed, it is possible to use analytical methods such as \textbf{zeta function regularization} to evaluate the sum of natural numbers by assigning a finite value to an otherwise divergent sum.\footnote{See \href{https://en.wikipedia.org/wiki/1_\%2B_2_\%2B_3_\%2B_4_\%2B_\%E2\%8B\%AF}{Wikipedia} for an interesting discussion about $1+2+3+4+\cdots$.}
\begin{equation}
	 \sum_{n=1}^{\infty} n = 1 + 2 + 3 + 4 + \cdots = -\frac{1}{12}   \label{eq:sumN}
\end{equation}

We will come back to this shortly, and as bizarre as this is, I ask you to trust me for the time being. We still have to find the total energy of the virtual photons \emph{outside} of the metal plates, which is similar to Equation~\ref{eq:casimir-in}, except we will now take an integral (instead of a sum) because the modes are no longer confined to be integers and can be any non-negative real number. Proceeding, we have
\begin{align*}
	E_{\text{out}} &= \frac{\hbar \pi c}{2d} \int_0^{\infty} n \dd{n} \\
	&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \int_0^{\infty} ne^{-sn} \dd{n} \\
	&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \int_0^{\infty} \dv{s} \int ne^{-sn} \dd{s} \dd{n} \\
	&= -\frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \dv{s} \int_0^{\infty} e^{-sn} \dd{n} \\
	&= -\frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \dv{s} \left(-\frac{1}{s} e^{-sn} \bigg|_0^{\infty} \right) \\
	&= -\frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \dv{s} \left( \frac{1}{s} \right) \\
	E_{\text{out}} &= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \frac{1}{s^2} \numberthis \label{eq:casimir-out}
\end{align*}

In going from the first line to the second, we employed \textbf{exponential regularization} to transform the integrand into something more manageable. Regularization is a common trick in QFT for dealing with infinities by employing a ``cutoff'' function to model physics at unobserved length scales. You can check for yourself that by taking the limit as $s$ approaches 0 we get back our original integral. In the third line we insert a derivative and integral with respect to $s$ to cleverly simplify our expression. These are \emph{not} obvious steps, so don't worry if you find yourself asking how you would know to do this on your own. I wish to simply expose you to this technique, and as long as you are able to follow along, it is sufficient for this course. \par

Of course, the question we \emph{should} be asking is how we could possibly subtract the two expressions we obtained in Equation~\ref{eq:casimir-in} and~\ref{eq:casimir-out}, which both approach infinity, and still get a non-zero result. As you may recall from calculus, some infinities are bigger than other infinities,\footnote{\href{https://en.wikipedia.org/wiki/Cantor\%27s_diagonal_argument}{Cantor's diagonal argument} is one proof of this fact, and \href{http://vihart.com/proof-some-infinities-are-bigger-than-other-infinities/}{Vi Hart} gives a great explanation in their video.} so as long as we can quantify \emph{how much} greater one expression is than the other, then we can reach a finite result. This touches upon the concept of \textbf{renormalization}, which is the other technique physicists use to handle infinities in QFT by assigning physical quantities to match observed values, thereby correcting for length-scale differences and self-interaction effects. \par

Just as we did in the derivation for $E_{\text{out}}$, we will also apply regularization to the expression we obtained for $E_{\text{in}}$. We will move quickly through the derivations here, and leave the details for Appendix~\ref{sec:casimir-deriv}. Proceeding, we have:
\begin{align*}
	E_{\text{in}} &= \frac{\hbar \pi c}{2d} \sum_{n=1}^{\infty} n \\
	&= \frac{\hbar \pi c}{2d} \left( - \lim\limits_{s \rightarrow 0} \dv{s} \sum_{n=0}^{\infty} e^{-sn} \right) \\
	&= \frac{\hbar \pi c}{2d} \left( - \lim\limits_{s \rightarrow 0} \dv{s} \frac{1}{1-e^{-s}} \right)
\end{align*}

where we have used the sum of an infinite geometric series with common ratio $e^{-s}$ to arrive at the last line. Now we can evaluate the derivative to obtain
\begin{equation*}
	E_{\text{in}} = \frac{\hbar \pi c}{2d} \left( \lim\limits_{s \rightarrow 0} \frac{e^{s}}{(e^s-1)^2} \right)
\end{equation*}

Now if we rewrite the last line using the Taylor series expansion around $s=0$, we get
\begin{align*}
	E_{\text{in}} &= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1+s+s^2/2 + \cdots}{(s + s^2/2 + s^3/6 + \cdots)^2} \right) \\
	&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1}{s^2} - \frac{1}{12} + \mathcal{O}(s^2) \right) \numberthis \label{eq:casimir-in2}
\end{align*}

As $s$ approaches 0, we can discard the terms of order 2 and greater, and subtract Equation~\ref{eq:casimir-in2} from Equation~\ref{eq:casimir-out}. This leaves us with
\begin{equation*}
	E_{\text{out}} - E_{\text{in}} = \frac{\hbar \pi c}{2d} \left[ \frac{1}{s^2} - \left( \frac{1}{s^2} - \frac{1}{12} \right) \right] = \frac{\hbar \pi c}{24d}
\end{equation*}

\begin{tcolorbox}[title=Casimir force in one dimension] \vspace{-2ex}
	\begin{equation}
		F_{\text{cas}} = -\dv{E}{d} = -\frac{\hbar \pi c}{24d^2}
	\end{equation}
\end{tcolorbox}

In three dimensions, the Casimir force per unit area (a ``pressure'' quantity) becomes
\begin{equation*}
	\frac{F_{\text{cas}}}{A} = -\frac{\hbar\pi^2c}{240d^4}
\end{equation*}

The negative sign here signifies an attractive force, which is what we expect if the energy density is larger on the outside of the plates than on the inside. The presence of $\hbar$ also means $F_{\text{cas}}$ is very small and hence only observable on the nanoscale. \par

The Casimir effect was finally measured experimentally by Steven K. Lamoreaux in 1997,\footnote{S. K. Lamoreaux, \href{https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.78.5}{\emph{Phys. Rev. Lett.}} \textbf{78}, 5 (1997).} and the photo in Figure~\ref{fig:casimir} is another experimental setup by Umar Mohideen that achieved measurement accuracy within 1\% of the theoretical value. The Casimir force significantly dominates the other fundamental forces at nanometer length scales and plays an important role in the performance of nanoelectronics and nanodevices. What's perhaps most surprising about the Casimir effect is that the force can change between attractive and repulsive simply based on the geometry of the conducting plates! \par

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Application: Phonons}
Materials scientists typically work with condensed matter (solids and liquids) whose atom centers are analogous to the arrangement of harmonic oscillators in the quantum field. The periodicity of the atom centers in a crystal, much like what we saw in Chapter~\ref{ch:period}, leads to distinct vibrational modes that are quantized as \textbf{phonons} (Figure~\ref{fig:phonons}). Nearest neighbor interactions (electrostatic forces, van der Waals forces, etc) create an energy landscape that is well approximated by a parabolic potential surface, much like the QHO. Analyzed in the framework of second quantization, phonons behave exactly like bosons, with the same Hamiltonian, creation and annihilation operators, and commutation relations.

\begin{figure}[!h]
	\centering
	\includegraphics[width=0.5\linewidth]{phonons}
	\caption{Collective vibrations in a crystal are quantized as phonons.}
	\label{fig:phonons}
\end{figure}

Phonons play a major role in the electrical conductivity, thermal conductivity, and thermal capacity of condensed matter. One of the most interesting features of phonons is when there are two different atoms vibrating next to each other, which results in two different phonon modes. The dispersion relation is given by the following equation and it is plotted in Figure~\ref{fig:phonon-modes}.
\begin{equation}
	\omega^2 = \frac{C}{m_1m_2} \left(m_1 + m_2 \pm \sqrt{m_1^2 + m_2^2 + 2m_1m_2\cos(kd)}\right)
\end{equation}

\begin{figure}[!h]
	\centering
	\subfloat[]{\includegraphics[width=0.5\linewidth]{phonon-modes} \label{phonon-modes}} \hspace{3ex}
	\subfloat[]{\includegraphics[width=0.35\linewidth]{phonon-absorption} \label{phonon-absorption}}
	\caption{\protect\subref{phonon-modes} Dispersion relation for phonons in a solid with two atoms per unit cell. The acoustic mode governs thermomechanical properties while the optical mode governs electronic properties. \protect\subref{phonon-absorption} Transmissivity of a film of RbI at different temperatures, with each minimum at a photon energy equal to that of the long wavelength transverse optical phonon. Reproduced from G. O. Jones \emph{et al.} \href{http://rspa.royalsocietypublishing.org/content/261/1304/10}{\emph{Proc. R. Soc. Lond.}} \textbf{A261}, 10-27, (1961).}
	\label{fig:phonon-modes}
\end{figure}

When atoms are vibrating coherently (in the same direction; corresponding to the minus sign in the above equation), \textbf{acoustic phonons} are produced, named because they regulate the speed of sound in the medium as well as the medium's mechanical and thermal properties.\footnote{See A. A. Balandin \href{https://www.nature.com/nmat/journal/v10/n8/full/nmat3064.html}{\emph{Nature Materials}}, \textbf{10}, 569-581 (2011) for a review of the thermal properties of carbon nanostructures.} On the other hand, atoms vibrating out-of-phase (in opposite directions) will produce \textbf{optical phonons}, which interact with light in absorption and \emph{Raman scattering}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Summary}
To recap, this chapter gave us a taste of quantum field theory and some of its important applications. Second quantization provided a suitable framework for interpreting fields with the new occupation number operator and new definitions for the creation and annihilation operators. Then we explored the strange nature of the Casimir effect using regularization and renormalization to handle various infinities. Finally, we related the theoretical framework of QFT to phonons, which are quantized lattice vibrations that govern a lot of material behavior. This chapter was largely enrichment in the context of this course, but you will definitely see more of QFT as you take more advanced courses in quantum mechanics due to its profound implications. Perturbation theory, which we will see in the next chapter, is another subfield of quantum mechanics that shares similarities with QFT.

%} % for doublespacing
%\end{document}


\section{Real functions as infinite-dimensional vectors}


% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
\documentclass[11pt,a4paper,twoside]{book}
\usepackage{amsmath,amssymb}
\usepackage{empheq}
\usepackage[semibold]{ebgaramond}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\usepackage{ebgaramond-maths}
\usepackage{bm}
\usepackage[OMLmathrm, OMLmathsfit, rmdefault=mdugm]{isomath}
\usepackage{tocbibind}
\usepackage{makeidx}
\makeindex

\makeatletter
  \DeclareSymbolFont{ntxletters}{OML}{ntxmi}{m}{it}
  \SetSymbolFont{ntxletters}{bold}{OML}{ntxmi}{b}{it}
  \re@DeclareMathSymbol{\leftharpoonup}{\mathrel}{ntxletters}{"28}
  \re@DeclareMathSymbol{\leftharpoondown}{\mathrel}{ntxletters}{"29}
  \re@DeclareMathSymbol{\rightharpoonup}{\mathrel}{ntxletters}{"2A}
  \re@DeclareMathSymbol{\rightharpoondown}{\mathrel}{ntxletters}{"2B}
  \re@DeclareMathSymbol{\triangleleft}{\mathbin}{ntxletters}{"2F}
  \re@DeclareMathSymbol{\triangleright}{\mathbin}{ntxletters}{"2E}
  \re@DeclareMathSymbol{\partial}{\mathord}{ntxletters}{"40}
  \re@DeclareMathSymbol{\flat}{\mathord}{ntxletters}{"5B}
  \re@DeclareMathSymbol{\natural}{\mathord}{ntxletters}{"5C}
  \re@DeclareMathSymbol{\star}{\mathbin}{ntxletters}{"3F}
  \re@DeclareMathSymbol{\smile}{\mathrel}{ntxletters}{"5E}
  \re@DeclareMathSymbol{\frown}{\mathrel}{ntxletters}{"5F}
  \re@DeclareMathSymbol{\sharp}{\mathord}{ntxletters}{"5D}
  \re@DeclareMathAccent{\vec}{\mathord}{ntxletters}{"7E}
\makeatother

\usepackage{array}
% to produce a comma between multiple footnotes / https://tex.stackexchange.com/questions/40072/incompatibility-between-footmisc-option-multiple-and-hyperref/62091#62091
\let\oldFootnote\footnote
\newcommand\nextToken\relax
\renewcommand\footnote[1]{%
    \oldFootnote{#1}\futurelet\nextToken\isFootnote}
\newcommand\isFootnote{%
    \ifx\footnote\nextToken\textsuperscript{,}\fi}

\defaultfontfeatures{Ligatures=TeX} % makes this a feature for all selected fonts
\usepackage{esint}
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage[text={18cm,26cm},centering]{geometry} %
\usepackage{natbib}
\usepackage{graphicx}
\graphicspath{{pics/}}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{hyperref}
\usepackage{url}
\usepackage[export]{adjustbox}

\hypersetup{
  colorlinks,
  citecolor=bleuSU,
  linkcolor=bleuSU
}
\definecolor{bleuSU}{RGB}{26,39,101}

\usepackage[normalem]{ulem}
\makeatletter
\renewcommand*{\uuline}{%
  \bgroup
  \UL@setULdepth
  \markoverwith{%
    \lower\ULdepth\hbox{%
      \kern-.03em%
      \vtop{%
        \hrule width.2em%
        \kern 0.6pt % distance between the two underlines
        \hrule
      }%
      \kern-.03em%
    }%
  }%
  \ULon
}
\makeatother
\setlength{\ULdepth}{-2pt}  % distance from double underline to letter

\newcommand{\delS}{\delta S}
\newcommand{\delA}{\delta A}
\newcommand{\delh}{\delta h}
\newcommand{\delt}{\delta t}
\newcommand{\delz}{\delta z}
\newcommand{\delbx}{\delta \matrixsym x}
\newcommand{\lp}{\left(}
\newcommand{\rp}{\right)}
\newcommand{\itA}{\textit A}
\newcommand{\itB}{\textit B}
\newcommand{\dAB}{\mathcal D_{AB}}
\newcommand{\bA}{\matrixsym A}
\newcommand{\bff}{\matrixsym{f}}
\newcommand{\bF}{\matrixsym{F}}
\newcommand{\bj}{\matrixsym{j}}
\newcommand{\bJ}{\matrixsym J}
\newcommand{\bn}{\matrixsym{n}}
\newcommand{\bN}{\matrixsym N}
\newcommand{\bp}{\matrixsym{p}}
\newcommand{\bP}{\matrixsym{P}}
\newcommand{\br}{\matrixsym r}
\newcommand{\bt}{\matrixsym t}
\newcommand{\be}{\matrixsym e}
\newcommand{\bu}{\matrixsym u}
\newcommand{\bU}{\matrixsym U}
\newcommand{\bv}{\matrixsym v}
\newcommand{\bV}{\matrixsym V}
\newcommand{\bw}{\matrixsym w}
\newcommand{\bx}{\matrixsym x}
\newcommand{\bX}{\matrixsym X}
\newcommand{\by}{\matrixsym y}
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\D}[2]{\frac{D #1}{D #2}}
\newcommand{\dd}[2]{\frac{\mathrm d #1}{\mathrm d #2}}
\newcommand{\dA}{\mathrm dA}
\newcommand{\dV}{\mathrm dV}
\newcommand{\dS}{\mathrm dS}
\newcommand{\prg}[1]{\paragraph{$\rhd$ #1}}
\newcommand{\alphaijkl}{\alpha_{ijkl}}
\newcommand{\Aijkl}{A_{ijkl}}
\newcommand{\delij}{\delta_{ij}}
\newcommand{\sigij}{\sigma_{ij}}
\newcommand{\sigji}{\sigma_{ji}}
\newcommand{\sigxy}{\sigma_{xy}}
\newcommand{\matL}{\mathcal L}
\newcommand{\matO}{\mathcal O}
\newcommand{\matS}{\mathcal S}
\newcommand{\kij}{k_{ij}}
\newcommand{\tensor}[1]{\smash{\uuline{#1}{}}}
\setlength{\parindent}{0pt} % remove indent

\counterwithout{footnote}{chapter}

\begin{document}
{
\title{\textit{Physics of fluids \& nonlinear physics}}
%\author{Arnaud Antkowiak \qquad Camille Duprat}
\author{
  \textsc{Arnaud Antkowiak}\footnote{\href{mailto:arnaud.antkowiak@upmc.fr}{arnaud.antkowiak@upmc.fr}}\\ \textsc{Sorbonne Université}
  \and
  \textsc{Camille Duprat}\footnote{\href{mailto:camille.duprat@ladhyx.polytechnique.fr}{camille.duprat@ladhyx.polytechnique.fr}}\\ \textsc{École polytechnique}
}
%\author{Arnaud Antkowiak}
%\affil{Sorbonne Université}
%\author{Camille Duprat}
%\affil{École polytechnique}

\date{v0.21.09$_\text{26}$}
\maketitle
\tableofcontents
}
\input{./01_equations.tex}
\input{./02_boundary_conditions.tex}
\input{./03_viscous_flows.tex}
\bibliographystyle{jfm}
\bibliography{biblio_pof}
\printindex
\end{document}


% mainfile: ../Refinement.tex
\chapter{Introduction}
\pagestyle{scrheadings}
\setcounter{page}{0}
\pagenumbering{arabic}
\label{chp_introduction}
Modeling distributed computing systems exhibit various aspects such as modeling the components of the system and modeling the behavior and communication between the concurrent mobile components. Formal specification techniques for such systems have to be able to describe all these aspects. Unfortunately, a single specification technique that is well suited for all these aspects is not yet available. Instead, one finds techniques that are very good at describing individual aspects of system. This observation has led to research into the combination and semantic integration of specification techniques. In this thesis we research combining the two specification techniques:
\picalc{} and Object-Z.

The \picalc{} is a process algebra originally introduced by Robin Milner, Joachim Parrow, and David Walker in \cite{milner1992calculus}. The central concepts of \picalc{} are communication via channels between different processes, creating new channels, parallel composition, and the mobility of channels, which we will use to model the mobility of components. Tool support comes through the \picalc{} visualizer Stargazer and the bisimulation checker ABC.

Object-Z \cite{smith2000the} is an object-oriented extension of the Z formal specification language. It represents a set-theoretic and predicate language for the specification of data. It extends Z by the addition of language constructs resembling the object-oriented paradigm, most notably, classes to encapsulate a state schema, an initial state schema and operation schemas. The state schema specifies the set of the legal states. The initial state schema specifies the set of the legal initial states. The operation schemas specify the legal ways of moving from one state to another.

The main contribution of this thesis is to develop the combination $\pi$-OZ and to transform it into a \picalc{} process, similarly to the approach for CSP-OZ in \cite{olderog}. $\pi$-OZ is a new combination of formal techniques for the specification of components and their behavior. The basic idea is to use a \picalc{} process to specify the behavior of an Object-Z class. This enables the mobility of Object-Z classes through the use of the state pattern \cite{erichgamma1994}, which is a behavioral software design pattern that allows an object to alter its behavior when its state changes. Syntactically, the $\pi$-OZ specification is divided into an OZ part specifying the data and the possible state transitions, and a $\pi$ part specifying the behavior.  This combination is illustrated by the example of a mobile vending machine and two shops, which alternate their behavior when they connect to the mobile vending machine.

 Transforming the combination $\pi$-OZ into a \picalc{} process enables checking the simulation of mobile processes with data. The transformation gives the combination a \picalc{} semantics. The idea is that this semantics comes from the parallel composition of the $\pi$ part and a $\pi$ process, representing the OZ part transformed syntactically into a \picalc{} process.

 Furthermore, we investigate a failure-model and a success-model for the \picalc{} processes and show their relation to the simulation and point out its limitations.

This thesis is divided into five chapters. Chapter 2 gives an overview of the \picalc{} and Object-Z. Thereby, Dynamic OZ, a new extension of Object-Z is introduced to model mobile components with alternating behavior. Chapter 3 proceeds by transforming OZ class into a \picalc{} process. Subsequently, Chapter 4 introduces the combination $\pi$-OZ and its transformation into the \picalc{}. Chapter 5 introduces the failure and the success refinement of the \picalc{} and their relation to the simulation. Finally, the conclusion in Chapter 6 summarizes our results and presents future directions of our research.


\chapter{Inelastic Cosmic Ray Collisions}\label{chap:cr}

Dark Matter direct detection experiments lose sensitivity to sub-GeV particles due to prohibitively small nuclear recoil energies. On the other hand, previous work such as ~\cite{Bringmann:2018cvk, Ema:2018bih} suggests that light dark matter may naturally lead to a sub-dominant flux of higher momenta particles. This would lead to a reinterpretation of the current direct detection limits. Here we present a calculation of such a flux arising from inelastic cosmic ray collisions in the atmosphere. We also derive limits from the XENON1T experiment and forecast the reach of the LZ detector.

\section{Cosmic Ray Dark Matter Flux}
We distinguish two possible sources for a dark matter flux arising from the mechanism described in the Introduction: inelastic cosmic ray collisions with protons in the interstellar medium and with the atmosphere on Earth. According to our calculations, the former yields a flux several orders of magnitude lower than the latter; therefore, we may safely neglect it and focus on our modelling of interactions at the atmosphere.

The incoming cosmic ray flux is taken to be the local interstellar proton spectrum parametrised as in Ref.~\cite{Boschini:2017fxq}; alternatively we have also checked that using the AMS02 spectrum~\cite{Consolandi:2014uia} leads to identical results. The differential intensity $dI/dR$ as a function of particle rigidity $R$ is converted to a flux $d\Phi_p / dT_p = 2\pi (dR/dT_p)(dI/dR)$ per unit area, time, and kinetic energy $T_p$, over a hemispherical solid angle. We performed a Monte-Carlo simulation of this incoming flux using EPOS-LHC~\cite{Pierog:2013ria}, as implemented in the CRMC package~\cite{CRMC}, to simulate the collisions assuming the atmospheric nuclei target to be nitrogen at rest. The resulting $\pi^0$ and $\eta$ mesons undergo two subsequent two-body decays via a vector or scalar mediator~\footnote{Here we consider only on-shell mediators though the sensitivity could in principle be extended to heavier off-shell mediators.} to a pair of dark matter particles, with a branching ratio that we keep as a free parameter. The rate of interactions is then integrated as follows over the volume of the atmosphere to obtain the total dark matter flux at the detector.

\begin{figure}[t]
\begin{center}
\includegraphics[width=0.6\textwidth]{pion_eta_chi_no_title.pdf}
\end{center}
\caption{Dark matter flux from cosmic rays for elastic collisions in dotted orange with $m_\chi = 1$ MeV, and for inelastic collisions with $BR(\pi^0 \to \chi \chi + ...) = 10^{-6}$ in solid green and $BR(\eta \to \chi\chi + ...) = 10^{-2}$ in solid red.
\label{fig:flux}}
\end{figure}

The differential cosmic ray flux gets attenuated through the atmosphere as a function of height $h$ from ground level:
%
\begin{equation}
\frac{d}{dh}\left(\frac{d\Phi_p}{dT_p}\right) = \sigma_{pN}(T_p) n_N(h) \frac{d\Phi_p}{dT_p} \, ,
\label{eq:diff}
\end{equation}
%
where $\sigma_{pN}$ is the inelastic proton-nitrogen cross-section and $n_N$ is the number density of air, taken from Ref.~\cite{Jursa:1985}, which is assumed to be entirely nitrogen for simplicity. \eqref{eq:diff} neglects higher order effects such as regenerations and secondary scatterings involved in a detailed cosmic ray shower model, but it is sufficient to provide a conservative estimate of our hidden sector flux. Since $\sigma_{pN} \simeq 255$ mb is constant to a good approximation over the relevant energy range, we may write $\frac{d\Phi_p}{dT_p}(T_p,h) \equiv y(h) \cdot \frac{d\Phi_p}{dT_p}(T_p)$ and solve for the attenuation factor $y(h)$. The dark matter flux at a detector located at a depth $z_d$ below ground is then given by
%
\begin{align} \frac{d \Phi_{\chi}}{d T_{\chi}} &=\int_{R_{E}}^{R_{E}+h} R^{2} d R \int_{0}^{2 \pi} d \phi \int_{\cos \theta_{\max }}^{1} \frac{d(\cos \theta)}{2 \pi l\left(R, \theta, z_{d}\right)^{2}} \nonumber \\ & y\left(R-R_{E}\right) \frac{d \Phi_{p}}{d T_{p}} n_{N}\left(R-R_{E}\right) \sigma_{p N \rightarrow M} B R_{M \rightarrow \chi \chi} \equiv \frac{d \Phi_{p}}{d T_{p}} n_{N}^{0} H_{\mathrm{eff}} \sigma_{p N \rightarrow M} B R_{M \rightarrow \chi \chi} \label{eq:integratedflux}\end{align}
where $R_E$ is the radius of the Earth and $\theta_{\mathrm{max}}$ is a maximum angle dependent on the path length attenuation through the Earth, as described in the next Section. The line of sight distance $l(R,\theta, z_d)$ is given by
%
\begin{equation}
l^2 = (R_E - z_d)^2 + R^2 - 2(R_E - z_d)R \cos{\theta} \, .
\end{equation}
%
It determines the rate dilution factor in the emission from source to detector that we have conservatively assumed to be isotropically distributed over a hemisphere. In the last line of \eqref{eq:integratedflux} we defined an equivalent effective height at a constant number density taken to be the ground-level value, $n_N^0 \simeq 5\times 10^{19} \mathrm{ cm}^{-3}$~\cite{Jursa:1985}. For example, with $\cos\theta_{\mathrm{max}} = -1$, i.e. the Earth completely transparent to dark matter, we obtain $H_{\mathrm{eff}} \simeq 5$ km.

The resulting dark matter flux in the transparent Earth case is plotted in Fig. \ref{fig:flux} in solid red for $BR(\eta \to \chi \chi + ...) = 10^{-2}$ and green for $BR(\pi^0 \to \chi\chi + ...) = 10^{-6}$, close to their experimental upper limits. The fluxes are rather insensitive to the mediator and dark matter masses when these are produced on-shell. For comparison, we show in dotted orange the up-scattered flux for $m_\chi = 1$ MeV coming from elastic collisions of cosmic rays with interstellar dark matter, calculated as in Ref.~\cite{Bringmann:2018cvk}. Finally we have also checked that, when restricting to an opaque Earth, the muon flux obtained in our approach is in good agreement with data~\cite{Haino:2004nq,Tanabashi:2018oca}.

\section{Attenuation through the Earth}

As dark matter travels from the point of production through the Earth a large enough nucleus interaction cross-section can prevent it from reaching the detector. The mean free path length together with the line of sight distance through the Earth to the detector then determines the maximum polar angle at which we cut off the atmospheric volume integral in \eqref{eq:integratedflux}. This line of sight distance through the Earth is given by
%
\begin{align}
l_E &= \frac{1}{2}\left( b + \sqrt{b^2 + 4(R_E^2 - (R_E - z_d)^2)} \right) \, , \nonumber \\
b &\equiv \text{Sign}\left[R_E - z_d - (R_E + h)\cos\theta \right]  \nonumber \\
& \quad \quad \quad \times 2(R_E - z_d) \sqrt{1 - \frac{(R_E +h)^2 \sin^2\theta}{l^2}} \, .
\end{align}
%

The mean free path length is determined by solving for the kinetic energy loss assuming a uniform distribution of nuclear recoil energy in elastic scattering, $d\sigma_{\chi N}/dT_r = \sigma_{\chi N} / T_r^{\mathrm{max}}$, following Ref.~\cite{Bringmann:2018cvk}. Summing over the nuclei $N$, we then have
%
\begin{align}
\frac{dT_\chi}{dz} &= - \sum_N n_N \int_0^{T_r^{\mathrm{max}}} \frac{d\sigma_{\chi N}}{dT_r} T_r dT_r \nonumber \underset{(T_\chi \ll m_N) }{\simeq} -\frac{1}{2m_\chi L}\left(T_\chi^2 + 2 m_\chi T_\chi \right) \, ,
\end{align}
%
where we used
%
\begin{equation}
T_r^{\mathrm{max}} = \frac{T_\chi^2 + 2m_\chi T_\chi}{T_\chi + (m_\chi + m_N)^2/(2m_N)} \, ,
\end{equation}
%
and defined the mean free path length
%
\begin{equation}
L \equiv \left( \sum_N n_N \sigma_{\chi N} \frac{2 m_N m_\chi}{(m_\chi + m_N)^2} \right)^{-1} \, .
\end{equation}
%
Integrating this equation gives the incoming energy $T_\chi^0$ that is required to arrive at the detector with energy $T_\chi^z$ a distance $l_E$ through the Earth:
%
\begin{equation}
T_\chi^0 = \frac{2 m_\chi T_\chi^z e^{l_E/L}}{2 m_\chi + T_\chi^z(1-e^{l_E/L})} \, .
\end{equation}
%
From this we obtain $\theta_{\mathrm{max}}$ when $T_\chi^0 \to \infty$. The mean free path length is calculated by summing over the average number density of the elements given in Table 2 of Ref.~\cite{Kavanagh:2016pyr}. We relate the nuclear interaction cross-section to the per nucleon spin-independent cross-section $\sigma_\chi^{\mathrm{SI}}$ as
%
\begin{equation}
\sigma_{\chi N} = \sigma_\chi^{\mathrm{SI}} A^2 \left(\frac{m_N}{m_p} \frac{(m_\chi + m_p)}{(m_\chi + m_N)} \right)^2 \, .
\end{equation}
%

In practise we find that at the depth of the XENON1T detector the attenuation starts cutting off the atmospheric volume integral for cross-sections above $\sigma_\chi^{\mathrm{SI}} \gtrsim 10^{-32} \, \mathrm{cm}^2$, with transmission falling exponentially above $\sim 10^{-28} \, \mathrm{cm}^2$.

\section{Limits}

Finally, we obtain the expected rate at a detector coming from our inelastic cosmic ray dark matter flux by integrating within the detector nuclear recoil thresholds $T_1$ and $T_2$:
%
\begin{equation}
\Gamma_N = N_T \int_{T_1}^{T_2} dT_N \int_{T_\chi^{\mathrm{min}}(T_N)}^\infty dT_\chi \epsilon(T_N) \frac{d\Phi_\chi}{dT_\chi} \frac{d\sigma_{\chi N}}{dT_N} \, ,
\end{equation}
%
where $N_T$ is the number of target atoms, $\epsilon$ is the detector nuclear recoil energy efficiency, and
%
\begin{equation}
T_\chi^{\mathrm{min}} = \left(\frac{T_N}{2} - m_\chi \right)\left(1 \pm \sqrt{1 + \frac{2T_N}{m_N}\frac{(m_\chi + m_N)^2}{(2m_\chi - T_N)^2}} \right) \, ,
\end{equation}
%
with a plus sign if $T_\chi > 2m_N$ and minus sign otherwise. As an illustrative example we will focus on the limits from XENON1T. Its nuclear recoil energy threshold window is from $T_1 = 4.9$ keV to $T_2 = 40.9$ keV and the detector is located at a water-equivalent depth of 3.6 km, corresponding to 1.4 km of rock~\cite{Aprile:2018dbl}. For the 90\% CL limits we require a total number of events $N_{90\% \text{ CL}} = 3.56$ for the full exposure of 278.8 days of data collection with 1.3t fiducial mass. This event count, in Table 1 of Ref.~\cite{Aprile:2018dbl}, is the best fit given by a likelihood analysis for a 200 GeV WIMP whose recoil spectrum is comparable to that of the energetic light dark matter flux.

\begin{figure}
\begin{center}
\includegraphics[width=0.615 \textwidth]{sigma_mchi_eta_pi_no_title.pdf} \\
\hspace{-0.25cm}\includegraphics[width=0.6 \textwidth]{limit_no_title.pdf}
\end{center}
\caption{90\% CL limits on the spin-independent dark matter-nucleon cross-section as a function of dark matter mass for a fixed branching ratio (\textit{top}) and as a function of branching ratio for a fixed dark matter mass (\textit{bottom}), as labelled. The inelastic cosmic ray dark matter limits from XENON1T~\cite{Aprile:2018dbl} are indicated in red and green for the flux originating from meson $M=\eta$ and $\pi^0$ decays, respectively, and in orange for elastic cosmic ray dark matter. The dashed lines are projections for the future LZ experiment~\cite{Akerib:2018lyp}. Other limits in grey are taken from Ref.~\cite{Bringmann:2018cvk} (based on CRESST~\cite{Angloher:2017sxg}, CMB~\cite{Xu:2018efh}, and gas cloud cooling~\cite{Bhoonah:2018wmw}), and from Milky-way satellites~\cite{Nadler:2019zrb}.
\label{fig:limits}}
\end{figure}

For comparison with Ref.~\cite{Bringmann:2018cvk}, we first assume a uniform recoil energy distribution, $d\sigma_{\chi N}/dT_N = \sigma_{\chi N} / T_{r,N}^{\mathrm{max}}$, and similarly obtain the resulting XENON1T limits on $\sigma_\chi^{\mathrm{SI}}$. This is plotted in Fig. \ref{fig:limits} as a function of the dark matter mass for a fixed mediator mass and branching ratio values (\textit{top}), and as a function of the meson branching ratio into dark matter for a fixed mediator and dark matter mass (\textit{bottom}). The 90\% CL limits on inelastic cosmic ray dark matter from $\pi^0$ and $\eta$ decays are shown in green and red, respectively. As mentioned previously, the dark matter flux is relatively insensitive to their masses when these are light enough to be produced on-shell. We note that despite the rate of neutral pion production being an order of magnitude larger than for $\eta$ mesons, the branching ratio of pions is experimentally bounded to be at most $\sim 10^{-6}$~\cite{Tanabashi:2018oca}. The projected limits for the future LZ experiment~\cite{Akerib:2018lyp} are shown as dashed lines; we see that they improve on the cross-section sensitivity by almost two orders of magnitude. The corresponding limits from the irreducible flux of up-scattered dark matter for $m_\chi = 1$ MeV is given by the orange band and is independent of branching ratio. However, there is a (model-dependent) relation between the two---a dark matter coupling to nucleons will generically induce meson decay into dark matter, if kinematically allowed.

\begin{figure}
\begin{center}
\includegraphics[width=0.6 \textwidth]{hadrophilic_no_title.pdf}
\end{center}
\caption{90\% CL limits from inelastic cosmic ray dark matter flux from $\eta$ decays in red, for a hadrophilic scalar mediator of mass $m_S$ with up-quark coupling $g_u$, setting $g_\chi=1, m_\chi = m_S/3$. The solid line denotes current limits from XENON1T~\cite{Aprile:2018dbl}; the dashed line are future projections for the LZ experiment~\cite{Akerib:2018lyp}. Current MiniBooNE limits from Ref.~\cite{Aguilar-Arevalo:2018wea} are shown in grey.
\label{fig:hadrophilic}}
\end{figure}

Next, we consider the hadrophilic scalar mediator model of Ref.~\cite{Batell:2018fqo}. The singlet scalar $S$ couples to a Dirac fermion dark matter $\chi$ and to the up quark through the Lagrangian terms
%
\begin{align}
\mathcal{L} \supset -g_\chi S\bar{\chi}_L \chi_R - g_u S \bar{u}_L u_R + \text{h.c.} \, .
\end{align}
%
The couplings to other flavours are assumed to be sub-dominant, so that we are left with four free parameters characterising the simplified model: $m_S$, $m_\chi$, $g_u$, and $g_\chi$. The branching ratio of $\eta$ mesons decaying into dark matter is given by
%
\begin{equation}
BR(\eta \to \pi^0 S) = \frac{C^2 g_u^2 B^2}{16\pi m_\eta \Gamma_\eta} \lambda^{1/2}\left(1, \frac{m_S^2}{m_\eta^2}, \frac{m_\pi^2}{m_\eta^2}\right) \, ,
\end{equation}
%
where $B \simeq m_\pi^2/(m_u+m_d)$, $C \equiv \sqrt{1/3} \cos\theta^\prime -\sqrt{2/3} \sin\theta^\prime$ with $\theta^\prime \simeq -20^\circ$ and $\lambda(a,b,c) = a^2 + b^2 + c^2 -2ab - 2bc - 2ac$. We assume here that $BR(S \to \chi \chi) = 1$. For the differential $\chi$-nucleus cross-section involving a scalar mediator we have
%
\begin{align}
\frac{d\sigma_{\chi N}}{dT_N} &= \frac{\left(Z y_{Spp} + (A-Z) y_{Snn}\right)^2 g_\chi^2}{8\pi} \nonumber \\
& \times \frac{(2m_N + T_N) (2 m_\chi^2 + m_N T_N)}{(T_\chi^2 + 2m_\chi T_\chi)(2m_N T_N + m_S^2)^2} F_H^2(\sqrt{2 m_N T_N}) \, ,
\end{align}
%
where $Z$ ($A-Z$) are the number of protons (neutrons), $y_{Spp} = 0.014 \cdot g_u m_p/m_u$, $y_{Snn} = 0.012 \cdot g_u m_n/m_u$, and $F_H$ is the Helm form factor~\cite{Duda:2006uk}. Computing the rate as described above, we obtain the 90\% CL limits shown in Fig. \ref{fig:hadrophilic} in red on the $g_u$ vs $m_S$ plane, for $g_\chi = 1, m_\chi = m_S/3$. The Earth suppresses the flux significantly only for values of $g_u$ greater than displayed. The MiniBooNE limits from Ref.~\cite{Batell:2018fqo} are shown in grey. Note that for $g_\chi=1$ the constraints from the E787/E949 experiment are stronger than the MiniBooNE and XENON1T limits~\cite{Batell:2018fqo}; however, they are set by invisible Kaon decays and are independent of $g_\chi$, whereas direct detection constraints from $\eta$ decay sources will grow quadratically with the dark matter coupling.

\section{Summary and Conclusions}

As the search for dark matter broadens, it is becoming increasingly important to maximise every resource that we have, both technological and astrophysical. In this respect cosmic rays provide a valuable tool. It has long been appreciated that cosmic rays are a natural accelerator for probing high energies, or as a background to indirect signals of dark matter decay; here we studied the potential of cosmic rays as a {\it source} of dark matter for direct detection. This opens up the potential of extending the sensitivity of various experiments to explore complementary parameter space, as we have illustrated for the case of XENON1T. It is remarkable that in this example the resulting limits are comparable to dedicated beam dump experiments such as MiniBooNE. These limits will improve in the future with the LZ experiment, by about two orders of magnitude. In forthcoming work we also plan to study the sensitivity of neutrino detectors, as well as cosmic ray production of long-lived hidden sectors that can decay back to Standard Model particles.


\chapter{Design}
\label{chap:structure}
The flowchart presented in the introduction of this document
represents the macro components making up the design of \Atlas
and reflects closely the capabilities of \Atlas. We subdivide this
chapter in various sections, each of them representing one
of the components in \fig{fig:intro-schematics}. The order in
which these components will be presented starts from the grid
and closes with the numerics. Note that some simple examples
are provided as part of this user-guide in \parte{p:core-functionalities}.

\section{Grid}
%
The Grid object forms the base class of a hierarchical inheritance tree
as shown in \fig{fig:grids}. A Grid implementation may be structured or
unstructured. The Grid base class interface gives the capability to
list the coordinates representing the points of a given grid, and how many
points exist in a given grid. It has no knowledge of any domain decomposition
or parallelisation in general.
The grids that \Atlas constructs can be \textit{global} or
\textit{local}. The \textit{GlobalGrid} type represents a complete
spherical grid, whereas the \textit{LocalGrid} type represents a limited
area of the sphere. Both global and local grids can be either
structured or unstructured. In \fig{fig:grids} we show the
various derived classes of the Grid class.
%
\begin{figure}[htb]
\centering
\includegraphics[width=\textwidth]{imgs/grids.pdf}
\label{fig:grids}
\caption{Grid class hierarchy.}
\end{figure}
%
Focussing on the Global grid classification, there exist several
possible sub classifications, such as the following derived types:
\begin{itemize}
  \setlength\itemsep{0.4em}
  \item Unstructured --- No structure is present in the grid
  \item Structured --- The grid has a structured distribution of latitudes, and on each latitude a uniform distribution in zonal direction (constant $\Delta\lambda$ for one latitude). No assumption is made on the location of latitudes, or the first longitude value on one latitude.
\end{itemize}
The Structured serves as the base class for three additional derived types:
\begin{itemize}
  \setlength\itemsep{0.4em}
  \item CustomStructured --- To instantiate a customised Structured grid,
        you have to use the CustomStructured concrete class. Any of the
        following grids could be expressed as a CustomStructured grid as well.
  \item Gaussian --- The grid's latitude distribution follows the
        roots of Legendre polynomials. The resolutions of these grids are
        usually expressed by a number, describing the number of latitudes
        between a pole and the equator.
  \item LonLat --- The grid's latitude distribution is uniform.
\end{itemize}
The Gaussian grid, in turn, serves as the base class for
\begin{itemize}
  \item RegularGaussian --- also referred to as \emph{full} Gaussian grid.
        This Gaussian grid has a constant number of points on each latitude,
        equal to $4\ N$, with $N$ the Gaussian number or number of latitudes
        between pole and equator.
  \item ClassicGaussian --- The number of points on each latitude is computed
        by optimisations involving the orthogonality of associated Legendre
        polynomials. This is a costly computations. Hence these tables have been
        pre-computed for resolutions that have been used in the past at ECMWF.
  \item OctahedralGaussian --- The number of points on each latitude
        can be inferred from triangulating a regular octahedron, projected to
        sphere. Certain modifications are required such as modifying the
        latitude locations to the roots of the Legendre polynomials.
  \item ReducedGaussian --- The number of points on each latitude can be
        configured by the user.
\end{itemize}
The LonLat grid class, in turn, serves as the base class for
\begin{itemize}
  \item RegularLonLat --- This grid has a constant number of points on each
        latitude, and includes typically the pole and the equatorial latitudes,
        and the Greenwich meridian.
  \item ShiftedLonLat --- This grid has a constant number of points on each
        latitude, but is shifted half of a longitude increment and half of a
        latitude increment compared to the RegularLonLat grid. This grid can
        also be referred to as the dual grid of the RegularLonLat grid. It does
        not include pole and equatorial latitudes, and not the Greenwich
        meridian.
  \item ShiftedLat --- This grid has a constant number of points on each
        latitude, but is shifted half of a latitude increment. It does
        not include pole and equatorial latitudes, but includes the Greenwich
        meridian.
  \item ShiftedLon --- This grid has a constant number of points on each
        latitude, but is shifted half of a longitude increment compared to the
        RegularLonLat grid. It includes pole and equatorial latitudes, but not
        the Greenwich meridian.
  \item ReducedLonLat --- The number of points on each latitude can be
        configured by the user. Typically these grids include the pole
        latitudes, and the Greenwich meridian.
\end{itemize}

We note that the object-oriented construction of the Grid
object allows one to add any other grid that might be of
interest without disrupting the existing grid workflow.

\section{Mesh} \label{s:mesh}
%
The \emph{Mesh} object describes how grid points are connected via lines,
essentially forming elements such as triangles, quadrilaterals, \ldots~
Furthermore, the \emph{Mesh} can be distributed across MPI tasks, called
partitions.
%
A \emph{Mesh} object has no inherent notion of structure. Therefore,
the nodes and elements in a mesh partition, even if originating from
a structured grid could be in any order, and should be treated as such.
A \emph{Mesh} is composed of \emph{Nodes}, \emph{Cells}, and \emph{Edges}.
These components each contain information stored in \emph{Field}s and
\emph{Connectivity} tables. In \fig{fig:mesh} we show the composition
of a \emph{Mesh} object. Due to the distributed nature of the mesh,
three specific fields are required in the \emph{Nodes}, \emph{Cells}
and \emph{Edges}, i.e.~the \inltc{global\_index}, \inltc{remote\_index},
and \inltc{partition}. More on parallelisation is presented in
section~\ref{s:parallelisation}.
%
\begin{figure}
\centering
\includegraphics[width=\textwidth]{imgs/mesh.pdf}
\caption{Mesh object composition \label{fig:mesh}}
\end{figure}
%
\begin{warningbox}
Note that a mesh is not equal to a grid. The grid describes globally the list
of points without elements and connectivities, while a mesh is a list of nodes
with specific connectivity rules, forming elements, and is distributed among
MPI tasks. Note also that, in \Atlas, the number of points of a grid is
generally different from the number of nodes of a mesh.
\end{warningbox}

\subsection{Nodes}
%
The \emph{Nodes} contains a \emph{Field} called \inltc{lonlat} which contains
the coordinates of the nodes on the sphere in longitude and latitude
degrees. Apart from the \inltc{lonlat} field, any \emph{Field} which relates
to the mesh nodes can be stored in the \emph{Nodes} object. The \emph{Nodes}
therefore can also be seen as a specialised \emph{FieldSet}
(see section~\ref{s:field-fieldset}).\\
%
Also stored in the \emph{Nodes} object are connectivity tables relating the
mesh nodes to edges and/or elements present in the mesh. These tables are
only allocated upon request.

\subsection{Elements and Connectivity}
%
As depicted in \fig{fig:elements}, the \emph{Cells} and \emph{Edges} classes
derive from a class \emph{HybridElements}. The reason for the naming
\emph{hybrid} refers to the possibility of having groups of elements with
different element types present under the same umbrella. One group of elements
sharing the same \emph{ElementType} is accessible through the \emph{Elements}
class. The \emph{HybridElements} class on the other hand offers access to all
elements irrespective of their \emph{ElementType}. It could be advantageous for
an algorithm to loop over \emph{Elements} corresponding to one
\emph{ElementType}, and apply specialised instructions in a nested loop
applicable to all elements of that specific \emph{ElementType}.\\
\begin{figure}
\centering
\includegraphics[width=\textwidth]{imgs/elements.pdf}
\caption{Class diagram related to the mesh \emph{Edges} and \emph{Cells}
\label{fig:elements}}
\end{figure}
Because of grouping of elements per \emph{ElementType}, \emph{Connectivity}
tables that e.g.~relate elements to nodes have the appearance of blocks. To
clarify, imagine 2 triangular elements and 3 quadrilateral elements. The table
of connectivities represented by the \emph{MultiBlockConnectivity} class would
have the form:\\[10pt]
\begin{minipage}{\textwidth}
\begin{verbatim}
                    element 1:    x  x  x
                    element 2:    x  x  x
                    element 3:    x  x  x  x
                    element 4:    x  x  x  x
                    element 5:    x  x  x  x
\end{verbatim}
\end{minipage}\\[10pt]
This \emph{MultiBlockConnectivity} table, can also be interpreted by two \emph{BlockConnectivity} tables:\\[10pt]
\begin{minipage}{\textwidth}
\begin{verbatim}
            block1, element 1:    x  x  x
            block1, element 2:    x  x  x

            block2, element 1:    x  x  x  x
            block2, element 2:    x  x  x  x
            block2, element 3:    x  x  x  x
\end{verbatim}
\end{minipage}\\[10pt]
Multiple \emph{BlockConnectivity} tables share exactly the same memory as the
one \emph{MultiBlockConnectivity} which is stored in the \emph{HybridElements}.
The \emph{Elements} objects, which are also stored in the \emph{HybridElements}
and each hold a \emph{BlockConnectivity}, therefore don't occupy any
significant memory.

\subsection{Mesh generation}
%
The mesh is constructed using the class \emph{MeshGenerator} which can generate
a mesh taking as input a \emph{Grid}, and and optionally a
\emph{GridDistribution}. The \emph{GridDistribution} describes for each grid
point which MPI task or partition the point belongs to. If the
\emph{GridDistribution} is not given, the \emph{MeshGenerator} will internally
create a temporary \emph{GridDistribution} internally. More on this can be
found in section~\ref{s:parallelisation}.
The \emph{MeshGenerator} base class can have several concrete implementations.
Depending on the \emph{Grid} type used, some concrete implementations may not
be available. For \emph{Structured} grid types, the
\emph{mesh::generators::Structured} is available. This mesh generator is very
fast as it can take advantage of the structured nature of a \emph{Structured}
grid. For any \emph{Grid}, a slower \emph{Delaunay} triangulation is also
available.\\
%
Figure~\ref{fig:meshgen} shows the usage and class diagram of the
\emph{MeshGenerator}.
%
\begin{figure}
\centering
\includegraphics[scale=0.5]{imgs/meshgenerator.pdf}
\caption{Mesh generation workflow, and \emph{MeshGenerator} class diagram
\label{fig:meshgen}}
\end{figure}

\section{Field and FieldSet} \label{s:field-fieldset}
%
\emph{Field} objects encapsulate given fields, such as the temperature
or the pressure, and they can be grouped into FieldSets.
The class diagram of the field object is depicted in \fig{fig:field}.
%
\begin{figure}
\centering
\includegraphics[scale=0.25]{imgs/field.png}
\label{fig:field}
\caption{Field and FieldSet object composition}
\end{figure}
%
In particular the \emph{Field} object is composed of
the \emph{Array} object which contains the actual field data, and the
\emph{Metadata} object which contains descriptions of the field.
A \emph{Field} also contains a reference to a \emph{FunctionSpace} object,
described section~\ref{s:functionspace}.

\section{FunctionSpace} \label{s:functionspace}
%
The \emph{FunctionSpace} defines how a \emph{Field} is represented on the
domain. There exist a variety of possible function spaces. Examples include
\emph{functionspace::Spectral}, \emph{functionspace::StructuredColumns}, \emph{functionspace::NodeColumns}, and \emph{functionspace::EdgeColumns}.
These are illustrated in the \emph{FunctionSpace} class inheritance diagram in \fig{fig:functionspace}.
\begin{itemize}
  \item \emph{functionspace::Spectral} describes the discretisation in terms of         spherical harmonics. The parallelisation (gathering and scattering) in
        spectral space is delegated to a \emph{Trans} object ( in turn
        delegating to the IFS trans library)
  \item \emph{functionspace::StructuredColumns} describes the discretisation
        of distributed fields on a \emph{Structured} grid. At the moment the
        \emph{Structured} must be a \emph{Gaussian} grid for parallel
        usage as a \emph{Trans} object is responsible for the parallelisation.
        In a future release this will be generalised to use a
        \emph{GatherScatter} object instead, which does not rely on having a
        \emph{Gaussian} grid.\\
        \emph{Field}s described using this function space may also be defined
        to have levels.
  \item \emph{functionspace::NodeColumns} describes the discretisation of fields
        with values colocated in the nodes of a \emph{Mesh}, and may have
        multiple levels defined in a vertical direction. These fields may have
        parallel halo's defined. A \emph{HaloExchange} object and
        \emph{GatherScatter} object are responsible for parallelisation.
  \item \emph{functionspace::EdgeColumns} describes the discretisation of fields
        with values colocated in the edge-centres of a \emph{Mesh}, and may have
        multiple levels defined in a vertical direction. These fields may have
        parallel halo's defined. A \emph{HaloExchange} object and
        \emph{GatherScatter} object are responsible for parallelisation.
\end{itemize}
%
\begin{figure}
\centering
\includegraphics[width=\textwidth]{imgs/functionspace.pdf}
\caption{FunctionSpace object diagram \label{fig:functionspace}}
\end{figure}
%
\section{Parallelisation} \label{s:parallelisation}
%
As described section~\ref{s:mesh} and shown in \fig{fig:mesh}, the \emph{Nodes},
\emph{Cells}, and \emph{Edges} contain three fields related to parallelisation:
\begin{itemize}
  \item \inltc{global\_index} --- This \emph{Field} contains for each
        node or element in the mesh partition a unique global index
        or ID as if the mesh was not distributed.
        This global index is independent of the number of partitions
        the mesh is distributed in.
  \item \inltc{partition} --- This \emph{Field} contains for each node
        or element the partition index that has ownership of the node
        or element. Nodes or elements whose partition does not match
        the partition index of the mesh partition are also called
        ghost nodes or ghost elements respectively. These ghost entities
        merely exist to facilitate stencil operations or to complete
        e.g. a mesh element.
   \item \inltc{remote\_index} --- This \emph{Field} contains for each
        node or element the local index in the mesh partition with index
        given by the \inltc{partition} field.
\end{itemize}
With the knowledge of \inltc{partition} and \inltc{remote\_index}, we now
know for each element or node which partition owns it, and at which location.
Usually the user has not to be aware of these three fields as they are
more required for \Atlas' internal parallelisation capabilities.\\
%
\Atlas has two parallel communication pattern classes that can be setup to
store how data can be sent and received between MPI tasks.
\begin{itemize}
\item The \emph{GatherScatter} class stores the communication pattern of
gathering all data to one MPI task, and the inverse, scattering or distributing
all data from one MPI task to all MPI tasks.
\item The \emph{HaloExchange} class stores the communication pattern of sending
and receiving data to nearest neighbour (in domain decomposition sense) MPI
tasks, typically required in exchanging small halo's of ghost entities
surrounding a domain partition.
\end{itemize}
%
\section{Numerics}
%
Apart from serving as a framework for constructing a flexible data structure,
\Atlas also provides some numerical algorithms such as gradient, divergence,
curl, and laplacian operators.
%
The gradient, divergence, curl and laplacian operators are bundled in a
abstract \emph{Nabla} class, of which a concrete implementation can be
instantiated with a \emph{Method} object. This is illustrated in
\fig{fig:numerics}. Here a concrete \emph{fvm::Nabla} is constructed using a
concrete \emph{fvm::Method}. These concrete classes implement a median-dual
finite volume method. The \emph{fvm::Method} internally uses two
\emph{FunctionSpace}s, i.e. a \emph{functionspace::NodeColumns}, and a
\emph{functionspace::EdgeColumns}, required to interprete \emph{Field}s
residing in nodes and edge-centres. For more information on the median-dual
Finite Volume Method, see section~\ref{s:fvm}.
%
\begin{figure}
\centering
\includegraphics[scale=0.5]{imgs/numerics.pdf}
\caption{Class diagram for the \emph{fvm::Nabla} operator
\label{fig:numerics}}
\end{figure}
%
\section{Utilities}
%
A number of utilities is also available \Atlas. These include
emph{Mesh}
writing, mpi communication, error and exception
handling, runtime behaviour, etc.
%

\subsection{Configuration}

\subsection{Logging} \label{s:utilities-logging}
TODO

\chapter{Theory}
\section{fvm: Median-dual Finite Volume Method}
\label{s:fvm}
TODO


\chapter{Study of the parameters of the fit}
    \label{app:FitResults}

This appendix collects further details on the fit performed in the analysis shown in Chapter~\ref{chapter:MonojetAnalysis}, which allows to estimate the normalization factors and the systematic uncertainties of the different background processes.

The correlation between the parameters of the fit for the signal selection M1 is shown in Figure~\ref{fig:corrMatrix}.
The three normalization factors used in the analysis (\texttt{mu\_Ele}, \texttt{mu\_Wmn} and \texttt{mu\_Zmm}) are highly correlated among themselves, as a consequence of the cross contamination between the background processes in the different control regions.
Correlation between the normalization factors and some systematic sources are also significant, for example in the case of the \texttt{alpha\_ktfac} or the \texttt{alpha\_qfac} nuisance parameters, for which their systematic effects are compensated by the normalization factors, computed in the control regions.
Finally, nuisance parameters for the systematic uncertainties are practically uncorrelated among themselves.
The fit parameters in the other signal selections show similar correlation patterns.

\begin{figure}[!ht]
  \begin{center}
    \mbox{
      \includegraphics[width=0.995\textwidth]{MonojetAnalysis/Figures/corrMatrix_Stop_M1.eps}
    }
  \end{center}
  \caption[Correlations among the different nuisance parameters and normalization factors after performing the fits with the background-only setup in the M1 signal selection.]{Correlations among the different nuisance parameters and normalization factors after performing the fits with the background-only setup in the M1 signal selection.}
  \label{fig:corrMatrix}
\end{figure}

The nuisance parameters for the selection M1 are shown in Table~\ref{tab:fitparameters_Stop_M1}.
After the fit, all of them lay below $0.001$.
The fact that these parameters have changed by less than $0.1\%$ with respect to the value to which they were initialized is an indication that there is no need for a significant profile of the systematic uncertainties to accommodate the data.
The central values of the nuisance parameters for all selections are shown in Figures~\ref{fig:corrMatrix_M1M2M3} and \ref{fig:corrMatrix_M4M5M6}.

%--- \ref{tab:fitparameters_Stop_M1}
\input{MonojetAnalysis/Tables/fitresult_Stop_M1.tex}

\begin{figure}[!ht]
  \begin{center}
    \mbox{
      \includegraphics[width=0.995\textwidth]{MonojetAnalysis/Figures/NuisanceParamsZoomPlot_Stop_M1.eps}
    }
    \mbox{
      \includegraphics[width=0.995\textwidth]{MonojetAnalysis/Figures/NuisanceParamsZoomPlot_Stop_M2.eps}
    }
    \mbox{
      \includegraphics[width=0.995\textwidth]{MonojetAnalysis/Figures/NuisanceParamsZoomPlot_Stop_M3.eps}
    }
  \end{center}
  \caption[Nuisance parameter values after the global fits with the background-only setup in the M1 to M3 signal selections.]{Values for the nuisance parameters after the global fits with the background-only setup in the M1 to M3 signal selections. The points do not include uncertainties.}
  \label{fig:corrMatrix_M1M2M3}
\end{figure}

\begin{figure}[!ht]
  \begin{center}
    \mbox{
      \includegraphics[width=0.995\textwidth]{MonojetAnalysis/Figures/NuisanceParamsZoomPlot_Stop_M4.eps}
    }
    \mbox{
      \includegraphics[width=0.995\textwidth]{MonojetAnalysis/Figures/NuisanceParamsZoomPlot_Stop_M5.eps}
    }
    \mbox{
      \includegraphics[width=0.995\textwidth]{MonojetAnalysis/Figures/NuisanceParamsZoomPlot_Stop_M6.eps}
    }
  \end{center}
  \caption[Nuisance parameter values after the global fits with the background-only setup in the M4 to M6 signal selections.]{Values for the nuisance parameters after the global fits with the background-only setup in the M4 to M6 signal selections. The points do not include uncertainties}
  \label{fig:corrMatrix_M4M5M6}
\end{figure}


\section{Introduction}

The parareal algorithm was originally proposed by Lions, Maday, and Turinici
\cite{original} as a numerical method to solve ordinary differential equations
that was parallel capable over the time domain. Here we intend to given a
overview of the method, and it's properties. In section 2 we describe the
parareal iteration, which later in 3 we discuss how to implement efficiently
using the parallel library OpenMP. Then in 4 we discuss the parallel efficiency
of this implementation, and measure the scalability of it in a high performance
computing context. Then in 5 and 6 we examine the analytic properties of the
method, deriving stability criteria and measuring and deriving theoretical
convergence rates.


\input{../../style/preamble}
\input{../../latex-math/basic-math}
\input{../../latex-math/basic-ml}
\input{../../latex-math/ml-gp}

\newcommand{\titlefigure}{figure/gp_pred/post_variance.pdf}
\newcommand{\learninggoals}{
  \item Know how to derive the posterior process
  \item GPs are interpolating and spatial models
  \item Model noise via a nugget term
}

\title{Introduction to Machine Learning}
\date{}

\begin{document}

\lecturechapter{Gaussian Process Prediction}
\lecture{Introduction to Machine Learning}

\begin{vbframe}{Gaussian Posterior Process And Prediction}

\vspace*{1cm}

\begin{itemize}
  \item So far, we have learned how to \textbf{sample} from a GP prior.
\item However, most of the time, we are not interested in drawing random functions from the prior. Instead, we usually like to use the knowledge provided by the training data to predict values of $f$ at a new test point $\xv_*$.
\item In what follows, we will investigate how to update the Gaussian process prior ($\to$ posterior process) and how to make predictions.
\end{itemize}

\end{vbframe}

\section{Gaussian Posterior Process and Prediction}

\begin{vbframe}{Posterior process}

% \textbf{Noise-free Case:}
%
% In the noise-free case, $y^{(i)} = f(\xi)$ ($\epsi \equiv 0$, no additive noise). The targets correspond to the true function values $\yv = \bm{f}$ (training observations) and $\yv^* = \bm{f}^*$ (test observations).
%
% \lz

\begin{itemize}
  \item Let us now distinguish between observed training inputs, also denote by a design matrix $\Xmat$, and the corresponding observed values
  $$
    \bm{f} = \left[f\left(\xi[1]\right), ..., f\left(\xi[n]\right)\right]
  $$

and one single \textbf{unobserved test point} $\xv_*$ with $f_* = f\left(\xv_*\right).$

\item We now want to infer the distribution of $f_* | \xv_*, \bm{X}, \bm{f}$.
  $$
    f_* = f\left(\xv_*\right)
  $$
  \item Assuming a zero-mean GP prior $\mathcal{GP}\left(\bm{0}, k(\xv, \xv^\prime)\right)$ we know

$$
\begin{bmatrix}
\bm{f} \\
f_*
\end{bmatrix} \sim
\mathcal{N}\biggl(\bm{0}, \begin{bmatrix} \Kmat & \bm{k}_* \\ \bm{k}_*^T & \bm{k}_{**}\end{bmatrix}\biggr).
$$

Here, $\Kmat = \left(k\left(\xi, \xv^{(j)}\right)\right)_{i,j}$, $\bm{k}_* = \left[k\left(\xv_*, \xi[1]\right), ..., k\left(\xv_*, \xi[n]\right)\right]$ and $ \bm{k}_{**}\ = k(\xv_*, \xv_*)$.

\framebreak

\item Given that $\bm{f}$ is observed, we can apply the general rule for condition $^{(*)}$ of Gaussian random variables and obtain the following formula:

\begin{eqnarray*}
f_* ~|~ \xv_*, \Xmat, \bm{f} \sim \mathcal{N}(\bm{k}_{*}^{T}\Kmat^{-1}\bm{f}, \bm{k}_{**} - \bm{k}_*^T \Kmat ^{-1}\bm{k}_*).
\end{eqnarray*}

% \begin{eqnarray*}
% \bm{f}_* | \Xmat_*, \Xmat, \bm{f} \sim \mathcal{N}(\Kmat_{*}^{T}\Kmat^{-1}\bm{f}, \Kmat_{**} - \Kmat_*^T \Kmat ^{-1}\Kmat_*).
% \end{eqnarray*}
\item As the posterior is a Gaussian, the maximum a-posteriori estimate, i.e. the mode of the posterior distribution, is $\bm{k}_{*}^{T}\Kmat^{-1}\bm{f}. $
\end{itemize}

\framebreak

$^{(*)}$ General rule for condition of Gaussian random variables:

\lz

  If the $m$-dimensional Gaussian vector $\bm{z} \sim \mathcal{N}(\mu, \Sigma)$ can be partitioned with $\bm{z} = \left(\bm{z}_1, \bm{z}_2\right)$ where $\bm{z}_1$ is $m_1$-dimensional and $\bm{z}_2$ is $m_2$-dimensional, and:
$$\left(\mu_1, \mu_2\right), \quad \Sigma = \begin{pmatrix} \Sigma_{11} & \Sigma_{12} \\ \Sigma_{21} & \Sigma_{22} \end{pmatrix},$$

then the conditioned distribution of $\bm{z}_2 ~|~ \bm{z}_1 = \bm{a}$ is a multivariate normal

$$
  \mathcal{N}\left(\mu_2 + \Sigma_{21} \Sigma_{11}^{-1}\left(\bm{a} - \mu_1\right), \Sigma_{22} - \Sigma_{21}\Sigma_{11}^{-1}\Sigma_{12} \right)
$$

\end{vbframe}

\begin{frame}{GP prediction: Two points}

Let us visualize this by a simple example:
\begin{itemize}
  \item Assume we observed a single training point $\xv = - 0.5$, and want to make a prediction at a test point $\xv_* = 0.5$.
  \item Under a zero-mean GP with $k(\xv, \xv^\prime) = \exp(-\frac{1}{2}\|\xv - \xv^\prime\|^2)$, we compute the cov-matrix:
  $$
    \begin{bmatrix} f \\ f_* \end{bmatrix} \sim \mathcal{N}\biggl(\bm{0}, \begin{bmatrix} 1 & 0.61 \\ 0.61 & 1\end{bmatrix}\biggr).
  $$
  \item Assume that we observe the point $\fx = 1$.
  \item We compute the posterior distribution:
  \begin{eqnarray*}
    f_* ~|~ \xv_*, \xv, f &\sim& \mathcal{N}(\bm{k}_{*}^{T}\Kmat^{-1}f, k_{**} - \bm{k}_*^T \Kmat^{-1}\bm{k}_*) \\
    &\sim& \mathcal{N}(0.61 \cdot 1 \cdot 1, 1 - 0.61 \cdot 1 \cdot 0.61) \\
    &\sim& \mathcal{N}\left(0.61, 0.6279\right)
  \end{eqnarray*}
  \item The MAP-estimate for $\xv_*$ is $f(\xv_*) = 0.61$, and the uncertainty estimate is $0.6279$.
  % what can we say about the function value at a new point $\xv_* = -0.5$?
  % \item<+-> We compute the covariance function and have

  % \item<+-> After observing $\fx = 1$ we want to predict a value for $f(\xv_*)$.
  % \item<+-> We compute the posterior distribution conditioned on $\fx = 1$
  % \begin{eqnarray*}

  % \end{eqnarray*}
\end{itemize}

\end{frame}

\begin{vbframe}{GP prediction: Two points}

\begin{footnotesize}
  Shown is the bivariate normal density, and the respective marginals.
\end{footnotesize}\vspace*{0.2cm}

\begin{figure}
  \includegraphics[width=0.8\textwidth]{figure/gp_pred/1.pdf}
\end{figure}

\end{vbframe}

\begin{frame}{GP prediction: Two points}

\begin{footnotesize}
  Assume we observed $\fx = 1$ for the training point $\xv = -0.5$.
\end{footnotesize}\vspace*{0.2cm}

\begin{figure}
  \includegraphics[width=0.8\textwidth]{figure/gp_pred/2.pdf}
\end{figure}

\end{frame}
\begin{frame}{GP prediction: Two points}

\begin{footnotesize}
  We condition the Gaussian on $\fx = 1$.
\end{footnotesize}\vspace*{0.2cm}

\begin{figure}
  \includegraphics[width=0.8\textwidth]{figure/gp_pred/3.pdf}
\end{figure}

\end{frame}

\begin{frame}{GP prediction: Two points}

\begin{footnotesize}
  We compute the posterior distribution of $f(\xv_*)$ given that $\fx = 1$.
\end{footnotesize}\vspace*{0.2cm}

\begin{figure}
  \includegraphics[width=0.8\textwidth]{figure/gp_pred/4.pdf}
\end{figure}

\end{frame}
\begin{frame}{GP prediction: Two points}

\begin{footnotesize}
  A possible predictor for $f$ at $\xv_*$ is the MAP of the posterior distribution.
\end{footnotesize}\vspace*{0.2cm}

\begin{figure}
  \includegraphics[width=0.8\textwidth]{figure/gp_pred/5.pdf}
\end{figure}

\end{frame}

\begin{frame}{GP prediction: Two points}

\begin{footnotesize}
  We can do this for different values $\xv_*$, and show the respective mean (grey line) and standard deviations (grey area is mean $\pm 2 \cdot $ posterior standard deviation).
\end{footnotesize}\vspace*{0.2cm}

\begin{figure}
  \includegraphics[width=0.8\textwidth]{figure/gp_pred/6.pdf}
\end{figure}

\end{frame}

\begin{vbframe}{Posterior Process}

\begin{itemize}
  \item We can generalize the formula for the posterior process for multiple unobserved test points:

$$
  \bm{f}_* = \left[f\left(\xi[1]_*\right), ..., f\left(\xi[m]_*\right)\right].
$$
  \item Under a zero-mean Gaussian process, we have
  $$
    \begin{bmatrix}
    \bm{f} \\
    \bm{f}_*
    \end{bmatrix} \sim
    \mathcal{N}\biggl(\bm{0}, \begin{bmatrix} \Kmat & \Kmat_* \\ \Kmat_*^T & \Kmat_{**} \end{bmatrix}\biggr),
  $$
    with $\Kmat_* = \left(k\left(\xi, \xv_*^{(j)}\right)\right)_{i,j}$, $\Kmat_{**} = \left(k\left(\xi[i]_*, \xi[j]_*\right)\right)_{i,j}$.

  \framebreak

  \item Similar to the single test point situation, to get the posterior distribution, we exploit the general rule of conditioning for Gaussians:
  \begin{eqnarray*}
    \bm{f}_* ~|~ \Xmat_*, \Xmat, \bm{f} \sim \mathcal{N}(\Kmat_{*}^{T}\Kmat^{-1}\bm{f}, \Kmat_{**} - \Kmat_*^T \Kmat ^{-1}\Kmat_*).
  \end{eqnarray*}
  \item This formula enables us to talk about correlations among different test points and sample functions from the posterior process.
\end{itemize}

\end{vbframe}

\section{Properties of a Gaussian Process}

\begin{vbframe}{GP as interpolator}

The \enquote{prediction} for a training point $\xi$ is the exact function value $\fxi$

\vspace*{-0.8cm}

\begin{eqnarray*}
\bm{f} ~|~ \Xmat, \bm{f} \sim \mathcal{N}(\Kmat\Kmat^{-1}\bm{f}, \Kmat - \Kmat^T \Kmat^{-1} \Kmat) = \mathcal{N}(\bm{f}, \bm{0}).
\end{eqnarray*}

Thus, a Gaussian process is a function \textbf{interpolator}.

\begin{center}
\includegraphics[width=0.8\textwidth]{figure/gp_pred/gp_interpolator.pdf}
\end{center}
% \begin{footnotesize}
% A the posterior process (black) after observing the training points (red) interpolates the training points.
% \end{footnotesize}

\end{vbframe}

\begin{vbframe}{GP as a spatial model}

\vspace*{-0.3cm}

\begin{itemize}
  \begin{footnotesize}
  \item The correlation among two outputs depends on distance of  the corresponding input points  $\xv$ and $\xv^\prime$ (e.g. Gaussian covariance kernel $k(\xv, \xv^\prime) = \exp \left(\frac{- \|\xv - \xv^\prime\|^2}{2 l^2}\right)$ )
  \item Hence, close data points with high spatial similarity $k(\xv, \xv^\prime)$ enter into more strongly correlated predictions: $\bm{k}_*^\top \bm{K}^{-1} \bm{f}$ ($\bm{k}_* := \left(k(\xv, \xv^{(1)}), ..., k(\xv, \xv^{(n)})\right)$).
  \end{footnotesize}

\begin{center}
\includegraphics[width=0.5\textwidth]{figure/gp_pred/post_mean.pdf}
\end{center}

\begin{footnotesize}
Example: Posterior mean of a GP that was fitted with the Gaussian covariance kernel with $l = 1$.
\end{footnotesize}

\framebreak

\item Posterior uncertainty increases if the new data points are far from the design points.
\item The uncertainty is minimal at the design points, since the posterior variance is zero at these points.
\end{itemize}

\begin{center}
\includegraphics[width=0.5\textwidth]{figure/gp_pred/post_variance.pdf}
\end{center}

\begin{footnotesize}
Example (continued): Posterior variance.
\end{footnotesize}

\end{vbframe}

\section{Noisy Gaussian Process}

\begin{vbframe}{Noisy Gaussian Process}

\begin{itemize}
  \item So far, we implicitly assumed that we had access to the true function value $\fx$.
  \item For the squared exponential kernel, for example, we have
  $$
    \cov\left(f(\xi), f(\xi)\right) = 1.
  $$
  \item As a result, the posterior Gaussian process is an interpolator:
  \begin{center}
    \includegraphics[width=0.8\textwidth]{figure/gp_pred/gp_interpolator.pdf}
  \end{center}

\framebreak

  \item In reality, however, this is often not the case.
  \item We often only have access to a noisy version of the true function value
  $$
    y = \fx + \eps, \eps \sim\mathcal{N}\left(0, \sigma^2\right).
  $$
  \item Let us still assume that $\fx$ is a Gaussian process.
  \item Then,
  \begin{footnotesize}
  \begin{eqnarray*}
    &&\cov(y^{(i)}, y^{(j)}) = \cov\left(f\left(\xi\right) + \epsilon^{(i)}, f\left(\xi[j]\right) + \epsilon^{(j)}\right) \\
    &=& \cov\left(f\left(\xi\right), f\left(\xi[j]\right)\right) + 2 \cdot \cov\left(f\left(\xi\right), \epsilon^{(j)}\right) + \cov\left(\epsilon^{(i)}, \epsilon^{(j)}\right)
    \\ &=& k\left(\xi, \xi[j]\right) + \sigma^2 \delta_{ij}.
  \end{eqnarray*}
  \end{footnotesize}
  \item $\sigma^2$ is called \textbf{nugget}.
\end{itemize}

\framebreak

\begin{itemize}
  \item Let us now derive the predictive distribution for the case of noisy observations.
  \item The prior distribution of $y$, assuming that $f$ is modeled by a Gaussian process is then
  $$
    \bm{y} = \begin{pmatrix} \yi[1] \\ \yi[2] \\ \vdots \\ \yi[n] \end{pmatrix} \sim \mathcal{N}\left(\bm{m}, \bm{K} + \sigma^2 \bm{I}_n \right),
  $$
  with
  \begin{eqnarray*}
    \textbf{m} &:=& \left(m\left(\xi\right)\right)_{i}, \quad
    \textbf{K} := \left(k\left(\xi, \xv^{(j)}\right)\right)_{i,j}.
  \end{eqnarray*}

  \framebreak

  \item We distinguish again between
  \begin{itemize}
    \item observed training points $\Xmat, \yv$, and
    \item unobserved test inputs $\Xmat_*$ with unobserved values $\bm{f}_*$
  \end{itemize}
  and get
  $$
  \begin{bmatrix}
  \bm{y} \\
  \bm{f}_*
  \end{bmatrix} \sim
    \mathcal{N}\biggl(\bm{0}, \begin{bmatrix} \Kmat + \sigma^2 \bm{I}_n & \Kmat_* \\ \Kmat_*^T & \Kmat_{**} \end{bmatrix}\biggr).
  $$

\framebreak

  \item Similarly to the noise-free case, we condition according to the rule of conditioning for Gaussians to get the posterior distribution for the test outputs $\bm{f}_*$ at $\Xmat_*$:

  \begin{eqnarray*}
    \bm{f}_* ~|~ \Xmat_*, \Xmat, \bm{y} \sim \mathcal{N}(\bm{m}_{\text{post}}, \bm{K}_\text{post}).
\end{eqnarray*}
  with
  \begin{eqnarray*}
    \bm{m}_{\text{post}} &=& \Kmat_{*}^{T} \left(\Kmat+ \sigma^2 \cdot \id\right)^{-1}\bm{y} \\
    \bm{K}_\text{post} &=& \Kmat_{**} - \Kmat_*^T \left(\Kmat ^{-1} + \sigma^2 \cdot \id\right)\Kmat_*,
  \end{eqnarray*}
\item This converts back to the noise-free formula if $\sigma^2 = 0$.

\framebreak

\item The noisy Gaussian process is not an interpolator any more.
\item A larger nugget term leads to a wider ``band'' around the observed training points.
\item The nugget term is estimated during training.

\begin{center}
    \includegraphics[width=0.8\textwidth]{figure/gp_pred/gp_regression.pdf}
\end{center}
\end{itemize}

\end{vbframe}

\section{Decision Theory for Gaussian Processes}

\begin{vbframe}{Risk Minimization for Gaussian Processes}

In machine learning, we learned about risk minimization. We usually choose a loss function and minimize the empirical risk

$$
  \riske(f) := \sumin \Lxyi
$$
as an approximation to the theoretical risk

$$
  \riskf := \E_{xy} [\Lxy] = \int \Lxy \text{d}\Pxy.
$$

\begin{itemize}
  \item How does the theory of Gaussian processes fit into this theory?
  \item What if we want to make a prediction which is optimal w.r.t. a certain loss function?
\end{itemize}

\framebreak

\begin{itemize}
  \item The theory of Gaussian process gives us a posterior distribution
  $$
    p(y ~|~\D)
  $$
  \item If we now want to make a prediction at a test point $\bm{x}_*$, we approximate the theoretical risk in a different way, by using the posterior distribution:
  $$
    \mathcal{R}(y_* ~|~ \bm{x}_*) \approx \int L(\tilde y_*, y_*) p(\tilde y_*~|~\bm{x}_*, \D)d\tilde y_*.
  $$
  \item The optimal prediciton w.r.t the loss function is then:
  $$
    \hat y_* | \bm{x}_* = \argmin_{y_*} \mathcal{R}(y_*~|~ \bm{x}_*).
  $$
\end{itemize}

% In practical applications, we are often forced to make predictions. We need a point-like prediction that is \enquote{optimal} in some sense.

% \lz

% We define \enquote{optimality} with respect to some loss function

% $$
% L(y_\text{true}, y_\text{guess}).
% $$

% \vfill

% \begin{footnotesize}
% Notice that we computed the predictive distribution without reference to the loss function. In non-Bayesian paradigms, the model is typically trained by minimizing the empirical risk (or loss). In contrast, in the Bayesian setting there is a clear separation between the likelihood function (used for training in addition to the prior) and the loss function.
% \end{footnotesize}

% \framebreak

% As we do not know the true value $y_\text{true}$ for our test input $\bm{x}_*$, we minimize w.r.t. to the expected loss called \textbf{risk} w.r.t. our model's opinion as to what the truth might be

% $$
% \mathcal{R}(y_\text{guess} | \bm{x}_*) = \int L(y_*, y_\text{guess}) p(y_*|\bm{x}_*, \D)dy_*.
% $$

% Our best guess w.r.t. $L$ is then

% $$
% $$

% For quadratic loss $L(y, y^\prime) = (y - y^\prime)^2$ this corresponds to the posterior mean.

\end{vbframe}

\endlecture
\end{document}