%!TEX root = forallxyyc.tex
\chapter[Quick reference]{Quick reference}
%\pagestyle{plain}
\section{Characteristic truth tables}
\label{app.CharacteristicTTs}

\begin{tabular}{c|c}
\meta{A} & \enot\meta{A}\\
\hline
T & F\\
F & T \\
\phantom{.}\\
\phantom{.}
\end{tabular}
\hfill
\begin{tabular}{c c|c|c|c|c}
\meta{A} & \meta{B} & $\meta{A}\eand\meta{B}$ & $\meta{A}\eor\meta{B}$ & $\meta{A}\eif\meta{B}$ & $\meta{A}\eiff\meta{B}$\\
\hline
T & T & T & T & T & T\\
T & F & F & T & F & F\\
F & T & F & T & T & F\\
F & F & F & F & T & T
\end{tabular}

\vfill

\section{Symbolization}
\begin{center}
\label{app.symbolization}
\begin{tabular*}{\textwidth}{rl}
\multicolumn{2}{c}{\textsc{Sentential Connectives}}\\ \\
It is not the case that $P$ & $\enot P$\\
Either $P$ or $Q$ & $(P \eor Q)$\\
Neither $P$ nor $Q$ & $\enot(P \eor Q)$\ or \ $(\enot P \eand \enot Q)$\\
Both $P$ and $Q$ & $(P \eand Q)$\\
If $P$ then $Q$ & $(P \eif Q)$\\
$P$ only if $Q$ & $(P \eif Q)$\\
$P$ if and only if $Q$ & $(P \eiff Q)$\\
$P$ unless $Q$ & $(P \eor Q)$\\
\\
\multicolumn{2}{c}{\label{SymbolizingPredicates}\textsc{Predicates}}\\ \\
All $F$s are $G$s & $\forall x(\atom{F}{x} \eif \atom{G}{x})$\\
Some $F$s are $G$s & $\exists x(\atom{F}{x} \eand \atom{G}{x})$\\
Not all $F$s are $G$s & $\enot\forall x(\atom{F}{x} \eif \atom{G}{x})$\ or\\
& $\exists x(\atom{F}{x} \eand \enot \atom{G}{x})$\\
No $F$s are $G$s & $\forall x(\atom{F}{x} \eif\enot \atom{G}{x})$\ or\\
& $\enot\exists x(\atom{F}{x} \eand \atom{G}{x})$\\
\\
\multicolumn{2}{c}{\textsc{Identity}}\\ \\
Only $c$ is $G$ & $\forall x(\atom{G}{x} \eiff x=c)$\\
Everything besides $c$ is $G$ & $\forall x(\enot x = c \eif \atom{G}{x} )$\\
%$j$ is more $R$ than anyone else. & $\forall x(x\neq j \eif Rjx)$\\
The $F$ is $G$ & $\exists x(\atom{F}{x} \eand \forall y(\atom{F}{y} \eif x=y) \eand \atom{G}{x} )$\\
It is not the case that\\
 the $F$ is $G$ & $\enot\exists x(\atom{F}{x} \eand \forall y(\atom{F}{y} \eif x=y) \eand \atom{G}{x} )$\\
The $F$ is non-$G$ & $\exists x(\atom{F}{x} \eand \forall y(\atom{F}{y} \eif x=y) \eand \enot \atom{G}{x} )$
\end{tabular*}
\end{center}

% BEGIN: symbolizing cardinality

\newpage
\section{Using identity to symbolize quantities}

\subsection*{There are at least \blank\ $F$s.}
\label{summary.atleast}

\begin{tabular*}{\textwidth}{rl}
one & $\exists x\,\atom{F}{x}$\\
two & $\exists x_1\exists x_2(\atom{F}{x_1} \eand \atom{F}{x_2} \eand \enot x_1  = x_2)$\\
three & $\exists x_1\exists x_2\exists x_3(\atom{F}{x_1} \eand \atom{F}{x_2} \eand \atom{F}{x_3} \eand {}$\\
& $\enot x_1 = x_2 \eand\enot x_1 = x_3 \eand \enot x_2 = x_3)$\\
four & $\exists x_1\exists x_2\exists x_3\exists x_4 (\atom{F}{x_1} \eand \atom{F}{x_2} \eand \atom{F}{x_3} \eand \atom{F}{x_4} \eand {}$\\
& $\enot x_1 = x_2 \eand \enot x_1 = x_3 \eand \enot x_1 = x_4 \eand {}$\\
& $ \enot x_2 = x_3 \eand \enot x_2 = x_4 \eand \enot x_3 = x_4)$\\
$n$ & $\exists x_1\ldots\exists x_n(\atom{F}{x_1} \eand \ldots \eand \atom{F}{x_n} \eand {}$\\
& $\enot x_1 = x_2 \eand\ldots\eand \enot x_{n-1} = x_n)$
\end{tabular*}

\subsection*{There are at most \blank\ $F$s.}
\label{summary.atmost}

One way to say `there are at most $n$ $F$s' is to put a negation sign in front of the symbolization for `there are at least $n+1$ $F$s'. Equivalently, we can offer:
\begin{tabular*}{\textwidth}{rl}
one & $\forall x_1\forall x_2\bigl[(\atom{F}{x_1} \eand \atom{F}{x_2}) \eif x_1=x_2\bigr]$\\
two & $\forall x_1\forall x_2\forall x_3\bigl[(\atom{F}{x_1} \eand \atom{F}{x_2} \eand \atom{F}{x_3}) \eif {}$\\ & $(x_1=x_2 \eor x_1=x_3 \eor x_2=x_3)\bigr]$\\
three & $\forall x_1\forall x_2\forall x_3\forall x_4\bigl[(\atom{F}{x_1} \eand \atom{F}{x_2} \eand \atom{F}{x_3} \eand \atom{F}{x_4}) \eif {}$\\
& $(x_1=x_2 \eor x_1=x_3 \eor x_1=x_4 \eor {}$\\
& $x_2=x_3 \eor x_2=x_4 \eor x_3=x_4)\bigr]$\\
$n$ & $\forall x_1\ldots\forall x_{n+1}
\bigl[(\atom{F}{x_1} \eand \ldots \eand \atom{F}{x_{n+1}}) \eif {}$\\
& $(x_1=x_2 \eor \ldots \eor x_n=x_{n+1})\bigr]$
\end{tabular*}

\subsection*{There are exactly \blank\ $F$s.}
\label{summary.exactly}

One way to say `there are exactly $n$ $F$s' is to conjoin two of the symbolizations above and say `there are at least $n$ $F$s and there are at most $n$ $F$s.' The following equivalent formulas are shorter:
\begin{tabular*}{\textwidth}{rl}
zero & $\forall x\,\enot \atom{F}{x}$\\
one & $\exists x\bigl[\atom{F}{x} \eand \forall y(\atom{F}{y} \eif x = y)\bigr]$\\
two & $\exists x_1\exists x_2\bigl[\atom{F}{x_1} \eand \atom{F}{x_2} \eand {}$\\
& $\enot x_1 = x_2 \eand \forall y\bigl(\atom{F}{y} \eif (y= x_1 \eor y = x_2)\bigr) \bigr]$\\
three & $\exists x_1\exists x_2\exists x_3\bigl[\atom{F}{x_1} \eand \atom{F}{x_2} \eand \atom{F}{x_3} \eand {}$\\
& $\enot x_1 =  x_2 \eand \enot  x_1 = x_3 \eand \enot x_2 = x_3 \eand {}$\\
& $\forall y\bigl(\atom{F}{y} \eif (y = x_1 \eor y = x_2 \eor y =  x_3)\bigr) \bigr]$\\
$n$ & $\exists x_1\ldots\exists x_n\bigl[\atom{F}{x_1} \eand\ldots\eand \atom{F}{x_n}  \eand {}$\\
&$ \enot x_1 = x_2 \eand\ldots\eand \enot x_{n-1}= x_n \eand \phantom{.}$\\
& $\forall y\bigl(\atom{F}{y} \eif (y= x_1 \eor \ldots \eor y= x_n)\bigr)\bigr]$
%\item[one] $\exists x\forall y\bigl[\atom{F}{x} \eand (\atom{F}{y} \eif y = x)\bigr]$
%\item[two] $\exists x\exists y\forall z\Bigl(\atom{F}{x} \eand \atom{F}{y} \eand \bigl[\atom{F}{z} \eif (z=x \eor z=y)\bigr] \eand x \neq y\Bigr)$
%\item[three] $\exists x_1\exists x_2\exists x_3\forall y\Bigl(\atom{F}{x_1} \eand \atom{F}{x_2} \eand \atom{F}{x_3} \eand [\atom{F}{y} \eif (y=x_1 \eor y=x_2 \eor y=x_3)] \eand x_1 \neq x_2 \eand x_1 \neq x_3 \eand x_2 \neq x_3\Bigr)$
%\item[n] $\exists x_1\cdots\exists x_n\forall y\Bigl(\atom{F}{x_1} \eand \cdots \eand \atom{F}{x_n} \eand \bigl[\atom{F}{y} \eif (y=x_1 \eor \cdots \eor y=x_n)\bigr] \eand x_1 \neq x_2 \eand\cdots\eand x_{n-1}\neq x_n\Bigr)$
\end{tabular*}

\label{ProofRules}
\newpage\section{Basic deduction rules for TFL}
\renewenvironment{proof}
	{\noindent\par\noindent\small$\begin{nd}}
	{\end{nd}$\noindent\normalsize\ignorespacesafterend}

%{\LARGE \textbf{Basic Rules of Proof}}
\begin{multicols}{2}
\subsection*{Reiteration}

\begin{proof}
	\have[m]{a}{\meta{A}}
	\have[\ ]{c}{\meta{A}} \by{R}{a}
\end{proof}

\subsection*{Conjunction}

\begin{proof}
	\have[m]{a}{\meta{A}}
	\have[n]{b}{\meta{B}}
	\have[\ ]{c}{\meta{A}\eand\meta{B}} \ai{a, b}

	\have[m]{ab}{\meta{A}\eand\meta{B}}
\\	\have[\ ]{a}{\meta{A}} \ae{ab}

	\have[m]{ab}{\meta{A}\eand\meta{B}}
\\	\have[\ ]{b}{\meta{B}} \ae{ab}
\end{proof}

\subsection*{Conditional}

\begin{proof}
	\open
		\hypo[i]{a}{\meta{A}}
		\have[j]{b}{\meta{B}}
	\close
	\have[\ ]{ab}{\meta{A}\eif\meta{B}}\ci{a-b}

	\have[m]{ab}{\meta{A}\eif\meta{B}}
\\	\have[n]{a}{\meta{A}}
	\have[\ ]{b}{\meta{B}} \ce{ab,a}
\end{proof}

\subsection*{Negation}

\begin{proof}
\open
	\hypo[i]{a}{\meta{A}}
	\have[j]{nb}{\ered}
\close
\have[\ ]{na}{\enot\meta{A}}\ni{a-nb}

\have[m]{na}{\enot\meta{A}}
\\ \have[n]{a}{\meta{A}}
\have[ ]{bot}{\ered}\ri{na, a}
\end{proof}

\subsection*{Indirect proof}

\begin{proof}
\open
	\hypo[i]{a}{\enot\meta{A}}
	\have[j]{nb}{\ered}
\close
\have[\ ]{na}{\meta{A}}\ip{a-nb}
\end{proof}

\subsection*{Explosion}

\begin{proof}
\have[m]{bot}{\ered}
\\\have[ ]{}{\meta{A}}\re{bot}
\end{proof}

\subsection*{Disjunction}

\begin{proof}
	\have[m]{a}{\meta{A}}
	\have[\ ]{ab}{\meta{A}\eor\meta{B}}\oi{a}

	\have[m]{a}{\meta{A}}
\\	\have[\ ]{ba}{\meta{B}\eor\meta{A}}\oi{a}

	\have[m]{ab}{\meta{A}\eor\meta{B}}
\\	\open
		\hypo[i]{a}{\meta{A}}
		\have[j]{c1}{\meta{C}}
	\close
	\open
		\hypo[k]{b}{\meta{B}}
		\have[l]{c2}{\meta{C}}
	\close
	\have[\ ]{c}{\meta{C}} \oe{ab,a-c1, b-c2}
\end{proof}

\subsection*{Biconditional}

\begin{proof}
	\open
		\hypo[i]{a1}{\meta{A}}
		\have[j]{b1}{\meta{B}}
	\close
	\open
		\hypo[k]{b2}{\meta{B}}
		\have[l]{a2}{\meta{A}}
	\close
	\have[\ ]{ab}{\meta{A}\eiff\meta{B}}\bi{a1-b1,b2-a2}

	\have[m]{ab}{\meta{A}\eiff\meta{B}}
\\	\have[n]{a}{\meta{A}}
	\have[\ ]{b}{\meta{B}} \be{ab,a}

	\have[m]{ab}{\meta{A}\eiff\meta{B}}
\\	\have[n]{a}{\meta{B}}
	\have[\ ]{b}{\meta{A}} \be{ab,a}
\end{proof}

\end{multicols}

\newpage
\section{Derived rules for TFL}
\begin{multicols}{2}
\subsection*{Disjunctive syllogism}
\begin{proof}
	\have[m]{ab}{\meta{A} \eor \meta{B}}
	\have[n]{nb}{\enot \meta{A}}
	\have[\ ]{con}{\meta{B}}\by{DS}{ab, nb}

	\have[m]{ab}{\meta{A} \eor \meta{B}}
\\	\have[n]{nb}{\enot \meta{B}}
	\have[\ ]{con}{\meta{A}}\by{DS}{ab, nb}
\end{proof}

\subsection*{Modus Tollens}

\begin{proof}
	\have[m]{ab}{\meta{A}\eif\meta{B}}
	\have[n]{a}{\enot\meta{B}}
	\have[\ ]{b}{\enot\meta{A}} \by{MT}{ab,a}
\end{proof}

\subsection*{Double-negation elimination}
	\begin{proof}
		\have[m]{dna}{\enot \enot \meta{A}}
		\have[ ]{a}{\meta{A}}\dne{dna}
	\end{proof}

\subsection*{Excluded middle}
	\begin{proof}
		\open
			\hypo[i]{a}{\meta{A}}
			\have[j]{c1}{\meta{B}}
		\close
		\open
			\hypo[k]{b}{\enot\meta{A}}
			\have[l]{c2}{\meta{B}}
		\close
		\have[\ ]{ab}{\meta{B}}\tnd{a-c1,b-c2}
	\end{proof}

%
%\subsection*{Hypothetical Syllogism}
%
%\begin{proof}
%	\have[m]{ab}{\meta{A}\eif\meta{B}}
%	\have[n]{bc}{\meta{B}\eif\meta{C}}
%	\have[\ ]{ac}{\meta{A}\eif\meta{C}}\by{HS}{ab,bc}
%\end{proof}

\subsection*{De Morgan Rules}
\begin{proof}
	\have[m]{ab}{\enot (\meta{A} \eor \meta{B})}
	\have[\ ]{dm}{\enot \meta{A} \eand \enot \meta{B}}\dem{ab}

	\have[m]{ab}{\enot \meta{A} \eand \enot \meta{B}}
\\	\have[\ ]{dm}{\enot (\meta{A} \eor \meta{B})}\dem{ab}

	\have[m]{ab}{\enot (\meta{A} \eand \meta{B})}
\\	\have[\ ]{dm}{\enot \meta{A} \eor \enot \meta{B}}\dem{ab}

	\have[m]{ab}{\enot \meta{A} \eor \enot \meta{B}}
\\	\have[\ ]{dm}{\enot (\meta{A} \eand \meta{B})}\dem{ab}
\end{proof}
\end{multicols}

\newpage

\section{Basic deduction rules for FOL}

\begin{multicols}{2}
\subsection*{Universal elimination}

\begin{proof}
	\have[m]{a}{\forall \meta{x}\meta{A}(\ldots \meta{x} \ldots \meta{x}\ldots)}
	\have[\ ]{c}{\meta{A}(\ldots \meta{c} \ldots \meta{c}\ldots)} \Ae{a}
\end{proof}

\subsection*{Universal introduction}

\begin{proof}
	\have[m]{a}{\meta{A}(\ldots \meta{c} \ldots \meta{c}\ldots)}
	\have[\ ]{c}{\forall \meta{x}\meta{A}(\ldots \meta{x} \ldots \meta{x}\ldots)} \Ai{a}
\end{proof}

\medskip\begin{raggedright}
\meta{c} must not occur in any undischarged assumption

\meta{x} must not occur in\\ $\meta{A}(\ldots \meta{c} \ldots \meta{c}\ldots)$
\end{raggedright}

\subsection*{Existential introduction}

\begin{proof}
	\have[m]{a}{\meta{A}(\ldots \meta{c} \ldots \meta{c}\ldots)}
	\have[\ ]{c}{\exists \meta{x}\meta{A}(\ldots \meta{x} \ldots \meta{c}\ldots)}\Ei{a}
\end{proof}

\medskip\begin{raggedright}
\noindent \meta{x} must not occur in\\ $\meta{A}(\ldots \meta{c} \ldots \meta{c}\ldots)$
\end{raggedright}
%\noindent You can replace one or more instance of \meta{c} with \meta{x}.

\subsection*{Existential elimination}

\begin{proof}
	\have[m]{a}{\exists \meta{x}\meta{A}(\ldots \meta{x} \ldots \meta{x}\ldots)}
	\open
		\hypo[i]{b}{\meta{A}(\ldots \meta{c} \ldots \meta{c}\ldots)}
		\have[j]{c}{\meta{B}}
	\close
	\have[\ ]{d}{\meta{B}}\Ee{a,b-c}
\end{proof}

\medskip\begin{raggedright}
\noindent \meta{c} must not occur in any undischarged assumption, in $\exists \meta{x}\meta{A}(\ldots \meta{x} \ldots \meta{x}\ldots)$, or in \meta{B}\end{raggedright}\vfill\columnbreak

\end{multicols}

\subsection*{Identity introduction}

\begin{proof}
	\have[\ \,\,\,]{x}{\meta{c}=\meta{c}} \by{=I}{}
\end{proof}

\subsection*{Identity elimination}

\begin{multicols}{2}
\begin{proof}
	\have[m]{e}{\meta{a}=\meta{b}}
	\have[n]{a}{\meta{A}(\ldots \meta{a} \ldots \meta{a}\ldots)}
	\have[\ ]{ea1}{\meta{A}(\ldots \meta{b} \ldots \meta{a}\ldots)} \by{=E}{e,a}
\end{proof}
\begin{proof}
	\have[m]{e}{\meta{a}=\meta{b}}
	\have[n]{a}{\meta{A}(\ldots \meta{b} \ldots \meta{b}\ldots)}
	\have[\ ]{ea2}{\meta{A}(\ldots \meta{a} \ldots \meta{b}\ldots)} \by{=E}{e,a}
\end{proof}
\end{multicols}

\begin{minipage}{\textwidth} % hack to keep section header with table
\section{Derived rules for FOL}

\begin{multicols}{2}
\begin{proof}
	\have[m]{ab}{\forall \meta{x}\enot \meta{A}}
	\have[\ ]{ac}{\enot \exists \meta{x} \meta{A}}\cq{m}

	\have[m]{ab}{\enot \exists \meta{x}  \meta{A}}
\\	\have[\ ]{ac}{\forall \meta{x}\enot\meta{A}}\cq{m}
\end{proof}
\begin{proof}
	\have[m]{ab}{\exists \meta{x}\enot\meta{A}}
	\have[\ ]{ac}{\enot \forall \meta{x} \meta{A}}\cq{m}

	\have[m]{ab}{\enot \forall \meta{x}  \meta{A}}
\\	\have[\ ]{ac}{\exists \meta{x}\enot \meta{A}}\cq{m}
\end{proof}
\end{multicols}
\end{minipage}


\section{Two-particle scattering}\label{sec:scattering}

Two non-relativistic particles interacting via a contact interaction of strength $C$ in $D$ dimensions are described by the Hamiltonian
\begin{equation}
    \label{eq:particle hamiltonian}
    \hat H = \frac{\hat p_1^2}{2 m_1} + \frac{\hat p_2^2}{2 m_2} + C \delta^D(\hat x_1 - \hat x_2)
    \,,
\end{equation}
where the subscripts identify the particle of the position and momentum operators.
Moving to center-of-mass and relative coordinates, this Hamiltonian may be rewritten
\begin{equation}
    \label{eq:hamiltonian}
    \hat H = \frac{\hat P^2}{2 M} + \frac{\hat p^2}{2 \mu} + C\delta^D(\hat{x})
\end{equation}
where capital letters represent center-of-mass variables, lower case implies relative coordinates, and $\mu$ is the reduced mass.
Specializing to the center of mass frame by setting $P=0$ we reduce the problem to an effective one-body quantum mechanics in an external delta-function potential.

For a general two-body interaction $V$ in $D$ dimensions we can obtain scattering data by solving the Lippmann-Schwinger equation,
\begin{align}
	T_D(\vec p', \vec p, E)
	&=
	V(\vec p', \vec p) + \lim\limits_{\epsilon \to 0}\int \frac{d \vec k^D}{(2\pi)^D} V(\vec p', \vec k) G(\vec k, E + i \epsilon) T(\vec k, \vec p, E) \, ,
	&
	G(\vec k, E+ i \epsilon) = \frac{1}{E + i \epsilon - \frac{k^2}{2\mu}}
	\, .
\end{align}
where $G$ is the free Green's function.
Projecting onto the set of partial waves in $D$ dimensions labelled by $\l$, the $T$ matrix may be re-expressed in terms of phase shifts.
For a central interaction like the contact interaction, partial waves do not mix and $\l$ labels the orbital angular momentum, which is conserved.
In this case, the phase shifts can be extracted from the scattering or $T$-matrix by
\begin{align}\label{eq:on-shell-T}
	\frac{1}{T_{D\l}(p)}
    \equiv
    \frac{1}{T_{D\l}(p, p, E_p)}
    = \frac{\mu}{2}
    \frac{1}{\mathcal F_{D\l}(p)} \left[\cot (\delta_{D\l}(p)) - i\right] \, ,
\end{align}
where $E_p = p^2 / (2 \mu)$ and $\mathcal F_{l D}(p)$ is a dimension-dependent kinematic function of the on-shell momentum.

At low energy one often considers the expansion of \eqref{on-shell-T} in scattering momentum $p$, called the effective range expansion (ERE), which takes the form \cite{Hammer:2010fw}
\begin{align}
    \label{eq:ere}
    \cot \left(\delta_{D\l}(p)\right)
    &=
    \theta_D \frac{2}{\pi}  \ln \left(p R_{D\l}\right)
    -
    \frac{1}{a_{D\l}} p^{2 - 2 \l - D} +\frac{1}{2} r_{D\l} p^{4 - 2 \l - D} + \order{p^{6 - 2 \l - D}}
    \, , &
    \theta_D &= \begin{cases}
        0 & D \;\text{odd} \\ 1 & D \;\text{even}
    \end{cases}
    \, ,
\end{align}
where $R_{D \l}$ is an arbitrary length scale that enters in even dimensions and $a_{D\l}$, $r_{D\l}$ and subsequent higher-order coefficients describe the properties of the two-particle interaction.
In three spatial dimensions, the S-wave phase shift is described by the \emph{scattering length} $a_{30}$, the \emph{effective range} $r_{30}$ and further shape parameters.

In this paper we refer to $a$ as the scattering length and $r$ the effective range, even when, by simple dimensional analysis, they may not be actual lengths.
Moreover, in this work we will focus on the S-wave or its $D$-dimensional equivalent partial wave for simplicity, and henceforth suppress the $\l$ label
\begin{align}
	\delta_{D} &\equiv \delta_{D0}\, , &
	a_{D} &\equiv a_{D0}\, , &
	r_{D} &\equiv r_{D0}\, , &
	\cdots &
	\,
\end{align}
We work in three, two, and one spatial dimension.

Contact interactions, which are analytically tractable, correspond to a momentum-independent scattering amplitude when properly renormalized (as long as the log dependence is handled carefully in even dimensions).
So, the strength of the contact interaction $C$ may be traded for the scattering length $a$ and all other scattering parameters vanish.
The lattice interactions we will construct, when analyzed appropriately, will exhibit this momentum independence.


\chapter{Photonics}
\label{ch:marketbasics}

\section{Basics}

The speed of light is given by $c=2.99\times10^8m/s$ in vacuum, and slower in other medium. Light can experience \textbf{refraction}\sidenote{deflection when passing from one medium to another} and \textbf{reflection}\sidenote{bouncing off a surface}. Detection and measurement of light energy is a field known as {\it radiometry}. The properties of light can be described by both particle and wave analogies.

\subsection{Light as a particle}

A "light particle" is called a photon, which is a particle with no mass or charge. It carries electromagnetic energy and can interact with other particles. The amount of energy $E$ for a photon is given by

\begin{equation}
E=\frac{hc}{\lambda}
\end{equation}
Where $h$ is Planck's constant ($6.25\times10^{-34}$), $c$ is the speed of light and $\lambda$ is the light's wavelength in meters.

The {\it photoelectric} effect gives evidence of light's particle like properties. This is the effect seen where some materials when a light is shone on them emit electrons. This behaviour reflects light as a particle because more intense radiation did not cause higher energy electrons to be emitted and electron energy was dependent on wavelength, not amplitude of the wave.

No matter how intense the light, photons below a given minimum frequency do not cause electrons to be emitted. The relationship governing the energy of emitted electrons is

\begin{equation}
E_{e-} = \frac{hc}{\lambda} - p
\end{equation}
Where $p$ is the characteristic escape energy for the given metal and $E_{e-}$ is the energy of the escaping electron.

\subsection{Light as a wave}

Light also exhibits the properties of {\it interference} and {\it diffraction} which fit the idea of a wave model of light. Waves move energy without moving mass at a speed independent of intensity or wavelength. Light waves have an electric and magnetic field which changes at right angles to the direction of motion. The wavelength ($\lambda$) is the distance between successive peaks or troughs in a wave. The wave number $\nu$ is the inverse of the wave length. Standard mathematical properties such as period $\tau$ and frequency $f$ can be calculated.

Light waves are not always sinusoidal in shape. In addition any particle light wave may consist of a series of waves with peaks in all different directions perpendicular to the direction of travel. The amount of energy that flows across a unit area perpendicular ot the direction of travel is called the irradiance or flux density of the wave.

Light waves may also be polarised, where the waves vibrate in specific directions perpendicular to the direction of travel. The intensity of light travelling through a linear polariser can be given by

\begin{equation}
I(\theta) = I_0\cos^2(\theta)
\end{equation}
where $I(\theta)$ is the light intensity passed by the polariser and $I_0$ is the incident light density.

Light waves exhibit the properties of {\it superposition}, {\it reflection}, {\it refraction}, {\it diffraction} and {\it interference}.

For refraction, the angle of incidence is the same as the angle of reflection, when measured from the surface normal.

Refraction occurs at the interface between surfaces due to the difference in speed of light in the particular material. The ratio of speeds for two surfaces can be given by the index of refraction:

\begin{equation}
	\frac{n_2}{n_1} = \frac{\sin\theta}{\sin\phi}
\end{equation}
Where $n_2$ and $n_1$ are the indices of refraction for the two media, $\theta$ is the angle of incidence (from the surface normal) and $\phi$ is the angle of refraction (measured from the normal).

the index of refraction can be calculated by

\begin{equation}
n_i = \frac{c}{v_i}
\end{equation}
Where $v_i$ is the velocity of light in the medium $i$.

The slit test proved the wave like properties of light. A slit of width d has a plane wave shone on it. Where $d < \lambda$ a very even diffuse light is shone on to a surface on the far side of the slit. Essentially small spherical waves are emitted from the slit . Where $d \approx \lambda$, then emitted wave appears to have similar properties to the plane wave.

The two slit experiment in 1801 showed the two waves of light emitted through the slits interfering, resulting in a ``zebra strip'' sort of pattern on the far surface.

\subsection{The electromagnetic spectrum}

Only a small spectrum of electromagnetic radiation is visible light. Waves go from long wave to radio through infrared, visible light, ultraviolet, xrays and gamma rays in order of decreasing wave length.

White light contains a mixture of different coloured light, each of which has a different wavelength. Due to their differing wavelength, the white light can be separated when refracted through a particular medium.

Any material above absolute zero emits electromagnetic radiation, with molecules having a characteristic set of spectral lines. Atoms changing state produce visible and ultraviolet radiation, whilst molecules changing vibrational or rotational states emit infrared radiation. Liquids and solids typically have much broader spectral lines than gases as they can take on a much wider range of energy states.

At an atomic level, an atom consisting of protons and neutrons has a series of energy shells (labelled K through O) which can contain electrons. In their {\it grounded} state electrons have limited energy. However as energy is added they can become excited and move into higher energy shells. As they do this they absorb or emit quanta (unique amounts) of energy, with the exact nature depending on the electronic structure of the atom.

For a hydrogen atom there are 6 major energy levels, ranging from $-0.38eV$ to $-13.6eV$. This means that if an electron is in the $n=3$ layer (which has an energy of $-1.5eV$ then it can emit a photon with

\begin{equation}
	-1.51 - (-13.6) = 12.09eV
\end{equation}
If an electron is freed from the atom then its energy level $E_\infty = 0$. Atoms can also absorb photons which have energy exactly matching the difference between electron energy levels. Additionally a molecule in a gas or liquid may absorb a photon where it has a vibrational or rotational energy level matching the energy of the photon.

\subsection{Blackbody radiation}

Blackbody radiation is the theoretical maximum radiation expected for temperature related self-radiation. That is the amount of energy radiated from a body (in various spectra) based on its temperature (in Kelvin).

The energy radiated by a black body in a given wave band is the sum of all energies radiated at the wavelengths within the band. The same holds for the power emitted, which can be calculated in watts per square meter using the Stefan-Boltzmann law:

\begin{equation}
W_s = \sigma_sT^4
\end{equation}
Where $W_s$ is the radiated power, $\sigma_s$ is the Stefan-Boltzmann constant, $5.67\times10^{-8}$ and $T$ is the temperature in Kelvin. $W_s$ is the power per unit area, also known as the emitted radiant flux density. Typically graybodies do not perfectly emit and the above equation is factored down bt the emissivity ($\varepsilon$) of the material.

\begin{equation}
W_s = \varepsilon\sigma_sT^4
\end{equation}
Blackbodies emit radiation over a range of wavelengths. The power radiated per unit area $W_\lambda$ within a given waveband $\Delta\lambda$ is given by Planck's radiation formula:

\begin{equation}
W_\lambda = \frac{c_1}{\lambda^5} - \frac{1}{\frac{c_2}{e\lambda T}-1}
\end{equation}
Where

\begin{equation}
c_1 = 2\pi c^2 h = 3.75\times10^{-16}
\end{equation}

\begin{equation}
c_2 = \frac{hc}{k} = 1.44\times10^{-4}
\end{equation}

\begin{equation}
c = 3\times10^8
\end{equation}

\begin{equation}
h = 6.626\times10^{-34}
\end{equation}

\begin{equation}
k = 1.38\times10^{-28}
\end{equation}
There is a maximum emission wavelength which can be given by Wien's displacement law:

\begin{equation}
	\lambda_{max}T = 2.898\times10^{-3}m\cdot K
\end{equation}

\subsection{Interaction with matter}
The two main interactions are {\it absorption} and {\it scattering}.
Absorption has been discussed as moving an electron into a higher energy level or exciting a molecule's vibration or rotation. The spectrum of absorbed light may have missing or removed wavelengths depending on what has been absorbed. This is the basis for objects having colour.

Scattering is redirection of light based on interaction with matter. Scattered radiation may have the same or longer wavelength (reduced energy) and may have a different polarisation.

If the scatterer are significantly smaller than the wavelength $\lambda$ then they may absorb and immediately re-emit photons in a different direction. Where the emitted photon has the same wavelength as the incident light it is known as {\it Rayleigh scattering}.

Where the wavelength of the emitted radiation is longer and the molecule is left in an excited state, it is known as {\it Raman scattering}. For Raman scattering, secondary photons may later be emitted when the molecule returns to the ground state.

Where the scatterer is of similar size or larger than the wavelength, all wavelengths of the incident light are equally scattered, a process known as {\it Mie scattering}.


\chapter{Straight Line}

\section{Gradient \& Equation of a Straight Line}
The gradient is the line's steepness. The bigger the number, the steeper it is. Its symbol is $m$.

Its equation is
\begin{equation*}
m = \frac{\text{vertical distance}}{\text{horizontal distance}}
\end{equation*}
or
\begin{equation}
m = \frac{y_2-y_1}{x_2-x_1}
\end{equation}

If the line is vertical ($\vert$), then it has an undefined gradient, e.g. when $x=1$. If it is horizontal (—), then $m=0$, e.g. when $y=1$.

From National 5, it should be known that, given a point and gradient, the equation of a line can be written using

\begin{equation}
y-b=m(x-a).
\end{equation}

\subsection{Example}
If $m=3$ and the line goes through point (-2,3), find the equation of the line.

\begin{align*}
y-b&=m(x-a)\\
y-3&=3(x+2)\\
y&=3(x+2)+3\\
y&=3x+6+9\\
y&=3x+9\\
\end{align*}

Note that the equation can be left in any form, no extra marks are awarded for leaving it in the form $0 = 3x - y + 9$

\section{$m=\tan\theta$}

\begin{figure}[h!]
	\centering
	\begin{tikzpicture}% function
		\begin{axis}
		[
			xlabel=$x$,
			ylabel=$y$,
			axis lines = left, % Only show axis on the left and bottom.
			axis equal,
			ymin = 0,
			xmin = 0,
		]
		\pgfplotsset{ticks=none}
		\addplot
		[
			samples = 100,
			color = black,
		]{sqrt(3)*x};
		\end{axis}
	\end{tikzpicture}
	\caption{Here, $\theta$ is 60$^\circ$.}
	\label{fig:mtan60}
\end{figure}
$\theta$ is the (in figure \ref{fig:mtan60} an acute) angle made from the $x$-axis in an anti-clockwise direction (also called in the positive direction of the $x$-axis). If $\theta$ is known, the gradient of the line can be found, and vice versa, by using

\begin{equation}
	m=\tan\theta
\end{equation}

\subsection{Examples}
\begin{enumerate}
	\item
	A line makes an angle of 120$^\circ$ with the positive direction of the $x$-axis. Find its gradient.

	One could just enter 120$^\circ$ into their calculator and get the right answer, but the following is a method of working it out if the question would appear in a non-calculator paper.
	\begin{align*}
	m&=\tan\theta\\
	&=\tan120^\circ\\
	&=-\tan60\\
	&=-\sqrt{3}
	\end{align*}

	\item
	A line's gradient is $-2$. Find the angle it makes in the positive direction of the $x$-axis.
	\begin{align*}
	\text{If $m=2$,}\\
	\tan\theta&=2\\
	\theta&=\tan^{-1}2\\
	&=63.43...\\
	\text{Now the proper line where $m=-2$,}\\
	\theta&=180-63.43...\\
	&=116.56...\\
	&\approx116.6^\circ
	\end{align*}

\end{enumerate}

\section{Perpendicular Lines ($\perp$)}
Perpendicular lines sit at right angles to each other. If lines are perpendicular, then
\begin{equation}
m_1 m_2 = -1.
\end{equation}

\subsection{Examples}
If two lines are perpendicular, calculate $m_1$ if $m_2$ is
\begin{enumerate}
	\item 6
	\item -7
	\item $\frac{2}{7}$
\end{enumerate}

\begin{enumerate}
	\item
	\begin{align*}
	m_1 m_2 &= -1\\
	3m_1 &= -1\\
	m_1&=-\frac{1}{3}
	\end{align*}

	\item
	\begin{align*}
	m_1 m_2 &= -1\\
	-7m_1 &= -1\\
	m_1&=\frac{1}{7}
	\end{align*}

	\item
	\begin{align*}
	m_1 m_2 &= -1\\
	\frac{2}{7}m_1 &= -1\\
	2m_1&=-7\\
	m_1&=-\frac{7}{2}
	\end{align*}
\end{enumerate}

As a shortcut, take the recipricol and change the sign.

\begin{enumerate}
	\setcounter{enumi}{3}
	\item
	Find the equation of the line perpendicular to $y=-\frac{2}{3}x+5$ that passes through the point $\left(1,7\right)$.

	\begin{align*}
		m &= -\frac{2}{3} & m_\perp &= \frac{3}{2}
	\end{align*}

	Now that the gradient of the perpendicular line has been found, it can be used in the equation.

	\begin{align*}
		y-b&=m(x-a)\\
		y-7&=\frac{3}{2}(x-1)\\
		y&=\frac{3}{2}x - \frac{3}{2} + 7\\
		y&=\frac{3}{2}x + \frac{11}{2}
	\end{align*}
\end{enumerate}

\section{Mid Point Formula}
To find the point in the middle of a line, use
\begin{equation}
\text{mid point} = \left(\frac{x_1 + x_2}{2},\frac{y_1 + y_2}{2}\right)
\end{equation}

\subsection{Examples}
\begin{enumerate}
	\item
	Find the mid point of $\left(1,-4\right)$ and $\left(7,8\right)$.

	\begin{align*}
		\text{mid point} &= \left(\frac{x_1 + x_2}{2},\frac{y_1 + y_2}{2}\right)\\
		&= \left(\frac{1 + 7}{2},\frac{-4 + 8}{2}\right)\\
		&= \left(4,2\right)
	\end{align*}

	\item
	A circle has centre point $(6,10)$. Two points $A(5,5)$ and $B$ are drawn on its circumference, these are connecting by a diameter (see figure \ref{fig:MidPointQ2}). Find the coordinates of B.
	\begin{figure}[h!]
		\centering
		\begin{tikzpicture}
		[
			scale=0.5,
			% Make a style for a black coordinate.
			cmark/.style={label={[anchor=center, color=black]:\pgfuseplotmark{#1}}},
			% And one for a blue coordinate.
			bmark/.style={label={[anchor=center, color=blue]:\pgfuseplotmark{#1}}}
		]
			\draw (6,10) circle [radius=sqrt(26)];
			\coordinate
			[
				label=below:{$A(5,5)$},
				black,
				cmark=*,
			] (a) at (5,5);
			\coordinate
			[
				label=right:{$C(6,10)$},
				black,
				cmark=*,
			] (c) at (6,10);
			\coordinate
			[
				label=above:{$B$},
				blue,
				bmark=*,
			] (b) at (7,15);

			% Draw diameter.
			\draw (a) -- (c) -- (b);
		\end{tikzpicture}
		\caption{Circle mentioned in example 2.}
		\label{fig:MidPointQ2}
	\end{figure}
	\begin{align*}
		\text{mid point} &= \left(\frac{x_1 + x_2}{2},\frac{y_1 + y_2}{2}\right)\\
		\left(17, 12\right) &= \left(\frac{9+x}{2},\frac{-2 + y_2}{2}\right)
	\end{align*}
	\begin{align*}
		\frac{9+x}{2} &= 17 & \frac{-2+y}{2} &= 12\\
		9+x &= 34 & -2+y &= 24\\
		x &= 25 & y &= 26
	\end{align*}

	So the coordinate of B is $\left(25,26\right)$.
\end{enumerate}

\section{Collinearity}
Points that are collinear lie on a straight line.

\begin{figure}[h!]
	\centering
	\begin{subfigure}[b]{0.4\linewidth}
		\begin{tikzpicture}% coordinates
			\begin{axis}
			[
				axis equal,
				axis line style={draw=none},
			]
			\pgfplotsset{ticks=none} % Get rid of numbers and ticks.
			\addplot
			[
				color=black,
				mark=*,
			] coordinates
			{
				(3,0)(6,1)(9,2)
			};
		\end{axis}
		\end{tikzpicture}
		\caption{Collinear.}
	\end{subfigure}
	\begin{subfigure}[b]{0.4\linewidth}
		\begin{tikzpicture}% coordinates
			\begin{axis}
			[
				axis equal,
				axis line style={draw=none},
			]
			\pgfplotsset{ticks=none} % Get rid of numbers and ticks.
			\addplot
			[
				color=black,
				mark=*,
			] coordinates
			{
				(1,0)(2,1)(7,2)
			};
			\end{axis}
		\end{tikzpicture}
		\caption{Not collinear.}
	\end{subfigure}
	\caption{Examples of collinearity.}
	\label{fig:collinearityExample}
\end{figure}

To test for collinearity of three points $A,B,C$:
\begin{enumerate}
	\item find $m_{AB}$,
	\item find $m_{BC}$,
	\item if $m_{AB}=m_{BC}$, then (because $B$ is a common point) they are collinear.
\end{enumerate}

\subsection{Examples}
\begin{enumerate}
	\item
	Show that the points $P\left(-6,-1\right), Q\left(0,2\right), R\left(8,6\right)$ are collinear.

	\begin{align*}
		m_{PQ}&=\frac{2+1}{0+6} & m_{QR}&=\frac{6-2}{8-0}\\
		&=\frac{3}{6} & &=\frac{4}{8}\\
		&=\frac{1}{2} & &=\frac{1}{2}
	\end{align*}
	Since $m_{PQ} = m_{QR}$, and $Q$ is a common point, $PQR$ are collinear.

	\item
	If $A\left(1,-1\right), B\left(-1,k\right), C\left(5,7\right)$ are collinear, find k.

	\begin{align*}
		m_{AB}&=m_{BC}\\
		\frac{k-(-1)}{-1-1}&=\frac{7-k}{5-(-1)}\\
		\frac{k+1}{-2}&=\frac{7-k}{6}\\
		6(k+1)&=-2(7-k)\\
		6k+6&=-14+2k\\
		4k&=-20\\
		k&=5
	\end{align*}
\end{enumerate}

\section{Median Lines}
\begin{figure}[h!]
	\centering
	\begin{tikzpicture}[scale=8]
		% Draw triangle.
		\coordinate[label=left:{$A$}] (a) at (0mm,0mm);		\coordinate[label=above:{$B$}] (b) at (7mm,5mm);		\coordinate[label=right:{$C$}] (c) at (10mm,1mm);
		\draw (a) -- (b) -- (c) -- cycle;

		% Draw point M.
		\coordinate
		[
			label=below:{$M$},
			circle,
			fill,
			color=blue,
			inner sep=1mm,
			scale=0.5
		] (m) at (5mm,0.5mm);

		% Connect point M and B.
		\draw[color=blue] (m) -- (b) -- cycle;
	\end{tikzpicture}
	\caption{Median from B.}
	\label{fig:median}
\end{figure}

The median is a line from a vertex of a triangle to the mid point of the opposite.

To find the median from $B$ in a triangle $ABC$ (such as in figure \ref{fig:median}):
\begin{enumerate}
	\item find the mid point of $AC$ (hereafter called $M$), since the opposite of $B$ is $AC$,
	\item find $m_{BM}$,
	\item use $y-b=m(x-a)$ with $B$ or $M$ and $m_{BM}$.
\end{enumerate}

\subsection{Example}
In $\triangle ABC$, $A(4,-9)$, $B(10,2)$, and $C(4,-4)$. Find the equation of the median from A.

\begin{align*}
	\text{mid point} &= \left(\frac{10+4}{2},\frac{2-4}{2}\right) & m_{AM} &= \frac{-1-(-9)}{7-4}\\
	&=\left(7,-1\right) & &= \frac{8}{3}
\end{align*}
\begin{align*}
	y-b&=m(x-a)\\
	y+9&=\frac{8}{3}\left(x-4\right)\\
	3y+27&=8\left(x-4\right)\\
	3y&=8x-32-27\\
	3y&=8x-59
\end{align*}

\section{Altitude}
\begin{figure}[h!]
	\centering
	\begin{tikzpicture}[scale=2]
		% Draw triangle.
		\coordinate[label=left:{$A$}] (a) at (0cm,0cm);		\coordinate[label=above:{$B$}] (b) at (1cm,2.5cm);		\coordinate[label=right:{$C$}] (c) at (2.5cm,0.5cm);
		\coordinate[] (q) at ($(c)!(b)!(a)$) {};
		\draw (a) -- (b) -- (c) -- cycle;
		\draw[color=blue] (b) -- (q);

		\tkzMarkRightAngle[radius=0.05cm](b,q,c)
	\end{tikzpicture}
	\caption{Altitude from B.}
	\label{fig:altitude}
\end{figure}

The altitude is a straight line from a vertex to the other side at right angles.

To find the altitude from $B$ in a triangle $ABC$ (such as in figure \ref{fig:altitude}):
\begin{enumerate}
	\item find $m_{AC}$,
	\item find $m_\perp$,
	\item use $y-b=m(x-a)$ with $m_\perp$ and $B$.
\end{enumerate}

\subsection{Example}
The triangle $ABC$ has vertices $A(3,-5)$, $B(4,3)$, and $C(-7,2)$. Find the altitude from A.

\begin{align*}
	m_{CB}&=\frac{3-2}{4-(-7)} & m_\perp&=-11\\
	&=\frac{1}{11}
\end{align*}
\begin{align*}
	y-b&=m(x-a)\\
	y+5&=-11(x-3)\\
	y&=-11x+33-5\\
	y&=-11x+28
\end{align*}

\section{Perpendicular Bisector}
\begin{figure}[h!]
	\centering
	\begin{tikzpicture}[scale=2]
		% Draw triangle.
		\coordinate[label=above:{$A$}] (a) at (0cm,0cm);
		\coordinate[label=above:{$B$}] (b) at (4cm,0cm);
		\coordinate[] (p) at (2cm,0.75cm);
		\coordinate[] (q) at (2cm,0cm);
		\coordinate[] (r) at (2cm,-0.75cm);
		\draw (a) -- (b);
		\draw[color=blue] (p) -- (r);

		\tkzMarkRightAngle[radius=0.05cm](p,q,b)
	\end{tikzpicture}
	\caption{The perpendicular bisector of $AB$ is here in blue.}
	\label{fig:pb}
\end{figure}

The perpendicular bisector (abbr. PB) is a line that cuts another line in the middle and sits at right angles.

To find the PB of a line $AB$:
\begin{enumerate}
	\item find the mid point $AB$,
	\item find $m_{AB}$,
	\item find $m_\perp$,
	\item use $y-b=m(x-a)$ with the mid point $AB$ and $m_\perp$.
\end{enumerate}

\subsection{Example}
Two points are $A(-2,1)$ and $B(4,7)$ are connected by a line. Find the equation of the perpendicular bisector.

\begin{align*}
	\text{mid point} &= \left(\frac{-2+4}{2},\frac{1+7}{2}\right) & m_{AB} &= \frac{7-1}{4-(-2)} & m_\perp&=-1\\
	&=(1,4) & &=1
\end{align*}
\begin{align*}
	y-b&=m(x-a)\\
	y-4&=-1(x-1)\\
	y&=-x+1+4\\
	y&=-x+5
\end{align*}

\begin{figure}[h!]
	\centering
	\begin{tikzpicture}
	[
		scale=0.5,
		% Make a style for a black coordinate.
		cmark/.style={label={[anchor=center, color=black]:\pgfuseplotmark{#1}}},
		% And one for a blue coordinate.
		bmark/.style={label={[anchor=center, color=blue]:\pgfuseplotmark{#1}}}
	]
		\coordinate
		[
			label=left:{$A(-2,1)$},
			black,
			cmark=*,
			] (a) at (-2,1);
		\coordinate
		[
			label=right:{$B(4,7)$},
			black,
			cmark=*,
		] (b) at (4,7);
		\coordinate (p) at (0,5);
		\coordinate [label=right:{$y=-x+5$}] (q) at (2,3);

		% Draw line
		\draw (a) -- (b);
		\draw[blue] (p) -- (q);
	\end{tikzpicture}
	\caption{Perpendicular bisector in blue. Note that this is only to show what's happening, it's not required to sketch this in an exam unless specifically asked for.}
	\label{fig:PBexample}
\end{figure}

\section{Intersection of Lines}
The point of intersection (abbr. POI) of two lines can be found through solving each line's equation simultaneously.

The National 5 course most likely focussed on the method of elimination, a better method is to use substitution. However, sometimes, such as in the second example, the equations are so simple that it would be stupid to not eliminate.

\subsection{Examples}
\begin{enumerate}
	\item
	Two lines have equations $2x-y+11=0$ and $x+2y-7 = 0$. Find the point of intersection.

	\begin{align*}
		2x-y+11&=0\\
		y&=2x+11
	\end{align*}
	Sub $y=2x+11$ into $x+2y-7=0$,
	\begin{align*}
		x+2(2x+11)-7&=0\\
		x+4x+22-7&=0\\
		5x+15&=0\\
		5x&=-15\\
		x&=-3
	\end{align*}
	\begin{align*}
		y&=2x+11 & POI=(-3,5)\\
		y&=2(-3)+11\\
		&=-6+11\\
		&=5
	\end{align*}
	\begin{figure}[h!]
		\centering
		\begin{tikzpicture}[bmark/.style={label={[anchor=center, color=blue]:\pgfuseplotmark{#1}}}]
			\begin{axis}
			[
				xlabel=$x$,
				ylabel=$y$,
				xmin=-6,
				xmax=2,
				xtick={-6,-5,...,1},
				ymin=0,
				ymax=7,
				ytick={0,1,...,6},
				axis lines=center,
				axis equal,
				smooth,
				scale=0.8,
			]
				\addplot [color=black,mark=none] {2*x+11};
				\addplot [color=black,mark=none] {3.5-0.5*x};
				\coordinate
				[
					label=right:{$(-3,5)$},
					bmark=*,
				] (a) at (-3,5);
			\end{axis}
		\end{tikzpicture}
		\caption{Solution to the first example, point of intersection in blue. Again, it's not required to sketch these two lines, this figure is simply there to give further clarification as to what's happening.}
		\label{fig:POIexample}
	\end{figure}

	\item
	In triangle $ABC$ with points $A(1,0)$, $B(-4,3)$, $C(0,-1)$, find the median from A, the altitude from C, and henceforth the POI.

	\textit{Median from A:}
	\begin{align*}
		\text{mid point} &= \left(\frac{-4+0}{2},\frac{3+(-1)}{2}\right) & m &= \frac{3-0}{-4-1} \\
		&= (-2,1) & &=-\frac{1}{3}
	\end{align*}
	\begin{align*}
		y-b&=m(x-a)\\
		y-1&=-\frac{1}{3}\left(x+2\right)\\
		3y-3&=-\left(x+2\right)\\
		3y&=-x-2+3\\
		3y&=-x+1
	\end{align*}

	\textit{Altitude from C:}
	\begin{align*}
		m_{AB}&=\frac{3-0}{-4-1} & m_\perp&=\frac{5}{3} \\
		&=-\frac{3}{5}
	\end{align*}
	\begin{align*}
		y-b&=m(x-a)\\
		y+1&=\frac{5}{3}\left(x+0\right)\\
		3y+3&=5\left(x+0\right)\\
		3y&=5x-3
	\end{align*}

	\textit{Point of intersection:}
	\begin{align*}
		3y&=-x+1 & 3y&=-x+1\\
		\makebox[0pt][l]{\uline{\phantom{$--3y=5x-3$}}}
		-\;\;3y&=5x-3 & 3y&=-\frac{2}{3}+1\\
		0&=-6x+4 & 9y&=-2+3\\
		6x&=4 & 9y&=1\\
		x&=\frac{2}{3} & y=\frac{1}{9}\\
	\end{align*}
	\begin{equation*}
		POI = \left(\frac{2}{3},\frac{1}{9}\right)
	\end{equation*}
\end{enumerate}


\documentclass{article}
%Some packages I commonly use.
\usepackage{amsmath}

%A bunch of definitions that make my life easier

\title{JPCB 2013 Detailed Math}
\author{Yi-Tsao Chen}
\date{April 2019}

\begin{document}

\maketitle

\section{From Langevin to Fokker-Planck}

\begin{equation}
\label{eq:ODLD}
dx_t=D F(x_t)dt  + \sqrt{2D}d{W}_t
\end{equation}

\begin{equation}
\begin{split}
x(t+d{t}) = x(t) + D F(x_t) d{t} + \sqrt{2D}d{W}_t \\
= x(t) + D F(x_t) d{t} + \xi(t) d{t}
\end{split}
\end{equation}

where

\begin{equation}
\begin{cases}
\xi(t) d{t} =  \sqrt{2D}d{W}_t \\
\langle \xi(t) \rangle = 0 \\
\langle \xi(t)^2 \rangle = \frac{2D}{d{t}} \\
\langle (\xi(t) d{t})^2 \rangle = 2D d{t} \\
\ P_{G}(\xi(t) d{t})= \frac{1}{\sqrt{4 \pi D d{t}}}exp{(\frac{-\xi^2}{4D d{t}})}
\end{cases}
\end{equation}

According to the Chapman-Kolmogorov equation:
\begin{equation}
\label{eq:lgtofk1}
\begin{split}
P(x, t+d{t}) = \int \int P(y,t) P_{G}(\xi d{t}) \delta(x-y-D F d{t} - \xi d{t}) d{(\xi d{t})} d{y} \\
= \int \int P(y,t) P_{G}(\xi d{t}) \delta(y - (x -D F d{t} - \xi d{t})) d{(\xi d{t})} d{y} \\
= \int P(x -D F d{t} - \xi d{t}, t) P_{G}(\xi d{t}) d{(\xi d{t})} \\
= \int P(x  + (-D F - \xi) d{t}, t) P_{G}(\xi d{t}) d{(\xi d{t})} \\
= \int ( P(x,t) + (-D F - \xi) d{t} \frac{\partial P(x,t)}{\partial x} + \frac{(-D F - \xi)^2 d{t}^2}{2}\frac{\partial^2 P(x,t)}{\partial x^2})P_{G}(\xi d{t}) d{(\xi d{t})}\\
=P(x,t)- D F d{t}\frac{\partial P(x,t)}{\partial x} + \frac{D^2 F^2 d{t}^2}{2}\frac{\partial^2 P(x,t)}{\partial x^2}+ D d{t} \frac{\partial^2 P(x,t)}{\partial x^2}
\end{split}
\end{equation}

The last two lines in equation (\ref{eq:lgtofk1}) we used the following:
\begin{equation}
\int P(x,t) P_{G}(\xi d{t}) d{(\xi d{t})} = P(x,t) \int P_{G}(\xi d{t}) d{(\xi d{t})} = P(x,t)
\end{equation}

\begin{equation}
\int (-D F d{t}) P_{G}(\xi d{t}) d{(\xi d{t})} = P(x,t) \int P_{G}(\xi d{t}) d{(\xi d{t})} = -D F d{t}
\end{equation}

\begin{equation}
\int (-\xi d{t}) P_{G}(\xi d{t}) d{(\xi d{t})} = \langle \xi(t)d{t} \rangle = 0
\end{equation}

\begin{equation}
\begin{split}
\frac{1}{2} \int (D^2 F^2 d{t}^2 - 2 DF\xi d{t}^2 + \xi^{2}d{t}^2) P_{G}(\xi d{t}) d{(\xi d{t})} \\
= \frac{D^2F^2 d{t}^2}{2} + \frac{\langle (\xi(t) d{t})^2 \rangle}{2} \\
= \frac{D^2F^2 d{t}^2}{2} + D d{t}
\end{split}
\end{equation}

Then, continue equation (\ref{eq:lgtofk1}),
\begin{equation}
\frac{P(x, t+d{t}) - P(x,t)}{dt} = - D F \frac{\partial P(x,t)}{\partial x} + \frac{D^2 F^2 d{t}}{2}\frac{\partial^2 P(x,t)}{\partial x^2}+ D \frac{\partial^2 P(x,t)}{\partial x^2}
\end{equation}
and make $d{t}$ very small,
\begin{equation}
\lim_{d{t}\to 0}\frac{P(x, t+d{t}) - P(x,t)}{dt} = - D F \frac{\partial P(x,t)}{\partial x} + D \frac{\partial^2 P(x,t)}{\partial x^2}
\end{equation}

where the second term disappears because
\begin{equation}
\lim_{d{t}\to 0}\frac{D^2 F^2 d{t}}{2}\frac{\partial^2 P(x,t)}{\partial x^2} = 0
\end{equation}
At last, we obtain Fokker-Planck equation,

\begin{equation}
\label{eq:FP}
\frac{\partial P(x,t)}{\partial t} = D \frac{\partial^2 P(x,t)}{\partial x^2} - D F \frac{\partial P(x,t)}{\partial x}
\end{equation}

\end{document}


\section{Model}
\subsection{Notation}
Before presenting the model we describe some notation used through out the appendix. For a $m \times n$ matrix $r$ we use the following broadcasting notation $\mv{r}_{k,j:l}=[ r_{k,j}, r_{k,j+1}, \ldots, r_{k,l}]$.
Further $x | y \sim \pi(.)$ implies that the random variable $x$ if we conditioning on $y$ follows distribution $\pi(.)$.
The relevant variables in the model are the following:

	\begin{tabularx}{\linewidth}{ccL}
		Variable name & Dimension & Description \\  \hline
		$\mv{d}$ & $T \times 1$ & $d_i$ is the number of deaths that occurred day $i$. \\
		$\mv{r}$ & $T \times T$ & $r_{ij}$ is number of death recorded for day $i$ at day $j$.  Note that $r_{ij}$ for $i<j$ is not defined.   \\
		$\mv{p}$ & $T \times T$ & $p_{ij}$ is the probability of that a death for day $i$ not yet recorded is recorded at day $j$.
		  Note that $p_{ij}$ for $i<j$ is not defined.  \\
		$\mv{\alpha}$ & $K \times 1$ & Latent prior parameter for $\mv{p}$ \\
		$\mv{\beta}$ & $K \times 1$ & Latent prior parameter for $\mv{p}$ \\
		$\mv{\alpha}^H$ & $2 \times 1$ & parameter for the probability, $\mv{p}$ for holiday adjustment. \\
		$\mv{\beta}^H$ & $2 \times 1$ & parameter for the probability, $\mv{p}$ for holiday adjustment. \\
		$\mv{\mu}$ &  $T \times 1$ &  $\mu_i$  is the intensity of the expected number of deaths at day $i$. \\
		$\sigma^2$ & $1\times 1$ & Variation of the random walk prior for the log intensity. \\
		$\phi$ & $1\times 1$ & overdispersion parameter for negative binomial distribution. \\
		$p_0$ & $1\times 1$ & probability of reporting for a low reporting event. \\
		$pi$ & $1\times 1$ & probability of a low reporting event.
	\end{tabularx}
\subsection{likelihood}
The most complex part of our model is the likelihood, i.e. the density of the observations given the parameters. Here the data consist the daily report of recorded deaths for the past days. This can conveniently be represented upper triangular matrix, $\mv{r}$, where $r_{i,j}$ represents number of new reported deaths for day $i$ reported at day $j$. This matrix is displayed on the left in Table \ref{tab:Data}.

\begin{table}
	\centering
	\begin{tabular}{cccccc}
		\multicolumn{1}{c}{} & \multicolumn{5}{c}{Reported date}                                             \\
		\parbox[t]{2mm}{\multirow{5}{*}{\rotatebox[origin=c]{90}{Death date}}}   & $r_{11}$ & $r_{12}$ & $\cdots$ &$\cdots$  &  $r_{1T}$\\
		& & $r_{22}$ &  $\cdots$ & $\cdots$   &$r_{2T}$ \\
		& & &$r_{33}$ &  $\cdots$ &  $r_{3T}$ \\
		& & & &  $\ddots$ & $\vdots$  \\
		& & & &  &  $r_{TT}$ \\

	\end{tabular}

	\caption{The table describes the observations data.}
	\label{tab:Data}
\end{table}

 We assume that given the true number of deaths at day $i$, $d_i$, that each reported day $j$ the remaining death $d_i - \sum_{k=1}^{j-1}r_{i,k}$ each recored with probability $p_{ij}$, i.e. $$r_{i,j}|D_i,r_{1,1:j}.p \sim Bin(d_i - \sum_{k=1}^{j-1}r_{i,k}, p_{i,j}).$$

Typically in removal sampling one would set the probability of reporting uniform, i.e. $p_{i,j}:=p$. However for this data this is clearly not realistic given weekly patterns in reporting --very little reporting during the weekends. Instead we assume that we have $k$ different probabilities. Further, to account for overdispertion, we assume that each probability rather being a fixed scalar is a random variable with a Beta distribution. The Beta distribution has two parameters $\alpha$ and $\beta$. This resulting the following distribution for the probabilities
$$
p_{i,j}| \mv{\alpha},\mv{\beta}, \mv{\alpha}^H,\mv{\beta}^H  \sim Beta(\alpha^H_j\alpha_{min(j-i,k)},\beta^H_j\beta_{min(j-i,k)}).
$$
Here, if $j\in H$ then day $j$ is a holidays or weekends, and the parameters above are
$$
\alpha^H_j = \begin{cases}
\alpha_1^H \alpha_2^H & \mbox{if }  \{j\in H \}\cup  \{j-1\in H \},  \\
\alpha_1^H & \mbox{if }  \{j\in H \}\cup  \{j-1\in H^c \}, \\
\alpha_2^H & \mbox{if }  \{j\in H^c \}\cup  \{j-1\in H \}, \\
1 & \mbox{else,}
\end{cases}
$$
and
$$
\beta^H_j = \begin{cases}
\beta_1^H \beta_2^H & \mbox{if }  \{j\in H \}\cup  \{j-1\in H \},  \\
\beta_1^H & \mbox{if }  \{j\in H \}\cup  \{j-1\in H^c \}, \\
\beta_2^H & \mbox{if }  \{j\in H^c \}\cup  \{j-1\in H \}, \\
1 & \mbox{else.}
\end{cases}
$$
These extra parameters are created to account for the under-reporting that occurs during weekend and holidays.
Finally we add an extra mixture component that allows for very low reporting.

\subsection{Priors}
For the $\mv{\alpha}$ and $\mv{\beta}$ parameters we use an (improper) uniform prior. For the deaths, $\mv{d}$, one could imagine several different prior ideally some sort of epidemiological model. However, here we just assume a log-Gaussian Cox processes \citep{Moller1998_log_gaussian}, but instead of Poisson distribution we use a negative binomial to handle possible over dispersion. The latent Gaussian processes has a intrinsic random walk distribution \citep{Rue2005_gaussian_markov} i.e.
\begin{align*}
\log(\mu_i) - \log(\mu_{i-1}) &\sim N(0,\sigma^2),\\
d_i| \lambda_i  &\sim NegBin(\mu_i, \phi).
\end{align*}
This model is created to create a temporal smoothing between the reported deaths.
For the hyperparameter $\sigma^2$ we impose a inverse Gamma distribution, this prior is suitable here because it guarantees that the process is not constant ($\sigma^2=0$) which we know is not the case.
\subsection{Full model}
Putting the likelihood and priors together we get the following hierarchical Bayesian model
\begin{align*}
\sigma^2 &\sim \Gamma(1,0.01) \\
\phi &\sim \Gamma(1,0.01) \\
\alpha_k &\sim U[0,\infty] \\
\beta_k &\sim U[0,\infty] \\
\alpha_k^H &\sim U[0,\infty] \\
\beta_k^H &\sim U[0,\infty] \\
\log(\mu_i) - \log(\mu{i-1}) &\sim N(0,\sigma^2)\\
d_i| \lambda_i  &\sim NegBin(\mu_i,\phi) \\
p_{i,j}|  \mv{\alpha},\mv{\beta}, \mv{\alpha}^H,\mv{\beta}^H &\sim Beta(\alpha^H_j\alpha_{min(j-i,k)},\beta^H_j\beta_{min(j-i,k)}) \\
r_{i,j}|d_i,\mv{r}_{1,1:j},p &\sim \pi Bin(d_i - \sum_{k=1}^{j-1}r_{i,k},p_0)+ (1-\pi) Bin(d_i - \sum_{k=1}^{j-1}r_{i,k}, p_{i,j}),
\end{align*}
where where and $j\leq i$ and $i=1,\ldots,T$.

\section{Inference}
As the main goal to generate inference of the number of death $\mv{d}$ is through the posterior distribution of number of deaths $\mv{d}$ given the observations $\mv{r}$.
In order to generate samples from this distribution we use a Markov Chain Monte Carlo method \citep{Brooks2011_handbook_markov}. In more detail we use a blocked Gibbs sampler, which generates samples in the following sequence:
\begin{itemize}
	\item  We sample $\mv{\alpha},\mv{\beta}, \mv{\alpha}^H,\mv{\beta}^H|\mv{d}, \mv{r}$ using the fact that one can integrate out $p$ in the model, and then  $\mv{d}|\mv{\alpha},\mv{\beta}, \mv{\alpha}^H,\mv{\beta}^H,\mv{r},\mv{\lambda}$  follows a Beta-Binomial distribution. Here to we use an adaptive MALA \citep{Atchade2006_adaptive_version} to sample from these parameters.
	\item  To sample $\mv{d}|\mv{\alpha},\mv{\beta}, \mv{\alpha}^H,\mv{\beta}^H,\mv{r},\mv{\lambda}$, that each death, $d_i$ is conditionally independent, and we just use a Metropolis Hastings random walk to sample each one.
	\item To sample $\mv{\lambda} | \mv{d},\sigma^2$ we again use an adaptive MALA.
	\item Finally We sample $\sigma^2|\mv{d}$,and  $p_0,\pi$ directly since this distribution is explicit, and $\phi$ using a MH-RW.
\end{itemize}

\section{Model Benchmark}
In this section, we present additional comparison of the model to the benchmark. We first describe the benchmark model in detail.

The benchmark model simply takes the sum of average historical reporting lags for the preceding 14 days. As before $r_{ij}$ is the number of deaths that happened on day $i$ and were recorded on day $j$. To predict the number of people that died on a given day, we first calculate lag averages:

\begin{align}
    \hat{r}_{i, i+L} = \frac{\sum^{14}_{k=i-14} r_{k - L, k}}{14},
\end{align}

where $\hat{r}_{i, i+L}$ is the average number of deaths reported with a lag of $L$ days, based on the 14 reports closest preceding day $i$. If we are looking at data released $2020-04-28$ and call this day 0, the latest death date that we have 10-day ($L=10$) reporting lag observation for is $r_{-10,0}$. The average for $Lag(0, 10)$ is therefore taken over the 14 days between $r_{-24,-14}$ and $r_{-10,0}$ (2020-04-04 and 2020-04-18). For this reason, some of the earlier predictions will not have data from $14$ days. The average is then taken over all available reports.

In the comparisons we aim at predicting the total number of deaths that will have been reported within 14 days of the death date. To do so, we sum over the average lag that has yet to be reported. If we are predicting the number of people that have yet to be reported dead for day -3, we already know the true values for $r_{-3,-3}$, $r_{-3,-2}$, $r_{-3,-1}$, and $r_{-3,0}$ so we only need to predict $r_{-3,1}\ldots r_{-3,10}$. The prediction is then

\begin{align}
    Benchmark(i, j) = \sum_{l=i}^{j} r_{i,l}+ \sum_{l = j}^{14} \hat{r}_{i, l}.
\end{align}

As confidence interval we simply use a Normal assumption with standard deviations of the reporting lags, assuming independence, i.e. this is just the square root of the sum of $Var(\hat{r})$.

\begin{figure}
    \centering
    \includegraphics[width=0.9\textwidth]{plots/SCRPS_over_states}
    \caption{Average SCRPS as the pandemic progresses.}
    \label{fig:SCRPS_states}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[width=0.9\textwidth]{plots/SCRPS_over_weekdays}
    \caption{Average SCRPS per weekday.}
    \label{fig:SCRPS_weekdays}
\end{figure}


\input{../common/common.tex}

\title{Math notes - No consecutive integers}
\author{Uwe Hoffmann}
\hypersetup{colorlinks, pdftitle={Math notes - No consecutive integers}}

\begin{document}

\setcounter{chapter}{1}
\section*{No consecutive integers}

\newthought{Integer equations} and multisets are the topics of the problem \footnote{Variation of Problem 1-72. on page 45 in \bibentry{loehr2017combinatorics}} in this note.\index{integer equation}\index{multiset}

\vspace{10 mm}
\begin{problem}
Determine the number of subsets of size $k$ from set $\{1, 2, \ldots, n\}$ that do not contain consecutive integers.
\end{problem}

The number of subsets of size $k$ from set $\{1, 2, \ldots, n\}$ (without any constraints) is given by the binomial coefficient $\binom{n}{k}$. Each subset of size $k$ can be represented as a word of length $n$ from alphabet $\{\bigstar, \talloblong\}$ with $k$ $\talloblong$'s and $n-k$ $\bigstar$'s: if $i$ is in the subset then the corresponding word has a $\talloblong$ at position $i$ otherwise it has a $\bigstar$ at position $i$. This representation is clearly a bijection. The constraint of no consecutive integers in a subset implies no adjacent $\talloblong$'s in the corresponding word\footnote{For example given set $\{1, 2, 3, 4\}$ the subset $\{2, 4\}$ corresponds to $\bigstar\talloblong\bigstar\talloblong$. The subset $\{1, 2\}$ has consecutive integers and corresponds to $\talloblong\talloblong\bigstar\bigstar$. The reason why we chose $\talloblong$ to indicate inclusion into a subset will become clear soon.}.

We will now associate words from $\{\bigstar, \talloblong\}^n$ with other combinatorial objects: the integer equations.

\begin{defn}
Given fixed integers $m > 0$ and $t \geq 0$ a sequence $(z_1, z_2, \ldots, z_m)$ is an \textbf{integer equation} if $\forall i: 1 \leq i \leq m: z_i \in \mathbb{N}_0$ and
$$
\sum_{i = 1}^m z_i = t
$$
The number $t$ is called the \textbf{target}	of the integer equation.
\end{defn}

Note that these are sequences and order matters. From an integer equation $(z_1, z_2, \ldots, z_m)$ we construct a $\{\bigstar, \talloblong\}^{t + m - 1}$ word in the following way: start with $z_1$ number of $\bigstar$'s, then a $\talloblong$, then $z_2$ number of $\bigstar$'s, then a $\talloblong$ and so on finishing with the $z_m$ number of $\bigstar$'s which are \textbf{not} followed by a $\talloblong$. The word will contain exactly $t$ $\bigstar$'s and they will need exactly $m - 1$ $\talloblong$ separators to know which stars belong to which $z_i$. It's easy to verify that this encoding is also a bijection\footnote{As an example let $m = 5$ and target $t = 10$. The sequence $(1, 2, 1, 3, 3)$ is an integer equation since
$$
1 + 2 + 1 + 3 + 3 = 10
$$
and it corresponds to the word
$$
\bigstar\talloblong\bigstar\bigstar\talloblong\bigstar\talloblong\bigstar\bigstar\bigstar\talloblong\bigstar\bigstar\bigstar
$$
This in turn corresponds to the subset $\{2, 5, 7, 11\}$ of set $\{1, \ldots, 14\}$.}.

\begin{lem}\label{consec_ints_association}
If we set $t = n - k$ (the number of $\bigstar$'s) and from $t + m - 1 = n$ we get $m = k + 1$ (the word length) then we can associate subsets of size $k$ from set $\{1, 2, \ldots, n\}$ with integer equations $(z_1, z_2, \ldots, z_{k + 1})$ for target $n - k$. The constraint of not having consecutive integers in the subsets translates to integer equations $(z_1, z_2, \ldots, z_{k + 1})$ where $z_i > 0$ except for $z_1$ and $z_{k + 1}$ (the first and the last in the sequence). This follows from the encoding not allowing adjacent $\talloblong$'s so there need to be $\bigstar$'s separating the $\talloblong$'s.
\end{lem}

According to this association if we can count the number of integer equations with all but the first and last $z_i$ strictly positive then we also have the number of subsets with no consecutive integers. To get there we will first count the number of anagrams, then the number of multisets, then the number of integer equations and finally the number of integer equations with all but the first and last $z_i$ strictly positive. In what follows we will use $n$ and $k$ for other things before we bring it back in the end to our initial problem.

Let's start this journey with anagrams. Let $\{s_1, s_2, \ldots, s_k\}$ be an alphabet of distinct symbols. We can build words with these symbols, for example $s_2s_2s_1s_3s_3s_1$. As a notational convenience $s_is_is_i \ldots s_i=s_i^j$ if $s_i$ appears $j$ consecutive times in a word, so the example would be $s_2^2s_1s_3^2s_1$.

\begin{defn}
A word is an \textbf{anagram}\footnote{For example given word $a^2b$ the words $aba$ and $baa$ are anagrams of it. The word $abb$ is not.} of $s_1^{n_1}s_2^{n_2} \ldots s_k^{n_k}$ with $n_i > 0$ if it is a word containing exactly $n_i$ number of $s_i$ symbols for each $1 \leq i \leq k$. We denote with $\mathcal{A}(s_1^{n_1}s_2^{n_2} \ldots s_k^{n_k})$ the set of all anagrams of $s_1^{n_1}s_2^{n_2} \ldots s_k^{n_k}$.
\end{defn}

\begin{thm}\label{num_anagrams}
Given the set of anagrams $\mathcal{A}(s_1^{n_1}s_2^{n_2} \ldots s_k^{n_k})$  let $n = \sum_{i = 1}^k n_k$. Then
$$
|\mathcal{A}(s_1^{n_1}s_2^{n_2} \ldots s_k^{n_k})| = \binom{n}{n_1,n_2, \ldots, n_k}
$$
where $\binom{n}{n_1,n_2, \ldots, n_k}$ is the multinomial coefficient\footnote{The multinomial coefficient is defined as
$$
\binom{n}{n_1,n_2, \ldots, n_k} = \frac{n!}{\prod_{i = 1}^k n_i!}
$$}.
\end{thm}

\begin{proof}
We have $n$ positions in our word that we need to fill with symbols. We are going to make the following choices: first we choose $n_1$ positions from those $n$ positions where we fill in the symbol $s_1$. Then we choose the $n_2$ positions from the remaining unfilled positions where we fill in $s_2$ and so on. In total we make $k$ such choices and the number of remaining unfilled positions at each stage is independent of the previous choices, so the multiplication rule applies. For our first symbol $s_1$ we have $\binom{n}{n_1}$ possibilities, for our second symbol we have $\binom{n - n_1}{n_2}$ possibilities and so on. Because of the multiplication rule the total number of choices is the product of all these binomial coefficients, so
$$
|\mathcal{A}(s_1^{n_1}s_2^{n_2} \ldots s_k^{n_k})| = \prod_{i = 1}^k \binom{n - (\sum_{j = 1}^{i - 1})}{n_i}
$$

Expanding\footnote{After the binomial coefficients are expanded the product becomes a telescoping product that simplifies to exactly the multinomial coefficient.} the binomial coefficients on the right-hand side into factorials according to the binomial coefficient definition and simplifying the expression gives us the desired result.
\end{proof}

We move on to \textbf{multisets}. Informally multisets are sets (order does not matter) where each element can appear more than once. So given a set $A$ (the alphabet) a multiset is a tuple of $A$ together with a function $\mu: A \mapsto \mathbb{N}$ that determines how often an element $a \in A$ appears in the multiset. For notational convenience we will use curly braces and list elements (with exponents if they appear more than once). For example $\{a^2, b, c^4\}$ is a multiset where $a$ appears twice, $b$ once and $c$ four times. Note that order does not matter, so $\{a^2, b, c^4\}$ is the same multiset as $\{b, a^2, c^4\}$. The size of the multiset is the number of elements in it with elements appearing more than once counted accordingly, so
$$
|(A, \mu)| = \sum_{a \in A} \mu(a)
$$

\begin{thm}\label{num_multisets}
The number of multisets of size $k$ from an alphabet set of size $n$ is\footnote{For example with alphabet set $\{a, b\}$ the multisets of size two are $\{a^2\}$, $\{b^2\}$, $\{a, b\}$, so there are three of them.}
$$
\binom{k + n - 1}{k}
$$
\end{thm}

\begin{proof}
We will do an encoding of multisets to anagrams similar to what we did at the beginning of this section with $\bigstar$'s and $\talloblong$'s. To avoid confusion with that previous encoding in this proof we will use the symbols $\circ$ and $|$.

Let $A=\{a_1, a_2, \ldots, a_n\}$ be our alphabet. For a multiset $(A, \mu)$ with size $k$ we define the following word\footnote{The multisets from the previous example would be encoded as follows:
\begin{align*}
\{a^2\} & \mapsto \circ\circ|\\
\{b^2\} & \mapsto |\circ\circ\\
\{a, b\} & \mapsto \circ|\circ
\end{align*}} with symbols $\{\circ,|\}$:
$$
\circ^{\mu(a_1)}|\circ^{\mu(a_2)}| \ldots |\circ^{\mu(a_n)}
$$
The first circles denote how often $a_1$ is in the multiset. They are separated by a $|$ from the circles that denote how often $a_2$ is in the multiset and so on. In total there are $k$ circles because the multiset has size $k$ and there need to be $n-1$ separators because the alphabet has size $n$ and the circles for each element need to be kept apart. It's easy to see that we have defined a bijection from the set of multisets of size $k$ with alphabet of size $n$ to the set of anagrams $\mathcal{A}(\circ^k|^{n-1})$. From theorem \ref{num_anagrams} we already know how to count the size of $\mathcal{A}(\circ^k|^{n-1})$ and with the bijection it proves this theorem.
\end{proof}

Our next stop are the number of integer equations. Given $m$ and $t$ how many integer equations $(z_1, z_2, \ldots, z_m)$ for target $t$ are there?

\begin{thm}\label{num_int_equations}
The number of integer equations $(z_1, z_2, \ldots, z_m)$ for target $t$ is
$$
\binom{t + m - 1}{t}
$$
\end{thm}

\begin{proof}
We will associate a multiset with each integer equation\footnote{For example with $m = 5$ and target $t = 10$ the integer equation $(1, 2, 1, 3, 3)$ would correspond to multiset $\{1, 2^2, 3, 4^3, 5^3\}$.}. The multiset will contain the element $i$ $z_i$ many times, for $1 \leq i \leq m$. Again it can be checked that this defines a bijection. These multisets belong to the set of multisets of size $t$ from an alphabet of size $m$ and theorem \ref{num_multisets} counts them. By the bijection rule we have proven this theorem.
\end{proof}

We are almost done. In the beginning of this section we encoded our subsets without consecutive integers as integer equations with all but the first and last summand strictly positive. So we need to count these types of integer equations with this constraint.

\begin{thm}\label{num_int_equations_pos}
The number of integer equations $(y_1, y_2, \ldots, y_m)$ for target $t$ with $y_i > 0$ for all $1 < i < m$ is
$$
\binom{t + 1}{m - 1}
$$
\end{thm}

\begin{proof}
For an integer equation $(y_1, y_2, \ldots, y_m)$ we have $\sum_{i = 1}^m y_i = t$ and $y_i > 0$ for all $1 < i < m$. So we can write
$$
y_1 + \sum_{i = 2}^{m-1} (y_i - 1) + y_m = t - (m - 2)
$$
This shows that we can transform the integer equations with the strictly positive constraints into normal integer equations without constraints but with a new target. This again is a bijection. We know how to count these from theorem \ref{num_int_equations}. The new target is $t - m + 2$. Plugging it in we get
$$
\binom{t - m + 2 + m - 1}{m - 1} = \binom{t + 1}{m - 1}
$$
\end{proof}

Using \ref{num_int_equations_pos} and $t = n - k$ and $m = k + 1$ as described by our association \ref{consec_ints_association} of subsets of size $k$ without consecutive integers from set $\mathbb{N}_n$ to integer equations with all but the first and last strictly positive terms, we are finally able to solve the problem in this section. The answer is $\binom{n - k + 1}{k}$.

\bibliographystyle{plainnat}
\bibliography{../common/math}

\end{document}


\chapter{Statistical model}
    \label{chapter:StatisticalModel}

This chapter describes the statistical treatment that is used in the analysis to calculate the normalization of the different background processes, the new physics signal strength, and to estimate the uncertainties.
The general procedure to search for new phenomena is also explained.

\section{Preliminary}
    \label{sec:StatisticsPreliminary}

Some simple case examples are studied first as a way to introduce the complete statistical machinery that will be used in the analysis.

\subsection{One signal region only}

A single region is considered, in which only one signal and one background process are present.
If the presence of any systematic effect is neglected, the probability of finding $n$ data events assuming $B$ expected background events and $S$ expected signal events, the latest normalized with a ``signal strength'', $\mu_s$, follows a Poissonian distribution, and is found to be:

\begin{equation}
P(n | \mu_s S + B) = \frac{(\mu_s S + B)^n}{n!} \exp{\left[-(\mu_s S + B)\right]}.
\label{eq:simplifiedPoisson}
\end{equation}

In the case where $\mu_s=0$, the signal yield is forced to be zero, thus corresponding to a ``background-only'' hypothesis.
On the other hand, $\mu_s=1$ corresponds to the nominal ``signal+background'' hypothesis \cite{Cranmer:2012sba}.
If the probability $P(n | \mu_s S + B)$ is regarded as a function of $\mu_s$, then it is called the likelihood of $\mu_s$, $L(\mu_s)$.
In particular, the maximization of this likelihood function (or equivalently, the minimization of this minus log-likelihood function),

\begin{equation}
-\ln{L(\mu_s)} = -n \ln{(\mu_s S + B)} + (\mu_s S + B) + \ln{n!},
\label{eq:simplifiedLogLikelihood}
\end{equation}

\noindent determines the optimal value for $\mu_s$.

\subsection{Multiple regions, one background process}

The previous example can be extended by considering the background to be corrected by a normalization factor, $\mu_b$, extracted from a calibration measurement in a control region.
Therefore, two regions are considered: a signal region, defined to enhance the signal process, and a control region, orthogonal to the signal region and optimized to enhance the background process.
The probability for finding $\vec{n} = (n_{\text{SR}}, n_{\text{CR}})$ data events assuming $\vec{B} = (B_{\text{SR}}, B_{\text{CR}})$ expected background events and $\vec{S} = (S_{\text{SR}}, S_{\text{CR}})$ expected signal events in both regions is:

\begin{equation}
\begin{split}
P(\vec{n} | \mu_s \vec{S} + \mu_b\vec{B}) &= \frac{(\mu_s S_{\text{SR}} + \mu_b B_{\text{SR}})^{n_{\text{SR}}}}{n_{\text{SR}}!} \exp{\left[-(\mu_s S_{\text{SR}} + \mu_b B_{\text{SR}})\right]} \\
& \times \frac{(\mu_s S_{\text{CR}} + \mu_b B_{\text{CR}})^{n_{\text{CR}}}}{n_{\text{CR}}!} \exp{\left[-(\mu_s S_{\text{CR}} + \mu_b B_{\text{CR}})\right]} ,
\end{split}
\label{eq:simplifiedPoissonControlRegion}
\end{equation}

\noindent where $\mu_s$ and $\mu_b$ are the scale factors for the signal and background processes respectively.
From this probability, the following minus log-likelihood function is derived:

\begin{equation}
\begin{split}
-\ln{L(\mu_s, \mu_b)} =& -n_{\text{SR}} \ln{(\mu_s S_{\text{SR}} + \mu_b B_{\text{SR}})} + (\mu_s S_{\text{SR}} + \mu_b B_{\text{SR}}) \\
                       & -n_{\text{CR}} \ln{(\mu_s S_{\text{CR}} + \mu_b B_{\text{CR}})} + (\mu_s S_{\text{CR}} + \mu_b B_{\text{CR}}) \\
                       & + \ln{n_{\text{SR}}!} + \ln{n_{\text{CR}}!}.
\end{split}
\label{eq:simplifiedLogLikelihoodControlRegion}
\end{equation}

The minimization of $-\ln{L(\mu_s, \mu_b)}$ leads to a system of equations from which the two normalization factors, $\mu_s$ and $\mu_b$ can be computed.

\subsection{Multiple regions, several background processes}
    \label{subsec:StatisticsMultipleRegionsNoSystematics}

The example from the previous subsection can be generalized to having more than one background, normalized with more than one normalization factor.
As a simplification, the signal yield in all the control regions will be considered negligible, $\vec{S} = (S_{\text{SR}}, 0, \ldots)$.
Then, the probability for finding $\vec{n} = (n_\text{SR}, n_\text{CR1}, \ldots)$ data events assuming $\mu_s \cdot \vec{S} + \vec{\mu_b}\cdot \hat{B}$ expected events in the different regions, is found to be:

\begin{equation}
\begin{split}
P(\vec{n} | \mu_s \cdot \vec{S} + \vec{\mu_b}\cdot \hat{B}) &= \frac{(\mu_s S_{\text{SR}} + \sum_{b}^{\text{bkg}}{\mu_{b} B_{{\text{SR}}b}})^{n_{\text{SR}}}}{n_{{\text{SR}}}!} \exp{\left[-(\mu_s S_{{\text{SR}}} + \sum_{b}^{\text{bkg}}{\mu_{b} B_{{\text{SR}}b}})\right]} \\
& \times \prod_{i}^{\text{control}}{ \frac{\left(\sum_{b}^{\text{bkg}}{\mu_{b} B_{ib}}\right)^{n_{i}}}{n_{i}!}} \exp{\left[-\sum_{b}^{\text{bkg}}\mu_{b} B_{ib}\right] }.
\end{split}
\label{eq:simplifiedPoissonSeveralBkg}
\end{equation}

From the previous equation, the likelihood function of $\vec{\mu} = (\mu_s, \mu_{b_1}, \ldots)$ is determined:

\begin{equation}
L(\vec{\mu}) =
 \prod_{c \in \text{regions}}{\frac{[\nu_c(\vec{\mu})]^{n_c}}{n_c!}e^{-\nu_c(\vec{\mu})}},
\label{eq:generalLikelihoodNoSystematics}
\end{equation}

\noindent where $n_c$ are the number of observed events in the region $c$, and

\begin{equation}
\nu_c = \mu_s S_c + \sum_{j}^{\text{bkg}}{\mu_{b,j}B_{c,j}} = \sum_{s}^{\text{samples}}{\mu_s \nu_{cs}^0},
\label{eq:definitionNuSimple}
\end{equation}

\noindent being $\nu_{cs}^0$ the nominal number of events for the process $s$, in the signal or control region $c$.
Equation~\ref{eq:generalLikelihoodNoSystematics} provides a general likelihood function for a model in which several processes normalized with different normalization factors are measured in different regions, ignoring the effect of any systematic uncertainty.

\subsection{Parametrization of the systematic uncertainties}
    \label{subsec:StatisticsSystematicSimplified}

The expected number of events for a process $s$, in a given region, $c$, can be written as $\eta_{cs} \nu_{cs}^0$, being $\nu_{cs}^0$ the expected nominal yield.
The factor $\eta_{cs}$ is the the relative variation with respect to the nominal expectation due to any systematic effect, and can be regarded as a function of a \emph{nuisance parameter}, $\alpha_p$, which parametrizes the ``number of standard deviations''.

As detailed in Ref.~\cite{Cranmer:2012sba}, different parametrization functions for $\eta_{cs}(\alpha_p)$ can be used, providing that $\eta_{cs}(0)=1$ (by definition, a variation of zero standard deviations must return the nominal yield), and $\eta_{cs}(\pm 1)$ returns exactly the $\pm 1$ standard deviation effect of the systematic uncertainty under study, determined with an auxiliary measurement.

In this example, the nuisance parameter $\alpha_p$ is considered normally distributed according to the probability density function:

\begin{equation}
P(a_p | \alpha_p, \sigma_p) = \frac{1}{\sqrt{2\pi\sigma_p^2}} \exp{\left(-\frac{(a_p - \alpha_p)^2}{2\sigma_p^2}\right)},
\label{eq:simplifiedAlphaParametersPDF}
\end{equation}

\noindent  where $a_p$ is the central value of the auxiliary measurement around which the $\alpha_p$ with standard deviation $\sigma_p$ can be varied when maximizing the likelihood.
The auxiliary measurement $a_p$ and the standard deviation of the gaussian, $\sigma_p$, are typically fixed to 0 and 1, respectively.

The introduction of systematic uncertainties in the analysis implies that the likelihood from Equation~\ref{eq:generalLikelihoodNoSystematics} needs to be multiplied by the PDF from Equation~\ref{eq:simplifiedAlphaParametersPDF}.
This introduces a dependence on $\alpha$ in the sample yields, $\nu_{cs}$.

\section{Complete statistical treatment}
    \label{sec:StatisticalTreatment}

The complete statistical treatment of the analysis is based on the profile likelihood method, which results from the combination and generalization of the simplified examples discussed above.
This method allows to determine the normalization factors to be applied to estimate the different processes as well as the systematic variations and the correlations among them.
As in the previous examples, no shape information is used in the analysis presented in this Thesis: the distributions in the signal and control regions consist of just one single bin.

\subsection{Parametrization of the model}
    \label{subsec:ParametrizationModel}

The signal and the backgrounds in the different region definitions, as well as the systematic uncertainties under consideration are parametrized by the likelihood function (see Equations~\ref{eq:generalLikelihoodNoSystematics} and \ref{eq:simplifiedAlphaParametersPDF}, in the previous section):

\begin{equation}
L(\vec{\mu}, \vec{\alpha}) =
 \prod_{c \in \text{regions}}{\frac{[\nu_c(\vec{\mu}, \vec{\alpha})]^{n_c}}{n_c!}e^{-\nu_c(\vec{\mu}, \vec{\alpha})}}
 \prod_{p\in\text{params}}{P_p(\alpha_p)},
\label{eq:PdfFit}
\end{equation}

\noindent where $n_c$ are the number of events measured in each region, $\vec{\mu}$ is the set of normalization factors used to normalize the different background and signal processes, and $\vec{\alpha}$ is a set of nuisance parameters that parametrize the different systematic uncertainties.
Furthermore, $\nu_c$ are the number of events expected in each region, in particular (see Equation~\ref{eq:definitionNuSimple}):

\begin{equation}
\nu_c(\vec{\mu}, \vec{\alpha}) = \sum_{s\in\text{samples}}{\mu_s(\vec{\alpha})\;\eta_{cs}(\vec{\alpha})\;\nu^0_{cs}},
\label{eq:nuInPdfFit}
\end{equation}

\noindent where $\nu^0_{cs}$ is the expected nominal number of events and $\eta_{cs}$ is the parametrized normalization uncertainty, that depend on the nuisance parameters $\vec{\alpha}$.
Finally, $P_p$ is a constraining term, that describes an auxiliary measurement to used constrain the nuisance parameter $\alpha_p$.
In the present analysis, the constraining term is assumed to be a gaussian, except for the nuisance parameters dedicated to the statistical uncertainties, which are poissonian distributed.

The maximization of this function allows to calculate the normalization factors and nuisance parameters used to estimate the yield of each process and the level of systematics in the different regions.
In the analysis, three fit configurations will be used for different purposes \cite{Baak:2014wma}:

\paragraph{Background-only fit:}Only the control regions are used to constrain the fit parameters.
Any potential signal contribution is neglected everywhere ($\mu_\text{signal} = 0$).
This fit is used to extract the normalization factors of the background processes and their systematic uncertainties.

\paragraph{Model independent signal fit:}Both control and signal regions are used in the fit.
The signal is independently considered in each signal region but neglected in the control regions.
This background prediction is conservative since any signal contribution in the control regions is attributed to background and thus results in a possible overestimation of the background in the signal regions.
In this analysis this contribution is negligible due to the requirement of leptons in the control regions.
This fit configuration is used to extract the 95\%~CL model independent upper limits on the visible cross section.

\paragraph{Model dependent signal fit:}Both control and signal regions are used in the fit.
The signal contribution is taken into account as predicted by the tested model in all the regions.
The model dependent signal fit configuration is used to interpret the results of this analysis in terms of the different new physics models that are studied.

\section{Statistical tests}
    \label{subsec:StatisticalTests}

This section describes the general procedure used to search for a new phenomena in the context of a frequentist statistical test.
If the purpose of the analysis is to discover a new signal process, the null hypothesis, $H_0$, is defined as describing the known SM processes, to be tested against $H_1$, which includes both background as well as the signal model.
Instead, if the purpose of the analysis is to set limits on a signal process, the model with signal plus background plays the role of $H_0$, tested against the background-only hypothesis, $H_1$.
In the outcome of such search, the level of agreement of the observed data with a given hypothesis $H$ is quantified by computing the probability, under the assumption of $H$, of finding data with equal or less incompatibility with the prediction of $H$.

According to Equation \ref{eq:nuInPdfFit}, each process is multiplied by a normalization factor, $\mu$.
A background-only hypothesis is constructed by fixing $\mu_\text{signal}=0$, while a signal+background hypothesis will be defined as having $\mu_\text{signal}\gt0$.
To test an hypothesized value of $\mu$, the profile likelihood can be defined as the ratio:

\begin{equation}
\lambda(\mu) = \frac{L(\mu, \vec{\hat{\hat{\theta}}})}{L(\hat{\mu}, \vec{\hat{\theta}})},
\label{eq:profileLikelihood}
\end{equation}

\noindent where $\mu$ here is the shortcut for $\mu_\text{signal}$ and $\vec{\theta}\supset\{\mu_{\text{no signal}}, \vec{\alpha}\}$.
$\vec{\hat{\hat{\theta}}}$ in the numerator denotes the value of $\vec{\theta}$ that maximizes $L$ for the specified $\mu$ (it is a conditional maximum likelihood estimator of $\theta$, and therefore a function of $\mu$).
The denominator is the maximized (unconditional) likelihood function.
Based on Equation~\ref{eq:profileLikelihood}, the test statistic $q_\mu$ is defined as:

\begin{equation}
q_\mu = -2\ln{\lambda(\mu)}.
\label{eq:testStatistic}
\end{equation}

Higher values of $q_\mu$ correspond to increasing compatibility between the data and $\mu$.
The $p$-value, defined to quantify the level of agreement between the data and the different hypotheses, is defined as:

\begin{equation}
p_\mu = \int_{q_{\mu,\;\text{obs}}}^{\infty}{f(q_\mu|\mu')\;dq_\mu},
\label{eq:pValueDefinition}
\end{equation}

\noindent where $f(q_\mu|\mu')$ denotes the PDF of $q_\mu$ under the assumption of the signal strength $\mu'$.
The estimations of $f(q_\mu|\mu')$ can be done with pseudo-experiments using Monte Carlo methods (Toy MC).
These methods are computationally heavy, especially when upper limits are calculated.
For this reason, an approximation valid in the large sample limit is normally used to describe the profile likelihood ratio instead (asymptotic approximation).

In the large sample limit, where the asymptotic approximation becomes exact, the PDF of $q_\mu$ assuming that the fitted strength parameter $\hat{\mu}$ follows a gaussian of mean $\mu'$ and standard deviation $\sigma$ is found to be \cite{Cowan:2010js}:

\begin{equation}
\begin{split}
&f(q_\mu|\mu')  =
\frac{1}{2\sqrt{q_\mu}}\frac{1}{\sqrt{2\pi}} \times \\
& \left[\exp{\left(-\frac{1}{2}\left(\sqrt{q_\mu}+\frac{\mu-\mu'}{\sigma}\right)^2 \right)}
+ \exp{\left(-\frac{1}{2}\left(\sqrt{q_\mu}-\frac{\mu-\mu'}{\sigma}\right)^2 \right)} \right].
\end{split}
\label{eq:pdfTestStatistic}
\end{equation}

Figure~\ref{fig:pdfTestStatisticExample} illustrates the previous equation, for the particular case of $q_{\mu=1}$ under a signal plus background and a background-only hypotheses, namely $\mu'=1$ and $\mu'=0$, respectively.
In this example, the requirement that the $p$-value computed from the $f(q_{\mu=1}|1)$ PDF is smaller than 0.05, would be enough to exclude the signal model at 95\% confidence level (CL).
However, the PDFs for both hypotheses could be similar.
These are cases in which the analysis has very low sensitivity and the effect produced by a statistical fluctuation could allow the exclusion of both the null (in this case, the signal plus background) and the alternate (background-only) hypotheses at the same time.
In an attempt to address this spurious exclusion, the $CL_s$ method is developed.
The $CL_s$ solution bases the test not only on the rejection of the null hypothesis but rather in the $p$-value of the null hypothesis divided by one minus the p-value of the alternate hypothesis.
Following the same illustrative example from Figure~\ref{fig:pdfTestStatisticExample}, in which the existence of a given signal model is tested, the $CL_{s+b}$, $CL_{b}$ and $CL_{s}$ can be defined, respectively, as:

\begin{equation}
\begin{split}
CL_{s+b} = p_{s+b} \\
CL_{b} = 1-p_{b} \\
CL_{s} = \frac{CL_{s+b}}{CL_{b}}.
\end{split}
\label{eq:CLsDefinition}
\end{equation}

\begin{figure}[!t]
  \begin{center}
    \mbox{
      \includegraphics[width=0.75\textwidth]{MonojetAnalysis/Figures/pdfTestHypothesisExample.eps}
    }
  \end{center}
  \caption[Illustration of the PDF of $q_{\mu}$ under the signal plus background and background-only hypotheses.]{Illustration of the PDF of $q_{\mu=1}$ under two different hypothesis: signal plus background (null, $\mu=1$) and background-only (alternative, $\mu=0$). The $CL_{s+b}$, $CL_b$ and $CL_s$ are also shown for this particular example.}
  \label{fig:pdfTestStatisticExample}
\end{figure}

In the work presented in this thesis, the $CL_s$ is calculated for each signal model under evaluation.
The models for which $CL_s < 0.05$, are excluded at 95\% CL.
With the $CL_s$ method, $CL_s \approx CL_{s+b}$ in the cases where the analysis is sensitive to the signal process under study.
Instead, in the cases where the analysis is insensitive, $CL_b$ is be small, thus increasing the value of $CL_s$ and therefore avoiding the exclusion of the signal model.


%!TEX root = ./jctt.tex

\subsection{Mixed Finite-Element Method for VEF Equation}
\begin{figure}
	\centering
	% \def\svgwidth{\textwidth}
	\input{figs/mfemgrid.pdf_tex}
	\caption{The distribution of unknowns in cell $i$ for MFEM. }
	\label{fig:mfem_grid}
\end{figure}
We apply the MFEM method to Eqs.~\ref{eq:zero} and \ref{eq:first} and then eliminate the currents to obtain a discretization for Eq.~\ref{eq:drift}.  In this
method, the grid is identical to that used in the LLDG \SN discretization. The unknowns in an MFEM cell are depicted in Fig.~\ref{fig:mfem_grid}. In MFEM, separate basis functions are used for the scalar flux and
current. The scalar flux is constant within the cell with discontinuous jumps at the cell edges and the current is a linear function defined by:
	\begin{equation} \label{eq:MFEM_current}
		J_i(x) = J_{i,L} B_{i,L}(x) + J_{i,R} B_{R,i}(x) \,,
	\end{equation}
where $J_{i,L/R}$ are the currents at the left and right edges of the cell, and the basis functions are identical to those
defined by Eqs.~\ref{eq:bfunL} and \ref{eq:bfunR} for the LLDG \SN discretization. The constant-linear MFEM yields second
order accuracy for both the scalar flux and the current.

The MFEM representation yields five unknowns per cell: $\phi_{i-1/2}$, $\phi_i$, $\phi_{i+1/2}$, $J_{i,L}$, and $J_{i,R}$. However,
each edge flux on the mesh interior is shared by two cells, so with $I$ cells there are $I$ cell-center scalar fluxes, $2I$ currents,
$2I-1$ interior-mesh cell-edge scalar fluxes, and 2 boundary cell-edge scalar fluxes. An equation for $\phi_i$ is found by integrating Eq.~\ref{eq:zero} over cell $i$:
	\begin{equation} \label{mfem:balance}
		J_{i,R} - J_{i,L} + \sigma_{a,i} h_i \phi_i = Q_i h_i \,,
	\end{equation}
where $\sigma_{a,i}$ and $Q_i$ are the absorption cross section and source in cell $i$. Equations for $J_{i,L/R}$ are found by multiplying Eq.~\ref{eq:first} by $B_{i,L/R}$ and integrating over cell $i$:
	\begin{subequations}
		\begin{equation} \label{mfem:bli}
			-\edd_{i-1/2} \phi_{i-1/2} + \edd_i \phi_i + \sigma_{t,i} h_i \left(\frac{1}{3} J_{i,L} + \frac{1}{6}J_{i,R}\right) = 0 \,,
		\end{equation}
		\begin{equation} \label{mfem:bri}
			\edd_{i+1/2} \phi_{i+1/2} - \edd_i \phi_i + \sigma_{t,i} h_i \left(\frac{1}{6} J_{i,L} + \frac{1}{3} J_{i,R}\right) = 0 \,.
		\end{equation}
	\end{subequations}
All Eddington factors are computed using the angular fluxes from the LLDG \SN step. Note that $\edd_{i\pm 1/2}$ denotes cell edge Eddington factors, while
$\edd_{i}$ denotes an average over cell $i$ of the Eddington factors. The edge Eddington factors are defined by Eq.~\ref{lldg:edde}, while the Eddington factors within each cell
are defined by Eq.~\ref{lldg:eddi}. We stress that evaluating Eq.~\ref{lldg:eddi} at $x_{i\pm1/2}$ does not yield $\edd_{i\pm 1/2}$
because of the upwinding used to define the cell edge angular fluxes. The spatial dependence of the Eddington factors within each cell takes the form of a rational polynomial prompting the use of numerical quadrature to compute the average. Two point Gauss quadrature was used:
	\be
	\edd_{i} = \frac{1}{2} \bracket{ \langle \mu^2 \rangle (x^G_{i,L}) + \langle \mu^2 \rangle (x^G_{i,R}) }
	\ee
where
\begin{equation}
		% x^G_{i,L/R} = \frac{h_i}{2} \mp \frac{x_{i+1/2} + x_{i-1/2}}{2\sqrt{3}} \,.
		x^G_{i,L/R} = \frac{x_{i+1/2} + x_{i-1/2}}{2} \mp \frac{h_i}{2\sqrt{3}} \,.
\end{equation}

Eliminating $J_{i,R}$ from Eq.~\ref{mfem:bli} and $J_{i,L}$ from Eq.~\ref{mfem:bri} yields:
	\begin{subequations}
		\begin{equation} \label{mfem:jli}
			J_{i,L} = \frac{-2}{\sigma_{t,i} h_i} \bigg\{
				2\br{\eddphi{i} - \eddphi{i-1/2}}
				- \br{\eddphi{i+1/2} - \eddphi{i}}
			\bigg\} \,,
		\end{equation}
		\begin{equation} \label{mfem:jri}
			J_{i,R} = \frac{-2}{\sigma_{t,i} h_i} \bigg\{
				2\br{\eddphi{i+1/2} - \eddphi{i}}
				- \br{\eddphi{i} - \eddphi{i-1/2}}
			\bigg\} \,.
		\end{equation}
	\end{subequations}
An equation for $\phi_{i+1/2}$ on the mesh interior is found by enforcing continuity of current at the cell edges:
	\begin{equation} \label{mfem:continuity}
		J_{i,R} = J_{i+1, L} \,.
	\end{equation}

Using the definitions of $J_{i,L}$ and $J_{i,R}$ from Eqs.~\ref{mfem:jli} and \ref{mfem:jri} in the balance equation (Eq.~\ref{mfem:balance}) and continuity equation (Eq.~\ref{mfem:continuity}) yields equations for all cell-center fluxes and
interior-mesh cell-edge fluxes, respectively.  The resulting balance equation for cell $i$ and continuity equation for
edge $i+1/2$ are respectively:
	\begin{subequations}
		\begin{equation} \label{mfem:center}
			-\frac{6}{\sigma_{t,i}h_i} \edd_{i-1/2} \phi_{i-1/2}
			+ \left(\frac{12}{\sigma_{t,i}h_i} \edd_i + \sigma_{a,i} h_i\right) \phi_i
			- \frac{6}{\sigma_{t,i} h_i} \edd_{i+1/2} \phi_{i+1/2}
			= Q_i h_i \,,
		\end{equation}
		and
		\begin{multline} \label{mfem:edge}
			-\ALPHA{2}{i} \eddphi{i-1/2} + \ALPHA{6}{i} \eddphi{i}
			- 4\paren{\ALPHA{1}{i} + \ALPHA{1}{i+1}} \eddphi{i+1/2} \\
			+ \ALPHA{6}{i+1}\eddphi{i+1}
			- \ALPHA{2}{i+1} \eddphi{i+3/2}
			= 0 \,.
		\end{multline}
	\end{subequations}
The equations for the outer boundary fluxes, $\phi_{1/2}$ and $\phi_{I+1/2}$, involve boundary conditions together with continuity conditions.  For instance,
the equation for $\phi_{1/2}$ is
\begin{equation}
		J_{1,L} = J_{1/2} \,,
\end{equation}
where $J_{1,L}$ is defined by Eq.~\ref{mfem:jli}, and $J_{1/2}$ is the left boundary current defined by a boundary condition.  For a reflective condition,
\begin{equation}
    J_{1/2} = 0 \, .
\end{equation}
For a source condition,
\begin{equation}
		J_{1/2} = 2 \sum_{\mu_n>0} \mu_n \psi_{n,1/2} w_n - B_{1/2} \phi_{1/2} \,,
\end{equation}
 where
\begin{equation}
		B_{1/2} = \frac{\sum_{n=1}^N |\mu_n| \psi_{n,1/2} w_n}{
			\sum_{n=1}^N \psi_{n,1/2} w_n
		}
\end{equation}
is the boundary Eddington factor \cite{QDBC}.  The equation for  $\phi_{I+1/2}$ is
\begin{equation}
		J_{I,R} = J_{I+1/2} \, .
\end{equation}
where $J_{I,R}$ is defined by Eq.~\ref{mfem:jri}, and $J_{I+1/2}$ is the right boundary current.  For a reflective condition,
\begin{equation}
    J_{I+1/2} = 0 \, .
\end{equation}
For a source condition,
\begin{equation}
		J_{I+1/2} = B_{I+1/2} \phi_{I+1/2} - 2 \sum_{\mu_n<0} |\mu_n| \psi_{n,I+1/2} w_n  \,,
\end{equation}
where
\begin{equation}
		B_{I+1/2} = \frac{\sum_{n=1}^N |\mu_n| \psi_{n,I+1/2} w_n}{
			\sum_{n=1}^N \psi_{n,I+1/2} w_n
		} \, .
\end{equation}

These transport-consistent, Marshak-like source boundary conditions are derived starting with the identity
\begin{equation}
J_{1/2}=j^+ - j^- \,,
\end{equation}
where $j^\pm$ denotes the positive half-range currents associated with $\mu >0$ and $\mu <0$, respectively.  For the left boundary condition, we simply perform the following algebraic manipulations:
\begin{equation}
J_{1/2} = j^+ - j^-  = 2j^+ - (j^+ + j^-) = 2j^+ - \frac{j^+ + j^-}{\phi} \phi = 2j^+ - B_{1/2} \phi  \, .
\end{equation}
For the right boundary condition, we similarly obtain
\begin{equation}
J_{I+1/2} = j^+ - j^-  = (j^+ + j^-) - 2j^- = \frac{j^+ + j^-}{\phi} \phi - 2j^- = B_{I+1/2} \phi - 2j^-\, .
\end{equation}
Note that these source boundary conditions become equivalent to the standard Marshak boundary conditions if the \SN angular flux
is isotropic.
The resulting system of $2I+1$ equations for the cell-center and cell-edge fluxes can be assembled into a matrix of both cell-center and cell-edge scalar fluxes and solved with a banded matrix solver of bandwidth five. The resulting drift-diffusion scalar flux can either be used as the final solution if the solution has converged or as an update to the LLDG \SN scattering source. Use of these piecewise-constant fluxes to represent the LLDG \SN scattering source is the default method, and is referred to as the flat update method.

% Applying the MFEM to Eqs.~\ref{eq:zero} and \ref{eq:first} and enforcing continuity of current yields:
% 	\begin{subequations} \label{eq:mfem}

% 	\begin{multline}
% 		-\frac{2}{\sigma_{t,i} h_i} \edd_{i-1/2}\phi_{i-1/2} +
% 		\frac{6}{\sigma_{t,i} h_i} \edd_i \phi_i
% 		- 4\left(\frac{1}{\sigma_{t,i} h_i} + \frac{1}{\sigma_{t,i+1} h_{i+1}}\right)
% 			\edd_{i+1/2} \phi_{i+1/2}
% 		\\ + \frac{6}{\sigma_{t,i+1} h_{i+1}} \edd_{i+1} \phi_{i+1}
% 		- \frac{2}{\sigma_{t,i+1} h_{i+1}} \edd_{i+3/2} \phi_{i+3/2}
% 		= 0 \,,
% 	\end{multline}
% 	\end{subequations}
% where the Eddington factor is evaluated at iteration $\ell+1/2$ and the scalar flux at $\ell+1$.
% Here, the Eddington factor has been assumed to be constant in each cell with discontinuous jumps at the edges.
% The simplest method of converting the Eddington factor from LLDG to MFEM is to compute the Eddington factor using the cell centered and cell edged angular fluxes using Eqs.~\ref{eq:lldg_i}, \ref{eq:downwind}, and \ref{eq:upwind}. A more consistent way to transfer the Eddington factor is to represent the LLDG angular flux as a linear function using the MFEM basis functions:
% 	\begin{equation} \label{eq:eddquad}
% 		\edd_i(x) = \frac{
% 			\sum_{n=1}^N \mu_n^2 \left[\psi_{n,i,L}B_{i,L}(x) + \psi_{n,i,R} B_{i,R}(x)\right]
% 		}
% 		{
% 			B_{i,L}(x) \sum_{n=1}^N w_n \psi_{n,i,L} + B_{i,R}(x) \sum_{n=1}^N w_n \psi_{n,i,R}
% 		} \,,
% 	\end{equation}
% where

% and

% When MFEM is applied, the integral over cell $i$ of the rational polynomial given in Eq.~\ref{eq:eddquad} is approximated with 2 point Gauss quadrature. The cell centered Eddington factors used in Eq.~\ref{eq:mfem} are then:
% 	\begin{equation}
% 		\edd_i = \half \left[ \edd_i(x_{i,L}) + \edd_i(x_{i,R}) \right] \,,
% 	\end{equation}
% where
% 	\begin{equation}
% 		x_{i,L/R} = \frac{x_{i+1/2} - x_{i-1/2}}{2} \mp \frac{x_{i+1/2} + x_{i-1/2}}{2\sqrt{3}}
% 	\end{equation}
% are the quadrature points in cell $i$.

% Transport consistent vacuum boundary conditions are applied through a modified Marshak boundary condition:
% 	\begin{equation}
% 		J(x) = B(x) \phi(x) \,,
% 	\end{equation}
% where
% 	\begin{equation}
% 		B(x) = \frac{\int_{-1}^1 |\mu| \psi(x, \mu) \ud \mu}
% 		{\int_{-1}^1 \psi(x, \mu) \ud \mu} \,.
% 	\end{equation}

\subsection{Increased Consistency Between LLDG and MFEM}

The MFEM representation for the scalar flux is constant within a cell, but the LLDG representation for the scalar flux is linear.  This suggests that improved
accuracy of the \SN solution could be achieved by somehow constructing a linear scalar flux dependence from the MFEM solution.  One simple method for doing
this is to use the MFEM cell-edge scalar fluxes to compute a slope, which is then combined with the MFEM cell-center flux value to
obtain a linear dependence.   This works quite well for neutronics.  However, it will be inadequate in a radiative transfer calculation because slopes must also be generated for the material temperatures, and an MFEM approximation for the temperatures will not include
edge temperatures.  We have chosen to use a more generally applicable approach based upon standard data reconstruction techniques
that require only cell-centered values to compute slopes \cite{vanLeer}.  We also limit such slopes to avoid non-physical scalar fluxes.  For example, the reconstructed left and right scalar fluxes in cell $i$ are given by
	\begin{equation} \label{consistent:reconstruction}
		\phi_{i,L/R} = \phi_i \mp \frac{1}{4} \xi_i \left(\Delta \phi_{i+1/2} + \Delta \phi_{i-1/2}\right) \,,
	\end{equation}
where $\xi$ is a van Leer-type slope limiter \cite{vanLeer}:
\begin{subequations}
	\begin{equation}
		\xi_i = \begin{cases}
			0, & r_i \leq 0 \,, \\
			\text{min}\bracet{\frac{2r_i}{1+r_i} , \frac{2}{1+r_i}} \,, & r_i > 0
		\end{cases} \,,
	\end{equation}
	\begin{equation}
		r_i = \frac{\Delta\phi_{i-1/2}}{\Delta \phi_{i+1/2}} \,,
	\end{equation}
\end{subequations}
and
	\begin{subequations}
		\begin{equation}
			\Delta \phi_{i+1/2} = \phi_{i+1} - \phi_i \,,
		\end{equation}
		\begin{equation}
			\Delta \phi_{i-1/2} = \phi_i - \phi_{i-1} \,.
		\end{equation}
	\end{subequations}

On the boundaries, we use
	\begin{subequations}
		\begin{equation}
			\phi_{1,L/R} = \phi_1 \mp \frac{1}{2} \Delta \phi_{3/2} \,,
		\end{equation}
		\begin{equation}
			\phi_{I,L/R} = \phi_I \mp \frac{1}{2} \Delta \phi_{I-1/2} \,.
		\end{equation}
	\end{subequations}
We also set any negative left or right flux values in the boundary cells to zero by appropriately rotating the slopes.