\section{Thermalization via a Nonlinear Boson Diffusion Equation (NBDE)}

\begin{frame}{Deriving the Nonlinear Boson Diffusion Equation I}
\vspace{0.5em}
The following derivation follows reference \cite{Wolschin2018}. \\[0.5em]
\begin{itemize}
\item The starting point for our investigation is the \alert{Boltzmann eqn.} (cf. Pavel's talk). %write it down
\item For \alert{spatial homogeneity} of the the boson distribution function $f(\mathbf{x}, \mathbf{p}, t)$ and a \alert{spherically symmetric momentum dependence} the equation for the single-particle occupation numbers  $n_j \equiv n_{\mathrm{th}}(\varepsilon_j,t)$ reads:
\begin{align}
\frac{\partial n_1}{\partial t} &= \sum_{\varepsilon_2,\varepsilon_3,\varepsilon_4}\langle V^{\phantom{.}2}\rangle G(\varepsilon_1+\varepsilon_2,\varepsilon_3+\varepsilon_4)\\
&\times \left[(1+n_1)(1+n_2)n_3n_4 - (1+n_3)(1+n_4)n_1n_2\right]
\end{align}

\item The \alert{collision term} can be written in the form of a \alert{Master eqn.}:
\begin{equation}
\frac{\partial n_1}{\partial_t} = (1+n_1)\sum_{\varepsilon_4}W_{4\rightarrow 1}n_4	- \sum_{\varepsilon_4}W_{1\rightarrow 4}(1+n_4)
\end{equation}
with
\begin{equation}
W_{4\rightarrow 1}=  W_{41}g_1 = \sum_{\varepsilon_2, \varepsilon_3} \langle V^{\phantom{.}2}\rangle G(\varepsilon_1+\varepsilon_2,\varepsilon_3+\varepsilon_4)(1+n_2)n_3
\end{equation}
\end{itemize}
\end{frame}

\begin{frame}{Deriving the Nonlinear Boson Diffusion Equation II}
\begin{itemize}
	\item In continuum $\sum\rightarrow\int$ and introduce \alert{density of states} $g_j \equiv g(\varepsilon_j)$.
	\item If $G$ acquires a width in a finite system:
	\begin{equation}
		W_{14}=W_{41}=W\left[\frac{1}{2}(\varepsilon_4+\varepsilon_1),\underbrace{\abs{\varepsilon_4-\varepsilon_1}}_{=: x}\right]
	\end{equation}
	\item Perform a \alert{gradient expansion} of $n_4$ and $g_4n_4$ around $x\approx 0$.
	\item Introduce \alert{transport coefficients} via moments of the transition probability:
\begin{align}
	D &= \frac{g_1}{2}\int\limits_0^{\infty}\dd x\ W(\varepsilon_1,x) \ x^2 \\
	v &= g_1^{-1}\frac{d}{d\varepsilon_1}(g_1D)
\end{align}
\end{itemize}
\end{frame}

\begin{frame}{Deriving the Nonlinear Boson Diffusion Equation III}
\begin{itemize}
	\item Nonlinear partial differential equation for $n \equiv n(\varepsilon_1,t) = n(\varepsilon,t)$:
		\begin{equation}
			\frac{\partial n}{\partial t} = -\frac{\partial}{\partial\varepsilon}\left[v\cdot n(1+n) + n\frac{\partial n}{\partial\varepsilon}\right] + \frac{\partial^2}{\partial\varepsilon^2}\left[Dn\right]\label{eqn:nbde1}
		\end{equation}

	\item Consider the limit of constant transport coefficients:
		\begin{equation}
			\frac{\partial n}{\partial t} = -v\frac{\partial}{\partial\varepsilon}\left[n(1+n)\right] + D\frac{\partial^2 n}{\partial\varepsilon^2}\label{eqn:nbde2}
		\end{equation}

\item Thermal \alert{Bose-Einstein distribution} provides stationary solution:
\begin{equation}
	n_{\mathrm{eq}}(\varepsilon) = \frac{1}{\exp(\frac{\varepsilon-\mu}{T}) - 1}
\end{equation}
\end{itemize}
\end{frame}

\begin{frame}{Some Remarks}
\begin{itemize}
	\item The present model does \alert{not} resolve the 2nd-order phase transition.
	\item The effects of condensation are included (cf. the following figures).
	\item A treatment resolving the singularity at $\epsilon=\mu$ is presented later.
\end{itemize}
\end{frame}

\begin{frame}{Linear Relaxation-Time Approximation (RTA)}
\begin{itemize}
	\item Given some initial distribution $n_{\mathrm{i}}(\varepsilon)$ we find an approximated solution for the thermalization process via the RTA:
\begin{equation}
	\frac{\partial n_{\mathrm{rel}}}{\partial t} = \frac{(n_{\mathrm{eq}} - n_{\mathrm{
rel}})}{\tau_{\mathrm{eq}}}
\end{equation}
with solution:
\begin{equation}
	n_{\mathrm{rel}}(\varepsilon,t) = n_{\mathrm{i}}(\varepsilon)\cdot\exp\left(-\frac{t}{\tau_{\mathrm{eq}}}\right) +  n_{\mathrm{eq}}(\varepsilon)\left(1-\exp\left(-\frac{t}{\tau_{\mathrm{eq}}}\right)\right)
\end{equation}
where $\tau_{\mathrm{eq}} = 4D/(9v^2)$.
\item Motivated by the study of early stages of RHICs, the initial distribution is chosen such that:
\begin{equation}
	n_{\mathrm{i}}(\varepsilon) = N_{\mathrm{i}}\cdot\theta\left(1-\varepsilon/Q_{\mathrm{s}}\right)\cdot\theta(\varepsilon) \label{eqn:rta_initial}
\end{equation}
with limiting momentum $Q_{\mathrm{s}} \sim \tau_0^{-1} \approx 1\ \mathrm{GeV}$.\mycite{Mueller1999}
\end{itemize}
\end{frame}

\begin{frame}{Results for the RTA}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{figures/rta}
\caption{Relaxation of a finite Bose system towards the equilibrium. \cite{Wolschin2018} \\
Here $T = -D/v \simeq 0.4\ \mathrm{GeV}$, $\tau_{\mathrm{eq}} = 4D/(9v^2) = 0.33\cdot 10^{-23} \mathrm{s} \simeq 1\ \mathrm{fm/c}$ and the timesteps are $\left\{0.1, 0.25, 0.5,\infty\right\}$ (in units of $10^{-23}s$) from top to bottom.}
\end{figure}
\end{frame}
%TODO: Maybe add another slide about conservation etc.

\begin{frame}{Exact Solution of the Nonlinear Boson Diffusion Equation}
\begin{itemize}
	\item To solve eqn. (\ref{eqn:nbde1}) analytically, we perform the following \alert{nonlinear transformation:}
	\begin{equation}
		n(\varepsilon,t) = -\frac{D}{v}\frac{\partial \ln \mathcal{Z}(\varepsilon,t)}{\partial\varepsilon}
	\end{equation}
	which reduces our problem to a \alert{linear diffusion eqn.} for $ \mathcal{Z}(\varepsilon,t)$:
	\begin{equation}
		\frac{\partial  \mathcal{Z}}{\partial t} = -v\frac{\partial  \mathcal{Z}}{\partial \varepsilon} +  D\frac{\partial^2  \mathcal{Z}}{\partial \varepsilon^2}
	\end{equation}
	\item Solutions to this equation can be written as:
 \begin{equation}
n(\varepsilon, t)=\frac{1}{2 v} \frac{\int_{-\infty}^{+\infty} \frac{\varepsilon-x}{t} F(x)\cdot G_{\mathrm{free}}(\varepsilon-x,t)\ \dd x}{\int_{-\infty}^{+\infty} F(x)\cdot G_{\mathrm{free}}(\varepsilon-x,t)\ \dd x}-\frac{1}{2}
\end{equation}
\end{itemize}
\end{frame}

\begin{frame}{Additional Definitions}
\begin{itemize}
\item The quantities appearing in the solution are the \alert{free Green's function}
\begin{align}
	G_{\mathrm{free}}(\varepsilon-x,t) = \exp\left[-\frac{(\varepsilon-x)^2}{4Dt}\right],\\
\end{align}
and the implementation of the \alert{initial conditions}
\begin{equation}
	    F(x)  = \exp\left[-\frac{1}{2D}(vx+2v\int_0^x n_{\mathrm{i}}(y) \dd y) \right].
\end{equation}
\item They define the \alert{free partition function} via:
\begin{equation}
	\mathcal{Z}(\varepsilon,t) = a(t)\cdot\int_{\infty}^{\infty} G_{\mathrm{free}}(\varepsilon,x,t)\cdot F(x)\ \dd x
\end{equation}
\end{itemize}
\end{frame}

\begin{frame}{Results for the Solution of the NBDE I}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{figures/nbde_positive_range}
\caption{Equilibration of a finite Bose system from the NBDE. \cite{Wolschin2018} \\
The integration range is restricted to $x \geq 0$. Here $T\simeq 0.4\ \mathrm{GeV}$, $\tau_{\mathrm{eq}} =  0.33\cdot 10^{-23} \mathrm{s}$ and the timesteps are $\left\{0.005, 0.05, 0.15,0.5\right\}$ (in units of $10^{-23}s$) from top to bottom.}
\end{figure}
\end{frame}

\begin{frame}{Results for the Solution of the NBDE II}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{figures/nbde_full_range}
\caption{Equilibration of a finite Bose system from the NBDE. \cite{Wolschin2018} \\
The integration range is extended to $-\infty \leq x \leq \infty$. Here $T\simeq 0.4\ \mathrm{GeV}$, $\tau_{\mathrm{eq}} =  0.33\cdot 10^{-23} \mathrm{s}$ and the timesteps are $\left\{0.005, 0.05, 0.15,0.5\right\}$ (in units of $10^{-23}s$) from top to bottom.}
\end{figure}
\end{frame}

\begin{frame}{Results for the Solution of the NBDE III}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{figures/nbde_gaussian}
\caption{Equilibration of a finite Bose system from the NBDE for Gaussian initial conditions $n_{\mathrm{i}}(\varepsilon) = N_{\mathrm{i}}\left(\sqrt{2\pi}\sigma\right)^{-1}\exp\left((\varepsilon - \langle\varepsilon\rangle)/(2\sigma^2)\right)$ with $\sigma = 0.04\ \mathrm{GeV}$. \cite{Wolschin2018} \\
Here $T\simeq 0.4\ \mathrm{GeV}$, $\tau_{\mathrm{eq}} =  0.33\cdot 10^{-23} \mathrm{s}$ and the timesteps are $\left\{0.002, 0.006, 0.02, 0.2\right\}$ (in units of $10^{-23}s$) from top to bottom.}
\end{figure}
\end{frame}

\begin{frame}{Treating the Singularity}
This part is based on the publication \cite{Wolschin2020_1} which provides an extension of \cite{Wolschin2018} and was published just recently.\\[0.5em]
\begin{itemize}
	\item To account for the singularity at $\varepsilon=\mu < 0$ we have to modify the initial distribution given before (eqn. (\ref{eqn:rta_initial})) as follows:
	\begin{equation}
		\tilde{n_{\mathrm{i}}}(\varepsilon) = n_{\mathrm{i}}(\varepsilon) + \frac{1}{\exp\left(\frac{\varepsilon-\mu}{T}\right)-1}
	\end{equation}
	\item The chemical potential $\mu$ has to be treated as a fixed parameter.
	\item Considering the limit $\lim_{\varepsilon\rightarrow\mu^{+}}\ n(\varepsilon,t) = \infty\ \forall t$ yields $\mathcal{Z}(\mu,t) = 0$.
	\item This results in a modified expression for the Green's function
	\begin{equation}
		G(\varepsilon,x,t) = G_{\mathrm{free}}(\varepsilon-\mu,x,t) - G_{\mathrm{free}}(\varepsilon-\mu,-x,t)
	\end{equation}
\end{itemize}
\end{frame}

\begin{frame}{Results for the RTA for the modified Initial Conditions}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{figures/rta_full}
\caption{Local thermalization of gluons in the linear RTA for $\mu<0$. \cite{Wolschin2020_1} \\
Here $T \simeq 513\ \mathrm{MeV}$ and the timesteps are $\left\{0.02, 0.08, 0.15,0.3,0.6\right\}$ (in units of $\mathrm{fm}/c$) from top to bottom.}
\end{figure}
\end{frame}
%TODO: Elaborate on Solutions#2
\begin{frame}{Results for the full Solution of the NBDE}
\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{figures/nbde_full_result}
\caption{Local thermalization of gluons from the time-dependent solutions of the NBDE for $\mu<0$. \cite{Wolschin2020_1} \\
Here $T \simeq 513\ \mathrm{MeV}$ and the timesteps are $\left\{6\cdot10^{-5}, 6\cdot10^{-4}, 6\cdot10^{-3},0.12,0.36\right\}$ (in units of $\mathrm{fm}/c$) from top to bottom.}
\end{figure}
\end{frame}


\chapter{PV Panel Curves and simulation program} \label{ap:pvPanelCurves}

	This appendix shows the simulation curves of the photovoltaic panel static equation \eqref{eq:PVPanelModelModified}. It also shows listing \ref{lst:pvPanelCurves}, the Python program used to obtain those curves. The parameter values of the photovoltaic panels are denoted in table \ref{tab:panelParameters}.

\begin{figure}[h]
	\centering
	\includegraphics[angle = -90, width = 0.9\textwidth]{../images/pvPanelCurves/ivCurve.pdf}
	\caption{Panel transconductance (continuous) and MPP (dashed) curves with fixed temperature $\theta_{SRC}$ and varying irradiance.}
	\label{fig:ivCurve}
\end{figure}

\begin{figure}[h]
	\centering
	\includegraphics[angle = -90, width = 0.9\textwidth]{../images/pvPanelCurves/pvCurve.pdf}
	\caption{Panel power(continuous) and MPP (dashed) curves with fixed temperature $\theta_{SRC}$ and varying irradiance.}
	\label{fig:pvCurve}
\end{figure}

\begin{figure}[h]
	\centering
	\includegraphics[angle = -90, width = 0.9\textwidth]{../images/pvPanelCurves/ivCurveVaryingTemperature.pdf}
	\caption{Panel transconductance (continuous) and MPP (dashed) curves with fixed irradiation $\phi_{SRC}$ and varying temperature.}
	\label{fig:ivCurveVaryingTemperature}
\end{figure}

\begin{figure}[h]
	\centering
	\includegraphics[angle = -90, width = 0.9\textwidth]{../images/pvPanelCurves/pvCurveVaryingTemperature.pdf}
	\caption{Panel power (continuous) and MPP (dashed) curves with fixed irradiation $\phi_{SRC}$ and varying temperature.}
	\label{fig:pvCurveVaryingTemperature}
\end{figure}

\begin{figure}[h]
	\centering
	\includegraphics[angle = -90, width = 0.9\textwidth]{../images/pvPanelCurves/vocVersusIrradiance.pdf}
	\caption{Panel open-circuit voltage versus irradiance and temperature.}
	\label{fig:vocVersusIrradiance}
\end{figure}

	\lstinputlisting[caption = {Python PV panel simulation program developed to generate figures \ref{fig:ivCurve} to \ref{fig:pvCurveVaryingTemperature}}, label = {lst:pvPanelCurves}, style = apaListing, language = Python]{../images/pvPanelCurves/mppTracking.py}


\begin{comment}

 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.

\end{comment}

\subsection{Principal Component Analysis}
\label{pca}

\noindent{\bf Description}

Principal Component Analysis (PCA) is a simple, non-parametric method to transform the given data set with possibly correlated columns into a set of linearly uncorrelated or orthogonal columns, called {\em principal components}. The principal components are ordered in such a way that the first component accounts for the largest possible variance, followed by remaining principal components in the decreasing order of the amount of variance captured from the data. PCA is often used as a dimensionality reduction technique, where the original data is projected or rotated onto a low-dimensional space with basis vectors defined by top-$K$ (for a given value of $K$) principal components.
\\

\noindent{\bf Usage}

\begin{tabbing}
\texttt{-f} \textit{path}/\texttt{PCA.dml -nvargs}
\=\texttt{INPUT=}\textit{path}/\textit{file}
  \texttt{K=}\textit{int} \\
\>\texttt{CENTER=}\textit{0/1}
  \texttt{SCALE=}\textit{0/1}\\
\>\texttt{PROJDATA=}\textit{0/1}
  \texttt{OFMT=}\textit{csv}/\textit{text}\\
\>\texttt{MODEL=}\textit{path}$\vert$\textit{file}
  \texttt{OUTPUT=}\textit{path}/\textit{file}
\end{tabbing}

\noindent{\bf Arguments}

\begin{itemize}
\item INPUT: Location (on HDFS) to read the input matrix.
\item K: Indicates dimension of the new vector space constructed from $K$ principal components. It must be a value between $1$ and the number of columns in the input data.
\item CENTER (default: {\tt 0}): Indicates whether or not to {\em center} input data prior to the computation of principal components.
\item SCALE (default: {\tt 0}): Indicates whether or not to {\em scale} input data prior to the computation of principal components.
\item PROJDATA: Indicates whether or not the input data must be projected on to new vector space defined over principal components.
\item OFMT (default: {\tt csv}): Specifies the output format. Choice of comma-separated values (csv) or as a sparse-matrix (text).
\item MODEL: Either the location (on HDFS) where the computed model is stored; or the location of an existing model.
\item OUTPUT: Location (on HDFS) to store the data rotated on to the new vector space.
\end{itemize}

\noindent{\bf Details}

Principal Component Analysis (PCA) is a non-parametric procedure for orthogonal linear transformation of the input data to a new coordinate system, such that the greatest variance by some projection of the data comes to lie on the first coordinate (called the first principal component), the second greatest variance on the second coordinate, and so on. In other words, PCA first selects a normalized direction in $m$-dimensional space ($m$ is the number of columns in the input data) along which the variance in input data is maximized -- this is referred to as the first principal component. It then repeatedly finds other directions (principal components) in which the variance is maximized. At every step, PCA restricts the search for only those directions that are perpendicular to all previously selected directions. By doing so, PCA aims to reduce the redundancy among input variables. To understand the notion of redundancy, consider an extreme scenario with a data set comprising of two variables, where the first one denotes some quantity expressed in meters, and the other variable represents the same quantity but in inches. Both these variables evidently capture redundant information, and hence one of them can be removed. In a general scenario, keeping solely the linear combination of input variables would both express the data more concisely and reduce the number of variables. This is why PCA is often used as a dimensionality reduction technique.

The specific method to compute such a new coordinate system is as follows -- compute a covariance matrix $C$ that measures the strength of correlation among all pairs of variables in the input data; factorize $C$ according to eigen decomposition to calculate its eigenvalues and eigenvectors; and finally, order eigenvectors in the decreasing order of their corresponding eigenvalue. The computed eigenvectors (also known as {\em loadings}) define the new coordinate system and the square root of eigen values provide the amount of variance in the input data explained by each coordinate or eigenvector.
\\

%As an example, consider the data in Table~\ref{tab:pca_data}.
\begin{comment}
\begin{table}
\parbox{.35\linewidth}{
\centering
\begin{tabular}{cc}
  \hline
  x & y \\
  \hline
  2.5 & 2.4  \\
  0.5 & 0.7  \\
  2.2 & 2.9  \\
  1.9 & 2.2  \\
  3.1 & 3.0  \\
  2.3 & 2.7  \\
  2 & 1.6  \\
  1 & 1.1  \\
  1.5 & 1.6  \\
  1.1 & 0.9  \\
	\hline
\end{tabular}
\caption{Input Data}
\label{tab:pca_data}
}
\hfill
\parbox{.55\linewidth}{
\centering
\begin{tabular}{cc}
  \hline
  x & y \\
  \hline
  .69  & .49  \\
  -1.31  & -1.21  \\
  .39  & .99  \\
  .09  & .29  \\
  1.29  & 1.09  \\
  .49  & .79  \\
  .19  & -.31  \\
  -.81  & -.81  \\
  -.31  & -.31  \\
  -.71  & -1.01  \\
  \hline
\end{tabular}
\caption{Data after centering and scaling}
\label{tab:pca_scaled_data}
}
\end{table}
\end{comment}

\noindent{\bf Returns}
When MODEL is not provided, PCA procedure is applied on INPUT data to generate MODEL as well as the rotated data OUTPUT (if PROJDATA is set to $1$) in the new coordinate system.
The produced model consists of basis vectors MODEL$/dominant.eigen.vectors$ for the new coordinate system; eigen values MODEL$/dominant.eigen.values$; and the standard deviation MODEL$/dominant.eigen.standard.deviations$ of principal components.
When MODEL is provided, INPUT data is rotated according to the coordinate system defined by MODEL$/dominant.eigen.vectors$. The resulting data is stored at location OUTPUT.
\\

\noindent{\bf Examples}

\begin{verbatim}
hadoop jar SystemML.jar -f PCA.dml -nvargs
            INPUT=/user/biuser/input.mtx  K=10
            CENTER=1  SCALE=1
            OFMT=csv PROJDATA=1
				    # location to store model and rotated data
            OUTPUT=/user/biuser/pca_output/
\end{verbatim}

\begin{verbatim}
hadoop jar SystemML.jar -f PCA.dml -nvargs
            INPUT=/user/biuser/test_input.mtx  K=10
            CENTER=1  SCALE=1
            OFMT=csv PROJDATA=1
				    # location of an existing model
            MODEL=/user/biuser/pca_output/
				    # location of rotated data
            OUTPUT=/user/biuser/test_output.mtx
\end{verbatim}


% chapter included in vclmanual.tex
\documentclass[vcl_manual.tex]{subfiles}
\begin{document}

\flushleft

\chapter{Boolean operations and per-element branches}\label{chap:BooleanOperations}
Consider this piece of C++ code:

\begin{lstlisting}[frame=none]
int a[4], b[4], c[4], d[4];
  ...
for (int i = 0; i < 4; i++) {
    d[i] = (a[i] > 0 && a[i] < 10) ? b[i] : c[i];
}
\end{lstlisting}
\vspacesmall

We can do this with vectors in the following way:

\begin{lstlisting}[frame=none]
Vec4i a, b, c, d;
  ...
d = select(a > 0 & a < 10, b, c);
\end{lstlisting}
\vspacesmall

The \codei{select} function is similar to the \codei{?:}  operator.
It has three vector parameters: The first parameter is a boolean vector that chooses between the elements of the second and the third vector parameter.
\vspacesmall

The relational operators \codei{\textgreater}, \codei{\textgreater=}, \codei{\textless}, \codei{\textless=}, \codei{==}, \codei{!=} produce boolean vectors,
which accept the boolean operations \codei{\&},
\codei{|}, \codei{$\wedge$}, \codei{$\sim$} (and, or, exclusive or, not).
\vspacesmall

In the above example, the expressions \codei{a \textgreater{} 0} and \codei{a \textless{} 10} are boolean vectors of type \codei{Vec4ib}. The boolean vectors must have a type that matches the data vectors they are used with. Table \ref{table:BooleanVectorClasses} on page \pageref{table:BooleanVectorClasses} shows which boolean vector class to use for each vector type.
\vspacesmall

The vector elements that are not selected are calculated anyway because normally all parts of a vector are calculated. For example:

\begin{lstlisting}[frame=none]
Vec4f a(-1.0f, 0.0f, 1.0f, 2.0f);
Vec4f b = select(a >= 0.0f, sqrt(a), 0.0f);
\end{lstlisting}
\vspacesmall

Here, we will be calculating the square root of -1 even though we are not using it. This will not cause problems if floating point exceptions are masked off, which they normally are. A safe solution that works even if floating point exceptions are enabled would be:

\begin{lstlisting}[frame=none]
Vec4f a(-1.0f, 0.0f, 1.0f, 2.0f);
Vec4f b = sqrt(max(a, 0.0f));
\end{lstlisting}
\vspacesmall

Likewise, the \codei{\&} and \codei{|} operators are calculating both input operands, even if the second operand is not needed. The following examples illustrates this:

\begin{lstlisting}[frame=none]
// array version:
float a[4] = {0.0f, 1.0f, 2.0f, 3.0f};
float b[4];
for (int i = 0; i < 4; i++) {
   if (a[i] > 0.0f && 1.0f/a[i] != 4.0f) {
      b[i] = a[i];
   }
   else {
      b[i] = 1.0f;
   }
}
\end{lstlisting}
\vspacesmall

and the vector version of the same:

\begin{lstlisting}[frame=none]
Vec4f a(0.0f, 1.0f, 2.0f, 3.0f);
Vec4f b = select(a > 0.0f & 1.0f/a != 4.0f, a, 1.0f);
\end{lstlisting}
\vspacesmall

In the array version, we will never divide by zero because the \codei{\&\&} operator does not evaluate the second operand when the first operand is false. But in the vector version, we are indeed dividing by zero because the \codei{\&} operator always evaluates both operands. The vector class library defines the operators \codei{\&\&} and \codei{||} as synonyms for \codei{\&} and \codei{|} for convenience, but they are still doing the bitwise AND or OR operation, so \codei{\&} and \codei{|} are actually more representative of what these operators really do. This example should be changed to:

\begin{lstlisting}[frame=none]
Vec4f a(0.0f, 1.0f, 2.0f, 3.0f);
Vec4f b = select(a > 0.0f & a != 0.25f, a, 1.0f);
\end{lstlisting}
\vspacesmall

\section{Internal representation of boolean vectors}\label{InternalRepresentationOfBoolean}

The way boolean vectors are stored depends on the instruction set and the Vector Class Library (VCL) version.
Older instruction sets have the boolean vectors stored with the same number of bits as the data vectors they are applied to (broad boolean vectors). The later instruction sets AVX512 and AVX512VL allow boolean vectors to be stored with only one bit for each element (compact boolean vectors).
\vspacesmall

Version 1.xx of the VCL is using the broad boolean vectors for the sake of backwards compatibility, while version 2.xx is prioritizing the more efficient compact boolean vectors when the appropriate instruction set is enabled. The boolean vector sizes are summarized in the following table.
\vspacesmall

\label{tableBooleanVectorSizes}
\begin{tabular}{|p{50mm}|p{40mm}|p{40mm}|}
\hline
\bfseries Data vector size \newline and instruction set & \bfseries VCL version 1 \newline Boolean vectors & \bfseries VCL version 2 \newline Boolean vectors \\ \hline
128 bits & broad & broad  \\ \hline
128 bits with AVX512VL & broad & compact \\ \hline
256 bits & broad & broad  \\ \hline
256 bits with AVX512VL & broad & compact \\ \hline
512 bits & broad & broad  \\ \hline
512 bits with AVX512F & compact & compact \\ \hline
\end{tabular}
\vspacebig

The broad boolean vectors are stored as integer vectors with the same number of bits per element as the integer or floating point vectors they are used for. For example, the broad boolean vector class \codei{Vec4fb} is stored as a vector of four 32-bit integers because it is used with vectors \codei{Vec4f} of four single precision floating point numbers, using 32 bits each. The broad boolean vector class \codei{Vec4db} is stored as a vector of four 64-bit integers because it is used with vectors \codei{Vec4d} of four double precision floating point numbers, using 64 bits each. Note that the integer representation of true in a broad boolean vector element is not 1, but  -1. The representation of false is 0. Any other values than 0 and -1 in broad boolean vectors will produce wrong and inconsistent results that depend on the instruction set.
\vspacesmall

The compact boolean vectors are stored with one bit per element (at least 8 bits).
You should make no assumption about how boolean vectors are stored if your code may be compiled for different instruction sets or different versions of VCL. For example,
\codei{Vec16ib} uses 16 bits of storage when compiling for AVX512, but 512 bits of storage when compiling for AVX2. Do not store boolean vectors directly to binary files, and do not transmit boolean vectors between different functions that may be compiled for different instruction sets or different VCL versions.
\vspacesmall

Different compact boolean vectors are mutually compatible if they have the same number of elements. Different broad boolean vectors are mutually compatible if they have the same number of elements and the same number of bits. Broad and compact boolean vectors are not compatible with each other. See page \pageref{ConversionBetweenBooleanTypes} for conversion between different types of boolean vectors.
\vspacesmall

\section{Functions for use with booleans}\label{FunctionsForBooleans}

\vspacesmall
\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & vector select(boolean vector s, vector a, vector b) \\ \hline
\bfseries Defined for & all integer and floating point vector classes \\ \hline
\bfseries Description & branch per element.\newline
result[i] = s[i] ? a[i] : b[i] \\ \hline
\bfseries Efficiency & good \\ \hline
\end{tabular}
\begin{lstlisting}[frame=none]
// Example:
Vec4i a(-1, 0, 1, 2);
Vec4i b = select(a>0, a+10, a-10); // b = (-11,-10,11,12)
\end{lstlisting}
\vspacesmall

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & if\_add(boolean vector f, vector a, vector b) \\ \hline
\bfseries Defined for & all integer and floating point vector classes \\ \hline
\bfseries Description & conditional addition \newline
result[i] = f[i] ? (a[i] + b[i]) : a[i] \\ \hline
\bfseries Efficiency & good \\ \hline
\end{tabular}
\begin{lstlisting}[frame=none]
// Example:
Vec4i a(-1, 0, 1, 2);
Vec4i b = if_add(a < 0, a, 100);  // b = (99,0,1,2)
\end{lstlisting}
\vspacesmall

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & if\_sub(boolean vector f, vector a, vector b) \\ \hline
\bfseries Defined for & all integer and floating point vector classes \\ \hline
\bfseries Description & conditional subtraction \newline
result[i] = f[i] ? (a[i] - b[i]) : a[i] \\ \hline
\bfseries Efficiency & good \\ \hline
\end{tabular}
\vspacebig

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & vector if\_mul(boolean vector f, vector a, vector b) \\ \hline
\bfseries Defined for & all integer and floating point vector classes \\ \hline
\bfseries Description & conditional multiplication\newline
result[i] = f[i] ? (a[i] * b[i]) : a[i] \\ \hline
\bfseries Efficiency & good \\ \hline
\end{tabular}
\vspacebig

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & vector if\_div(boolean vector f, vector a, vector b) \\ \hline
\bfseries Defined for & all floating point vector classes \\ \hline
\bfseries Description & conditional division\newline
result[i] = f[i] ? (a[i] / b[i]) : a[i] \\ \hline
\bfseries Efficiency & medium \\ \hline
\end{tabular}
\vspacebig

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & vector andnot(vector, vector) \\ \hline
\bfseries Defined for & all boolean vector classes \\ \hline
\bfseries Description & andnot(a,b) = a \& $\sim$ b \\ \hline
\bfseries Efficiency & good \\ \hline
\end{tabular}
\vspacebig

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & bool horizontal\_and(boolean vector) \\ \hline
\bfseries Defined for & all boolean vector classes \\ \hline
\bfseries Description & The output is the AND combination of all elements \\ \hline
\bfseries Efficiency & Medium for broad boolean vectors. Better if SSE4.1 or later. Good for compact boolean vectors \\ \hline
\end{tabular}
\begin{lstlisting}[frame=none]
// Example:
Vec4i a(-1, 0, 1, 2);
bool  b = horizontal_and(a > 0);  // b = false
\end{lstlisting}
\vspacesmall

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & bool horizontal\_or(boolean vector) \\ \hline
\bfseries Defined for & all boolean vector classes \\ \hline
\bfseries Description & The output is the OR combination of all elements \\ \hline
\bfseries Efficiency & Medium for broad boolean vectors. Better if SSE4.1 or later. Good for compact boolean vectors \\ \hline
\end{tabular}
\begin{lstlisting}[frame=none]
// Example:
Vec4i a(-1, 0, 1, 2);
bool  b = horizontal_or(a > 0);  // b = true
\end{lstlisting}
\vspacesmall

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & int horizontal\_find\_first(boolean vector) \\ \hline
\bfseries Defined for & all boolean vector classes \\ \hline
\bfseries Description & Returns an index to the first element that is true.
Returns -1 if all elements are false \\ \hline
\bfseries Efficiency & medium \\ \hline
\end{tabular}
\begin{lstlisting}[frame=none]
// Example:
Vec4i  a(1, 2, 3, 4);
Vec4i  b(0, 2, 3, 5);
int c = horizontal_find_first(a == b);  // c = 1
\end{lstlisting}
\vspacesmall

\begin{tabular}{|p{30mm}|p{120mm}|}
\hline
\bfseries Function & unsigned int horizontal\_count(boolean vector) \\ \hline
\bfseries Defined for & all boolean vector classes \\ \hline
\bfseries Description & counts the number of elements that are true \\ \hline
\bfseries Efficiency & medium if SSE4.2 or later \\ \hline
\end{tabular}
\begin{lstlisting}[frame=none]
// Example:
Vec4i  a(1, 2, 3, 4);
Vec4i  b(0, 2, 3, 5);
int c = horizontal_count(a == b);  // c = 2
\end{lstlisting}
\vspacesmall

\end{document}


\documentclass[12]{scrartcl}
\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}
\makeatletter
\newcommand\Aboxed[1]{
   \@Aboxed#1\ENDDNE}
\def\@Aboxed#1&#2\ENDDNE{%
   &
   \settowidth\@tempdima{$\displaystyle#1{}$}
   \setlength\@tempdima{\@tempdima+\fboxsep+\fboxrule}
   \kern-\@tempdima
   \boxed{#1#2}
}
\makeatother

\begin{document}

\title{Homework 7, Section 1.7: 6, 10, 12, 18, 21, 29, 36, 37}
\author{Alex Gordon}
\date{\today}
\maketitle
\section*{Homework}
\subsection*{6.}
$\begin{bmatrix} -4&-3&0&0&0 \\ 0&-1&5&0 \\ 0&0&-15&0 \\ 0&0&0&0  \end{bmatrix}$\\

As we can see the three basic variables give the trivial solution and no free variable. Therefore the columns of A are linearly independent.
\subsection*{10. A)}
$v_3$ in span $\{v_1, v_2\}$\\
The augmented matrix is:\\
$\begin{bmatrix} 1&-3&2 \\ -3&9&-5 \\ -5&15&h  \end{bmatrix}$\\
The reduced matrix is:\\
$\begin{bmatrix} 1&-3&2 \\ 0&0&1 \\ 0&0&10+h  \end{bmatrix}$\\
As we can see, $0 = 1$ is not possible, therefore the system has no solution to this equation.
\subsection*{10. B)}
The reduced matrix is:\\
$\begin{bmatrix} 1&-3&2&0 \\0&0&1&0 \\ 0&0&10+h&0  \end{bmatrix}$\\
If the system has a non trivial solution then $\{v_1, v_2, v_3\}$ is linearly dependent. For non-trivial solutions, $10+h = 0$ means that $h = -10$. $x_2$ is a free variable, which means we have a non-trivial solution.
\subsection*{12.}
The system is linearly dependent. Therefore the system has a non-trivial solution and $h = -18$
\subsection*{18.}
Linearly dependent.
\subsection*{21. A)}
Since the homogeneous system $Ax = 0$ always has the trivial solution, that means that regardless of A, to possess linearly independent columns, $Ax = 0$ always has a trivial solution. This means the statement is not true.
\subsection*{21. B)}
If we consider that linear combinations of all vectors then set $S = 0$, then there exists at least one nonzero scalar to satisfy the equation. \\
Since that means every vector in the set $S$ can be left on one side of the equation and all other vectors are on the other side that shows that S is a linear combination of the other vectors, meaning the statement is true. \\
\subsection*{21. C)}
The columns of any 4x5 matrix are linearly dependent. The statement is true.
\subsection*{21. D)}
If x and y are linearly independent then z is in the span of $\{x,y\}$. \\
Therefore any one of the conditions are true (they can't be true simultaneously)
\subsection*{36.}
By theorem 7, it is true.
\subsection*{37.}
The given set of vectors $\{v_1, v_2, v_3\}$ are linearly dependent and so the set of vectors $\{v_1, v_2, v_3, v_4\}$ are linearly dependent, hence the statement is true.

\end{document}


\chapter{Experimental Concepts}
This chapter serves as a reminder of commonly used ideas in high-energy physics (HEP) experiments.

\section{Experimental possibilities}
In reality there are rather few experimental possibilities for HEP experiments:
\begin{itemize}
\item Scatter one particle off another and observe the reaction;
\item Generate a particle in a reaction and observe its decay;
\item Detect neutrinos and observe neutrino oscillations;
\item Measure a particular particle's properties such as mass, charge, spin, parity, lifetime.
\end{itemize}

\section{Cross section}
The cross section, $\sigma$, for a particular reaction is proportional to the probability for the interaction to take place. In HEP experiments, it is expressed in the unit barns, where $\SI{1}{\barn} = \SI{1e-28}{\meter^2}$.

\subsection{Beam incident on a target}
Assume the beam is comprised of bunches with $N_B$ particles per bunch. The beam is incident on a target with area $A$, length $l$ inside the luminous region, and mass density $\rho$. Then the number of target particles seen by the beam is
\begin{equation}
N_T = \frac{Al\rho N_A}{m}
\end{equation}
where $N_A$ is Avagadro's number and $m$ is the molecular mass, such that $N_A/m$ is the mass of each target particle.

Now we can define the cross section as
\begin{align}
P(\text{interaction}) &= (\text{Number of target particles per unit area}) \times \sigma \\
&= \frac{Al\rho N_A}{m} \times \frac{\sigma}{A} \nonumber \\
&= \frac{l\rho N_A \sigma}{m}.
\end{align}
Therefore the total number of interactions per bunch is given by
\begin{equation}
N_I = \frac{l\rho N_A N_B \sigma}{m}.
\end{equation}
Now take the target and bunch to contain number densities $n_B$ and $n_T$ of particles, respectively. They have relative speed $u \simeq c$. Then the number of target particles in the luminous region is $n_T V$, so the probability of interaction may now be written
\begin{equation}
P(\text{interaction}) = \frac{n_T V \sigma}{A}.
\end{equation}
There are $n_B u A$ beam particles passing through the luminous region per second, so the rate of interactions is
\begin{equation}
\frac{\dd N_I}{\dd t} = n_B n_T V u \sigma.
\end{equation}

\subsection{Beam-beam collision}
For a circular collider, assume a rotation frequency $f$ for both counter-circulating beams consisting of $n$ bunches, each with $N_B$ particles and area $A$. Then the rate of interactions is
\begin{align}
\frac{\dd N_I}{\dd t} &= P(\text{collision}) \times (\text{particles per second in one beam}) \\
&= \frac{N_B \sigma}{A} \times n f N_B \nonumber \\
&= \frac{n f N_B^2 \sigma}{A} \label{eq:collRate}.
\end{align}

\section{Luminosity}
Using the result from \eqref{eq:collRate}, we define the instantaneous luminosity
\begin{equation}\boxed{
L \equiv \frac{1}{\sigma} \frac{\dd N_I}{\dd t}
}\end{equation}
hence for beam-beam collisions
\begin{equation}
L = \frac{n f N_B^2}{A}.
\end{equation}

In an effort to increase the luminosity, focussing magnets near to the collision regions are used to decrease the bunch area. Also, the number of particles per bunch should be made as large as possible while also maintaining a stable bunch.

Spontaneous luminosity tends to decrease with run time due to collision remnants decreasing the vacuum in the beam pipe and consequently deforming the bunches. An LHC beam has a typical lifetime of around 10--15 hours (the lifetime is the time for $L$ to decay by a factor $e$). At this point the beam is dumped and a new beam is accelerated and injected into the storage ring ready for collisions.

The units of $L$ are typically \si{\per \pico\barn \per \second}. To get a measure of the total number of interactions observed, and hence the amount of data collected, $L$ may be integrated to give the integrated luminosity,
\begin{equation}\boxed{
L_\text{int} = \int L \, \dd t
}
\end{equation}
which often has the units of inverse femtobarns, \si{\per \femto \barn}.

\section{Natural units and conversion factors}
In natural units, we have $\hbar = c = 1$. $c$ is the conversion factor between space and time or mass and energy, and $\hbar$ is the conversion between energy and time. Consider the units of their product:
\begin{align}
[\hbar c] &= [ET][LT^{-1}] \nonumber \\
&= [E][L].
\end{align}
Now we have $c = \SI{3e8}{\meter\per\second}$ and $\hbar = \SI{1.05e-34}{\joule\second} = \SI{6.56e-22}{\mega\electronvolt\second}$, so
\begin{equation}\boxed{
\hbar c = \SI{197}{\mega \electronvolt \femto \meter} \equiv 1}.
\end{equation}
Therefore, we have
\begin{equation}
\SI{1}{\giga\electronvolt} = \frac{1000}{\SI{197}{\femto\meter}} = \SI{5.08e15}{\per\meter} = \SI{1.52e24}{\per\second}
\end{equation}
\begin{equation}
\Rightarrow\quad \frac{1}{\si{\giga\electronvolt^2}} = \SI{3.88e-32}{\meter^2} = \SI{0.388}{\milli\barn}.
\end{equation}


% \newappendix{Algorithmic details for estimating surplus description length} \label{sec:sdl_details}

% Recall that the SDL is defined as
% \begin{align}
%         m_{\mathrm{SDL}}(\phi, \mathcal{D}, \mathcal{A},\eps) &= \sum_{n=1}^\infty \Big[ L(\mathcal{A}_\phi, n) - \eps \Big]_+
% \end{align}
% For simplicity, we assume that $L$ is bounded in $[0,1]$. Note that this can be achieved by truncating the cross-entropy loss.

% \begin{algorithm}
% \caption{Estimate surplus error}
% \label{alg:sdl}
% \KwIn{tolerance $\eps $, max iterations $M$, number of datasets $K$, representation $ \phi$, data distribution $\mathcal{D}$, algorithm $\mathcal{A}$ }
% \KwOut{Estimate $\hat m $ of  $m(\phi, \mathcal{D}, \eps, \mathcal{A})$ and indicator $ I$ of whether this estimate is tight or lower bound}
% \vspace{1mm} \hrule \vspace{1mm}
% Sample $ K$ datasets $ D_M^{k}\sim \mathcal{D}$ of size $ M+1$\\
% \For{$n = 1$ \KwTo $M$}{
%     For each $ k \in [K]$, run $ \mathcal{A}$ on $ D_M^{k}[1:n]$ to produce a predictor $ \hat p_n^k$\\
%     Take $ K $ test samples $ (x_k, y_k) = D_M^k[M+1]$\\
%     Evaluate $ \hat L_n = \frac{1}{K}\sum_{k=1}^K \ell(\hat p_n^k, x_k , y_k) $
%     }
% Set $ \hat m = \sum_{n=1}^M [\hat L_n - \eps]_+$ \vspace{1mm}\\
% \lIf {$ \hat L_M \leq \eps/2$} {Set $I = $ \texttt{tight} \textbf{else} {Set $ I = $ \texttt{lower bound}}}
% \Return $\hat m, I$
% \end{algorithm}

% In our experiments we replace $D^k_M[1:n]$ of Algorithm \ref{alg:sdl} with sampled subsets of size $n$ from a single evaluation dataset.
% Additionally, we use between 10 and 20 values of $n$ instead of evaluating $L(\mathcal{A}_\phi, n)$ at every integer between $1$ and $M$.
% This strategy, also used by \citet{Blier2018TheDL} and \citet{Voita2020InformationTheoreticPW}, corresponds to the description length under a code which updates only periodically during transmission of the data instead of after every single point.

% \begin{theorem}
% Let the loss function $L$ be bounded in $[0,1]$ and assume that it is decreasing in $ n$. With $ (M+1)K $ datapoints, if the sample complexity is less than $ M$, the above algorithm returns an estimate $ \hat m$ such that with probability at least $ 1- \delta$
% \begin{align}
%     |\hat m - m(\phi, \mathcal{D}, \eps, \mathcal{A})| \leq  M\sqrt{ \frac{\log (2M/\delta)}{2K}}.
% \end{align}
% If $ K \geq \frac{\log(1/\delta)}{2\eps^2}$ and the algorithm returns \texttt{tight} then with probability at least $ 1-\delta$ the sample complexity is less than $ M $ and the above bound holds.
% \end{theorem}
% \begin{proof}
% First we apply a Hoeffding bound to show that each $ \hat L_n$ is estimated well. For any $ n$, we have
% \begin{align}
%     P \bigg( \big|\hat L_n   - L(\mathcal{A}_\phi,n)  \big| > \sqrt{\frac{\log(2M/\delta)}{2K}} \bigg) \leq 2 \exp\bigg(-2K  \frac{\log(2M/\delta)}{2K}\bigg) = 2 \frac{\delta}{2M} = \frac{\delta}{M}
% \end{align}
% since each $ \ell(\hat p_n^k, x_k , y_k)$ is an independent variable, bounded in [0,1] with expectation $ L(\mathcal{A}_\phi, n)$.

% Now when sample complexity is less than $ M$, we use a union bound to translate this to a high probability bound on error of $ \hat m$, so that with probability at least $ 1- \delta$:
% \begin{align}
%     |\hat m - m(\phi, \mathcal{D}, \eps, \mathcal{A})| &= \bigg|\sum_{n=1}^M [\hat L_n - \eps]_+  - [L(\mathcal{A}_\phi,n) - \eps]_+  \bigg|\\
%     &\leq \sum_{n=1}^M\bigg| [\hat L_n - \eps]_+  - [L(\mathcal{A}_\phi,n) - \eps]_+ \bigg|\\
%     &\leq \sum_{n=1}^M \bigg|\hat L_n - L(\mathcal{A}_\phi,n) \bigg|\\
%     &\leq M \sqrt{ \frac{\log (2M/\delta)}{2K}}
% \end{align}
% This gives us the first part of the claim.

% We want to know that when the algorithm returns \texttt{tight}, the estimate can be trusted (i.e. that we set $ M $ large enough). Under the assumption of large enough $K$, and by an application of Hoeffding, we have that
% \begin{align}
%     P \bigg(  L(\mathcal{A}_\phi,M) - \hat L_M  > \eps/2 \bigg) \leq  \exp\bigg(-2K \eps^2 \bigg) \leq  \exp\bigg(-2 \frac{\log(1/\delta)}{2\eps^2} \eps^2 \bigg) = \delta
% \end{align}
% If $ \hat L_M \leq \eps/2$, this means that $ L(\mathcal{A}_\phi,M) \leq \eps$ with probability at least $ 1-\delta$. By the assumption of decreasing loss, this means the sample complexity is less than $ M$, so the bound on the error of $ \hat m$ holds.
% \end{proof}

% \newappendix{Algorithmic details for estimating sample complexity} \label{sec:sc_details}
% Recall that $\eps$ sample complexity ($\eps$SC) is defined as
% \begin{align}
%      m_{\eps\mathrm{SC}}(\phi, \mathcal{D}, \mathcal{A},\eps) &= \min \Big\{ n \in \mathbb{N} : L(\mathcal{A}_\phi, n) \leq \eps \Big\}.
% \end{align}

% We estimate $m_{\eps\mathrm{SC}}$ via recursive grid search. To be more precise, we first define a search interval $[1,N]$, where $N$ is a large enough number such that $L(\mathcal{A}_\phi,N) \ll \eps$. Then, we partition the search interval in to 10 sub-intervals and estimate risk of hypothesis learned from $D^n \sim \mathcal{D}^n$ with high confidence for each sub-interval. We then find the leftmost sub-interval that potentially contains $m_{\eps\mathrm{SC}}$ and proceed recursively. This procedure is formalized in Algorithm~\ref{alg:esc} and its guarantee is given by Theorem~\ref{thm:esc}.
% \begin{algorithm}[h!]
% \caption{Estimate sample complexity via recursive grid search}
% \label{alg:esc}
% \KwIn{Search upper limit $N$, parameters $\eps$, confidence parameter $\delta$, data distribution $\mathcal{D}$, and learning algorithm $\mathcal{A}$.}
% \KwOut{Estimate $\hat{m}$ such that $m_{\eps\mathrm{SC}}(\phi,\mathcal{D},\mathcal{A},\eps) \le \hat m$ with probability $1-\delta$.}
% \vspace{1mm} \hrule \vspace{1mm}
% let $S = 2\log (20k/\delta)/\eps^2$, and let $[\ell,u]$ be the search interval initialized at $\ell = 1, u = N$.\\
% \For{$r=1$ \KwTo $k$}{
%     Partition $[\ell,u]$ into 10 equispaced bins and let $\Delta$ be the length of each bin. \\
%     \For{$j = 1$ \KwTo $10$}{
%         Set $n = \ell + j \Delta$. \\
%         Compute $\hat L_n = \frac{1}{S}\sum_{i=1}^S \ell(\mathcal{A}(D^n_i),x_i,y_i)$ for $S$ independent draws of $D^n$ and test sample $(x,y)$. \\
%         \If{$\hat L_n \le \eps/2$}{
%         Set $u = n$ and $\ell = n - \Delta$. \\
%         \textbf{break}
%         }
%         }
% }
% \Return $\hat m = u$, which satisfies $m_{\eps\mathrm{SC}}(\phi,\mathcal{D},\mathcal{A},\eps) \le \hat m$ with probability $1-\delta$, where the randomness is over independent draws of $D^n$ and test samples $(x,y)$.
% \end{algorithm}

% \begin{theorem}
% \label{thm:esc}
% Let the loss function $L$ be bounded in $[0,1]$ and assume that it is decreasing in $ n$. Then, Algorithm~\ref{alg:esc} returns an estimate $ \hat m$ that satisfies $m_{\eps\mathrm{SC}}(\phi,\mathcal{D},\mathcal{A},\eps) \le \hat m$ with probability at least $ 1- \delta$.
% \end{theorem}

% \begin{proof}
% By Hoeffding, the probability that $|\hat L_n-L(\mathcal{A}_{\phi},n)| \ge \eps/2$, where $\hat L$ is computed with $S = 2\log(20k/\delta)/\eps^2$ independent draws of $D^n \sim \mathcal{D}^n$ and $(x,y) \sim \mathcal{D}$, is less than $\delta/(10k)$. The algorithm terminates after evaluating $\hat L$ on at most $10k$ different $n$'s. By a union bound, the probability that $|\hat L_n - L(\mathcal{A}_{\phi},n)| \le \eps/2$ for all $n$ used by the algorithm is at least $1-\delta$. Hence, $\hat L_n \le \eps/2$ implies $L(\mathcal{A}_\phi,n) \le \eps$ with probability at least $1-\delta$.
% \end{proof}

\newappendix{Experimental details} \label{sec:experiment_details}

In each experiment we first estimate the loss-data curve using a fixed number of dataset sizes $n$ and multiple random seeds, then compute each measure from that curve.
Reported values of SDL correspond to the estimated area between the loss-data curve and the line $y=\eps$ using Riemann sums with the values taken from the left edge of the interval.
This is the same as the chunking procedure of \citet{Voita2020InformationTheoreticPW} and is equivalent to the code length of transmitting each chunk of data using a fixed model and switching models between intervals.
Reported values of $\eps$SC correspond to the first measured $n$ at which the loss is less than $\eps$.

All of the experiments were performed on a single server with 4 NVidia Titan X GPUs, and on this hardware no experiment took longer than an hour.
All of the code for our experiments, as well as that used to generate our plots and tables, is included in the supplement.

\subsection{MNIST experiments}

For our experiments on MNIST, we implement a highly-performant vectorized library in \hyperlink{https://jax.readthedocs.io/en/latest/}{JAX} to construct loss-data curves.
With this implementation it takes about one minute to estimate the loss-data curve with one sample at each of 20 settings of $n$.
We approximate the loss-data curves at 20 settings of $n$ log-uniformly spaced on the interval $[10, 50000]$ and evaluate loss on the test set to approximate the population loss.
At each dataset size $n$ we perform the same number of updates to the model; we experimented with early stopping for smaller $n$ but found that it made no difference on this dataset.
In order to obtain lower-variance estimates of the expected risk at each $n$, we run 8 random seeds for each representation at each dataset size, where each random seed corresponds to a random initialization of the probe network and a random subsample of the evaluation dataset.

Probes consist of two-hidden-layer MLPs with hidden dimension 512 and ReLU activations.
All probes and representations are trained with the Adam optimizer \citep{Kingma2015AdamAM} with learning rate $10^{-4}$.

Each representation is normalized to have zero mean and unit variance before probing to ensure that differences in scaling and centering do not disrupt learning.
The representations of the data we evaluate are implemented as follows.

\paragraph{Raw pixels.}
The raw MNIST pixels are provided by the Pytorch \texttt{datasets} library \citep{Paszke2019PyTorchAI}.
It has dimension $28 \times 28 = 784$.

\paragraph{CIFAR.}
The CIFAR representation is given by the last hidden layer of a convolutional neural network trained on the CIFAR-10 dataset.
This representation has dimension 784 to match the size of the raw pixels.
The network architecture is as follows:

\begin{verbatim}
    nn.Conv2d(1, 32, 3, 1),
    nn.ReLU(),
    nn.MaxPool2d(2),
    nn.Conv2d(32, 64, 3, 1),
    nn.ReLU(),
    nn.MaxPool2d(2),
    nn.Flatten(),
    nn.Linear(1600, 784)
    nn.ReLU()
    nn.Linear(784, 10)
    nn.LogSoftmax()
\end{verbatim}

\paragraph{VAE.}
The VAE (variational autoencoder; \citet{Kingma2014AutoEncodingVB,Rezende2014StochasticBA}) representation is given by a variational autoencoder trained to generate the MNIST digits.
This VAE's latent variable has dimension 8.
We use the mean output of the encoder as the representation of the data.
The network architecture is as follows:
\begin{verbatim}
self.encoder_layers = nn.Sequential(
    nn.Linear(784, 400),
    nn.ReLU(),
    nn.Linear(400, 400),
    nn.ReLU(),
    nn.Linear(400, 400),
    nn.ReLU(),
)
self.mean = nn.Linear(400, 8)
self.variance = nn.Linear(400, 8)

self.decoder_layers = nn.Sequential(
    nn.Linear(8, 400),
    nn.ReLU(),
    nn.Linear(400, 400),
    nn.ReLU(),
    nn.Linear(400, 784),
)
\end{verbatim}

\subsection{Part of speech experiments}

We follow the methodology and use the official code\endnote{Code available at \url{https://github.com/lena-voita/description-length-probing}.} of \citet{Voita2020InformationTheoreticPW} for our part of speech experiments using ELMo \citep{Peters2018DeepCW} pretrained representations.
In order to obtain lower-variance estimates of the expected risk at each $n$, we run 4 random seeds for each representation at each dataset size, where each random seed corresponds to a random initialization of the probe network and a random subsample of the evaluation dataset.
We approximate the loss-data curves at 10 settings of $n$ log-uniformly spaced on the range of the available data $n \in [10, 10^6]$.
To more precisely estimate $\eps$SC, we perform one recursive grid search step: we space 10 settings over the range which in the first round saw $L(\mathcal{A}_\phi, n)$ transition from above to below $\eps$.

Probes consist of the MLP-2 model of \citet{Hewitt2019DesigningProbes,Voita2020InformationTheoreticPW} and all training parameters are the same as in those works.


\begin{appendix}
\section{Examples}

\subsection{Leech word square-freeness}
Let us consider the SLP $\slp{L}$ that derives substring of Leech square free word:

\begin{center}
$\slpterm{L}{1}{a}, \slpterm{L}{2}{b}, \slpterm{L}{3}{c}, \slpnonterm{L}{4}{2}{3}, \slpnonterm{L}{5}{2}{1},
\slpnonterm{L}{6}{1}{4}$

$\slpnonterm{L}{7}{3}{4}, \slpnonterm{L}{8}{6}{5}, \slpnonterm{L}{9}{8}{4}, \slpnonterm{L}{10}{8}{7},
\slpnonterm{L}{11}{10}{9}$
\end{center}

Parse tree for $\slp{L}$ presented at figure 4.

\begin{figure}[th]
\LeechSLP
\end{figure}

Let us check square freeness of $\slp{L}$. Since $|L| = 15$ then the algorithm check the following segments of root
length: [1, 1], [2, 3], [4, 7]. Notice that rules of $\slp{L}$ already ordered by length of derived text.

\begin{itemize}
  \item \textbf{checking square freeness of squares that root length equals to 1}

  Firstly the algorithm skip terminal rules. Next it consecutively look for squares exactly in other rules. For
  instance, let us consider how it checks $\slpnonterm{L}{10}{8}{7}$. The algorithm find $L_8[5] = a$ and $L_7[1] = c$
  using $\slp{L}_{10}$. Since $a \neq c$ it moves to $\slp{L}_{11}$.

  It is clear that $\slp{L}_4, \dots, \slp{L}_{11}$ have no squares of length 2 around its cut positions.
  \item \textbf{checking square freeness of squares that root length belong to [2, 3]}

  The algorithm skip all rules that have length less 4 (i.e. $\slp{L}_1, \dots, \slp{L}_7$). For instance, let us
  consider how it checks $\slpnonterm{L}{8}{6}{5}$. Since $|L_8| = 5$ and block length is equal to 1 then the algorithm
  construct an SLP $\slp{L}_8'$ that derives text \emph{\$~\$~\$~\$~\$~a~b~c~b~a~\$~\$~\$~\$~\$~\$}, where \emph{\$} is
  special symbol not from $\Sigma$. At figure 5 presented partition of $L_8'$ into blocks of length 1.

  \LeechWordPartitionSimple

  Remind that the algorithm necessary to check blocks $B_5, \dots, B_{12}$. It no need to check $B_5$ since it contains
  \emph{\$}. Also it no need to check $B_9$ and $B_{10}$ since the search area is out of $L_8$. For instance, let us
  consider how it checks $B_7$. The algorithm build $\slp{L}_8'\substr{6}{7}$ that derives $B_7$ and
  $\slp{L}_8'\substr{8}{11}$ that derives search area $B_9 \cdot B_{10}$. Next it runs pattern matching algorithm on
  $\slp{L}_8'\substr{6}{7}$, $\slp{L}_8'\substr{8}{11}$ and obtain occurrence of $B_7$ at position 9 of $L_8'$. Finally
  it runs \textbf{SubsExt} problem with the following parameters: $\slp{L}_8'$ and positions 6, 7, 8, 9. The algorithm
  obtains $\ell_{ex} = r_{ex} = 0$. Since $\ell_{ex} + r_{ex} = 0 = a - (k - 1) \cdot 2^{i-2} = 8 - (9 - 1) \cdot 1$ then
  algorithm moves to $L_9$.

  \item \textbf{checking square freeness of squares that root length belongs to [4, 7]}

  The algorithm skip all rules that have length less 8 (i.e. $\slp{L}_1, \dots, \slp{L}_9$). For instance, let us
  consider how it checks $\slpnonterm{L}{11}{10}{9}$. Firstly it construct an SLP $\slp{L}_{11}'$ that derives $L$
  surrounded with \emph{\$} and $|L_{11}'| = 32$. At figure 6 presented partition of $L_{11}'$ into blocks of length
  2.

  \LeechWordPartitionComplex

  Next the algorithm find no squares for $B_5, \dots, B_8$ since pattern matching algorithm returns empty set of
  results. Next the algorithm find occurrence of $B_9$ at position 22 of $L_{11}'$ and run \textbf{SubsExt}
  problem with the following parameters: $\slp{L}_{11}'$ and positions 16, 18, 20, 22. Since $\ell_{ex} = r_{ex} = 0$ the
  algorithm moves to $B_{10}$. Finally the algorithm find no squares for $B_{10}, B_{11}, B_{12}$ since correspond
  search areas contains \emph{\$}.
\end{itemize}

\subsection{Construction PS-table for $\slp{F}_7$}

Let us consider how the algorithm construct PS-table for $\slp{F}_7$ that derives text \emph{a~b~a~a~b~a~b~a~a~b~a~a~b}.
The PS-table size is equal to $(\lfloor\log |F_7|\rfloor+1)\times (|\slp{F}_7|+1) = 4 \times 8$.

\begin{itemize}
  \item \textbf{looking for squares that root length equals to 1}

  Firstly the algorithm mark cells with $\varnothing$ for rules with length less than 2. Next it consecutively look for
  squares exactly in other rules. PS(1, 3) = $\varnothing$ since $F_1[1] = a \neq b = F_2[1]$. Analogously PS(1, 4) =
  PS(1, 6) = $\varnothing$. PS(1, 5) = \{1, 3, 3\} since $F_4[3] = a = F_3[1]$. PS(1, 7) = \{1, 8, 8\} since $F_6[8] = a
  = F_5[1]$. After first step PS-table has the following view:

  \begin{figure}[h]
	  {\footnotesize\noindent
		\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
	 	& $\slpterm{F}{1}{a}$ & $\slpterm{F}{2}{b}$ & $\slpnonterm{F}{3}{1}{2}$ & $\slpnonterm{F}{4}{3}{1}$ &
	 	$\slpnonterm{F}{5}{4}{3}$ & $\slpnonterm{F}{6}{5}{4}$ & $\slpnonterm{F}{7}{6}{5}$ \\ \hline

	 	[1, 1] & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & \{1, 3, 3\} & $\varnothing$ & \{1, 8, 8\} \\
	 	\hline

	 	[2, 3] & & & & & & & \\ \hline

	 	[4, 7] & & & & & & & \\ \hline
		\end{tabular}
	  }
  \end{figure}

  \item \textbf{looking for squares that root length belongs to [2, 3]}

  The algorithm mark cells with $\varnothing$ for rules with length less than 4. For instance, let us consider
  how the algorithm fill PS(2, 6). The algorithm construct SLP $\slp{F}_6'$ that derives text
  \emph{\$~\$~\$~a~b~a~a~b~a~b~a~\$~\$~\$~\$~\$} of length 16. At figure 7 presented partition of $F_6'$ into blocks.

  \FibonacciWordPartition

  $B_5$: using \textbf{PM} problem the algorithm obtain occurrence of $B_5$ at position 8 of $F_6'$ on
  $\slp{F}_{6}'\substr{5}{6}, \slp{F}_{6}'\substr{7}{9}$; the substring extending algorithm obtain $\ell_{ex} = r_{ex} = 1$
  on $\slp{F}_{6}'$ with parameters 5, 6, 8, 9; so family of repetitions \{3, 7, 7\} was found;

  $B_6$: using \textbf{PM} problem the algorithm obtain occurrence of $B_6$ at position 9 of $F_6'$ on
  $\slp{F}_{6}'\substr{6}{7}, \slp{F}_{6}'\substr{8}{10}$; the substring extending algorithm obtain $\ell_{ex} = 2, r_{ex}
  = 0$ on $\slp{F}_{6}'$ with parameters 6, 7, 9, 10; so family of repetitions \{3, 7, 7\} was found;

  $B_7$: using \textbf{PM} problem the algorithm obtain occurrence of $B_7$ at position 9 of $F_6'$ on
  $\slp{F}_{6}'\substr{7}{8}, \slp{F}_{6}'\substr{9}{11}$; the substring extending algorithm obtain $\ell_{ex} = 0, r_{ex}
  = 1$ on $\slp{F}_{6}'$ with parameters 7, 8, 9, 10; so no family of repetitions was found;

  $B_8$: using \textbf{PM} problem the algorithm obtain occurrence of $B_8$ at position 10 of $F_6'$ on
  $\slp{F}_{6}'\substr{8}{9}, \slp{F}_{6}'\substr{10}{12}$; the substring extending algorithm obtain $\ell_{ex} = r_{ex}
  = 1$ on $\slp{F}_{6}'$ with parameters 8, 9, 10, 11; so family of repetitions \{2, 8, 9\} was found;

  $B_9$: using \textbf{PM} problem the algorithm obtain occurrence of $B_9$ at position 11 of $F_6'$ on
  $\slp{F}_{6}'\substr{9}{10}, \slp{F}_{6}'\substr{11}{13}$; the substring extending algorithm obtain $\ell_{ex} = 1,
  r_{ex} = 0$ on $\slp{F}_{6}'$ with parameters 9, 10, 11, 12; so family of repetitions \{2, 9, 9\} was found;

  The algorithm skip blocks $B_{10}, \dots, B_{12}$ since the search area consist of \emph{\$}. After merging families
  of repetitions the algorithm have the following result: \{3, 7, 7\}, \{2, 8, 9\}. Finally the algorithm check purity
  of families and shift them form $F_{6}'$ to $F_6$.

  After second step PS-table has the following view:

  \begin{figure}[h]
	  {\footnotesize\noindent
		\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
	 	& $\slpterm{F}{1}{a}$ & $\slpterm{F}{2}{b}$ & $\slpnonterm{F}{3}{1}{2}$ & $\slpnonterm{F}{4}{3}{1}$ &
	 	$\slpnonterm{F}{5}{4}{3}$ & $\slpnonterm{F}{6}{5}{4}$ & $\slpnonterm{F}{7}{6}{5}$ \\ \hline

	 	[1, 1] & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & \{1, 3, 3\} & $\varnothing$ & \{1, 8, 8\} \\
	 	\hline

	 	[2, 3] & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & \{3, 4, 4\}, \{2, 5, 6\} &
	 	\{3, 10, 10\} \\ 	\hline

	 	[4, 7] & & & & & & & \\ \hline
		\end{tabular}
	  }
  \end{figure}

  \item \textbf{looking for squares that root length belongs to [4, 7]}

  The algorithm mark cells with $\varnothing$ for rules with length less than 8. The algorithm construct SLP
  $\slp{F}_7'$ that surrounds with \emph{\$} and has length 32. At figure 8 presented partition of $F_7'$ into
  blocks. Let us consider how the algorithm fill PS(3, 7). It skips $B_5$ since $B_5$ contains \emph{\$}.

   \FibonacciWordPartitionComplex

  $B_6$: using \textbf{PM} problem the algorithm obtain occurrence of $B_6$ at position 15; the substring extending algorithm
  obtain $\ell_{ex} = 1, r_{ex} = 3$ on $\slp{F}_{7}'$ with parameters 10, 12, 14, 18; so family of repetitions \{5, 14,
  15\} was found;

  $B_7$: using \textbf{PM} problem the algorithm obtain occurrence of $B_7$ at position 17; the substring extending algorithm
  obtain $\ell_{ex} = 3, r_{ex} = 1$ on $\slp{F}_{7}'$ with parameters 12, 14, 16, 20; so family of repetitions \{5, 14,
  15\} was found;

  $B_8$: using \textbf{PM} problem the algorithm obtain occurrence of $B_8$ at position 20; the substring extending algorithm
  obtain $\ell_{ex} = r_{ex} = 0$ on $\slp{F}_{7}'$ with parameters 14, 16, 18, 22; so there are no families of
  repetitions;

  $B_9$: using \textbf{PM} problem the algorithm obtain no occurrence of $B_9$; so there are no families of repetitions;

  The algorithm skips $B_{10}$ and $B_{11}$ since search areas consist of \emph{\$}. It skips $B_{12}$ since $B_{12}$
  contains \emph{\$}. After merging families of repetitions the algorithm have the following result: \{5, 14, 15\}.
  Finally the algorithm check purity of families and shift them form $F_{7}'$ to $F_7$.

  Finally PS-table has the following view:

  \begin{figure}[h]
	  {\footnotesize\noindent
		\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
	 	& $\slpterm{F}{1}{a}$ & $\slpterm{F}{2}{b}$ & $\slpnonterm{F}{3}{1}{2}$ & $\slpnonterm{F}{4}{3}{1}$ &
	 	$\slpnonterm{F}{5}{4}{3}$ & $\slpnonterm{F}{6}{5}{4}$ & $\slpnonterm{F}{7}{6}{5}$ \\ \hline

	 	[1, 1] & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & \{1, 3, 3\} & $\varnothing$ & \{1, 8, 8\} \\
	 	\hline

	 	[2, 3] & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & \{3, 4, 4\}, \{2, 5, 6\} &
	 	\{3, 10, 10\} \\ \hline

	 	[4, 7] & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & $\varnothing$ & \{5, 5, 6\}
	 	\\ \hline
		\end{tabular}
	  }
  \end{figure}
\end{itemize}

\subsection{Text with complex family of pure squares}
Let us consider an SLP $\slp{E} = \slp{E}_l \cdot \slp{E}_r$ such that $\slp{E}_l$ derives text $(a~b~a~b~a)^6~a~b~a$
and $\slp{E}_r$ derives text $b~a~a~b~a~(a~b~a~b~a)^7$. So $\slp{E}$ derives text $(a~b~a~b~a)^7~a~b~a~(a~b~a~b~a)^7$
and $|E| = 73$. Let us consider how the algorithm looking for pure squares for rule $\slp{E}$ and segment [16, 31]. The
algorithm construct SLP $\slp{E}'$ that surrounds with \emph{\$} and has length 128. The partition of $E'$ into blocks
presented at figure 9.

\ComplexExamplePartititon

Let us consider how the algorithm process block $B_8$. It find occurrence of $B_8$ in $B_9 \cdot B_{10}$ at positions
$\prog{72}{2}{5}$. Since the algorithm find more than one occurrence it extends periodicity to calculate parameters
$\alpha_L, \alpha_R, \gamma_L, \gamma_R$. So $\alpha_L = \infty, \alpha_R = 69, \gamma_L = 66, \gamma_R = \infty$.
According to lemma !!! the algorithm find complex family of pure squares associated with each of root length \{18, 23\}
and centred at positions \{66, 67, 68, 69\}. Next we write every root from the family exactly:

\begin{itemize}
  \item \textbf{roots of length 18}

  $a~b~a(a~b~a~b~a)^3$, $b~a(a~b~a~b~a)^3a$, $a(a~b~a~b~a)^3a~b$, $(a~b~a~b~a)^3a~b~a$;
  \item \textbf{roots of length 23}

  $a~b~a(a~b~a~b~a)^4$, $b~a(a~b~a~b~a)^4a$, $a(a~b~a~b~a)^4a~b$, $(a~b~a~b~a)^4a~b~a$;
\end{itemize}

\end{appendix}