\section{Theoretical Foundations}
\label{sec:Theoretical_Foundations}
This section summarizes the theory and formulas necessary to understand the following experiments on the magnetic field in section \ref{sec:Evaluation}.

\subsection{Magnetic Flux Density}
\label{subsec:Magnetic_Flux_Density}
The decisive factor for the magnetic interactions is the magnetic flux density $\vect{B}$. In a vacuum or in the air, it is proportional to the magnetic field strength $\vect{H}$ \cite{magnetic_fields}.

The magnetic field strength $\vect{H}$ is used to calculate the magnetic flux density $\vect{B}$:
\begin{equation}
\vect{B}=\mu_0 \cdot \mu_r \cdot \vect{H} \qquad \text{with} \qquad
\begin{cases}
	\mu_0=4\pi\cdot 10^{-7}\ \,^\text{Vs}\!/_\text{Am}\\
	\mu_r=1 \qquad \text{for vacuum or air} \\
\end{cases}
\label{eq:magnetic_flux_density}
\end{equation}
where:
\begin{conditions}
	\vect{B} & magnetic flux density \\
	\vect{H} & magnetic field strength \\
	\mu_0 & vacuum permeability \\
	\mu_r & relative permeability
\end{conditions}

\subsection{Calculating Magnetic Fields}
\label{subsec:Calculating_Magnetic_Fields}
The relationship between the electric current and the magnetic field generated by it can be formulated in two different ways. Either in an integral form with the Ampère's circuital law or in a differential form with the Biot-Savart law \cite{magnetic_fields}.
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\subsubsection{Ampère's circuital law}
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}
\label{subsubsec:Amperes_circuital_law}
Ampère's circuital law describes the total current $\Theta$ that passes through the area $A$, which is enclosed by the curve $\Gamma$ (graphically shown in figure \ref{fig:amperes_circuit_law}). The following formula is only suitable for the calculation of a symmetrical magnetic field, even though it is valid in any situation \cite{magnetic_fields}.
\begin{equation}
\Theta=\oint_\Gamma \,^{\vect{B}}\!/_{\mu} \cdot\vect{\text{d}l}=\oint_\Gamma \vect{H}\cdot\vect{\text{d}l}=\int \vect{j}\cdot \vect{\text{d}A}
\end{equation}
where:
\begin{conditions}
	\vect{B} & magnetic flux density \\
	\vect{H} & magnetic field strength \\
	\mu & permeability of a specific medium \\
	\vect{\text{d}l} & infinitesimal element of the curve $\Gamma$ \\
	\vect{j} & current density \\
	\vect{\text{d}A} & vector area of an infinitesimal element of the area A
\end{conditions}
\begin{figure}[H]
	\centering
	\includegraphics[scale=1]{amperes_circuit_law}
	\caption{Graphical representation of the Ampère's circuital law \cite{magnetic_fields} - partially modified}
	\label{fig:amperes_circuit_law}
\end{figure}
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\subsubsection{Biot-Savart law}
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}
\label{subsubsec:Biot-Savart_law}
The Biot-Savart law describes the contribution of a current path to the magnetic field at the point P. The resulting total magnetic field at the point P can be calculated by the integration over the whole conductor (graphically shown in figure \ref{fig:biot-savart_law}). This law can always be applied because it is based on the known geometry of the conductor \cite{magnetic_fields}.
\begin{equation}
\text{d}\vect{B}=\mu\cdot \text{d}\vect{H}=\frac{1}{4\pi|\vect{r}-\vect{r}_\text{L}|^2}\cdot\mu\cdot I\cdot\vect{\text{d}l}\times\frac{(\vect{r}-\vect{r}_\text{L})}{|\vect{r}-\vect{r}_\text{L}|}
\label{eq:biot-savart_law}
\end{equation}
where:
\begin{conditions}
	\vect{B} & magnetic flux density \\
	\vect{H} & magnetic field strength \\
	\mu & permeability of a specific medium \\
	I & current path \\
	\vect{\text{d}l} & infinitesimal element of the current path $I$
\end{conditions}
\begin{figure}[H]
	\centering
	\includegraphics[scale=0.35]{biot-savart_law}
	\caption{Graphical representation of the Biot-Savart law \cite{magnetic_fields}}
	\label{fig:biot-savart_law}
\end{figure}
\newpage
\subsection{Measuring Magnetic Fields}
\label{subsec:Measuring_Magnetic_Fields}
The most common method to measure the magnetic flux density (see equation \ref{eq:magnetic_flux_density}) is to use a Hall effect sensor. A known current flows through a thin rectangular plate of a conductive material (usually a semiconductor). At the same time it is penetrated by the magnetic field $\vect{B}$. This results in an electrical field $\vect{F}_{\text{el.}}$ which is perpendicular to the current and the magnetic field. Furthermore, in equilibrium it compensates the Lorentz force $\vect{F}_L$. This means that the Lorentz force is equal to the electrical field ($\vect{F}_L=\vect{F}_{\text{el.}}$). The so-called Hall voltage can be measured at the narrow sides of the plate \cite{magnetic_fields}.
\begin{equation}
U_H=\frac{1}{N\cdot q\cdot d}\cdot I\cdot B\qquad \text{with}\qquad q=-e=-1.602\cdot 10^{-19}\ \text{C}
\end{equation}
where:
\begin{conditions}
	U_H & Hall voltage \\
	N & charge carrier density \\
	q & elementary charge \\
	d & thickness of the plate \\
	I & current \\
	B & magnetic field
\end{conditions}
Since the conductive material used in Hall sensors is usually a temperature-dependent semiconductor, alternating current (e.g. 1 kHz) is used to compensate thermoelectric voltages \cite{magnetic_fields}.
\begin{figure}[H]
	\centering
	\includegraphics[scale=1]{hall_element}
	\caption{Construction of a Hall element \cite{magnetic_fields} - partially modified}
	\label{fig:hall_element}
\end{figure}

\subsection{Cylindrical Coil}
\label{subsec:Cylindrical_Coil}
For the derivation of the magnetic field of a cylindrical coil, it is assumed that the coil is of length $l$, with a diameter of $2R$ and $N$ turns (one or two layer wound). For the construction see figure \ref{fig:cylindrical_coil}. The following derivation is based on the Biot-Savart law (see equation \ref{eq:biot-savart_law}) \cite{magnetic_fields}.

First, the discrete winding current is replaced by an equivalent surface current $j_{2-d}$:
\[
N\cdot I=l\cdot j_{2-d}
\]
This results in a current segment with the length $\text{dz}_\text{L}$ which represents a cylindrical coil with the radius $R$ and the current:
\[
\text{d}I=j_{2-d}\cdot \text{dz}_\text{L}
\]
Its contribution to the magnetic field at the point P is:
\[
\text{d}B_z=\frac{\mu_0\cdot R^2}{2}\cdot\frac{\text{d}I}{\left[(z-z_\text{L})^2+R^2\right]^{\,^{3}\!/_{2}}}=\frac{\mu_0\cdot N\cdot I \cdot R^2}{2l}\cdot\frac{\text{dz}_L}{\left[(z-z_\text{L})^2+R^2\right]^{\,^{3}\!/_{2}}}
\]
To obtain the magnetic field $B$ at the position $z$, one has to integrated over the entire length of the coil (from $\,^{-l}\!/_{2}$ to $\,^{+l}\!/_{2}$):
\[
B_z(z)=\frac{\mu_0\cdot N\cdot I \cdot R^2}{2l}\cdot\int_{\,^{-l}\!/_{2}}^{\,^{+l}\!/_{2}}\frac{1}{\left[(z-z_\text{L})^2+R^2\right]^{\,^{3}\!/_{2}}}\cdot\text{dz}_L
\]
This results in the following equation for the magnetic field $B_z$:
\begin{equation}
B_z(z)=\frac{\mu_0 N I}{l}\cdot\frac{1}{2} \left[\frac{\,^{l}\!/_{2}+z}{\sqrt{(\,^{l}\!/_{2}+z)^2+R^2}}+\frac{\,^{l}\!/_{2}-z}{\sqrt{(\,^{l}\!/_{2}-z)^2+R^2}}\right]
\label{eq:cylindrical_coil_bz}
\end{equation}
To obtain the magnetic field in the center of the coil $B_z(z=0)$, the following equation is used:
\begin{equation}
B_0=B_z(0)=\frac{\mu_0 N I}{l}\cdot \frac{1}{\sqrt{1+(\,^{2R}\!/_{l})^2}}
\label{eq:cylindrical_coil_b0}
\end{equation}
where:
\begin{conditions}
	B_z & magnetic field at the position z \\
	B_0 & magnetic field in the center \\
	\mu_0 & vacuum permeability \\
	N & number of turns \\
	I & current \\
	l & length \\
	z & position \\
	R & radius
\end{conditions}
\begin{figure}[H]
	\centering
	\includegraphics[scale=0.25]{cylindrical_coil}
	\caption{Construction of a Cylindrical Coil \cite{magnetic_fields}}
	\label{fig:cylindrical_coil}
\end{figure}


\chapter{Differential Cross Section Derivation}
%---------------------------------------------------------------------
\section{Probability Calculation}
\label{full}

\subsection{Differential Cross Section at the Parton Level}

The matrix element analysis technique reconstructs each event to the
final state four-vectors to evaluate the signal and background leading
order matrix element. The following sections derive the signal and
background probabilities starting from the final state at the parton
level and then relating these objects to the physical quantities
measured in the detector. The following also assumes a lepton,
neutrino, and two quarks in the final state.

The probability density for a process to occur at a hadron-hadron
collider is given as an integral of the hard-scatter differential
cross section over all possible ways of producing the process from the
quarks and gluons inside the hadron. This probability density, shown
below, is a convolution of the hard scatter differential cross section
with a parton distribution function for each of the two partons from
the hadrons with an integral over all possible momentum fractions
$x_{i}, x_{j}$ from each initial parton.
\begin{equation}
{\cal P}(\vec{y}) = \frac{1}{\sigma} \sum_{i,j}
\int f_{i}(q_{1}, Q^{2})dq_{1}
\times f_{j}(q_{2}, Q^{2})dq_{2}
\times d\sigma_{hs,ij}(\vec{y})
\end{equation}
\noindent where the normalization constant $\sigma$ is defined as
integral of the differential cross section over the initial- and
final-state phase spac:
\begin{equation}
\label{ds}
\sigma = \int  \sum_{i,j}
\int f_{i}(q_{1}, Q^{2})dq_{1}
\times f_{j}(q_{2}, Q^{2})dq_{2}
\times \pderiv{\sigma_{hs,ij}(\vec{y})}{\vec{y}} d\vec{y}
\end{equation}
\noindent and finally, the hard-scatter differential cross section is
defined as the product of the final state phase space factor, the
square of the matrix element amplitude and an overall flux factor:
\begin{equation}
d\sigma_{hs} = \frac{(2\pi)^4}{4}
\frac{{|\cal M|}^{2}}
{\sqrt{(q_{1}q_{2})^2 - m_{1}^2 m_{2}^2}}
\frac{d^{3}p_{1}}{(2\pi)^3 2E_{1}}
\frac{d^{3}p_{2}}{(2\pi)^3 2E_{2}}
\frac{d^{3}p_{\ell}}{(2\pi)^3 2E_{\ell}}
\frac{d^{3}p_{\nu}}{(2\pi)^3 2E_{\nu}}
\delta^{4}(q_{1}q_{2};p_{1},p_{2},p_{\ell},p_{\nu})
\end{equation}

\subsection{Evaluating the Hard Scatter Differential Cross Section}

The following section evaluates the differential cross section shown
in Eq.~\ref{ds} given a set of inital and final state four-vectors.

The first assumption made is that all collisions occur along the beam
axis with no net transverse momentum. This means the initial state
four vectors can be written as
\begin{equation}
q_{1} = ( E_{beam} x_{1}, 0, 0, E_{beam} x_{1} )
\end{equation}
\begin{equation}
q_{2} = ( E_{beam} x_{2}, 0, 0, -E_{beam} x_{2} )
\end{equation}
\noindent The next assumption is that all particle masses are known
and are negligible compared to their energies and thus can be ignored
for this calculation. The flux factor (shown below) in the hard
scatter cross section can now be written in terms in the two momentum
fractions of the incoming partons:
\begin{equation}
\frac{1}{\sqrt{(q_{1}q_{2})^2 - m_{1}^2m_{2}^2}} \rightarrow
\frac{1}{\sqrt{(q_{1}q_{2})^2}} \rightarrow
\frac{1}{2E_{beam}x_{1}x_{2}}
\end{equation}
\noindent For the remainder of the note, the following notation will
be used to distinquish quarks, leptons, and neutrinos: $p_{\ell}$ is
the momemtum of the lepton, $p_{1,2}$ is the momentum of the first and
second final state partons, and $p_{\nu}$ is the neutrino
momentum. Because the phase space is written in terms of rectangular
coordinates, the next step towards the final differential cross
section equation is to redefine the phase space factors in terms of
spherical coordiniates. This is done for all final state particles
except the neutrino for reasons that will be clear later in the
document.
\begin{eqnarray}
d\Phi_{4} =
\frac{d^{3}p_{1}}{(2\pi)^3 2E_{1}}
\frac{d^{3}p_{2}}{(2\pi)^3 2E_{2}}
\frac{d^{3}p_{\ell}}{(2\pi)^3 2E_{\ell}}
\frac{d^{3}p_{\nu}}{(2\pi)^3 2E_{\nu}} \delta^{4}
\rightarrow \\
\frac{1}{16(2\pi)^{12}}
\frac{|p_{1}|^{2}d|p_{1}|d\Omega_{1}}{E_{1}}
\frac{|p_{2}|^{2}d|p_{2}|d\Omega_{2}}{E_{2}}
\frac{|p_{\ell}|^{2}d|p_{\ell}|d\Omega_{\ell}}{E_{\ell}}
\frac{d^{x}_{\nu} d^{y}_{\nu} d^{z}_{\nu}}{E_{\nu}}\delta^{4}
%\frac{d^{3}p_{1}}{(2\pi)^3 2E_{1}} \frac{d^{3}p_{2}}{(2\pi)^32E_{2}} \frac{d^{3}p_{\ell}}{(2\pi)^3 2E_{\ell}}
%\frac{d^{3}p_{\nu}}{(2\pi)^3 2E_{\nu}} \delta^{4} \righarrow
%\frac{1}{16(2\pi)^{12}}
\end{eqnarray}
\noindent To summarize, the full hard scatter differential cross
section is now
\begin{equation}
\label{dhs}
d\sigma_{hs} = \frac{1}{128(2\pi)^{8}E_{beam}}
\frac{{|\cal M|}^{2}}{2x_{1}x_{2}}
\frac{|p_{1}|^{2}d|p_{1}|d\Omega_{1}}{E_{1}}
\frac{|p_{2}|^{2}d|p_{2}|d\Omega_{2}}{E_{2}}
\frac{|p_{\ell}|^{2}d|p_{\ell}|d\Omega_{\ell}}{E_{\ell}}
\frac{d^{x}_{\nu} d^{y}_{\nu} d^{z}_{\nu}}{E_{\nu}} \delta^{4}
\end{equation}

\subsection{Evaluating the Hadron-Hadron Differential Cross Section}

The next step to writing the full hadron-hadron differential cross
section is to rewrite Eq.~\ref{dhs} such that any integration over the
phase space will remove the four-dimensional delta function required
for energy and momentum conservation. The delta function is currently
written such that it will vanish only over integrations of total
$p_{x}, p_{y}, p_{z}$, and $E$. Because there was an original
assumption of no net transverse momentum in the collision, the total
$p_{x}$ and $p_{y}$ can be solved for the neutrino transverse
momentum.
\begin{eqnarray}
\sum_{i}P^{x}_{i} =
p^{x}_{1} + p^{x}_{2} + p^{x}_{\ell} + p^{x}_{\nu} = 0
\rightarrow p^{x}_{\nu} =
- p^{x}_{1} - p^{x}_{2} - p^{x}_{\ell} \\
\sum_{i}P^{y}_{i} =
p^{y}_{1} + p^{y}_{2} + p^{y}_{\ell} + p^{y}_{\nu} = 0
\rightarrow p^{y}_{\nu} =
- p^{y}_{1} - p^{y}_{2} - p^{y}_{\ell}
\end{eqnarray}
\noindent The total $p_{z}$ and requirement can be rewritten in terms
of the intial parton's momemtum fraction and the other final state
partons' $z$ momenta and thus solve for the neutrino $p_{z}$:
\begin{eqnarray}
\nonumber
\sum_{i}P^{z}_{i} =
p^{z}_{1} + p^{z}_{2} + p^{z}_{\ell} + p^{z}_{\nu} -
E_{beam}x_{1} + E_{beam}x_{2} = 0 \rightarrow \\
p^{z}_{\nu} =
- E_{beam}(x_{1} - x_{2}) - p^{z}_{1} - p^{z}_{2} - p^{z}_{\ell}
\end{eqnarray}
\noindent Finally, the total energy delta function implies the
following:
\begin{equation}
E_{beam}x_{1} + E_{beam}x_{2} = E_{1} + E_{2} + E_{\ell} + E_{\nu}
\end{equation}

At this point, is it useful to rewrite the full differential cross
section at the parton level:
\begin{eqnarray}
\nonumber
d\sigma(\vec{y}) = \sum_{i,j} \int f_{i}(x_{1}, Q^{2})dx_{1}
\times f_{j}(x_{2}, Q^{2})dx_{2}
\times \frac{1}{128(2\pi)^{8}E_{beam}}
\frac{{|\cal M|}^{2}}{2x_{1}x_{2}} \times \\
\nonumber
\frac{|p_{1}|^{2}d|p_{1}|d\Omega_{1}}{E_{1}}
\frac{|p_{2}|^{2}d|p_{2}|d\Omega_{2}}{E_{2}}
\frac{|p_{\ell}|^{2}d|p_{\ell}|d\Omega_{\ell}}{E_{\ell}}
\frac{d^{x}_{\nu} d^{y}_{\nu} d^{z}_{\nu}}{E_{\nu}} \times \\
\nonumber
\delta(p^{x}_{\nu} + p^{x}_{1} + p^{x}_{2} + p^{x}_{\ell}) \times \\
\nonumber
\delta(p^{y}_{\nu} + p^{y}_{1} + p^{y}_{2} + p^{y}_{\ell}) \times \\
\nonumber
\delta(p^{z}_{\nu} + E_{beam}(x_{1} - x_{2}) + p^{z}_{1}
+ p^{z}_{2} + p^{z}_{\ell}) \times \\
\delta(E_{beam}x_{1} + E_{beam}x_{2} - E_{1} - E_{2}
- E_{\ell} - E_{\nu})
\end{eqnarray}

The next step is to rewrite the integrational variables, $x_{1}$ and
$x_{2}$, in terms of the total energy and total $p_{z}$:
\begin{eqnarray}
\label{x1}
x_{1} = \frac{E_{tot} + p^{z}_{tot}}{2E_{beam}} \\
\label{x2}
x_{2} = \frac{E_{tot} - p^{z}_{tot}}{2E_{beam}}
\end{eqnarray}
\noindent Now, the integration over $x_{1}$ and $x_{2}$ can be
rewritten in terms of $E_{tot}$ and $p_{z}$:
\begin{eqnarray}
dx_{1}dx_{2} =
\frac{1}{J(x_{1},x_{2};E_{tot},p^{z}_{tot})}dE_{tot}dp^{z}_{tot} \\
J(x_{1},x_{2};E_{tot},p^{z}_{tot}) = 2E^{2}_{beam}
\end{eqnarray}
\noindent At this point the integration over the total energy and
$p_{z}$ will constrain the two incoming partons' momentum fractions
through Eq.~\ref{x1} and \ref{x2}.

The full differential cross section at the parton level can now be
written as
\begin{eqnarray}
\nonumber
d\sigma(\vec{y}) = \sum_{i,j} \int f_{i}(x_{1}, Q^{2})
\times
f_{j}(x_{2}, Q^{2}) \times \frac{1}{128(2\pi)^{8}E_{beam}}
\frac{{|\cal M|}^{2}}{2x_{1}x_{2}} \times \\
\nonumber
\frac{|p_{1}|^{2}d|p_{1}|d\Omega_{1}}{E_{1}}
\frac{|p_{2}|^{2}d|p_{2}|d\Omega_{2}}{E_{2}}
\frac{|p_{\ell}|^{2}d|p_{\ell}|d\Omega_{\ell}}{E_{\ell}}
\frac{d^{x}_{\nu} d^{y}_{\nu} d^{z}_{\nu}}{E_{\nu}} \times \\
\int \frac{1}{2E^{2}_{beam}} dp^{z}_{tot}
\end{eqnarray}
\noindent where the implicit integration over the four dimensional
delta function yields the following formulas for the neutrino four
vector and the incoming partons' momentum fraction in terms of the
remaining differential variables.
\begin{eqnarray}
p^{x}_{\nu} = - p^{x}_{1} - p^{x}_{2} - p^{x}_{\ell} \\
p^{y}_{\nu} = - p^{y}_{1} - p^{y}_{2} - p^{y}_{\ell} \\
p^{z}_{\nu} = - p^{z}_{tot} - p^{z}_{1} - p^{z}_{2} - p^{z}_{\ell} \\
x_{1} = \frac{E_{1} + E_{2} + E_{\ell} + E_{\nu} + p^{z}_{tot}}
{2E_{beam}} \\
x_{2} = \frac{E_{1} + E_{2} + E_{\ell} + E_{\nu} - p^{z}_{tot}}
{2E_{beam}}
\end{eqnarray}

\subsection{Relating Reconstructed Objects to Partons}

The previous sections have calculated the differential cross section
for a hadron-hadron collision producing a lepton, neutrino, and two
partons in the final state. These particles are not exactly what is
measured in the detector and thus it is necessary to relate
quantities. To do this, the differential cross section is convoluted
with a function, $W(\vec{x}, \vec{y})$, which is the probability of
producing a final state, $\vec{y}$, and observed state, $\vec{x}$, in
the detector. The resulting differential cross section is then
integrated over the final state phase space, $d\vec{y}$:
\begin{equation}
\pderiv{\sigma^{'}(\vec{x})}{\vec{x}} =
\int \pderiv{\sigma(\vec{y})}{\vec{y}} W(\vec{x}, \vec{y}) d\vec{y}
\end{equation}
\noindent where the function $W(\vec{x}, \vec{y})$ is assumed to be
factorizable for each measured object:
\begin{equation}
W(\vec{x}, \vec{y}) = \prod_{i} W_{i}(\vec{x_{i}}, \vec{y_{i}})
\end{equation}

\subsubsection{Jets}

The transfer function for jets measured in the calorimter is assumed
to only be a function of the relative energy difference between the
two objects and all angles are assumed to be well measured:
\begin{equation}
W_{jet}(\vec{x}_{jet}, \vec{y}_{parton}) = W(E_{jet} -
E_{parton}) \times \delta(\Omega_{jet} - \Omega_{parton})
\end{equation}
\noindent where $W(E_{jet} - E_{parton})$ is parametrized using the
following functional form:
\begin{equation}
W(E_{jet} - E_{parton}) = \frac{e^{-\frac{(E_{jet}
- E_{parton} - p_{1})^{2}}{2p^{2}_{2}}} + p_{3}e^{-\frac{(E_{jet}
- E_{parton} - p_{4})^{2}}{2p^{5}_{2}}}}{2\pi(p_{2} + p_{3}p_{5})}
\end{equation}
\noindent where $p_{i} = \alpha_{i} + \beta_{i} \times E_{parton}$.
The five $\alpha$ and five $\beta$ parameters are determined by
minimizing a likelihood formed by measuring the parton energy in Monte
Carlo and the matched jet energy also in Monte Carlo. The parameters
used for this analysis were determined in several regions of the
calorimeter to account for the resolution differences in the detector.

\subsubsection{Electrons}

The transfer function for electrons is assumed to be
solely a function of the reconstructed energy of the electron,
$E_{reco}$, the parton energy of the electron, $E_{parton}$, and
$\theta$, the production angle with respect to the beam axis:
\begin{equation}
W_{electron}(\vec{x}_{reco}, \vec{y}_{parton}) = W(E_{reco},
E_{parton}, \theta) \times \delta(\Omega_{reco} - \Omega_{parton})
\end{equation}
\noindent where $W(E_{reco}, E_{parton}, \theta)$ is parametrized
using the following functional form:
\begin{eqnarray}
W(E_{reco}, E_{parton}, \theta) & = &
\frac{1}{2\pi\sigma}\mathrm{exp}
[-\frac{(E_{reco} - E_{center})^{2}}{2\sigma^{2}}]\\
E_{center} & = &
1.0002 E_{parton} + 0.324\,{GeV}/c^2 \\
\sigma & = &
0.028 E_{center} \oplus \textrm{Sampling}(E_{center},
\eta) E_{center} \oplus 0.4 \\
\textrm{Sampling}(E, \theta) & = &
\left[\frac{0.164}{\sqrt{E}} + \frac{0.122}{E}\right]
\textrm{exp}\left[\frac{\textrm{p1}(E)}
{\textrm{sin}\theta}-\textrm{p1}(E)\right] \\
\textrm{p1}(E)& = & 1.35193 - \frac{2.09564}{E} - \frac{6.98578}{E^2}.
\end{eqnarray}

\subsubsection{Muons}

The transfer function for muons is assumed to be a
function of
\begin{equation}
\Delta\left( \frac{q}{p_t}\right) =
\left( \frac{q}{p_t}\right)_{reco} -
\left( \frac{q}{p_t}\right)_{parton}
\end{equation}
\noindent and of $\eta_\mathrm{CFT}$,
\begin{equation}
W_{muon}(\vec{x}_{reco}, \vec{y}_{parton}) =
W\left(\Delta\left( \frac{q}{p_t}\right),
\eta_\mathrm{CFT}\right) \times
\delta(\Omega_{reco} - \Omega_{parton})
\end{equation}
\noindent where $W\left(\Delta\left( \frac{q}{p_t}\right),
\eta_\mathrm{CFT}\right)$ is parametrized using a single Gaussian:
\begin{equation}
W\left(\Delta\left( \frac{q}{p_t}\right), \eta_\mathrm{CFT}\right) =
\frac{1}{2\pi\sigma}\mathrm{exp}
\left\{-\frac{\left[\Delta
\left( \frac{q}{p_t} \right)\right]^2}
{2\sigma^2}\right\}
\end{equation}
\begin{equation}
\sigma  =  \left\{
\begin{array} {c@{\quad:\quad}l} \sigma_o &
|\eta_\mathrm{CFT}| \le \eta_o \\
\sqrt{\sigma^2_o + [c(|\eta_\mathrm{CFT}| - \eta_o)]^2} &
|\eta_\mathrm{CFT}| > \eta_o
\end{array} \right.
\end{equation}

\noindent There are three fitted parameters in the above equations:
$\sigma_o$, $c$, and $\eta_o$, each of which is actually fitted by two
sub-parameters:
\begin{equation}
par = par(0) + par(1) \cdot 1/p_t.
\end{equation}
\noindent Furthermore, these parameters are derived for four classes
of events: those that were from before or after the 2004 shutdown,
when the magnetic field strength changed, and in each run range, those
that have an SMT hit and those that do not.

As a simplification, we assume $q_{reco} = q_{parton}$, that is, we
do not consider charge misidentification

\subsection{Full Differential Cross Section and Normalization}

The full differential cross section at the detector object level can
now be written as
\begin{eqnarray}
\label{fullds}
\nonumber
\pderiv{\sigma^{'}(\vec{x})}{\vec{x}} =
\int dp^{z}_{tot}dq_{1}dq_{2}dp_{\ell} \sum_{i,j}
f_{i}(q_{1}, Q^{2}) \times f_{j}(q_{2}, Q^{2}) \\
\times \frac{1}{256(2\pi)^{8}E^{3}_{beam}}
\frac{{|\cal M|}^{2}}{2x_{1}x_{2}} \times
\frac{p_{1}^{2}}{E_{1}} \frac{p_{2}^{2}}{E_{2}}
\frac{p_{\ell}^{2}}{E_{\ell}} \frac{1}{E_{\nu}}
\times W_{Lepton}W_{Jet1}W_{Jet2}
\end{eqnarray}
\noindent The final step to evaluating the probability density is to
properly normalize the differential cross section in
Eq.~\ref{fullds}. This is done by integration of the differential
cross section over all possible states in the detector. Since the
event selection cuts will change the number events due to acceptance
losses, this must be accounted for in the overall normalization (cross
section) calculation. The total cross section is then written as
\begin{eqnarray}
\label{norm}
\nonumber
\sigma = \int \pderiv{\sigma^{'}(\vec{x})}{\vec{x}} d\vec{x} =
\int d\vec{x}dp^{z}_{tot}dq_{1}dq_{2}dp_{\ell} \sum_{i,j}
f_{i}(q_{1}, Q^{2}) \times f_{j}(q_{2}, Q^{2}) \\
\times \frac{1}{256(2\pi)^{8}E^{3}_{beam}}
\frac{{|\cal M|}^{2}}{2x_{1}x_{2}} \times
\frac{p_{1}^{2}}{E_{1}} \frac{p_{2}^{2}}{E_{2}}
\frac{p_{\ell}^{2}}{E_{\ell}} \frac{1}{E_{\nu}}
\times W_{Lepton}W_{Jet1}W_{Jet2} \times \Theta_{\rm{Cuts}}(\vec{x})
\end{eqnarray}

 \section{Integration Variable Remapping}

\subsection{Introduction}
This section will layout the jacobian needed for the 10 $\rar$ 10 remapping of
variables for the parton level cross section. The base variables used are shown below.

\begin{itemize}
\item $p_{3}$: Absolute momentum of the lepton
\item $p_{5}$: Absolute momentum of the first quark
\item $p_{6}$: Absolute momentum of the second quark
\item $p_{tot}^{z}$: Total $p_{z}$ of the system
\item $cos(\theta_{3})$: Cosine($\theta$) of the lepton
\item $\phi_{3}$: $\phi$ of the lepton
\item $cos(\theta_{5})$: Cosine($\theta$) of the first quark
\item $\phi_{5}$: $\phi$ of the first quark
\item $cos(\theta_{6})$: Cosine($\theta$) of the second quark
\item $\phi_{6}$: $\phi$ of the second quark
\end{itemize}

Other variables that are useful for the integration are
\begin{itemize}
\item $m_{34}$: Mass of the lepton and neutrino (W mass)
\item $m_{345}$: Mass of the lepton, neutrino, and first quark (top mass)
\item $m_{56}$: Mass of the first and second quark ($b\bar{b}$ mass)
\end{itemize}

Since some of these variables are sharp peaks (W and top masses), it is much
better to sample from the expected distribution rather than make requirements of
the invariant masses. The W and top masses are expected to follow a Breit-Wigner
distribution shown below.

\begin{equation}
\sigma(M_{34}) = \frac{1}{\pi} \left[ \frac{\gamma}{(M_{34} - M_{W})^{2} +
\gamma^{2}} \right]
\end{equation}

where $M_{34}$ is the mass of the lepton and neutrino. Similarly, the top mass
has the following expected distribution.

\begin{equation}
\sigma(M_{345}) = \frac{1}{\pi} \left[ \frac{\gamma}{(M_{345} - M_{top})^{2} +
\Gamma^{2}} \right]
\end{equation}

where  $M_{345}$ is the mass of the lepton, neutrino, and first quark.

\subsection{Sampling from a Breit-Wigner mass distribution}

Sampling from a Breit-Wigner distribution is done by selecting a random point
between 0 and 1 from the cumulative distribution function of the BW
function. The cumulative distribution function, of cdf, for the Breit-Wigner
distribution is shown below.

\begin{equation}
\label{sample}
\int \sigma(m;m_{0};\Gamma) = F(m;m_{0},\Gamma) = \frac{1}{\pi} \tan^{-1} \left[
\frac{m-m_{0}}{\Gamma} \right] + \frac{1}{2}
\end{equation}

The value of F is taken as a random number between 0 and 1. After selecting a
value of F, the next step is to solve for m. As a function of F, defined as u for
the following, the mass is

\begin{equation}
m = m_{0} + \Gamma \tan \left[ \pi(u - \frac{1}{2}) \right]
\end{equation}

\subsection{Sampling from a Breit-Wigner $S_{cm}$ distribution}

In the previous example, a distribution was sampled using a random number
uniformly distributed from 0 to 1. In, this example, a new random number is used
that is uniformaly samples from 0 to 1, but the maximum and minimum values of
the variable are taken into account in the Jacobian.

The distribution of the variable $S_{cm}$ is the following

\begin{equation}
\label{defines}
s = m_{0}^{2} + m_{0}\Gamma \tan \left[ m_{0} \Gamma r \right]
\end{equation}

where r is defined in terms of the random variable, u, that is uniformaly
distributed between 0 and 1.

\begin{equation}
\label{rtou}
r = (r_{max} - r_{min}) \times u + r_{min}
\end{equation}

where $r_{max}$ and $r_{min}$ are defined in terms of the variable $s_{cm}$.

\begin{eqnarray}
\label{definer}
r = \frac{1}{m_{0}\Gamma} \tan \left[ \frac{s - m_{0}^{2}}{m_{0}\Gamma} \right] \\
r_{min} = \frac{1}{m_{0}\Gamma} \tan \left[ \frac{s_{min} -
m_{0}^{2}}{m_{0}\Gamma} \right] \\
r_{max} = \frac{1}{m_{0}\Gamma} \tan \left[ \frac{s_{max} - m_{0}^{2}}{m_{0}\Gamma} \right]
\end{eqnarray}

\subsection{Jacobian for random sampling of a Breit-Wigner distribution around
the W mass squared, $s_{34}$}

The first case to consider is the Breit-Wigner sampling around the W mass
$S_{34}$ distribution and replace the integration variable, $p_{3}$ or the
lepton momentum.

\begin{equation}
\label{jacobian1}
|J(p_{3}, u)| = \left| \pderiv{p_{3}}{u} \right|
\end{equation}

Because u is redined in terms of the variable r, we can rewrite ~\ref{jacobian1}
in terms of r instead of u.

\begin{equation}
\label{jacobian2}
|J(p_{3}, u)| = \left| \pderiv{p_{3}}{u} \right| = \left| \pderiv{p_{3}}{r}
\times \pderiv{r}{u} \right|
\end{equation}

And since the variable r is sampling the $S_{34}$ distribution it makes sense to
define the Jacobian in terms of this variable instead of $p_{3}$.

\begin{equation}
\label{jacobian3}
|J(p_{3}, u)| = \left| \pderiv{p_{3}}{r} \times \pderiv{r}{u} \right| = \left|
\pderiv{p_{3}}{s_{34}} \times \pderiv{s_{34}}{r} \times \pderiv{r}{u} \right| =
\left | \frac{\pderiv{s_{34}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{34}}{p_{3}}} \right |
\end{equation}

Equation ~\ref{jacobian3} has three components: $\pderiv{s_{34}}{r}$,
$\pderiv{r}{u}$, and $\pderiv{s_{34}}{p_{3}}$. From equation ~\ref{rtou}, the
partial derivative of r with respect to u is

\begin{equation}
\label{drdu}
\pderiv{r}{u} = r_{max} - r_{min} = \Delta r
\end{equation}

Next, the partial of $s_{34}$ with respect to r can be determined from equation
~\ref{defines}.

\begin{equation}
\label{ds34dr}
\pderiv{s_{34}}{r} = (m_{W} \Gamma_{W})^{2} \sec^{2} \left[m_{W} \Gamma_{W} r \right]
\end{equation}

Inserting the value of r(s) as defined in equation ~\ref{definer}, equation
~\ref{ds34dr} can be re-written as

\begin{equation}
\label{ds34dr_2}
\pderiv{s_{34}}{r} = (m_{W} \Gamma_{W})^{2} \sec^{2} \left[m_{W} \Gamma_{W} r \right] =
(m_{W} \Gamma_{W})^{2} \sec^{2} \left[\arctan \left[ \frac{s_{34} - m_{W}^{2}}{m_{W}
\Gamma_{W}}  \right] \right]
\end{equation}

Equation ~\ref{ds34dr_2} is solved by defining a right triangle where

\begin{eqnarray}
\nonumber
\tan(\theta) = \frac{s_{34}-m_{W}^{2}}{m_{W}\Gamma_{W}} \\
\cos(\theta) = \frac{1}{\sqrt{1+\left[ \frac{s_{34}-m_{W}^{2}}{m_{W}\Gamma_{W}}
\right]^{2}}}
\end{eqnarray}

Using these definitions, equation ~\ref{ds34dr_2} is finally defined as

\begin{equation}
\label{ds34dr_3}
\pderiv{s_{34}}{r} = (m_{W} \Gamma_{W})^{2} \sec^{2} \left[\arctan \left[ \frac{s_{34} - m_{W}^{2}}{m_{W}
\Gamma_{W}}  \right] \right] = (m_{W}\Gamma_{W})^{2} + (s_{34} - m_{W}^{2})^{2}
\end{equation}

Finally, we need the partial derivative of $s_{34}$ with repect to
$p_{3}$. First, we define $s_{34}$

\begin{equation}
\label{defines34}
s_{34} = m_{3}^{2} + m_{4}^{2} + 2E_{3}E_{4} - 2p_{3}^{x}p_{4}^{x} - 2p_{3}^{y}p_{4}^{y} - 2p_{3}^{z}p_{4}^{z}
\end{equation}

Since the neutino four-vector is defined in terms of all the other particles in
the event, we need to rewrite equation ~\ref{defines34} to expose all the
dependences on $p_{3}$. For the following, it is assumed that the lepton and
neutrino are massless meaning $E_{3} = p_{3}$.

\begin{eqnarray}
\label{defines34_2}
\nonumber
s_{34} = 2p_{3}\sqrt{(-p_{3}^{x} -p_{5}^{x} -p_{6}^{x})^{2} + (-p_{3}^{y} -p_{5}^{y} -p_{6}^{y})^{2} + (p_{tot}^{z} -p_{3}^{z} -p_{5}^{z} -p_{6}^{z})^{2}} \\
- 2p_{3}^{x}(-p_{3}^{x} -p_{5}^{x} -p_{6}^{x}) -
2p_{3}^{y}(-p_{3}^{y} -p_{5}^{y} -p_{6}^{y}) - 2p_{3}^{z}(p_{tot}^{z} -p_{3}^{z} -p_{5}^{z} -p_{6}^{z})
\end{eqnarray}

After combining like terms, we can evaluate the partial derivative of $s_{34}$
with respect to $p_{3}$ that yields the relatively
simple formula

\begin{equation}
\label{ds34dp3}
\pderiv{s_{34}}{p_{3}} = 2(p_{3} + p_{4})(1 - \hat{p_{3}} \cdot \hat{p_{4}})
\end{equation}

Finally, we can rewrite the Jacobian defined in ~\ref{jacobian3} as

\begin{equation}
\label{jacobian4}
|J(p_{3}, u)| = \left | \frac{\pderiv{s_{34}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{34}}{p_{3}}} \right | = \frac{\Delta R \times \left[
(m_{W}\Gamma_{W})^{2} + (s_{34} - m_{W}^{2})^{2} \right]}{2(p_{3} + p_{4})(1 - \hat{p_{3}} \cdot \hat{p_{4}})}
\end{equation}

In some cases, it is also common to replace the first quark momentum integration
with the Breit-Wigner sampling variable. In that case, we need to evaluate

\begin{equation}
\label{jacobian_5}
|J(p_{5}, u)| = \left | \frac{\pderiv{s_{34}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{34}}{p_{5}}} \right |
\end{equation}

For this substitution, we only need to evaluate the partial derivative of
$s_{34}$ with respect to $p_{5}$. Assuming a massless quark, the result is

\begin{equation}
\label{ds34dp5}
\pderiv{s_{34}}{p_{5}} = 2p_{3}(\hat{p_{3}} \cdot \hat{p_{5}} - \hat{p_{4}} \cdot \hat{p_{5}})
\end{equation}

Combining equation ~\ref{ds34dp5} with ~\ref{jacobian_5} yields

\begin{equation}
\label{jacobian_6}
|J(p_{5}, u)| = \left | \frac{\pderiv{s_{34}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{34}}{p_{5}}} \right | = \frac{\Delta R \times \left[
(m_{W}\Gamma_{W})^{2} + (s_{34} - m_{W}^{2})^{2} \right]}{2p_{3}(\hat{p_{3}} \cdot \hat{p_{5}} - \hat{p_{4}} \cdot \hat{p_{5}})}
\end{equation}

%
%-----------------------------------------------------------------------
%

\subsection{Jacobian for random sampling of a Breit-Wigner distribution around
the top mass squared, $s_{345}$}

The next case to consider is the Breit-Wigner sampling around the top mass squared
$S_{345}$ distribution and replace the integration variable, $p_{3}$ or the
lepton momentum. As before, we need need to calculate the following

\begin{equation}
\label{jacobian_1}
|J(p_{3}, u)| = \left| \pderiv{p_{3}}{r} \times \pderiv{r}{u} \right| = \left|
\pderiv{p_{3}}{s_{345}} \times \pderiv{s_{345}}{r} \times \pderiv{r}{u} \right| =
\left | \frac{\pderiv{s_{345}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{345}}{p_{3}}} \right |
\end{equation}

Equation ~\ref{jacobian_1} has three components: $\pderiv{s_{345}}{r}$,
$\pderiv{r}{u}$, and $\pderiv{s_{345}}{p_{3}}$. We know $\pderiv{r}{u}$ from
equation ~\ref{drdu} where $r_{min}$ and $r_{max}$ are defined by the $s_{345}$
system instead of the $s_{34}$ system. We also know $\pderiv{s_{345}}{r}$ from ~\ref{ds34dr_3}
where we replace $s_{34}$ with $s_{345}$.

\begin{equation}
\label{ds345dr}
\pderiv{s_{345}}{r} = (m_{t}\Gamma_{t})^{2} + (s_{345} - m_{t}^{2})^{2}
\end{equation}

We do need the partial derivative of $s_{345}$ with repect to
$p_{3}$. First, we define $s_{345}$

\begin{eqnarray}
\label{defines345}
\nonumber
s_{345} = m_{3}^{2} + m_{4}^{2} + m_{5}^{2} + 2E_{3}E_{4} + 2E_{3}E_{5} +
2E_{4}E_{5} - \\
2p_{3}^{x}p_{4}^{x} - 2p_{3}^{x}p_{5}^{x} - 2p_{4}^{x}p_{5}^{x} -
2p_{3}^{y}p_{4}^{y} - 2p_{3}^{y}p_{5}^{y} - 2p_{4}^{y}p_{5}^{y} -
2p_{3}^{z}p_{4}^{z} - 2p_{3}^{z}p_{5}^{z} - 2p_{4}^{z}p_{5}^{z}
\end{eqnarray}

As before, the neutino four-vector is defined in terms of all the other particles in
the event so we need to rewrite equation ~\ref{defines345} to expose all the
dependences on $p_{3}$. For the following, it is assumed that the lepton,
neutrino, and quark are massless meaning $E_{3} = p_{3}$.

\begin{eqnarray}
\label{defines345_2}
\nonumber
s_{345} = 2p_{3}\sqrt{(-p_{3}^{x} -p_{5}^{x} -p_{6}^{x})^{2} + (-p_{3}^{y}
-p_{5}^{y} -p_{6}^{y})^{2} + (p_{tot}^{z} -p_{3}^{z} -p_{5}^{z} -p_{6}^{z})^{2}}
+ \\
\nonumber
2p_{3}p_{5} + 2\sqrt{(-p_{3}^{x} -p_{5}^{x} -p_{6}^{x})^{2} + (-p_{3}^{y} -p_{5}^{y}
-p_{6}^{y})^{2} + (p_{tot}^{z} -p_{3}^{z} -p_{5}^{z} -p_{6}^{z})^{2}}p_{5} - \\
\nonumber
2p_{3}^{x}(-p_{3}^{x} -p_{5}^{x} -p_{6}^{x}) - 2p_{3}^{x}p_{5}^{x} -
2(-p_{3}^{x} -p_{5}^{x} -p_{6}^{x})p_{5}^{x} - \\
\nonumber
2p_{3}^{y}(-p_{3}^{y} -p_{5}^{y} -p_{6}^{y}) - 2p_{3}^{y}p_{5}^{y} -
2(-p_{3}^{y} -p_{5}^{y} -p_{6}^{y})p_{5}^{y} - \\
2p_{3}^{z}(-p_{3}^{z} -p_{5}^{z} -p_{6}^{z}) - 2p_{3}^{z}p_{5}^{z} - 2(-p_{3}^{z} -p_{5}^{z} -p_{6}^{z})p_{5}^{z}
\end{eqnarray}

After combining like terms, we can evaluate the partial derivative of $s_{345}$
with respect to $p_{3}$ as

\begin{equation}
\label{ds345dp3}
\pderiv{s_{345}}{p_{3}} = 2(p_{3} + p_{4} + p_{5})(1 - \hat{p_{3}} \cdot \hat{p_{4}})
\end{equation}

Finally, we can rewrite the Jacobian defined in ~\ref{jacobian_1} as

\begin{equation}
\label{jacobian_2}
|J(p_{3}, u)| = \left | \frac{\pderiv{s_{345}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{345}}{p_{3}}} \right | = \frac{\Delta R \times \left[
(m_{t}\Gamma_{t})^{2} + (s_{345} - m_{t}^{2})^{2} \right]}{2(p_{3} + p_{4} + p_{5})(1 - \hat{p_{3}} \cdot \hat{p_{4}})}
\end{equation}

Instead of replacing the lepton momentum integration variable, it is also common
to replace the first quark momentum integration variable, $p_{5}$. In that case,
we need to evaluate the following Jacobian.

\begin{equation}
\label{jacobian_3}
|J(p_{5}, u)| = \left| \pderiv{p_{5}}{r} \times \pderiv{r}{u} \right| = \left|
\pderiv{p_{5}}{s_{345}} \times \pderiv{s_{345}}{r} \times \pderiv{r}{u} \right| =
\left | \frac{\pderiv{s_{345}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{345}}{p_{5}}} \right |
\end{equation}

The only difference is that partial derivative of $s_{345}$ with respect to
$p_{5}$ instead of $p_{3}$. However, since $s_{345}$ is invariant under a change
of $p_{3}$ and $p_{5}$ the partial derivatives must be equal. Thus,

\begin{equation}
\label{jacobian_4}
|J(p_{5}, u)| = \left | \frac{\pderiv{s_{345}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{345}}{p_{5}}} \right | = \frac{\Delta R \times \left[
(m_{t}\Gamma_{t})^{2} + (s_{345} - m_{t}^{2})^{2} \right]}{2(p_{3} + p_{4} + p_{5})(1 - \hat{p_{4}} \cdot \hat{p_{5}})}
\end{equation}

%
%-----------------------------------------------------------------------
%

\subsection{Jacobian for random sampling of two Breit-Wigner distributions around
the top mass squared, $s_{345}$ and W mass squared, $s_{34}$}

The next situation is to sample from a Breit-Wigner around the
top mass squared and the W mass squared, or $s_{345}$ and $s_{34}$. It is common
to replace the lepton momentum and first quark momentum integration variables
with the two new variables. Since we are
replacing two variables, we need to evaluate the following Jacobian

\begin{equation}
|J(p_{3}, p_{5} ; u_{1}, u_{2})| = \left| \begin{array}{cc}
\pderiv{p_{3}}{u_{1}}	& \pderiv{p_{3}}{u_{2}} \\
\pderiv{p_{5}}{u_{1}}	& \pderiv{p_{5}}{u_{2}} \\
\end{array} \right|
\end{equation}

where $u_{1}$ and $u_{2}$ are the sampling variables around the top mass squared
and W mass squared, respectively.

We have already computed the partial derivatives for each of these cases
in the previous two sections, thus the result is

\begin{eqnarray}
\nonumber
|J(p_{3}, p_{5} ; u_{1}, u_{2})| = \left| \begin{array}{cc}
\pderiv{p_{3}}{u_{1}}	& \pderiv{p_{3}}{u_{2}} \\
\pderiv{p_{5}}{u_{1}}	& \pderiv{p_{5}}{u_{2}} \\
\end{array} \right| =
\nonumber
\left| \begin{array}{cc}
\frac{\pderiv{s_{345}}{r} \times \pderiv{r}{u}}{\pderiv{s_{345}}{p_{3}}}	& \frac{\pderiv{s_{345}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{345}}{p_{5}}} \\
\frac{\pderiv{s_{34}}{r} \times \pderiv{r}{u}}{\pderiv{s_{34}}{p_{3}}}	& \frac{\pderiv{s_{34}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{34}}{p_{5}}}
\end{array} \right| = \\
\left| \begin{array}{cc}
\frac{\Delta R_{345} \times \left[
(m_{t}\Gamma_{t})^{2} + (s_{345} - m_{t}^{2})^{2} \right]}{2(p_{3} + p_{4} + p_{5})(1 - \hat{p_{3}} \cdot \hat{p_{4}})}	& \frac{\Delta R_{34} \times \left[
(m_{W}\Gamma_{W})^{2} + (s_{34} - m_{W}^{2})^{2} \right]}{2(p_{3} + p_{4})(1 -
\hat{p_{3}} \cdot \hat{p_{4}})} \\
\frac{\Delta R_{345} \times \left[
(m_{t}\Gamma_{t})^{2} + (s_{345} - m_{t}^{2})^{2} \right]}{2(p_{3} + p_{4} + p_{5})(1 - \hat{p_{4}} \cdot \hat{p_{5}})}	& \frac{\Delta R_{34} \times \left[
(m_{W}\Gamma_{W})^{2} + (s_{34} - m_{0}^{2})^{2} \right]}{2p_{3}(\hat{p_{3}} \cdot \hat{p_{5}} - \hat{p_{4}} \cdot \hat{p_{5}})}
\end{array}
\right|
\end{eqnarray}

\subsection{Sampling from a Polynomial $S_{cm}$ distribution}

*** This is where I am taking a function from Aurelio and I can't seem to derive
it on my own ***

The distribution of the variable $S_{cm}$ according to a polynomial power
distribution is

\begin{equation}
\label{defines_power}
s = m_{0}^{2} + \left[ (1-\alpha)r \right]^{\frac{-1}{\alpha - 1}}
\end{equation}

where r is defined in terms of the random variable, u, that is uniformaly
distributed between 0 and 1.

\begin{equation}
\label{rtou_power}
r = (r_{max} - r_{min}) \times u + r_{min}
\end{equation}

where $r_{max}$ and $r_{min}$ are defined in terms of the variable $s_{cm}$.

\begin{eqnarray}
\label{definer_power}
r = \frac{1}{1-\alpha} \times \left[ s - m_{0}^{2} \right]^{1-\alpha} \\
r_{min} = \frac{1}{1-\alpha} \times \left[ s_{min} - m_{0}^{2}
\right]^{1-\alpha} \\
r_{max} = \frac{1}{1-\alpha} \times \left[ s_{max} - m_{0}^{2}
\right]^{1-\alpha}
\end{eqnarray}

where alpha can not equal 1.

\subsection{Jacobian for random sampling of a polynomial distribution
starting at $m_{pole}$}

The first case to consider is sampling around a falling polynomial distribution
for the mass squared of two quarks in the event, $s_{56}$. We need to define the
Jacobian with respect $p_{5}$ or $p_{6}$. Since $s_{56}$ is invariant under an
interchange of particle 5 and 6, the Jacobian will be the same for each momentum
integration. The following assume $p_{5}$ will be replaced with the variable,
$u$, which is sampled from a polynomial distribution.

\begin{equation}
\label{jacobian_7}
|J(p_{5}, u)| = \left| \pderiv{p_{5}}{u} \right|
\end{equation}

Because u is redined in terms of the variable r, we can rewrite ~\ref{jacobian_7}
in terms of r instead of u.

\begin{equation}
\label{jacobian_8}
|J(p_{5}, u)| = \left| \pderiv{p_{5}}{u} \right| = \left| \pderiv{p_{5}}{r}
\times \pderiv{r}{u} \right|
\end{equation}

And since the variable r is sampling the $S_{56}$ distribution it makes sense to
define the Jacobian in terms of this variable instead of $p_{5}$.

\begin{equation}
\label{jacobian_9}
|J(p_{5}, u)| = \left| \pderiv{p_{5}}{r} \times \pderiv{r}{u} \right| = \left|
\pderiv{p_{5}}{s_{56}} \times \pderiv{s_{56}}{r} \times \pderiv{r}{u} \right| =
\left | \frac{\pderiv{s_{56}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{56}}{p_{5}}} \right |
\end{equation}

Equation ~\ref{jacobian_9} has three components: $\pderiv{s_{56}}{r}$,
$\pderiv{r}{u}$, and $\pderiv{s_{56}}{p_{5}}$. From equation ~\ref{rtou_power}, the
partial derivative of r with respect to u is

\begin{equation}
\label{drdu_power}
\pderiv{r}{u} = r_{max} - r_{min} = \Delta R_{56}
\end{equation}

Next, the partial of $s_{56}$ with respect to r can be determined from equation ~\ref{defines_power}.

\begin{equation}
\label{ds56dr_power}
\pderiv{s_{56}}{r} = \left[ r(1-\alpha) \right]^{\frac{\alpha}{1-\alpha}}
\end{equation}

Inserting the value of r(s) as defined in equation ~\ref{definer_power}, equation ~\ref{ds56dr_power} can be re-written as

\begin{equation}
\label{ds56dr_power2}
\pderiv{s_{56}}{r} = \left[ s_{56} - m_{0}^{2} \right]^{\alpha}
\end{equation}

Finally, we need the partial derivative of $s_{56}$ with repect to $p_{5}$. First, we define $s_{56}$

\begin{equation}
\label{defines56_power}
s_{56} = m_{5}^{2} + m_{6}^{2} + 2E_{5}E_{6} - 2p_{5}^{x}p_{6}^{x} - 2p_{5}^{y}p_{6}^{y} - 2p_{5}^{z}p_{6}^{z}
\end{equation}

we can evaluate the partial derivative of $s_{56}$ with respect to $p_{5}$.

\begin{equation}
\label{ds56dp5_power}
\pderiv{s_{56}}{p_{5}} = 2p_{6}(1 - \hat{p_{5}} \cdot \hat{p_{6}})
\end{equation}

Finally, we can rewrite the Jacobian defined in ~\ref{jacobian_9} as

\begin{equation}
\label{jacobian_10}
|J(p_{5}, u)| = \left | \frac{\pderiv{s_{56}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{56}}{p_{5}}} \right | = \frac{\Delta R_{56} \times \left[ s_{56}-m_{0}^{2} \right]^{\alpha}}{2p_{6}(1 - \hat{p_{5}} \cdot \hat{p_{6}})}
\end{equation}

and

\begin{equation}
\label{jacobian_11}
|J(p_{6}, u)| = \left | \frac{\pderiv{s_{56}}{r} \times
\pderiv{r}{u}}{\pderiv{s_{56}}{p_{6}}} \right | = \frac{\Delta R_{56} \times \left[ s_{56}-m_{0}^{2} \right]^{\alpha}}{2p_{5}(1 - \hat{p_{5}} \cdot \hat{p_{6}})}
\end{equation}


\section{Multiphysics Finite-Element Formulation}
\label{sec:multiphysics:formulation}

Within the PETSc solver framework, we want to solve a system of
partial differential equations in which the weak form can be
expressed as $F(t,s,\dot{s}) = G(t,s)$, $s(t_0) = s_0$, where $F$ and
$G$ are vector functions, $t$ is time, and $s$ is the solution vector.

Using the finite-element method we manipulate the weak form of the
system of equations involving a vector field $\vec{u}$ into integrals
over the domain $\Omega$ matching the form,
\begin{equation}
  \label{eqn:problem:form}
  \int_\Omega \trialvec[u] \cdot \vec{f}_0(t,s,\dot{s}) + \nabla \trialvec[u] : \tensor{f}
_1(t,s,\dot{s}) \,
d\Omega =
  \int_\Omega \trialvec[u] \cdot \vec{g}_0(t,s) + \nabla \trialvec[u] : \tensor{g}_1(t,s) \,
d\Omega,
\end{equation}
where $\trialvec[u]$ is the trial function for field $\vec{u}$,
$\vec{f}_0$ and $\vec{g}_0$ are vectors, and $\tensor{f}_1$ and
$\tensor{g}_1$ are tensors. With multiple partial differential
equations we will have multiple equations of this form, and the
solution vector $s$, which we usually write as $\vec{s}$, will be
composed of several different fields, such as displacement $\vec{u}$,
velocity $\vec{v}$, pressure $p$, and temperature $T$. Boundary
conditions will also contribute similar terms with integrals over the
corresponding boundaries.

For consistency with the PETSc time stepping formulation, we call
$G(t,s)$ the RHS function and call $F(t,s,\dot{s})$ the LHS (or I)
function. Likewise, the Jacobian of $G(t,s)$ is the RHS Jacobian and
the Jacobian of $F(t,s,\dot{s})$ is the LHS Jacobian.  Using a
finite-element discretization we break up the domain and boundary
integrals into sums over the cells and boundary faces/edges,
respectively. Using numerical quadrature those sums in turn involve
sums over the values at the quadrature points with appropriate
weights. Thus, computation of the RHS function boils down to pointwise
evaluation of $\vec{g}_0(t,s)$ and $\tensor{g}_1(t,s)$, and
computation of the LHS function boils down to pointwise evaluation of
$\vec{f}_0(t,s,\dot{s})$ and $\tensor{f}_1(t,s,\dot{s})$.

\subsection{Jacobian}

The LHS Jacobian $J_F = \frac{\partial F}{\partial s} +
s_\mathit{tshift} \frac{\partial F}{\partial \dot{s}}$ and the RHS
Jacobian $J_G = \frac{\partial G}{\partial s}$, where
$s_\mathit{tshift}$ arises from the temporal discretization. We put
the Jacobians for each equation into the form:
\begin{align}
  \label{eqn:jacobian:form}
  J_F &= \int_\Omega \trialvec \cdot \tensor{J}_{f0}(t,s,\dot{s}) \cdot \basisvec
  + \trialvec \cdot \tensor{J}_{f1}(t,s,\dot{s}) : \nabla \basisvec
  + \nabla \trialvec : \tensor{J}_{f2}(t,s,\dot{s}) \cdot \basisvec
  + \nabla \trialvec : \tensor{J}_{f3}(t,s,\dot{s}) : \nabla \basisvec \, d\Omega \\
%
  J_G &= \quad \int_\Omega \trialvec \cdot \tensor{J}_{g0}(t,s) \cdot \basisvec
  + \trialvec \cdot \tensor{J}_{g1}(t,s) : \nabla \basisvec
  + \nabla \trialvec : \tensor{J}_{g2}(t,s) \cdot \basisvec
  + \nabla \trialvec : \tensor{J}_{g3}(t,s) : \nabla \basisvec \, d\Omega,
\end{align}
where $\basisvec$ is a basis function.  Expressed in index notation
the Jacobian coupling solution field components $s_i$ and $s_j$ is
\begin{equation}
\label{eqn:jacobian:index:form}
J^{s_is_j} = \int_\Omega \trialscalar_i J_0^{s_is_j} \basisscalar_j + \trialscalar_i
J_1^{s_js_jl}
\basisscalar_{j,l} + \trialscalar_{i,k} J_2^{s_is_jk} \basisscalar_j + \trialscalar_{i,k}
J_3^{s_is_jkl}
\basisscalar_{j,l} \, d\Omega,
\end{equation}
It is clear that the tensors $J_0$, $J_1$, $J_2$, and $J_3$ have
various sizes: $J_0(n_i,n_j)$, $J_1(n_i,n_j,d)$, $J_2(n_i,n_j,d)$,
$J_3(n_i,n_j,d,d)$, where $n_i$ is the number of components in
solution field $s_i$, $n_j$ is the number of components in solution
field $s_j$, and $d$ is the spatial dimension.  Alternatively,
expressed in discrete form, the Jacobian for the coupling between
solution fields $s_i$ and $s_j$ is
\begin{equation}
  \label{eqn:jacobian:discrete:form}
  J^{s_is_j} = J_{0}^{s_is_j} + J_{1}^{s_is_j} B + B^T J_{2}^{s_is_j} + B^T J_{3}^{s_is_j} B,
\end{equation}
where $B$ is a matrix of the derivatives of the basis functions and $B^T$
is a matrix of the derivatives of the trial functions.

\important{See
  \url{https://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/FE/PetscFEIntegrateJacobian.html}
  for the ordering of indicies in the Jacobian pointwise functions.}

\subsection{PETSc TS Notes}

\subsubsection{Explicit Time Stepping}

Explicit time stepping with the PETSc TS requires
$F(t,s,\dot{s}) = \dot{s}$.
\begin{itemize}
\item We do not specify the functions $\vec{f}_0(t,s,\dot{s})$ and
  $\tensor{f}_1(t,s,\dot{s})$ because the PETSc TS will assume
  $F(t,s,\dot{s}) = \dot{s}$ if no LHS (or I) function is given.
\item The PETSc TS will verify that the LHS (or I) function is null.
\item We also do not specify $J_F$ or $J_G$.
\item This leaves us with only needing to specify $\vec{g}_0(t,s)$
  and $\tensor{g}_1(t,s)$.
\end{itemize}

For explicit time stepping with the PETSc TS, we need
$F(t,s,\dot{s}) = \dot{s}$. Using a finite-element formulation for
elastodynamics, $F(t,s,\dot{s})$ generally involves integrals of the
inertia over the domain. It is tempting to simply move these terms to
the RHS, but that introduces inertial terms into the boundary
conditions, which makes them less intuitive. Instead, we transform our
equation into the form $\dot{s} = G^*(t,s)$ where
$G^*(t,s) = M^{-1} G(t,s)$. We take $M$ to be a lumped (diagonal)
matrix, so that $M^{-1}$ is trivial to compute. In computing the RHS
function, $G^*(t,s)$, we compute $G(t,s)$, then compute $M$ and
$M^{-1}$, and then $M^{-1}G(t,s)$. For the elasticity equation with
inertial terms, $M$ contains the mass matrix.

\subsubsection{Implicit Time Stepping}

The LHS (or I) function is associated with implicit time-stepping.
When using implicit time-stepping, we place all of the terms on the
LHS. Even though placing all of the terms on the LHS sometimes
requires different pointwise functions for implicit and explicit time
stepping, it minimizes the number of pointwise functions needed for
implicit time stepping.  If no RHS function is given, then the PETSc
TS assumes $G(t,s) = 0$, so we only need to specify $F(t,s,\dot{s})$
and $J_f$.

\subsubsection{Implicit-Explicit Time Stepping}

For implicit-explicit time stepping algorithms, the equations
integrated with explicit time stepping have $\dot{s}$ as the LHS
function, and the equations integrated with implicit time stepping
have 0 as the RHS function.


\section{Specific Object Recognition}

A specific object = an instance of an object class e.g. “my car” instead of “a car”

Must overcome:
\begin{itemize}
	\item Illumination
	\item Object pose
	\item Clutter
	\item Occlusions
	\item Viewpoint
\end{itemize}

For class recognition also intra-class variation must be detected.

\subsection{Model based}
comparing image features with features of objects in a database, trying to figure out type + pose

this is SLOW and especially the need to get both object type and pose
right to formulate a correct hypothesis is problematic

\subsubsection{Invariant-based recognition of planar shapes}
The crucial advantage of invariants is that they decouple object type and pose issues

ratios of areas
are affine invariant and the following invariants are based on this

\includegraphics[width=\columnwidth]{pictures/affine}

\subsection{Image based}
PCA represents data in a lower-dimensional space keeping most of the variance
It was seen to be powerful for similar patterns like faces, that exhibit a lot of redundancy

\subsubsection{Appearance manifold approach}
Training:\\
for every object : - sample the set of viewing conditions (mainly viewpoints in this ex.)
- use these images as feature vectors (after manual bounding-box fitting around the object, rescaling, brightness normalization)
over all objects: - apply a PCA over all the images of all objects (directly on the images)
- keep the dominant PCs (10-20 enough already)
- sequence of views for 1 object represent a manifold in the space of projections (fit splines to manifolds + resample if desired)

Recognition stage (aka `Testing’)\\

Represent the incoming image as a point in the same PC space
Type: what is the nearest manifold to the point ?
Pose: what is the closest point on that closest manifold ?

\subsection{Model based vs appearance based}
Model vs Image\\

+Compact model vs -Large models
+Can deal with clutter vs -Cannot deal with clutter
-Slow analysis-by-synthesis vs +Efficient
-Models difficult to produce vs +Models easy to produce
-For limited object classes vs +For wide classes of objects

\subsection{Hybrid techniques}
\subsubsection{Euclidean invariant feature}

Training
\begin{enumerate}
	\item look for corners (with the Harris corner detector)
	\item  take circular regions around these points, of multiple radii (cope a bit with scale changes)
	\item calculate from the intensities in the circular regions . invariants under planar rotation -> feature vectors
	\item do this from different viewpoints, where the invariance cuts down on the number of views needed (here no in-plane rotations necessary)
	\item put for every object and for each of its viewpoints the . list of corner positions and their invariant feature . vectors (descriptors) in a database
\end{enumerate}

Testing
\begin{enumerate}
	\item extract corners and their invariant descriptors from the incoming image
	\item compare these invariants with those stored in the database -> find matches
	\item look for consistent placement of candidate matching corner points (e.g. using epipolar geometry)
	\item decide which object based on the number of remaining matches (i.e. consistently placed matches) (the best matching image yields the object type+appr.pose)
\end{enumerate}

\subsubsection{Recognition using local affine and photometric invariant features}
Invariant features = features that are preserved under a specific group of transformations\\

hyprid approach that aims to deal with large variations in
\begin{itemize}
	\item Viewpoint
	\item Illumination
	\item Background
	\item Occlusions
\end{itemize}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{fullpage}
\usepackage{titlesec}
\setlength\parindent{0pt}
\newcommand{\ifm}[1]{\text{if $#1$}}
\newcommand{\form}[1]{\text{for $#1$}}
\newcommand\HN{\mathit{HN}}
\newcommand\HNU{\mathit{HNU}}

\titleformat*{\section}{\normalsize\bfseries}
\begin{document}
\title{ High-order matching and head normalization }

\author{Faucheux Sébastien}
\maketitle
\section{Grammar}
$X_i$ is an unknown meta-variable of arity $i$.\\
$C_n$ is an arbitrary constructor with a known arity $n$.\\
$c$ is a constant (can be free variables), $x$ should be bound by an enclosing lambda.\\
\begin{align*}
M &::= x \mid c \mid \lambda x.M \mid M\ N \mid X_n[M_1, \ldots, M_n] \mid C_n(M_1,\dots, M_n)\\
\mathit{Ctx}_n &::= \pi_i (1 \leq i \leq n) \mid c \mid \lambda x.X_n \mid X_n\ Y_n \mid C_n(X_n,\dots, Y_n)\\
S &::= \cdot \mid [X_n \rightarrow \mathit{Ctx}_n]S
F &::= \cdot \mid F S
\end{align*}
\section{Head normalization}
This function takes a term and a list of solutions and return the head-normalized term
\begin{align*}
\HN(S_0, M) &= \HN'(S_0, M)\\
\HN'(\cdot, M) &= M\\
\HN'([X_n \rightarrow \pi_i]S, X_n[M_1, \ldots M_n]) &= \HN'(S_0, M_i)\\
\HN'([X_n \rightarrow c]S, X_n[M_1,\ldots ,M_n]) &= c\\
\HN'([X_n \rightarrow \lambda x.Yn]S, X_n[M_1,\ldots ,M_n]) &= \lambda x.Yn[x, M_1,\ldots ,M_n]\\
\HN'([X_n \rightarrow Y_n\ Z_n]S, X_n[M_1,\ldots ,M_n]) &= (Y_n[M_1,\ldots ,M_n]) (Z_n[M_1,\ldots ,M_n])\\
\HN'([X_n \rightarrow C_n(Y_n, \dots, Z_n)]S, X_n[M_1,\ldots ,M_n]) &= C_n(Y_n[M_1,\ldots ,M_n],\dots,Z_n[M_1,\ldots ,M_n])\\
\HN'([X_n \rightarrow \mathit{Ctx}_n]S, Y_n[M_1,\ldots ,M_n]) &= \HN'(S,Yn[M_1,\ldots ,M_n]) &\ifm{X_n \neq Y_n}\\
    \HN'(S, M) &= M &\text{Otherwise}
\end{align*}

\section{Context}
This function build the context associated to a term. Since substitutions are capture-avoiding, the context of a bound variable has no sense.
\begin{align*}
  Ctx(x) &= undef\\
  Ctx(c) &= c\\
  Ctx(\lambda x.M) &= \lambda x.X_n &(\text{for fresh $X_n$})\\
  Ctx(M\ N) &= X_n\ Y_n &(\text{for fresh $X_n\ Y_n$})\\
  Ctx(C_n(M_1, \dots, M_n)) &= C_n(X_n, \dots, Y_n) &(\text{for fresh $X_n, \dots, Y_n$})
\end{align*}

\section{Matching}
\begin{align*}
    \HNU(M_1, M_2, F) &= U(\HN(M_1, S), M_2, S)\\\\
  U(x, x, S) &= \{S\}\\
  U(c, c, S) &= \{S\}\\
  U(\lambda x.M_1, \lambda x.M_2, S) &= \HNU(M_1, M_2, S)\\
  U(M_1\ N_1, M_2\ N_2, S) &=
      \bigcup_{S’}{\HNU(N_1, N_2, S’)}\ \form{S' \in \HNU(M_1, M_2, S)}\\
    U(C_n(M_1, \dots, M_n), C_n(N_1, \dots, N_n), S) &= S_n\ \span{\text{where}\
      S_i = \bigcup_{S' \in S_{i-1}}{\HNU(M_i, N_i, S')}\ \text{and}\ S_0 = \{S\}}\\
  U(X_n[M_1,\ldots ,M_n], M, S) &=
     \bigcup_{S_i}\{\HNU(X_n[M_1,\ldots ,M_n],M,S_i) \mid 0 \leq i \leq n\}
     \shortintertext{when $M$ is not of the form $Yn[\ldots]$ and where}
     S_0 &= [X_n \rightarrow Ctx(M)]S &(imitation)\\
     S_i &= [X_n \rightarrow \pi_i]S\ (\form{i > 0)} &\text{(projection)}\\\\
  U(M, N, S) &= \{\} &\text{(no solution)}\\\\\\
 % (* possible optimization *)
 % U(X[], M, S) = {[X0 \rightarrow M]S} (\ifm{M is closed}})
\end{align*}

\end{document}


\section{Temporal-Difference Learning}
We first focus on the prediction problem, that is, finding $v\_pi$ given a $\pi$. The control problem, finding $\pi_*$, is approached using the GPI framework.

\subsection{TD Prediction}

\subsubsection*{Connection between TD, MC \& DP}
Monte-Carlo methods wait until the end of an episode to update the values. A simple MC update suitable for non-stationary environments is
\begin{equation}
    V(S_t) \leftarrow V(S_t) + \alpha [G_t - V(S_t)]
\end{equation}
we will call this \emph{constant-$\alpha$ MC}. Temporal difference learning (TD) increments the values at each timestep. The following is the TD(0) (or one-step TD) update which is made at $t+1$ (we will see TD($\lambda$) in Chapter 12)
\begin{equation}
    V(S_t) \leftarrow V(S_t) + \alpha [R_{t+1} + \gamma V(S_{t+1}) - V(S_t)].
\end{equation}
The key difference is that MC uses $G_t$ as the target whereas TD(0) uses $R_{t+1} + \gamma V(S_{t+1})$. TD uses an estimate in forming the target, hence is known as a \emph{bootstrapping method}. Below is TD(0) in procedural form. \\

\includegraphics[width=\textwidth]{\NotesImages/TD0_prediction.png} \\

The core of the similarity between MC and TD is down to the following relationship
\begin{align}
    v_\pi(s) &\doteq \Epi{}[G_t|S_t = s]\\
             &= \Epi{}[R_{t+1} + \gamma G_{t+1}|S_t = s]\\
             &= \Epi{}[R_{t+1} + \gamma V(S_{t+1})|S_t = s]
\end{align}

\begin{itemize}
    \item MC uses an estimate of the first line, since it uses sample returns to approximate the expectation
    \item DP uses an estimate of the final line, because it approximates $v_\pi$ by $V$
    \item TD does both, it samples the returns like MC and also uses the current value estimates in the target
\end{itemize}

\subsubsection*{TD Error}
We can think of the TD(0) update as an error, measuring the difference between the estimated value for $S_t$ and the better estimate of $R_{t+1} + \gamma V(S_{t+1})$. We define the \emph{TD error}
\begin{equation}
    \delta_t \doteq R_{t+1} + \gamma V(S_{t+1}) - V(S_t),
\end{equation}
now if the array $V$ does not change within the episode we can show (by simple recursion) that the MC error can be written
\begin{equation}
    G_t - V(S_t) = \sum_{k=t}^{T-1} \gamma_{k-t}\delta_k.
\end{equation}

\subsection{Advantages of TD Prediction Methods}
\begin{itemize}
    \item TD methods do not require a model of the environment
    \item TD methods are implements online, which can speed convergence vs. MC methods which must wait until the end of (potentially very long) episodes before learning. TD methods can be applied to continuing tasks for the same reason
    \item TD methods learn from all actions, whereas MC methods required that the tails of the episodes be greedy
    \item For any fixed policy $\pi$, TD(0) has been proved to converge to $v_\pi$, in the mean with probability 1 if the step-size parameter decreases according to the usual stochastic approximation conditions
    \item It is an open question as to whether TD methods converge faster than constant-$\alpha$ MC methods in general, though this seems to be the case in practice
\end{itemize}

\subsection{Optimality of TD(0)}
Given a finite number of training steps or episodes, a common method for estimating $V$ is to present the experience repeatedly until $V$ converges. We call the following \emph{batch updating}: given finite experience following a policy and an approximate value function $V$, calculate the increments for each $t$ that is non-terminal and change $V$ once by the sum of all the increments. Repeat until $V$ converges.\\

Under batch updating, we can make some comments on the strengths of TD(0) relative to MC. In an online setting we can do no better than to guess that online TD is faster than constant-$\alpha$ MC because it is similar towards the batch updating solution.

\begin{itemize}
    \item Under batch updating, MC methods always find estimates that minimize the mean-squared error on the training set.
    \item Under batch updating, TD methods always finds the estimate that would be exactly correct for the maximum-likelihood model of the Markov process. The MLE model is the one in which the estimates for the transition probabilities are the fraction of observed occurrences of each transition.
    \item We call the value function calculated from the MLE model the \emph{certainty-equivalence estimate} because it is equivalent to assuming that the estimate of the underlying process is exact. In general, batch TD(0) converges to the certainty equivalence estimate.
\end{itemize}

\subsection{Sarsa: On-policy TD Control}
We now use TD methods to attack the control problem.  The \emph{Sara} update is as follows
\begin{equation}
    Q(S_t, A_t) \leftarrow Q(S_t, A_t) + \alpha[R_{t+1} + \gamma Q(S_{t+1}, A_{t+1}) - Q(S_t, A_t)].
\end{equation}
This update is done after every transition from a non-terminal state $S_t$. If $S_{t+1}$ is terminal then we set $Q(S_{t+1}, A_{t+1}) = 0$. Note that this rule uses the following elements $(S_t, A_t, R_{t+1}, S_{t+1}, A_{t+1})$ which gives rise to the name Sarsa. The theoroms regarding convergene of the state-value versions of this update apply here too. \\

We write an on-policy control algorithm using Sarsa in the box below, at each time step we move the policy towards the greedy policy with respect to the current action-value function. Sarsa converges with probability 1 to an optimal policy and action-value function as long as all state action pairs are visited infinitely often and the policy also converges to the greedy policy in the limit (e.g. maybe $\pi$ is $\varepsilon$-greedy with $\varepsilon=\frac1t$). \\

\includegraphics[width=\textwidth]{\NotesImages/sarsa_on_policy_control.png} \\

\subsection{Q-learning: Off-policy TD Control}
The \emph{Q-learning} update is
\begin{equation}
    Q(S_t, A_t) \leftarrow Q(S_t, A_t) + \alpha [R_{t+1} + \gamma \max_a Q(S_{t+1}, a) - Q(S_t, A_t)].
\end{equation}
The learning function $Q$ directly approximates $q_*$. All that is required for convergence is that all pairs continue to be updated. An algorithm for Q-learning is given in the box below. \\

\includegraphics[width=\textwidth]{\NotesImages/q_learning.png}\\

\subsection{Expected Sarsa}
The update rule for \emph{Expected Sarsa} is
\begin{align}
        Q(S_t, A_t) & \leftarrow Q(S_t, A_t) + \alpha [R_{t+1} + \gamma \E{}[Q(S_{t+1}, A_{t+1})|S_{t+1}] - Q(S_t, A_t)] \\
                    & \leftarrow Q(S_t, A_t) + \alpha [R_{t+1} + \gamma \sum_a \pi(a|S_{t+1}) Q(S_{t+1}, a) - Q(S_t, A_t)].
\end{align}
This algorithm moves deterministically in the same direction as Sarsa moves in \emph{expectation}, hence the name. It is more computationally complex than Sarsa, but eliminates the variance due to random selection of $A_{t+1}$. Given the same amount of experiences, it generally performs slightly better than Sarsa.

\subsection{Maximisation Bias and Double Learning}
All the control algorithms we have discussed so far involve some sort of maximisation in the construction of their target policies. This introduces a positive bias to the value estimates because they form uncertain estimates of the true values. This is known as the \emph{maximisation bias}. It is essentially down to the fact the the expectation of the max of a sample is $\geq$ the max of the expected values of the samples.\\

To solve this we introduce the idea of \emph{double learning}, in which we learn two independent sets of value estimates $Q_1$ and $Q_2$, then at each time step we choose one of them at random and update it using the other as a target. This produces two unbiased estimates of the action-values (which could be averaged). Below we show an algorithm for \emph{double Q-learning}. \\

\includegraphics[width=\textwidth]{\NotesImages/double_q_learning.png} \\

\subsection{Games,  Afterstates, and other Special Cases}
In this book we try to present a uniform approach to solving tasks, but sometimes more specific methods can do much better. \\

We introduce the idea of \emph{afterstates}. Afterstates are relevant when the agent can deterministically change some aspect of the environment. In these cases, we are better to value the resulting state of the environment, after the agent has taken action and before any stochasticity, as this can reduce computation and speed convergence.\\

Take chess as an example. One should choose as states the board positions \emph{after} the agent has taken a move, rather than before. This is because there are multiple states at $t$ than can lead to the board position that the opponent sees at $t+1$ (assuming we move second) via deterministic actions of the agent.


    \filetitle{lrtest}{Likelihood ratio test for VAR models}{VAR/lrtest}

	\paragraph{Syntax}\label{syntax}

\begin{verbatim}
[Stat,Crit] = lrtest(V1,V2,Level)
\end{verbatim}

\paragraph{Input arguments}\label{input-arguments}

\begin{itemize}
\item
  \texttt{V1} {[} VAR {]} - Unrestricted VAR model.
\item
  \texttt{V2} {[} VAR {]} - Restricted VAR model.
\item
  \texttt{Level} {[} numeric {]} - Significance level; if not specified,
  5 percent significance is used, \texttt{Level=0.05}.
\end{itemize}

\paragraph{Output arguments}\label{output-arguments}

\begin{itemize}
\item
  \texttt{Stat} {[} numeric {]} - LR test stastic.
\item
  \texttt{Crit} {[} numeric {]} - LR test critical value based on
  chi-square distribution.
\end{itemize}

\paragraph{Description}\label{description}

\paragraph{Example}\label{example}


\chapter{Bonus: A Bit on Artin Reciprocity}
In this chapter, I'm going to state some big theorems of
global class field theory and use them to deduce the
Kronecker-Weber plus Hilbert class fields.
No proofs, but hopefully still appreciable.
For experts: this is global class field theory, without ideles.

Here's the executive summary: let $K$ be a number field.
Then all abelian extensions $L/K$ can be understood
using solely information intrinsic to $K$:
namely, the ray class groups (generalizing ideal class groups).

\section{Infinite primes}
\prototype{$\QQ(\sqrt{-5})$ has a complex infinite prime,
$\QQ(\sqrt5)$ has two real infinite ones.}
Let $K$ be a number field of degree $n$ and signature $(r,s)$.
We know what a prime ideal of $\OO_K$ is,
but we now allow for the so-called infinite primes,
which I'll describe using the embeddings.\footnote{This is
	not really the right definition; the ``correct'' way to think of
	primes, finite or infinite, is in terms of valuations.
	But it'll be sufficient for me to state the theorems I want.}
Recall there are $n$ embeddings $\sigma : K \to \CC$, which consist of
\begin{itemize}
	\ii $r$ real embeddings where $\img\sigma \subseteq \RR$, and
	\ii $s$ pairs of conjugate complex embeddings.
\end{itemize}
Hence $r+2s = n$.
The first class of embeddings form the \vocab{real infinite primes},
while the \vocab{complex infinite primes} are the second type.
We say $K$ is \vocab{totally real} (resp \vocab{totally complex})
if all its infinite primes are real (resp complex).
\begin{example}
	[Examples of infinite primes]
	\listhack
	\begin{itemize}
		\ii $\QQ$ has a single real infinite prime.
		We often write it as $\infty$.
		\ii $\QQ(\sqrt{-5})$ has a single complex infinite prime,
		and no real infinite primes. Hence totally complex.
		\ii $\QQ(\sqrt{5})$ has two real infinite primes,
		and no complex infinite primes. Hence totally real.
	\end{itemize}
\end{example}

\section{Modular arithmetic with infinite primes}
A \vocab{modulus} is a formal product
\[ \km = \prod_{\kp} \kp^{\nu(\kp)} \]
where the product runs over all primes, finite and infinite.
(Here $\nu(\kp)$ is a nonnegative integer,
of which only finitely many are nonzero.)
We also require that
\begin{itemize}
	\ii $\nu(\kp) = 0$ for any complex infinite prime $\kp$, and
	\ii $\nu(\kp) \le 1$ for any real infinite prime $\kp$.
\end{itemize}
Obviously, every $\km$ can be written as $\km = \km_0\km_\infty$
by separating the finite from the (real) infinite primes.

We say $a \equiv b \pmod{\km}$ if
\begin{itemize}
	\ii If $\kp$ is a finite prime, then $a \equiv b \pmod{\kp^{\nu(\kp)}}$
	means exactly what you think it should mean:
	$a-b \in \kp^{\nu(\kp)}$.
	\ii If $\kp$ is a \emph{real} infinite prime $\sigma : K \to \RR$, then
	$a \equiv b \pmod{\kp}$ means that $\sigma(a/b) > 0$.
\end{itemize}
Of course, $a \equiv b \pmod{\km}$ means $a \equiv b$
modulo each prime power in $\km$.
With this, we can define a generalization of the class group:
\begin{definition}
	Let $\km$ be a modulus of a number field $K$.
	\begin{itemize}
		\ii Let $I_K(\km)$ denote the set of all fractional ideals of $K$
		which are relatively prime to $\km$, which is an abelian group.
		\ii Let $P_K(\km)$ be the subgroup of $I_K(\km)$ generated by
		\[
			\left\{
				\alpha \OO_K
				\mid
				\alpha \in K^\times \text{ and }
				\alpha \equiv 1 \pmod{\km}
			\right\}.
		\]
		This is sometimes called a ``ray'' of principal ideals.
	\end{itemize}
	Finally define the \vocab{ray class group} of $\km$
	to be $C_K(\km) = I_K(\km) / P_K(\km)$.
\end{definition}
This group is known to always be finite.
Note the usual class group is $C_K(1)$.

One last definition that we'll use right after Artin reciprocity:
\begin{definition}
	A \vocab{congruence subgroup} of $\km$ is a subgroup $H$ with
	\[ P_K(\km) \subseteq H \subseteq I_K(\km). \]
\end{definition}
Thus $C_K(\km)$ is a group which contains a lattice of various
quotients $I_K(\km) / H$, where $H$ is a congruence subgroup.

This definition takes a while to get used to, so here are examples.
\begin{example}
	[Ray class groups in $\QQ$, finite modulus]
	Consider $K = \QQ$ with infinite prime $\infty$. Then
	\begin{itemize}
		\ii If we take $\km = 1$ then $I_\QQ(1)$ is all fractional ideals,
		and $P_\QQ(1)$ is all principal fractional ideals.
		Their quotient is the usual class group of $\QQ$, which is trivial.

		\ii Now take $\km = 8$.
		Thus $I_\QQ(8) \cong \left\{ \frac ab\ZZ \mid
			a/b \equiv 1,3,5,7 \pmod 8 \right\}$.
		Moreover
		\[ P_\QQ(8) \cong \left\{ \frac ab\ZZ \mid
			a/b \equiv 1 \pmod 8 \right\}. \]
		You might at first glance think that
		the quotient is thus $(\ZZ/8\ZZ)^\times$.
		But the issue is that we are dealing with \emph{ideals}:
		specifically, we have
		\[ 7\ZZ = -7\ZZ \in P_\QQ(8) \]
		because $-7 \equiv 1 \pmod 8$.
		So \emph{actually}, we get
		\[
			C_\QQ(8)
			\cong \left\{ 1,3,5,7 \text{ mod } 8 \right\}
			/ \left\{ 1,7 \text{ mod } 8 \right\}
			\cong (\ZZ/4\ZZ)^\times.
		\]
	\end{itemize}
	More generally,
	\[ C_\QQ(m) = (\ZZ/m\ZZ)^\times / \{\pm1\}. \]
\end{example}
\begin{example}
	[Ray class groups in $\QQ$, infinite moduli]
	Consider $K = \QQ$ with infinite prime $\infty$ again.
	\begin{itemize}
		\ii Now take $\km = \infty$.
		As before $I_\QQ(\infty) = \QQ^\times$.
		Now, by definition we have
		\[ P_\QQ(\infty) = \left\{ \frac ab \ZZ \mid a/b > 0 \right\}. \]
		At first glance you might think this was $\QQ_{>0}$,
		but the same behavior with ideals shows in fact $P_\QQ(\infty) = \QQ^\times$.
		So in this case, $P_\QQ(\infty)$ still has all principal fractional ideals.
		Therefore, $C_\QQ(\infty)$ is still trivial.

		\ii Finally, let $\km = 8\infty$.
		As before $I_\QQ(8\infty) \cong \left\{ \frac ab\ZZ \mid
			a/b \equiv 1,3,5,7 \pmod 8 \right\}$.
		Now in this case:
		\[ P_\QQ(8\infty) \cong \left\{ \frac ab\ZZ \mid
			a/b \equiv 1 \pmod 8 \text{ and } a/b > 0 \right\}.  \]
		This time, we really do have $-7\ZZ \notin P_\QQ(8\infty)$:
		we have $7 \not\equiv 1 \pmod 8$ and also $-8 < 0$.
		So neither of the generators of $7\ZZ$ are in $P_\QQ(8\infty)$.
		Thus we finally obtain
		\[
			C_\QQ(8\infty)
			\cong \left\{ 1,3,5,7 \text{ mod } 8 \right\}
			/ \left\{ 1 \text{ mod } 8 \right\}
			\cong (\ZZ/8\ZZ)^\times
		\]
		with the bijection $C_\QQ(8\infty) \to (\ZZ/8\ZZ)^\times$
		given by $a\ZZ \mapsto |a| \pmod 8$.
	\end{itemize}
	More generally,
	\[ C_\QQ(m\infty) = (\ZZ/m\ZZ)^\times. \]
\end{example}

\section{Infinite primes in extensions}
I want to emphasize that everything above is
\emph{intrinsic} to a particular number field $K$.
After this point we are going to consider extensions $L/K$
but it is important to keep in mind the distinction that
the concept of modulus and ray class group are objects
defined solely from $K$ rather than the above $L$.

Now take a \emph{Galois} extension $L/K$ of degree $m$.
We already know prime ideals $\kp$ of $K$ break into
a product of prime ideals $\kP$ of $K$ in $L$ in a nice way,
so we want to do the same thing with infinite primes.
This is straightforward: each of the $n$ infinite primes
$\sigma : K \to \CC$ lifts to $m$ infinite primes $\tau : L \to \CC$,
by which I mean the diagram
\begin{center}
\begin{tikzcd}
	L \ar[r, "\tau", dashed] & \CC \\
	K \ar[u, hook]  \ar[ur, "\sigma", swap]
\end{tikzcd}
\end{center}
commutes.
Hence like before, each infinite prime $\sigma$ of $K$
has $m$ infinite primes $\tau$ of $L$ which lie above it.

For a real prime $\sigma$ of $K$, any of the resulting $\tau$ above it
are complex, we say that the prime $\sigma$ \vocab{ramifies}
in the extension $L/K$. Otherwise it is \vocab{unramified} in $L/K$.
An infinite prime of $K$ is always unramified in $L/K$.
In this way, we can talk about an unramified Galois extension $L/K$:
it is one where all primes (finite or infinite) are unramified.

\begin{example}
	[Ramification of $\infty$]
	Let $\infty$ be the real infinite prime of $\QQ$.
	\begin{itemize}
		\ii $\infty$ is ramified in $\QQ(\sqrt{-5})/\QQ$.
		\ii $\infty$ is unramified in $\QQ(\sqrt{5})/\QQ$.
	\end{itemize}
	Note also that if $K$ is totally complex
	then any extension $L/K$ is unramified.
\end{example}

\section{Frobenius element and Artin symbol}
Recall the key result:
\begin{theorem}
	[Frobenius element]
	Let $L/K$ be a \emph{Galois} extension.
	If $\kp$ is a prime unramified in $K$,
	and $\kP$ a prime above it in $L$.
	Then there is a unique element of $\Gal(L/K)$,
	denoted $\Frob_\kP$, obeying
	\[ \Frob_\kP(\alpha) \equiv \alpha^{N\kp} \pmod{\kP}
		\qquad \forall \alpha \in \OO_L. \]
\end{theorem}
\begin{example}
	[Example of Frobenius elements]
	Let $L = \QQ(i)$, $K = \QQ$.
	We have $\Gal(L/K) \cong \ZZ/2\ZZ$.

	If $p$ is an odd prime with $\kP$ above it,
	then $\Frob_\kP$ is the unique element such that
	\[ (a+bi)^p \equiv \Frob_\kP(a+bi) \pmod{\kP} \]
	in $\ZZ[i]$. In particular,
	\[ \Frob_\kP(i) = i^p =
		\begin{cases}
			i & p \equiv 1 \pmod 4 \\
			-i & p \equiv 3 \pmod 4.
		\end{cases}
	\]
	From this we see that $\Frob_\kP$ is the identity when $p \equiv 1 \pmod 4$
	and $\Frob_\kP$ is complex conjugation when $p \equiv 3 \pmod 4$.
\end{example}
\begin{example}
	[Cyclotomic Frobenius element]
	Generalizing previous example, let $L = \QQ(\zeta)$ and $K = \QQ$,
	with $\zeta$ an $m$th root of unity.
	It's well-known that $L/K$ is unramified outside $\infty$
	and prime factors of $m$.
	Moreover, the Galois group $\Gal(L/K)$ is $(\ZZ/m\ZZ)^\times$:
	the Galois group consists of elements of the form
	\[ \sigma_n : \zeta \mapsto \zeta^n \]
	and $\Gal(L/K) = \left\{ \sigma_n \mid n \in (\ZZ/m\ZZ)^\times \right\}$.

	Then it follows just like before that
	if $p \nmid n$ is prime and $\kP$ is above $p$
	\[ \Frob_\kP(x) = \sigma_p. \]
\end{example}

An important property of the Frobenius element is its order
is related to the decomposition of $\kp$ in the higher field $L$
in the nicest way possible:
\begin{lemma}
	[Order of the Frobenius element]
	The Frobenius element $\Frob_\kP \in \Gal(L/K)$
	of an extension $L/K$ has order equal to the
	inertial degree of $\kP$, that is,
	\[ \ord \Frob_\kP = f(\kP \mid \kp). \]
	In particular, $\Frob_\kP = \id$ if and only if $\kp$
	splits completely in $L/K$.
\end{lemma}
\begin{proof}
	We want to understand the order of the map $T : x \mapsto x^{N\kp}$ on
	the field $\OO_K / \kP$.
	But the latter is isomorphic to the splitting field
	of $X^{N\kP} - X$ in $\FF_p$, by Galois theory of finite fields.
	Hence the order is $\log_{N\kp} (N\kP) = f(\kP \mid \kp)$.
\end{proof}

\begin{exercise}
	Deduce from this that the rational primes which split completely
	in $\QQ(\zeta)$ are exactly those with $p \equiv 1 \pmod m$.
	Here $\zeta$ is an $m$th root of unity.
\end{exercise}

The Galois group acts transitively among the set of $\kP$ above a given $\kp$,
so that we have
\[ \Frob_{\sigma(\kP)} = \sigma \circ (\Frob_{\kp}) \circ \sigma\inv.  \]
Thus $\Frob_\kP$ is determined by its underlying $\kp$ up to conjugation.

In class field theory, we are interested in \vocab{abelian extensions},
i.e.\ those for which $\Gal(L/K)$ is Galois.
Here the theory becomes extra nice:
the conjugacy classes have size one.
\begin{definition}
	Assume $L/K$ is an \textbf{abelian} extension.
	Then for a given unramified prime $\kp$ in $K$,
	the element $\Frob_\kP$ doesn't depend on the choice of $\kP$.
	We denote the resulting $\Frob_\kP$ by the \vocab{Artin symbol},
	\[ \left( \frac{L/K}{\kp} \right). \]
\end{definition}
The definition of the Artin symbol is written deliberately to
look like the Legendre symbol.
To see why:
\begin{example}[Legendre symbol subsumed by Artin symbol]
	Suppose we want to understand
	$(2/p) \equiv 2^{\frac{p-1}{2}}$ where $p > 2$ is prime.
	Consider the element
	\[ \left( \frac{\QQ(\sqrt 2)/\QQ}{p\ZZ} \right)
		\in \Gal(\QQ(\sqrt 2) / \QQ). \]
	It is uniquely determined by where it sends $a$.
	But in fact we have
	\[
		\left( \frac{\QQ(\sqrt 2)/\QQ}{p\ZZ} \right) \left( \sqrt 2 \right)
		\equiv \left( \sqrt 2 \right)^{p}
		\equiv 2^{\frac{p-1}{2}} \cdot \sqrt 2
		\equiv \left( \frac 2p \right) \sqrt 2
		\pmod{\kP}
	\]
	where $\left( \frac 2p \right)$ is the usual Legendre symbol,
	and $\kP$ is above $p$ in $\QQ(\sqrt 2)$.
	Thus the Artin symbol generalizes the quadratic Legendre symbol.
\end{example}
\begin{example}[Cubic Legendre symbol subsumed by Artin symbol]
	Similarly, it also generalizes the cubic Legendre symbol.
	To see this, assume $\theta$ is primary in $K = \QQ(\sqrt{-3}) = \QQ(\omega)$
	(thus $\OO_K = \ZZ[\omega]$ is Eisenstein integers).
	Then for example
	\[
		\left( \frac{K(\cbrt 2)/K}{\theta \OO_K} \right) \left( \cbrt 2 \right)
		\equiv \left( \cbrt 2 \right)^{N(\theta)}
		\equiv 2^{\frac{N\theta-1}{3}} \cdot \sqrt 2
		\equiv \left( \frac{2}{\theta} \right)_3 \cbrt 2.
		\pmod{\kP}
	\]
	where $\kP$ is above $p$ in $K(\cbrt 2)$.
\end{example}

\section{Artin reciprocity}
Now, we further capitalize on the fact that $\Gal(L/K)$ is abelian.
For brevity, in what follows let $\Ram(L/K)$ denote the primes of $K$
(either finite or infinite) which ramify in $L$.

\begin{definition}
	Let $L/K$ be an abelian extension and let $\km$ be
	divisible by every prime in $\Ram(L/K)$.
	Then since $L/K$ is abelian we can extend the Artin symbol
	multiplicatively to a map
	\[
		\left( \frac{L/K}{\bullet} \right) :
		I_K(\km) \surjto \Gal(L/K).
	\]
	This is called the \vocab{Artin map},
	and it is surjective (for example by Chebotarev Density).
	Thus we denote its kernel by
	\[ H(L/K, \km) \subseteq I_K(\km). \]
\end{definition}
In particular we have
$\Gal(L/K) \cong I_K(\km) / H(L/K, \km)$.

We can now present the long-awaited Artin reciprocity theorem.
\begin{theorem}
	[Artin reciprocity]
	Let $L/K$ be an abelian extension.
	Then there is a modulus $\kf = \kf(L/K)$,
	divisible by exactly the primes of $\Ram(L/K)$, such that:
	for any modulus $\km$ divisible by all primes of $\Ram(L/K)$, we have
	\[
		P_K(\km) \subseteq H(L/K, \km) \subseteq I_K(\km)
		\quad\text{if and only if}\quad
		\kf \mid \km.
	\]
	We call $\kf$ the \vocab{conductor} of $L/K$.
\end{theorem}
So the conductor $\kf$ plays a similar role to the discriminant
(divisible by exactly the primes which ramify),
and when $\km$ is divisible by the conductor,
$H(L/K, \km)$ is a \emph{congruence subgroup}.

Here's the reason this is called a ``reciprocity'' theorem.
Recalling that $C_K(\kf) = I_K(\kf) / P_K(\kf)$,
the above theorem tells us we get a sequence of maps
\begin{center}
\begin{tikzcd}
	I_K(\kf) \ar[r, two heads] & C_K(\kf) \ar[rd, two heads]
		\ar[rr, "\left( \frac{L/K}{\bullet} \right)", two heads]
		&& \Gal(L/K) \\
	&& I_K(\kf) / H(L/K, \kf) \ar[ru, "\cong", swap] &
\end{tikzcd}
\end{center}
Consequently:
\begin{moral}
	For primes $\kp \in I_K(\kf)$,
	$\left( \frac{L/K}{\kp} \right)$ depends
	only on ``$\kp \pmod \kf$''.
\end{moral}

Let's see how this result relates to quadratic reciprocity.
\begin{example}
	[Artin reciprocity implies quadratic reciprocity]
	The big miracle of quadratic reciprocity states that:
	for a fixed (squarefree) $a$,
	the Legendre symbol $\left( \frac ap \right)$
	should only depend the residue of $p$ modulo something.
	Let's see why Artin reciprocity tells us this \emph{a priori}.

	Let $L = \QQ(\sqrt a)$, $K = \QQ$.
	Then we've already seen that the Artin symbol
	\[ \left( \frac{\QQ(\sqrt a)/\QQ}{\bullet} \right) \]
	is the correct generalization of the Legendre symbol.
	Thus, Artin reciprocity tells us that there is a conductor
	$\kf = \kf(\QQ(\sqrt a)/\QQ)$ such that
	$\left( \frac{\QQ(\sqrt a)/\QQ}{p} \right)$ depends only on
	the residue of $p$ modulo $\kf$, which is what we wanted.
\end{example}

Here is an example along the same lines.
\begin{example}
	[Cyclotomic field]
	Let $\zeta$ be a primitive $m$th root of unity.
	For primes $p$, we know that $\Frob_p \in \Gal(\QQ(\zeta)/\QQ)$
	is ``exactly'' $p \pmod m$.
	Let's translate this idea into the notation of Artin reciprocity.

	We are going to prove
	\[
		H(\QQ(\zeta) / \QQ,  m\infty)
		= P_\QQ(m\infty)
		= \left\{ \frac ab \ZZ \mid a/b \equiv 1 \pmod m \right\}.
	\]
	This is the generic example of achieving the lower bound in Artin reciprocity.
	It also implies that $\kf(\QQ(\zeta)/\QQ) \mid m\infty$.

	It's well-known $\QQ(\zeta)/\QQ$ is unramified outside finite primes dividing $m$,
	so that the Artin symbol is defined on $I_K(\km)$.
	Now the Artin map is given by
	\begin{center}
	\begin{tikzcd}
		I_\QQ(\km) \ar[r, "\left( \frac{\QQ(\zeta)/\QQ}{\bullet} \right)"]
			& \Gal(\QQ(\zeta)/\QQ) \ar[r, "\cong"] & (\ZZ/m\ZZ)^\times \\[-2em]
		p \ar[r, mapsto] & (x \mapsto x^p) \ar[r, mapsto] & p \pmod m.
	\end{tikzcd}
	\end{center}
	So we see that the kernel of this map is trivial,
	i.e.\ it is given by the identity of the Galois group,
	corresponding to $1 \pmod m$.
	On the other hand, we've also computed $P_\QQ(m\infty)$ already,
	so we have the desired equality.
\end{example}

In fact, we also have the following ``existence theorem'':
every congruence subgroup appears uniquely once we fix $\km$.
\begin{theorem}
	[Takagi existence theorem]
	Fix $K$ and let $\km$ be a modulus.
	Consider any congruence subgroup $H$, i.e.\
	\[ P_K(\km) \subseteq H \subseteq I_K(\km). \]
	Then $H = H(L/K, \km)$ for a \emph{unique} abelian extension $L/K$.
\end{theorem}

Finally, such subgroups reverse inclusion in the best way possible:
\begin{lemma}
	[Inclusion-reversing congruence subgroups]
	Fix a modulus $\km$.
	Let $L/K$ and $M/K$ be abelian extensions
	and suppose $\km$ is divisible by the conductors of $L/K$ and $M/K$.
	Then
	\[ L \subseteq M
		\quad\text{if and only if}\quad
		H(M/K, \km) \subseteq H(L/K, \km).  \]
\end{lemma}
Here by $L \subseteq M$ we mean that $L$ is isomorphic to some subfield of $M$.
\begin{proof}
	[Sketch of proof]
	Let us first prove the equivalence with $\km$ fixed.
	In one direction, assume $L \subseteq M$;
	one can check from the definitions that the diagram
	\begin{center}
	\begin{tikzcd}
		I_K(\km)
			\ar[r, "\left( \frac{M/K}\bullet \right)"]
			\ar[rd, "\left( \frac{L/K}\bullet \right)", swap]
			& \Gal(M/K) \ar[d, two heads] \\
		& \Gal(L/K)
	\end{tikzcd}
	\end{center}
	commutes, because it suffices to verify this for prime powers,
	which is just saying that Frobenius elements behave well
	with respect to restriction.
	Then the inclusion of kernels follows directly.
	The reverse direction is essentially the Takagi existence theorem.
\end{proof}
Note that we can always take $\km$ to be the product of conductors here.

\bigskip

To finish, here is a quote from Emil Artin on his reciprocity law:
\begin{quote}
	I will tell you a story about the Reciprocity Law.
	After my thesis, I had the idea to define $L$-series
	for non-abelian extensions. But for them to agree
	with the $L$-series for abelian extensions,
	a certain isomorphism had to be true.
	I could show it implied all the standard reciprocity laws.
	So I called it the General Reciprocity Law and tried to prove it but couldn't,
	even after many tries. Then I showed it to the other number theorists,
	but they all laughed at it, and I remember Hasse in particular
	telling me it couldn't possibly be true.

	Still, I kept at it, but nothing I tried worked.
	Not a week went by --- \emph{for three years!} ---
	that I did not try to prove the Reciprocity Law.
	It was discouraging, and meanwhile I turned to other things.
	Then one afternoon I had nothing special to do, so I said,
	`Well, I try to prove the Reciprocity Law again.'
	So I went out and sat down in the garden.  You see,
	from the very beginning I had the idea to use the cyclotomic fields,
	but they never worked, and now I suddenly saw that all this time
	I had been using them in the wrong way
	--- and in half an hour I had it.
\end{quote}

\section{\problemhead}
\begin{dproblem}
	[Kronecker-Weber theorem]
	Let $L$ be an abelian extension of $\QQ$.
	Then $L$ is contained in a cyclic extension $\QQ(\zeta)$
	where $\zeta$ is an $m$th root of unity (for some $m$).
	\begin{hint}
		Pick $m$ so that $\kf(L/\QQ) \mid m\infty$.
	\end{hint}
	\begin{sol}
		Suppose $\kf(L/\QQ) \mid m\infty$ for some $m$.
		Then by the example from earlier we have the chain
		\[ P_{\QQ}(m\infty) = H(\QQ(\zeta)/\QQ, m\infty)
			\subseteq H(L/\QQ, m) \subseteq I_\QQ(m\infty). \]
		So by inclusion reversal we're done.
	\end{sol}
\end{dproblem}

\begin{dproblem}
	[Hilbert class field]
	Let $K$ be any number field.
	Then there exists a unique abelian extension $E/K$
	which is unramified at all primes (finite or infinite)
	and such that
	\begin{itemize}
		\ii $E/K$ is the maximal such extension by inclusion.
		\ii $\Gal(E/K)$ is isomorphic to the class group of $E$.
		\ii A prime $\kp$ of $K$ splits completely in $E$
		if and only if it is a principal ideal of $\OO_K$.
	\end{itemize}
	We call $E$ the \vocab{Hilbert class field} of $K$.
	\begin{hint}
		Apply the Takagi existence theorem with $\km = 1$.
	\end{hint}
	\begin{sol}
		Apply the Takagi existence theorem with $\km = 1$
		to obtain an unramified extension $E/K$ such that
		$H(E/K, 1) = P_K(1)$.
		We claim this works:
		\begin{itemize}
			\ii To see it is maximal by inclusion, note that any other extension $M/K$
			with this property has conductor $1$ (no primes divide the conductor),
			and then we have $P_K(1) = H(E/K, 1) \subseteq H(M/K, 1) \subseteq I_K(1)$,
			so inclusion reversal gives $M \subseteq E$.
			\ii We have $\Gal(L/K) \cong I_K(1) / P_K(1) = C_K(1)$ the class group.
			\ii The isomorphism in the previous part is given by the Artin symbol.
			So $\kp$ splits completely if and only if $\left( \frac{L/K}{\kp} \right) = \id$
			if and only if $\kp$ is principal (trivial in $C_K(1)$).
		\end{itemize}
		This completes the proof.
	\end{sol}
\end{dproblem}


\subsection{Example: Build-up and wash-off of contaminant from an urban catchment}

In this example we will build a model to simulate the build-up and wash-off of a hypothetical pollutant. For the simulation A 30m$\times$30m square shaped catchment descritized into a 3$\times$3 grid is considered. Table \ref{table:Build-up} shows the parameters of the model. The model can for example represent a squared shaped parking lot. For the sake of simplicity, no infiltration or evaporation over the catchment has been considered.

\begin{table}
\caption{Parameters of build-up/wash-off example}
\begin{tabular}{l l}\label{table:Build-up}
parameter & value \\
\hline
Area of the catchment & $30m\times 30m$ \\
Build-up rate constant, $k_{bld}$ & $2mg/m^2 day$ \\
Saturation build-up concentration, $C_{bsat}$ & $10mg/m2$ \\
Slope of the catchment & 0.01 in both directions \\
\end{tabular}\\
\end{table}

Steps to create the build-up and wash-off example:
\begin{itemize}
   \item \textbf{Add a constituent: } Right-click on on \textbf{Project Explorer}$\rightarrow$\textbf{Water quality}$\rightarrow$\textbf{Constituents} and click on \textbf{Add constituent}. Change the name of the constituent to \textbf{Pb}.
    \item \textbf{Creating the build-up object: } Right-click on \textbf{Project Explorer}$\rightarrow$\textbf{Water quality}$\rightarrow$\textbf{Build-ups} and click on \textbf{Add build-up}.
    Set the following properties for the block that was just added: \\
    - \textbf{Accumulation rate: } 2\\
    - \textbf{Model: } Exponential \\
    - \textbf{Constituent: } Pb \\
    - \textbf{Sorbed/attached: } Yes \\
    - \textbf{Saturation: } 10 \\

    \textbf{Note: } Setting \textbf{Sorbed/attached} to yes indicates that the built-up Pb will be accumulated as sorbed to the solid phase (in this case pavement surface). So  solid-water exchange parameters for Pb needs to be adjusted to let the sorbed Pb to be released into the overland flow during rain events. \\
    \item \textbf{Add a catchment block: } From the top tool bar click on the \textbf{Add catchment} bottom \includegraphics[width=0.5cm]{Icons/catchment_icon.png}. Set the following properties for the catchment block: \\
    - \textbf{Area: } 100$m^2$ \\
    - \textbf{Manning's roughness coefficient: } 0.011$s  m^{-1/3}$. \\
    - \textbf{Width: } 10m \\
    - \textbf{Length: } 10m \\
    - \textbf{Build-up: } \textit{Build-up} \\
    \textbf{Note: } The \textbf{width} and \textbf{length} properties of a \textbf{Catchment} block will be used to assign length and width to the connectors that will be generated as a result of creating an array.
   \item \textbf{Create an array of catchments: } Right-click on the catchment block and click on \textbf{Make grid of blocks}. Change \textbf{number of rows} and \textbf{number of columns} to the value of 3. Also enter a value of -0.3 into \textbf{Total bottom elevation change in x direction} and \textbf{Total bottom elevation change in y direction}. Change the values of \textbf{Horizontal distance between cells in x direction} and \textbf{Horizontal distance between cells in x direction} to 10m.
   \item \textbf{Precipitation: } We will use a previously prepared precipitation input file (precipitation.txt) saved in the example folder. Make sure to download the precipitation file and save it somewhere on your hard-drive.
   - From \textbf{Project Explorer}$\rightarrow$\textbf{Settings}$\rightarrow$\textbf{Climate Setting} select "precipitation.txt" as the \textbf{Precipitation time-series}.
   - Right-click on the box where the name of the precipitation input file is written and click on \textbf{flow} from the drop-down menu. A graph similar to what is shown in Fig \ref{fig:33} will pop-up.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=8cm]{Images/Figure33.png} \\
\caption{Precipitation time series for the build-up example}\label{fig:33}
\end{center}
\end{figure}
   \item \textbf{Duration of simulation} Our duration of simulation will cover a portion of the period for which precipitation data is available. From \textbf{Project Setting}$\rightarrow$\textbf{Project Setting} set the start date of the project to \textbf{Sep 01 2012} and the end date to \textbf{Oct 01 2012}.
   \item \textbf{Adding a Receiving water pond: } In order to impose the down stream boundary condition correctly and also to keep track of the runoff volume and pollutant load leaving the catchment a pond will be added to the model and will be connected to the lowest catchment (lower-right) block. Add a pond \includegraphics[width=0.5cm]{Icons/pond_icon.png} and move it to the lower left side of the screen. Then connect it to the lower left catchment block (Figure \ref{fig:34}).\\

   Assign the following properties to the pond block: -\textbf{Area: } \textit{1000$m^2$}, -\textbf{Bottom Elevation: }  \textit{-1m}, -\textbf{Precipitation: } \textit{No}. \\

   The reason for the last setting is to prevent precipitation to enter the pond in order to be able to use the pond's storage to keep track of runoff volume:

   Assign the following properties to the connector connecting \textbf{Catchment (9)} to \textbf{Pond (1)}: -\textbf{Manning's roughness coefficient: } \textit{0.011 $s  m^{-1/3}$}, -\textbf{Width: } \textit{10m}, -\textbf{Length: } \textit{5m}.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=10cm]{Images/Figure34.png} \\
\caption{Catchment and pond diagram for the build-up, wash-off example}\label{fig:34}
\end{center}
\end{figure}

\item Save the model and run it. After the simulation is done, check the hydraulic and water quality results by right-clicking on blocks or connectors (Figure \ref{fig:38}).

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=7cm]{Images/Figure38.png} \\
\caption{Runoff rate leaving the catchment}\label{fig:38}
\end{center}
\end{figure}

\item Right-click on one of the catchment blocks and click on \textbf{Plot water quality results}$\rightarrow$\textbf{Sorbed/particle associated}$\rightarrow$\textbf{Pb}$\rightarrow$\textbf{Soil} to see the temporal variation of Pb accumulated on the surface. The results should look like Figure \ref{fig:39}. As it can be seen the concentration asymptotically approach $10mg/m^2$. The concentration of Pb in the runoff is zero due to the fact that no release properties have been attributed to Pb.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=7cm]{Images/Figure39.png} \\
\caption{Concentration of Pb accumulated on the surface for the case when solid-water exchange is inactive}\label{fig:39}
\end{center}
\end{figure}

\item \textbf{Setting solid-water exchange properties: } To set solid-water exchange properties for Pb, click on \textbf{Water Quality}$\rightarrow$\textbf{Constituents}$\rightarrow$\textbf{Pb} from the project explorer and then click on \textbf{Exchange rate} from the \textbf{Properties} menu. In the table, select \textbf{Soil} in the first column and type $0.1$ as the exchange rate and $0.1$ for the partitioning coefficient. This indicates that the release rate constant for the exchange between solid phase and aqueous phase is $0.1day^{-1}$ while the equilibrium partition coefficient $S/C$ is $0.01m^2/m^3$ (Figure \ref{fig:40}). Close the dialog. \\

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=7cm]{Images/Figure40.png} \\
\caption{Entering exchange properties}\label{fig:40}
\end{center}
\end{figure}

\item Run the model again.

\item Right-click on one of the blocks to see the concentration of Pb in the runoff and the sorbed Pb concentrations. The results should look like Figure \ref{fig:41}.

\begin{figure}[!ht]
\begin{center}
\includegraphics[width=7cm]{Images/Figure41.png} \\
\caption{Aqueous phase (top) and surface-bound (bottom) Pb in \textbf{Catchment (9)} block}\label{fig:41}
\end{center}
\end{figure}

\end{itemize}


\section{Results}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.4\textheight,keepaspectratio]{cost_sgd.png}
  \caption{Cost for SGD}
  \label{fig:cost_sgd}
\end{figure}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.4\textheight,keepaspectratio]{cost_sgd_momentum.png}
  \caption{Cost for SGD with momentum cofficient($\mu$)$=0.5$}
  \label{fig:cost_sgd_momentum}
\end{figure}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.4\textheight,keepaspectratio]{cost_bipolar.png}
  \caption{Cost for bipolar sigmoid with bipolar XOR representation}
  \label{fig:cost_bipolar}
\end{figure}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.4\textheight,keepaspectratio]{cost_tanh.png}
  \caption{Cost for SGD with hyperbolic tangent as activation}
  \label{fig:cost_tanh}
\end{figure}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.4\textheight,keepaspectratio]{cost_tanh_nw.png}
  \caption{Cost for SGD with hyperbolic tangent and Nguyen-Widrow weight initializer}
  \label{fig:cost_tanh_nw}
\end{figure}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.4\textheight,keepaspectratio]{tanh_nw_first_2500_compare.png}
  \caption{Comparision of first 2500 iterations for hyperbolic tangent without and with Nguyen-Widrow weight initializer}
  \label{fig:tanh_nw_first_2500_compare}
\end{figure}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.4\textheight,keepaspectratio]{cost_two_hidden_layer.png}
  \caption{Cost for SGD with momentum for two hidden layers}
  \label{fig:cost_two_hidden_layer}
\end{figure}