\documentclass[10pt,preprint]{../aastex}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{booktabs}
\usepackage{mathrsfs}
\usepackage{cite}
\usepackage{times}
\usepackage{url}
\usepackage{hyperref}
\usepackage{lineno}
\usepackage{yhmath}
\usepackage{natbib}
\usepackage{../../definitions}
\hypersetup{
  bookmarksnumbered = true,
  bookmarksopen=false,
  pdfborder=0 0 0,         % make all links invisible, so the pdf looks good when printed
  pdffitwindow=true,      % window fit to page when opened
  pdfnewwindow=true, % links in new window
  colorlinks=true,           % false: boxed links; true: colored links
  linkcolor=blue,            % color of internal links
  citecolor=magenta,    % color of links to bibliography
  filecolor=magenta,     % color of file links
  urlcolor=cyan              % color of external links
}

\usepackage{float}
\usepackage{graphicx}
\newtheorem{remark}{Remark}
\graphicspath{{Figures/}}
\newcommand{\figref}[1]{Figure \ref{#1}}

\begin{document}
Throughout this document, lowercase latin indices ($i,j,$ etc.) run from 1 to 3, lowercase Greek indices ($\mu,\nu,$ etc.) run from 0 to 3, and uppercase latin indices ($J$) run from 1 to 5.

\section{Equations}
We are solving the general relativistic hydrodynamics (GRH) equations \citep{RezzollaRelHyd}:
\begin{equation}\label{Eq:GRH}
\pd{\left(\sqrt{\gamma}\,\bU\right)}{t}+\pd{\left(\alpha\,\sqrt{\gamma}\,\bF^{i}\right)}{i}=\sqrt{\gamma}\,\bS,
\end{equation}
where $\bU$ is the vector of conserved variables, defined as
\begin{equation}
\bU\longrightarrow U^{J}=\begin{pmatrix}D\\ S_{j}\\ E\end{pmatrix}=\begin{pmatrix}\rho\,W\\ \rho\,h\,W^{2}\,v_{j}\\\rho\,h\,W^{2}-p\end{pmatrix},
\end{equation}
$\bF^{i}$ is the vector of fluxes of the conserved variables in the $x^{i}$-direction, defined as
\begin{equation}
\bF^{i}\longrightarrow \left(F^{i}\right)^{J}=\begin{pmatrix}D\left(v^{i}-\eta^{i}\right)\\ S_{j}\left(v^{i}-\eta^{i}\right)+p\,\delta^{i}_{~j}\\S^{i}-\eta^{i}\,E\end{pmatrix},
\end{equation}
$\bS$ is the vector of sources, defined as
\begin{equation}
\bS\longrightarrow S^{J}=\begin{pmatrix}0\\\frac{1}{2}\,\alpha\,P^{ik}\,\pd{\gamma_{ik}}{j}+S_{i}\,\pd{\beta^{i}}{j}-E\,\pd{\alpha}{j}\\\alpha\,P^{ij}\,K_{ij}-S^{j}\,\pd{\alpha}{j}\end{pmatrix},
\end{equation}
where $\rho$ is the mass-density of the fluid, $v^{i}$ are the contravariant components of the fluid three-velocity, and $p$ is the pressure of the fluid. The quantity $h$ is the specific enthalpy of the fluid, defined as
\begin{equation}
h\equiv1+\frac{e+p}{\rho},
\end{equation}
where $e$ is the internal energy-density of the fluid. The quantity $W$ is the Lorentz factor of the fluid, defined as
\begin{equation}
W\equiv\left(1-\vv{v}\cdot\vv{v}\right)^{-1/2}.
\end{equation}
The quantity $\alpha$ is the lapse function, $\eta^{i}$ are the ratio of the components shift-vector, $\beta^{i}$, to the lapse function:
\begin{equation}
\vv{\eta}\longrightarrow\eta^{i}\equiv\alpha^{-1}\,\beta^{i},
\end{equation}
and $\gamma_{ij}$ are the covariant components of the spatial three-metric tensor, i.e. $\gamma^{ij}\,\gamma_{jk}=\delta^{i}_{~k}$, where $\delta^{i}_{~k}$ are the usual components of the Kronecker delta tensor. The $P^{ij}$ are the components of the stress-tensor, defined as
\begin{equation}
\bP\longrightarrow P^{ij}\equiv\rho\,h\,W^{2}\,v^{i}\,v^{j}+p\,\gamma^{ij},
\end{equation}
and the $K_{ij}$ are the components of the extrinsic curvature, defined as
\begin{equation}
\text{FILL IN HERE}.
\end{equation}

\section{Derivation of Middle Wave-Speed Estimate for General Relativistic HLLC Numerical Flux}
For a given Riemann problem we assume that a discontinuity breaks up into four distinct regions (see \figref{Fig:HLLC_RiemannFan}).
\begin{figure}[H]
\centering
\includegraphics[scale=0.5]{HLLC_RiemannFan_MB2005}
\caption{HLLC Riemann fan from \citet{Mignone2005}.}\label{Fig:HLLC_RiemannFan}
\end{figure}

\subsection{Derivation of Rankine-Hugoniot Jump Conditions}
This derivation closely follows \citet{RezzollaRelHyd}.

We start the derivation by integrating the one-dimensional version of \eqref{Eq:GRH} in space from a point $x_{L}$ to a point $x_{R}$, that contains a shock, which we define to be at a time-dependent point $x_{L}<\lambda\left(t\right)<x_{R}$:
\begin{equation}
\int\limits_{x_{L}}^{x_{R}}\pd{\left(\sqrt{\gamma}\,\bU\right)}{t}\,dx+\int\limits_{x_{L}}^{x_{R}}\pd{\left(\alpha\,\sqrt{\gamma}\,\bF^{x}\right)}{x}\,dx=\int\limits_{x_{L}}^{x_{R}}\sqrt{\gamma}\,\bS\,dx.
\end{equation}
First, we note that in the first integral on the LHS we can pull out the partial derivative with respect to time, which converts it into a total derivative. We also perform an integration-by-parts on the second integral on the LHS, yielding
\begin{align}
\frac{d}{dt}\int\limits_{x_{L}}^{x_{R}}&\sqrt{\gamma}\,\bU\,dx+\left[\alpha\,\sqrt{\gamma}\,\bF^{x}\right]^{x_{R}}_{x_{L}}=\int\limits_{x_{L}}^{x_{R}}\sqrt{\gamma}\,\bS\,dx\\
&\implies\frac{d}{dt}\int\limits_{x_{L}}^{x_{R}}\sqrt{\gamma}\,\bU\,dx+\alpha_{R}\,\sqrt{\gamma_{R}}\,\bF_{R}^{x}-\alpha_{L}\,\sqrt{\gamma_{L}}\,\bF_{L}^{x}=\int\limits_{x_{L}}^{x_{R}}\sqrt{\gamma}\,\bS\,dx,
\end{align}
where $\alpha_{L}=\alpha\left(x_{L}\right)$, etc. The integral over the vector of conserved variables contains the discontinuity, and therefore it's derivative is not well-defined. To overcome this we split the integral into one integral from $x_{L}$ to the location of the shock as approached from below, $s^{-}\left(t\right)$, and another integral from the location of the shock as approached from above, $s^{+}\left(t\right)$, to $x_{R}$:
\begin{equation}
\int\limits_{x_{L}}^{x_{R}}\sqrt{\gamma}\,\bU\,dx=\int\limits_{x_{L}}^{s^{-}\left(t\right)}\sqrt{\gamma}\,\bU\,dx+\int\limits_{s^{+}\left(t\right)}^{x_{R}}\sqrt{\gamma}\,\bU\,dx.
\end{equation}
Both of these integrals are smooth. Next we use the rule for differentiation of an integral depending on a parameter \citep{RezzollaRelHyd}:
\begin{equation}
\f{d}{dt}\int\limits_{x_{1}\left(t\right)}^{x_{2}\left(t\right)}Q\left(x,t\right)\,dx=\int\limits_{x_{1}\left(t\right)}^{x_{2}\left(t\right)}\pd{Q\left(x,t\right)}{t}\,dx+Q\left(x_{2}\left(t\right),t\right)\,\frac{dx_{2}\left(t\right)}{dt}-Q\left(x_{1}\left(t\right),t\right)\,\frac{dx_{1}\left(t\right)}{dt}.
\end{equation}
This yields, since $x_{L}$ and $x_{R}$ are constant,
\begin{align}
\int\limits_{x_{L}}^{s^{-}\left(t\right)}&\pd{\left(\sqrt{\gamma}\,\bU\right)}{t}\,dx+\sqrt{\gamma\left(s^{-}\left(t\right),t\right)}\,\bU\left(s^{-}\left(t\right),t\right)\,\frac{ds^{-}}{dt}\\
&+\int\limits_{s^{+}\left(t\right)}^{x_{R}}\pd{\left(\sqrt{\gamma}\,\bU\right)}{t}\,dx-\sqrt{\gamma\left(s^{+}\left(t\right),t\right)}\,\bU\left(s^{+}\left(t\right),t\right)\,\frac{ds^{+}}{dt}\\
&+\alpha_{R}\,\sqrt{\gamma_{R}}\,\bF_{R}-\alpha_{L}\,\sqrt{\gamma_{L}}\,\bF_{L}=\int\limits_{x_{L}}^{x_{R}}\sqrt{\gamma}\,\bS\,dx.
\end{align}
We will now take the limit that $x_{L}\longrightarrow s^{-}$ and $x_{R}\longrightarrow s^{+}$. When we do this, we see that the integrals vanish, because the integrands are all smooth in the regions considered. This yields (defining $\bU_{L}\equiv\bU\left(s^{-}\left(t\right),t\right)$, etc.)
\begin{equation}
\sqrt{\gamma_{L}}\,\bU_{L}\,\frac{ds_{L}}{dt}-\sqrt{\gamma_{R}}\,\bU_{R}\,\frac{ds_{R}}{dt}=\alpha_{L}\,\sqrt{\gamma_{L}}\,\bF_{L}-\alpha_{R}\,\sqrt{\gamma_{R}}\,\bF_{R}.
\end{equation}
Now, we note that $s_{L}=s_{R}$, and that geometry fields are continuous across discontinuities, which means that the metric determinant cancels. This yields, defining the middle wave-speed $\lambda$ as
\begin{equation}
\lambda\equiv\frac{ds}{dt},
\end{equation}
\begin{equation}
\lambda\left(\bU_{L}-\bU_{R}\right)=\alpha\left(\bF_{L}-\bF_{R}\right).
\end{equation}
These are the \textit{Rankine-Hugoniot jump conditions} and they describe how the fluid variables change across a discontinuity. Next we derive an expression for an estimate of the value of the middle wave-speed, $\lambda$.

\subsection{Derivation of Estimate of Middle Wave-Speed $\lambda$}
Now we apply the jump conditions to the shocked and un-shocked fluid (either the left or the right state):
\begin{equation}
\lambda^{i}\left(\bU^{*}-\bU\right)=\alpha\left(\left(\bF^{*}\right)^{i}-\bF^{i}\right).
\end{equation}
We will use the shorthand notation:
\begin{equation}
\bF^{*i}=\left(\bF^{*}\right)^{i}.
\end{equation}
Recalling that the geometry fields are continuous, we assume that the flux in the shocked region can be written as
\begin{equation}
\bF^{*i}\longrightarrow\left(F^{*i}\right)^{J}=\begin{pmatrix}D^{*}\left(\lambda^{*i}-\eta^{i}\right)\\ S^{*}_{j}\left(\lambda^{*i}-\eta^{i}\right)+p^{*}\,\delta^{i}_{~j}\\S^{*i}-\eta^{i}\,E^{*}\end{pmatrix}.
\end{equation}
Applying the jump conditions to the momentum-density equation we get
\begin{align}
\lambda^{i}\left(S_{j}^{*}-S_{j}\right)&=\alpha\left[S^{*}_{j}\left(\lambda^{*i}-\eta^{i}\right)+p^{*}\,\delta^{i}_{~j}-S_{j}\left(v^{i}-\eta^{i}\right)-p\,\delta^{i}_{~j}\right]\\
\implies S^{*}_{j}\left[\lambda^{i}-\alpha\left(\lambda^{*i}-\eta^{i}\right)\right]&=S_{j}\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]+\alpha\left(p^{*}-p\right)\delta^{i}_{~j}.
\end{align}
Now we apply the jump conditions to the energy-density equation, which gives
\begin{equation}
\lambda^{i}\left(E^{*}-E\right)=\alpha\left[S^{*i}-\eta^{i}\,E^{*}-S^{i}+\eta^{i}\,E\right].
\end{equation}
Now, we note that
\begin{align}
S^{i}&=\left(E+p\right)v^{i}\label{Eq:Mom-En}\\
S^{*i}&=\left(E^{*}+p^{*}\right)\lambda^{*i}.
\end{align}
Substituting this into the energy-density equation gives
\begin{align}
\lambda^{i}\left(E^{*}-E\right)&=\alpha\left[\left(E^{*}+p^{*}\right)\lambda^{*i}-\eta^{i}\,E^{*}-\left(E+p\right)v^{i}+\eta^{i}\,E\right]\\
\implies E^{*}\left[\lambda^{i}-\alpha\left(\lambda^{*i}-\eta^{i}\right)\right]&=E\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]+\alpha\left(p^{*}\,\lambda^{*i}-p\,v^{i}\right).\label{Eq:En1}
\end{align}
Now we substitute \eqref{Eq:Mom-En} into the momentum-density equation which yields
\begin{align}
\left(E^{*}+p^{*}\right)\lambda^{*}_{j}\left[\lambda^{i}-\alpha\left(\lambda^{*i}-\eta^{i}\right)\right]&=S_{j}\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]+\alpha\left(p^{*}-p\right)\delta^{i}_{~j}\\
\implies E^{*}\left[\lambda^{i}-\alpha\left(\lambda^{*i}-\eta^{i}\right)\right]\lambda^{*}_{j}&=-p^{*}\left[\lambda^{i}-\alpha\left(\lambda^{*i}-\eta^{i}\right)\right]\lambda^{*}_{j}+S_{j}\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]+\alpha\left(p^{*}-p\right)\delta^{i}_{~j}.
\end{align}
Equating this with \eqref{Eq:En1} gives
\begin{align}
&\left\{E\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]+\alpha\left(p^{*}\,\lambda^{*i}-p\,v^{i}\right)\right\}\lambda^{*}_{j}\\
&\hspace{5em}=-p^{*}\left[\lambda^{i}-\alpha\left(\lambda^{*i}-\eta^{i}\right)\right]\lambda^{*}_{j}+S_{j}\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]+\alpha\left(p^{*}-p\right)\delta^{i}_{~j}.
\end{align}
We see that the term $\alpha\,p^{*}\,\lambda^{*i}\,\lambda^{*}_{j}$ cancels from both sides. We now isolate $p^{*}$ to get
\begin{align}
p^{*}&=\frac{E\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]\lambda^{*}_{j}-\alpha\,p\,v^{i}\,\lambda^{*}_{j}-S_{j}\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]+\alpha\,p\,\delta^{i}_{~j}}{\alpha\,\delta^{i}_{~j}-\left(\lambda^{i}+\alpha\,\eta^{i}\right)\lambda^{*}_{j}}\\
&=\frac{\left\{E\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]-\alpha\,p\,v^{i}\right\}\lambda^{*}_{j}-\left\{S_{j}\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]-\alpha\,p\,\delta^{i}_{~j}\right\}}{\alpha\,\delta^{i}_{~j}-\left(\lambda^{i}+\alpha\,\eta^{i}\right)\lambda^{*}_{j}}.
\end{align}
Now we note that
\begin{equation}
E\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]-\alpha\,p\,v^{i}=\lambda^{i}\,E-\alpha\left[\left(E+p\right)v^{i}-\eta^{i}\,E\right]=\lambda^{i}\,E-\alpha\left(S^{i}-\eta^{i}\,E\right)=\lambda^{i}\,E-\alpha\,F^{i}_{E},
\end{equation}
and
\begin{equation}
S_{j}\left[\lambda^{i}-\alpha\left(v^{i}-\eta^{i}\right)\right]-\alpha\,p\,\delta^{i}_{~j}=\lambda^{i}\,S_{j}-\alpha\left[S_{j}\left(v^{i}-\eta^{i}\right)+p\,\delta^{i}_{~j}\right]=\lambda^{i}\,S_{j}-\alpha\,F^{i}_{S_{j}}.
\end{equation}
With this, we have
\begin{equation}
p^{*}=\frac{\left(\lambda^{i}\,E-\alpha\,F^{i}_{E}\right)\lambda^{*}_{j}-\left(\lambda^{i}\,S_{j}-\alpha\,F^{i}_{S_{j}}\right)}{\alpha\,\delta^{i}_{~j}-\left(\lambda^{i}+\alpha\,\eta^{i}\right)\lambda^{*}_{j}}.
\end{equation}
Now, since the pressure is continuous across contact discontinuities we can equate the left and right states, giving
\begin{equation}
\frac{\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)\lambda^{*}_{j}-\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right)}{\alpha\,\delta^{i}_{~j}-\left(-\lambda^{i}_{L}+\alpha\,\eta^{i}\right)\lambda^{*}_{j}}=\frac{\left(\lambda^{i}_{R}\,E_{R}-\alpha\,F^{i}_{E,R}\right)\lambda^{*}_{j}-\left(\lambda^{i}_{R}\,S_{j,R}-\alpha\,F^{i}_{S_{j},R}\right)}{\alpha\,\delta^{i}_{~j}-\left(\lambda^{i}_{R}+\alpha\,\eta^{i}\right)\lambda^{*}_{j}}.
\end{equation}
Now, cross-multiplying and focusing on the LHS:
\begin{align}
&\left[\alpha\,\delta^{i}_{~j}-\left(\lambda^{i}_{R}+\alpha\,\eta^{i}\right)\lambda^{*}_{j}\right]\left[\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)\lambda^{*}_{j}-\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right)\right]\\
&=\left[\alpha\,\delta^{i}_{~j}-\left(\lambda^{i}_{R}+\beta^{i}\right)\lambda^{*}_{j}\right]\left[\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)\lambda^{*}_{j}-\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right)\right]\\
&=\alpha\,\delta^{i}_{~j}\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)\lambda^{*}_{j}-\alpha\,\delta^{i}_{~j}\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right)\\
&\hspace{3em}-\left(\lambda^{i}_{R}+\beta^{i}\right)\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)\left(\lambda^{*}_{j}\right)^{2}+\left(\lambda^{i}_{R}+\beta^{i}\right)\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right)\lambda^{*}_{j}\\
&=-\left(\lambda^{i}_{R}+\beta^{i}\right)\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)\left(\lambda^{*}_{j}\right)^{2}\\
&\hspace{3em}+\left[\alpha\,\delta^{i}_{~j}\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)+\left(\lambda^{i}_{R}+\beta^{i}\right)\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right)\right]\lambda^{*}_{j}\\
&\hspace{3em}-\alpha\,\delta^{i}_{~j}\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j,L}}\right).
\end{align}
Expanding out the terms gives
\begin{align}
&\left[\lambda^{i}_{R}\,\lambda^{i}_{L}\,E_{L}+\lambda^{i}_{R}\,\alpha\,F^{i}_{E,L}-\beta^{i}\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)\right]\left(\lambda^{*}_{j}\right)^{2}\\
&+\left[\alpha\,\delta^{i}_{~j}\left(-\lambda^{i}_{L}\,E_{L}-\alpha\,F^{i}_{E,L}\right)-\lambda^{i}_{R}\,\lambda^{i}_{L}\,S_{j,L}-\lambda^{i}_{R}\,\alpha\,F^{i}_{S_{j},L}+\beta^{i}\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right)\right]\lambda^{*}_{j}\\
&-\alpha\,\delta^{i}_{~j}\left(-\lambda^{i}_{L}\,S_{j,L}-\alpha\,F^{i}_{S_{j},L}\right).
\end{align}
From symmetry, by letting $L\leftrightarrow R$ and $\lambda^{i}_{L}\leftrightarrow-\lambda^{i}_{R}$, we can immediately write down the RHS as
\begin{align}
&\left[\lambda^{i}_{R}\,\lambda^{i}_{L}\,E_{R}-\lambda^{i}_{L}\,\alpha\,F^{i}_{E,R}-\beta^{i}\left(\lambda^{i}_{R}\,E_{R}-\alpha\,F^{i}_{E,R}\right)\right]\left(\lambda^{*}_{j}\right)^{2}\\
&+\left[\alpha\,\delta^{i}_{~j}\left(\lambda^{i}_{R}\,E_{R}-\alpha\,F^{i}_{E,R}\right)-\lambda^{i}_{R}\,\lambda^{i}_{L}\,S_{j,R}+\lambda^{i}_{L}\,\alpha\,F^{i}_{S_{j},R}+\beta^{i}\left(\lambda^{i}_{R}\,S_{j,R}-\alpha\,F^{i}_{S_{j},R}\right)\right]\lambda^{*}_{j}\\
&-\alpha\,\delta^{i}_{~j}\left(\lambda^{i}_{R}\,S_{j,R}-\alpha\,F^{i}_{S_{j},R}\right).
\end{align}
Now we subtract the LHS from the RHS, giving
\begin{align}
&\left[\lambda^{i}_{R}\,\lambda^{i}_{L}\left(E_{R}-E_{L}\right)-\left(\lambda^{i}_{R}\,\alpha\,F^{i}_{E,L}+\lambda^{i}_{L}\,\alpha\,F^{i}_{E,R}\right)-\beta^{i}\left(\lambda^{i}_{R}\,E_{R}+\lambda^{i}_{L}\,E_{L}+\alpha\,F^{i}_{E,L}-\alpha\,F^{i}_{E,R}\right)\right]\left(\lambda^{*}_{j}\right)^{2}\\
&+\left[\alpha\,\delta^{i}_{~j}\left(\lambda^{i}_{R}\,E_{R}+\lambda^{i}_{L}\,E_{L}+\alpha\,F^{i}_{E,L}-\alpha\,F^{i}_{E,R}\right)-\lambda^{i}_{R}\,\lambda^{i}_{L}\left(S_{j,R}-S_{j,L}\right)+\lambda^{i}_{R}\,\alpha\,F^{i}_{S_{j},L}+\lambda^{i}_{L}\,\alpha\,F^{i}_{S_{j},R}\right.\\
&\hspace{3em}\left.+\beta^{i}\left(\lambda^{i}_{R}\,S_{j,R}+\lambda^{i}_{L}\,S_{j,L}+\alpha\,F^{i}_{S_{j},L}-\alpha\,F^{i}_{S_{j},R}\right)\right]\\
&-\alpha\,\delta^{i}_{~j}\left(\lambda^{i}_{R}\,S_{j,R}+\lambda^{i}_{L}\,S_{j,L}+\alpha\,F^{i}_{S_{j},L}-\alpha\,F^{i}_{S_{j},R}\right).
\end{align}
By making use of the HLL conserved variables and fluxes,
\begin{align}
\left(\lambda^{i}_{R}+\lambda^{i}_{L}\right)\bU_{HLL}&=\lambda^{i}_{R}\,\bU_{R}+\lambda^{i}_{L}\,\bU_{L}+\alpha\,\bF^{i}_{L}-\alpha\,\bF^{i}_{R}\\
\left(\lambda^{i}_{R}+\lambda^{i}_{L}\right)\bF^{i}_{HLL}&=\lambda^{i}_{R}\,\alpha\,\bF^{i}_{L}+\lambda^{i}_{L}\,\alpha\,\bF_{R}-\lambda^{i}_{R}\,\lambda^{i}_{L}\left(\bU_{R}-\bU_{L}\right),
\end{align}
we can simplify the quadratic equation to (assuming that $\lambda^{i}_{L}\neq0$ \textbf{and} $\lambda^{i}_{R}\neq0$)
\begin{equation}
\left(-F^{i}_{E,HLL}-\beta^{i}\,E_{HLL}\right)\left(\lambda^{*}_{j}\right)^{2}+\left[\alpha\,\delta^{i}_{~j}\,E_{HLL}+F^{i}_{S_{j},HLL}+\beta^{i}\,S_{j,HLL}\right]\lambda^{*}_{j}-\alpha\,\delta^{i}_{~j}\,S_{j,HLL}=0.
\end{equation}
Now we just multiply the equation by $-1$, which gives
\begin{equation}
\left(F^{i}_{E,HLL}+\beta^{i}\,E_{HLL}\right)\left(\lambda^{*}_{j}\right)^{2}-\left[\alpha\,\delta^{i}_{~j}\,E_{HLL}+F^{i}_{S_{j},HLL}+\beta^{i}\,S_{j,HLL}\right]\lambda^{*}_{j}+\alpha\,\delta^{i}_{~j}\,S_{j,HLL}=0.
\end{equation}
Finally, we use the metric to raise the index on the contact wave-speed, which gives
\begin{equation}
\left(\gamma_{jk}\right)^{2}\left(F^{i}_{E,HLL}+\beta^{i}\,E_{HLL}\right)\left(\lambda^{*k}\right)^{2}-\gamma_{jk}\left[\alpha\,\delta^{i}_{~j}\,E_{HLL}+F^{i}_{S_{j},HLL}+\beta^{i}\,S_{j,HLL}\right]\lambda^{*k}+\alpha\,\delta^{i}_{~j}\,S_{j,HLL}=0.
\end{equation}

We see that in the special relativistic, Cartesian coordinate limit of $\alpha\rightarrow1$, $\beta^{i}\rightarrow0^{i}$, and $\gamma_{ij}=\delta_{ij}$, we recover the result of \citet{Mignone2005}.

\newpage
\bibliographystyle{../apj}
\bibliography{../../References/references.bib}
\end{document}


\section{Bounded Model Checking,  k-induction, and IC3}~\label{sec:mck}

Highly automated proof techniques are a necessary step for the
widespread adoption of formal methods in the software industry.
 One of the more popular techniques used in industry is {\em Model
  checking}, where a design is modeled as finite state machine, and
specification of some property is formalized in a suitable logic.  The
model checker traverses all of the
reachable states of the design in order to verify that the property
holds.  If the property fails, then a sequence of states leading to
the failure is produced as a {\em counterexample.} The main difficulty
with this technique is the huge size of usual search spaces. To tackle
this, we use logical formula as a concise description for sets of
states and the transition relation in the graph of states is decided
by SMT solvers.  Our work applies
the technique of {\em bounded model checking with satisfiability
  solving}~\cite{ClarkeBounded01,ClarkeBounded03} to the problem of
verifying Copilot monitors.

To quote Clarke~\cite{ClarkeBounded01}
\begin{quote}
  In bounded model checking, we construct a Boolean formula that is
  satisfiable if and only if the underlying state transition system
  can realize a finite sequence of state transitions that reaches
  certain states of interest. If such a path segment cannot be found
  at a given length, $k$, the search is continued for larger $k.$
\end{quote}

\paragraph{Background and Definitions} Recall that a state transition system is a triple $(S,I,T),$
where $S$ is a set of states, $I \subseteq S$ is the set of initial
states and $T \subseteq S \times S $ is a transition relation over $S.$ A {\em kripke
  structure} is a state transition system $(S,I,T,L)$  with a labeling function
$L: S \rightarrow  \mathcal{P}(A)$.  A state $s
\in S$ is said to be {\em k-reachable} if there exists a path from an
initial state $i\in I$ to $s$ of length at most $k.$ A state is said
to be {\em reachable} if it is $k$-reachable for some $k\in \mathbb{N}.$
Likewise, a set of states $Q \subset S$ is said to be reachable if
there exists a reachable state in $S.$  Given a transition system, a
set of states containing all the reachable states of the system is
said to be {\em invariant.} In the classic procedure for model checking of Linear
Temporal Logic (LTL) specifications, one computes the product of
the kripke structure modeling the system and an transition system that
represents the negation of the specification~\cite{ClarkeMC}. This product captures
the counterexamples of executions violating the property.

\paragraph{Bounded Model Checking} Bounded model checking was developed to exploit the success of modern
satisfiability (SAT) solvers and more recently satisfiability modulo
theories (SMT) solvers. Bounded model checking only considers finite
prefixes of length $k$  of a path that may be a witness acting as a
counterexample. In practice, the value of $k$ is systematically
increased to look for counterexamples in longer traces.

Suppose we wish to apply bounded model checking to show that property
$P$ holds in  the system modeled by the transition
system $(S,I,T,L),$ where $P: S \rightarrow \mathbb{B}$ represents
the predicate $P$ defined over the states of $S$ such that $P(s)$
holds in states $s.$
Formulating this as the following entailment:
$$ I(s_0) \tland T(s_0,s_1) \tland \cdots \tland T(s_{k-1},s_k)
\models P(s_k)$$
for increasing values of $k.$ In the case of $\tlnot P$ is reachable,
the SMT solver will provide an assignment for
$$I(s_0) \tland T(s_0,s_1) \tland T(s_{k-1},s_k) \tland \tlnot
P(s_k)$$
that can be used a counterexample.

\paragraph{$k$-induction}  In proving $P$ manually, a common technique
is mathematical induction.  Applying classical induction to prove a
property $P$ holds on  for a model one would first show the base case
by proving that the property is satisfied by the initial state:
$$I(s_0) \models P(s_0).$$
If the base case holds, then show the inductive step that $P$ holds
for some state $n$ and prove it holds for the next state $n+1:$
$$ T(s_{n},s_{n+1}) \tland P(s_n) \models P(s_{n+1}).$$

Sheeran~\etal~\cite{Sheeran00, EenS03} introduced
$k-$induction that has the advantage that it is well suited for SAT
based bounded model checking.  One begins as with the standard
induction, but if one cannot show the property to be true, the
property is strengthened by extending the formula and
progressively increasing the length of the reachable states
considered.  To show $P$ holds in the transition system one must first
show the base case holds, that is $P$ holds in all states reachable
from an initial state in $k$ steps, and then show the induction step,
that if $P$ holds in states $s_0,\ldots,s_{k-1}$ then it holds in
state $s_k.$ The $k$-induction principle is formally expressed in the
following two entailments:
\begin{eqnarray*}
I(s_0) \tland T(s_0,s_1) \tland \cdots \tland T(s_{k-1},s_k) &\models&
P(s_k) \\
P(s_0) \tland \cdots \tland P(s_{k-1}) \tland T(s_0,s_1) \tland \cdots \tland T(s_{k-1},s_k) &\models&
P(s_k)
\end{eqnarray*}

Property $P$ said to be a $k$-inductive property with respect to
$(S,I,T)$ if there exists some $k \in \mathbb{N}^{0<}$ such that $P$
satisfies the $k$-induction principle. As $k$ increases, weaker
invariants may be proved. \jonathantxt{If $P$ is a safety property that doesn't hold, then the first entailment will break for a finite $k$ and a counterexample will be provided.} The trick is to find an invariant that is
tractable by the SMT solver yet weak enough to satisfy the desired
property.

\paragraph{Path Compression}  A major enhancement to the basic
$k$-induction
algorithm eliminates redundant searches via a procedure
known as path compression~\cite{dMRS03} that strengthens the left-hand
side of the entailments to eliminate paths that contain repeated configurations  (due to
a cycle) or configurations that are equivalent.

Indeed, if $P$ is not invariant, a
counterexample exists such that it is cycle-free and only its first state belongs to $I$. More formally, these constraints hold for the path $s_0 \cdots s_k$ if and only if  $C_k(s_0,\ldots,s_k)$ hold, where :

$$C_k(s_0,\ldots,s_k) = \bigwedge_{i \neq j} s_i \neq s_j  \tland
\bigwedge_{i > 0} \tlnot I(s_i),$$
and where equality is defined  pointwise over the state vectors.
We can now strengthen the left hand side of the induction step
entailment:
$$\bigwedge^{k-1}_{i=0} P(s_i) \tland \bigwedge ^{k-1}_{i=0}
T(s_i,s_{i+1}) \tland C_k(s_0, \ldots, s_k) \models P(s_k). $$
Now, we can make the algorithm complete for bounded state spaces by
checking the entailment
$$I(s_0) \tland T(s_0,s_1) \tland \cdots \tland T(s_{k-1}, s_{k})
 \models \tlnot C_k(s_0,\ldots, s_{k-1})$$
after the $k$-th bounded model checking iteration.  If this entailment
holds, and $P$ is $k$-invariant, then $P$ is invariant.

\paragraph{Structural Abstraction}
A limiting factor when it comes to applying $k-$induction in practice
is the computing resources required by the SMT solver. Abstraction is
often applied to the model the system being analyzed in order to
reduce the problem space to a more manageable problem.  {\em
  Structural abstraction}~\cite{ bh07structural} is a technique that
constructs a abstract model that simulates the concrete one and
accepts at least the behaviors accepted by the concrete model. The
abstraction can reduce the size of the problem
space and render $k-$induction tractable. This
approach is
related to counterexample guided refinement
(CEGAR)~\cite{Clarke2003CAR}, where if a counterexample is produced in
the analysis of the abstract model that is inconsistent with the
concrete model, the abstraction is refined to eliminate the
counterexample. The idea is to replace $T$
by a weaker approximation $T'$ by removing some clauses. Then,
\begin{itemize}
\item If $P$ is invariant for $T',$ then $P$ is also invariant for $T.$
\item Otherwise, we use the counterexample produced by the SMT solver
  to refine $T'$ by restoring some well-chosen clauses.
\end{itemize}
Indeed, suppose a counterexample $(v_0,\ldots, v_k)$ is found for $T'$. Then we can
check whether or not
%$$\bigwedge_{i=0}^k  \bigwedge_{j=1}^n v_{ij} = s_{ij} \tland I(s_0)
%\tland \bigwedge_{i=0}^{k-1} T(s_i,s_{i+1})$$

$$ I(v_0)
\tland \bigwedge_{i=0}^{k-1} T(v_i,v_{i+1})$$

\jonathan{I simplified the old formula, which I originally made too complex for subtle reasons (optimal use of incremental SMT solvers)}

is satisfiable.  If it is, then the counterexample is valid for $T$.
Otherwise, the counterexample is spurious. In that case, it is possible to query
the SMT solver to obtain an unsatisfiable core of state variables that
candidates for refinement.

%\paragraph{IC3 Algorithm}

%\jonathan{Concerning this paragraph, I wonder if it's a good thing to give such a brief but formal description. I'm not sure anyone who don't already know the algorithm could understand more than the very basic idea just with this. In my case, it took me several much longer articles to understand the very subtle IC3 algorithm. Maybe we should give up trying to give a formal description, just give the main idea and a reference to a more detailed document in a shorter paragraph. What do you think ? I'm not sure I'm right, I'm really biased on this question.}

%Bounded model checking approaches such as $k$-induction suffer from
%the drawback of searching for a single strengthening of the invariant
%to be proved. This monolithic approach often  overwhelms the SAT
%solver due to its many iterations. \jonathan{Moreover, we should add that k-induction technique is limited to k-inductive properties.}

%Recall that a property $P$ is inductive if
%\jonathan{I don't agree with your notations in this paragraph. Instead of :}
%$$ P(s_{k-1}) \tland T(s_{k-1},s_k) \models P(s_k). $$
%\jonathan{I would have written $$ P(s) \tland T(s, s') \models P(s'). $$ Indeed, you notation suggests the last equation is about a path and not about a single transition. The use of indexes is misleading I think. What is your opinion about this ? }
% Otherwise there
%exists states $s_{k-1}$ and $s_k$ such that
$$P(s_{k-1}) \tland T(s_{k-1},s_k) \tland \tlnot P(s_k),$$
%where $s_{k-1}$ is said to be the {\em counterexample to
%  inductiveness} (CTI). The property $P$ is said to be inductive
%relative to $A$ if and only if
%$$A(s_{k-1}) \tland  P(s_{k-1}) \tland T(s_{k-1},s_k) \models P(s_k). $$
%Note that if $P$ is inductive relative to $Q$ and $Q$ is inductive
%relative to $P,$ then $P \tland Q$ is inductive.  The idea of using
%relative inductiveness to prove inductiveness lead to the development
%of incremental approaches such as that used in the FSIS model
%checker~\cite{Bradley06, Bradley2011}.  The basic incremental
%algorithm used in FSIS is as follows:
%\begin{itemize}
%\item Try to prove $P$ is inductive.
%\item If fails,  if $s$ is CTI, then find an inductive invariant
 % $\phi_0$ such that $\phi_0(s)$ does not hold.
%\item Continue finding such lemmas $\phi_0, \phi_1, \ldots$ until
%  there are no more CTIs.
%\item As $P$ is inductive to $\bigwedge_{i} \phi_i$ it s proven
%  invariant if it holds for the initial states.
%\end{itemize}
%Note that each $\phi_i$ has only to be proven inductive relative to
%the previously discovered CTIs $\phi_0, \phi_1, \ldots, \phi_{i-1}$
%or even inductive to $\{ \phi_j \}_{j<i} \tland P.$

%As it is difficult to find inductive lemmas, we can limit our search
%to lemmas that are inductive relative to a formula $R_k$ that
%over-approximates the set of $k$-reachable states. We then try to
%propagate these lemmas as $k$ increases, stopping only when reaching a
%fixed point. The IC3 algorithm~\cite{Somenzi-FMCAD11,
%  BradleyCAV12,bradley2012understanding} searches for an
%over approximation $R$ of the reachable sets such that:
%\begin{eqnarray*}
%I(s_{k-1})  & \models & R(s_{k-1}) \\
%R(s_{k-1})  \tland  T(s_{k-1},s_k) &\models & R(s_k)  \\
%R(s_{k-1})  & \models & P(s_{k-1})
%\end{eqnarray*}
%where $R$  is constructed as a fixed point of an increasing sequence
%of $(R_k),$ where each frame $(R_k)$ can be viewed as a conjunction of
%lemmas. The sequence exhibits the following properties:
%\begin{eqnarray*}
%R_0 & = & \{ I \} \\
%R_{i+1} & \subset & R_i \\
%R_i(s_{k-1}) \tland  T(s_{k-1},s_k) &\models & R_{i+1}(s_k)   \\
%P &\in& R_i \ \ \mbox{for} \ i > 0.
%\end{eqnarray*}
 %If the sequence satisfies these four constraints and admits a fixed
 %point, then $P$ is invariant.   In constructing the sequence, $R_0$
 %is initialized to $\{ I \}$ and  $R_1 = P.$  We continue in similar
 %fashion, at  each step, $k,$ is initialized to $P$ then propagate as
% many lemmas from the previous frame as possible while ensuring that
 %the an error is not reached within one transition step.

%Just as $R$ represents the reachable good states, the IC3 algorithm
%maintains a set of bad states $B$ such that each state in $B$ leads to
%an error in one step.  In order to show $B$ is unreachable in $R_k$
%the predicate $\tlnot B$ is conjoined to $R_k$ as a lemma.  Although
%$B$ may not be inductive, it is sufficient to show that it is
%inductive relative to the previous frame and consequently $B$ is not
%$k-$reachable.  This can be accomplished by checking the following two
%entailments:
%\begin{eqnarray*}
%I(s_{i-1}) & \models & \tlnot B(s_{i-1}) \\
%R_{k-1} (s_{i-1}) \tland \tlnot  B(s_{i-1}) \tland T(s_{i-1}, s_i)
%& \models & \tlnot B(s_i).
%\end{eqnarray*}
%If the first entailment fails, then $P$ is not an invariant. If the
%second fails,  then $B$ is reachable from some state of the previous
%frame. We generalize this state to a set of states $B',$ consisting of
%states belonging to the previous frame that lead to $B$ in a single
%transition.  Next, the algorithm recursively refines $R_{k-1}$ to
%remove the states in $B'.$ This backward reachability is performed
%until one of the following conditions are met:
%\begin{itemize}
%\item The algorithm reaches $R_0 = I$ whence $P$ is not invariant.
%\item All the bad states that are recursively generated have been
 % shown to be $k$-unreachable.
%\end{itemize}

%Once the strengthening process completes, meaning that no error state
%is reachable from the last frame, the IC3 algorithm propagates the new
%lemmas we discovered from each frame to its successor. This is
%accomplished by verifying the entailment

%$$ R_j(s_{i-1}) \tland  T(s_{i-1}, s_i)  \models C(s_i)$$
%for all $C \in R_j - R_{j+1},$ where $j$ increases from $0$ to $k.$
%If all the lemmas of $R_{k-1}$ are successfully propagated to $R_k$,
%the sequence $(R_j)$ reaches a fixed point and $P$ is proven to be
%invariant.  Otherwise,  a new frame $R_{k+1}$ is added that is  initialized to $P$
%and the algorithm continues.  Numerous improvements to the basic
%algorithm such as {\em lemma tightening} can be found in the
%literature that can produce an invariant that is more tractable to
%modern SMT solvers.


\subsection{Decomposition of T}
\SecLabel{t}

The decomposition of $T$ follows similar path as that of $U$, but with a couple of differences. all permutations $T_i$ are linearly-equivalent, excluding $T_{\hex{0}}$. The latter function stands out and does not follow any patterns. Furthermore, all $T_i,i \ne 0$ are related only by linear layer in the input. Let $N_{\hex{1}},\ldots,N_{\hex{f}}\colon \field{4} \to \field{4}$ be given by
$$
N_k(x) \eqdef T_k^{-1}(x) \circ T_{\hex{1}}(x).
$$
For any $k \ne 0$, $T_k = T_{\hex{1}} \circ N_k$ and each of $N_i$ is affine. The look-up table of $N$ is given in \TabRef{n}.

In order to obtain linear mapping from affine, we detach the constant xor \emph{before} the linear map. It could also be detached \emph{after}, but detaching \emph{before} allows to merge it with the outer linear layer $L$. Let $\delta\colon \field{4} \to \field{4}$ be given by
$$
\delta(k) \eqdef \begin{cases}
    0, &~\text{if}~k = 0,\\
    N_k^{-1}(0), &~\text{otherwise}.
\end{cases}
$$
It turns out that $\delta$ is a linear map:
$$
\delta(k_1, k_2, k_3, k_4) = (0, k_1 \oplus k_3, 0, k_1 \oplus k_2 \oplus k_3).
$$

Let $N'_{\hex{1}},\ldots,N'_{\hex{f}}\colon \field{4} \to \field{4}$ be given by
$$
N'_k(x) = N_k(x \oplus \delta(k)).
$$
Then all $N'_k$ are linear functions, i.e. $N'_k(0) = 0$ for all $k \in \field{4},k\ne 0$. The codebook of $N'$ is given in \TabRef{np}.

\FigTex{n-np.tex}

Consider $N'_{\hex{2}}$ (other choices are possible, but this one leads to simplest linear layers in the decomposition). It is linear-similar to the same field multiplication chosen in the decomposition of $U$: there exists $\eta \in \linbij{4}$ such that
$$
N'_{\hex{2}} = \eta \circ (\cdot~\odot X) \circ \eta^{-1}.
$$
Such $\eta$ is given by:
$$
\eta(x_1, x_2, x_3, x_4) \eqdef (x_1, x_2 \oplus x_4, x_3 \oplus x_2, x_4).
$$
Further, all $N'_k$ turn out to be multiplications by a $k$-dependent constant in the finite field. Let $\varepsilon\colon \field{4} \to \field{4}$ be given by
$$
\varepsilon(k) \eqdef \begin{cases}
0, & ~\text{if}~ k = 0,\\
\eta^{-1} \circ N'_{k} \circ \eta (1), & ~\text{otherwise}.
\end{cases}
$$
Then $\varepsilon$ turns out to be a bijection, and the following holds for $k \ne 0$:
$$
\eta^{-1} \circ N'_{k} \circ \eta (x) = \varepsilon(k) \odot x,
$$
$\varepsilon$ seems to be a complicated permutation without any pattern. Note that when the inverse of $T$ is computed, the field multiplication becomes the field division and thus, the output of $\varepsilon$ is inverted. Denote the composition of the inversion in the finite field with $\varepsilon$ by $1/\varepsilon$ (defining $1/0 = 0$). Surprisingly, it is a linear function. Furthermore, when composed with $\swaplsb$ which appears here from the decomposition of $U$, it becomes a simple multiplication by a constant in the finite field:
$$
1/\varepsilon \circ \swaplsb(k) = k \odot (X^3 + X^2)
$$
for all $k \in \field{4}$.
It follows that
$$
\varepsilon(k) = 1/(\swaplsb(x) \odot (X^3 + X^2)) = X \odot (1 / \swaplsb(k)),
$$
where $X \odot (X^3 + X^2) = 1$ in the chosen finite field. The multiplication by constant can be transferred through the main multiplication in $N'$ and merged with $T_{\hex{1}}$.

We obtain that, when $k \ne 0$, $T_k$ can be computed as:
$$
T_k(x) = T_{\hex{1}} \circ \eta (\cdot~\odot X) \pround{
(1/\swaplsb(k)) \odot \eta^{-1} (x \oplus \delta(k))
}.
$$
The addition of $\delta(k)$, $\eta^{-1}$ and $\swaplsb$ can be merged with the outer linear layer $L$. $\eta$ can be merged with $T_{\hex{1}}$, and $\swaplsb$ will cancel out when $T$ is merged with $U$.

Let
\begin{align*}
\zeta_0 &\eqdef T_{\hex{0}} \circ \eta,\\
\zeta_+ &\eqdef T_{\hex{1}} \circ \eta \circ (\odot X).
\end{align*}

Then $$
T_k(x) = \begin{cases}
\zeta_+ \pround{
(1/\swaplsb(k)) \odot \eta^{-1} (x \oplus \delta(k))
},&~\text{if}~k\ne 0,\\
\zeta_0\pround {
\eta^{-1} (x \oplus \delta(k))
},&~\text{if}~k = 0.
\end{cases}
$$

The final decomposition of $T^{-1}$ and the codebooks of $\delta, \eta, \swaplsb, \zeta_0, \zeta_+$ and the field inverse $1/x$ are given are shown in \FigRef{final-t}. It uses a multiplexer, which chooses its left input branch if the control branch (i.e., $k$) is equal to zero, and its right input branch otherwise.
The only differences between $T$ and $T^{-1}$ are using the inverses of $\zeta_0, \zeta+$, removing the field inversion, and changing the position of the multiplexer. Note that $\eta$ is an involution, and the addition of $\delta(k)$ is involution too.

\FigTex{final-t.tex}


\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage[pdftex]{graphicx}
%\usepackage{physymb}
%\usepackage{wrapfig}
\usepackage{braket}
\usepackage{subcaption}
\title{PH 304: Assignment 1}

\author{Manish Goregaokar (120260006)}
\date{January 25, 2015}
\begin{document}
\maketitle
\section*{Problem 1}

The probability of there not being a single 1 in four rolls is $\frac56\times\frac56\times\frac56\times\frac56 = \frac{625}{1296}$ since we restrict each die roll to the space of 2-6 (5 possibilities) out of its actual space of 6.

The inverse of this, i.e. the probability of there being at least one 1 in four rolls, is  $\boxed{1 - \frac{625}{1296} = \frac{671}{1296} = 0.517747}\hfill \text{Ans (i)}$

When a pair of dice are rolled 24 times, the probability of never getting a double 1 is $\left(\frac{35}{36}\right)^{24}$ since the (equiprobable) sample space for a single roll has 36 candidates, of which  one is a double-1. Thus the probability of having at least one double 1 is $\boxed{1-\left(\frac{35}{36}\right)^{24} = 0.491404}\hfill\text{Ans (ii)}$
\section*{Problem 2}
Let the probability for a single ameoba to die or have its progeny eventually die out be $d$.

\begin{align*}
d & = P(\text{amoeba dies}) + P(\text{amoeba lives but descendants die})\\
&= 1-p + p(P(\text{amoeba or descendants die out})^2)\\
&= 1-p + pd^2\\
\therefore d &= 1-p + pd^2\\
\therefore 0 &=pd^2 -d +1-p\\
\therefore d &= \frac{1\pm \sqrt{1-4p(1-p)}}{2p}\\
 &= \frac{1\pm \sqrt{4p^2 - 4p + 1}}{2p}\\
  &= \frac{1\pm \sqrt{(2p - 1)^2}}{2p}\\
  &= \frac{1\pm (2p -1)}{2p}
\end{align*}

For $p<\frac12$, the solution with the $+$ is the only possible one, and thus $d=1$. For $p>\frac12$, it is the solution with the $-$, and we get the probability of death as $\frac{1-p}{p}$.

Thus, the minimum value of $p$ for there to be a non-zero probability of survival ($d<1$) is $\boxed{\frac12}$.

For $p=3/4$, $d=\frac13$, so the probability of survival is $1-d = \boxed{\frac23}$
\section*{Problem 3}
Given: $P(\text{twin}) = 0.02, P(\text{identical twin}) = 0.002$

We want $P(\text{identical}|\text{twin})$, which by Bayes' theorem is $$\frac{P(\text{twin}|\text{identical})P(\text{identical})}{P(\text{twin})}=\frac{P(\text{identical})}{P(\text{twin})}=0.1$$

Thus the probability that he was an identical twin is $\boxed{0.1}\hfill \text{Ans.}$

\section*{Problem 4}

The distribution is $P(n|N) = {n\choose N}p^n(1-p)^{N-n}$, and thus the characteristic function is
\begin{align*}\tilde{P}(k) &= \Braket{e^{-ikn}}\\
&= \sum_{n=0}^N e^{-ikn}{n\choose N}p^n(1-p)^{N-n}\\
&= \sum_{n=0}^N {n\choose N}\left(e^{-ik}\cdot p\right)^n(1-p)^{N-n}\\
&= (1 - p(e^{-ik}-1))^N
\end{align*}

$\therefore \boxed{\tilde{P}(k) = (1 - p(e^{-ik}-1))^N}\hfill \text{Ans.}$

Cumulant generating function

\begin{align*}
Q(k) & = \ln\tilde{P}(k)\\
&= \ln (1 - p(e^{-ik}-1))^N\\
&= N \ln (1 - p(e^{-ik}-1))
\end{align*}

$\therefore \boxed{\ln\tilde{P}(k) = N\ln (1 - p(e^{-ik}-1))}\hfill \text{Ans.}$
~\\
If $-ik = y$, then $Q(k) = \ln\tilde{P}(k) = \sum_n \frac{y^n}{n!}\Braket{x^n}_C$. This means that $\left.Q^{(j)}(k)\right|_{k=0} = \Braket{x^j}_C$. Thus the first moment is $Q(0) = 0$, and the second moment is calculated as:

\begin{align*}
Q'(0) &= \left.\frac{d}{dk}N\ln (1 - p(e^{-ik}-1))\right|_{k=0}\\
&= \left.\frac{N p e^y}{1-p \left(e^y-1\right)}\right|_{k=0}\\
&= Np
\end{align*}

Thus the first two cumulants are $\boxed{0}$ and $\boxed{Np}\hfill$ Ans.
\section*{Problem 5}
$$p(x) = \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{(x-\lambda)^2}{2\sigma^2}\right]$$

\begin{align*}
\therefore \tilde{p}(k) &= \int_{-\infty}^{\infty} e^{-ikx} \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{(x-\lambda)^2}{2\sigma^2}\right] dx\\
&=\int \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{(x-\lambda)^2 + 2ikx\sigma^2}{2\sigma^2}\right] dx\\
&=\int \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{x^2 + \lambda^2 - 2x\lambda + 2ikx\sigma^2}{2\sigma^2}\right] dx\\
&=\int \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{x^2 - 2x(\lambda - ik\sigma^2) + \lambda^2 }{2\sigma^2}\right] dx\\
&=\int \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{x^2 - 2x(\lambda - ik\sigma^2) + (\lambda - ik\sigma^2)^2 -2\lambda ik\sigma^2 +i^2k^2\sigma^4 }{2\sigma^2}\right] dx\\
&=\int \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{(x -(\lambda - ik\sigma^2))^2 -2\lambda ik\sigma^2 +i^2k^2\sigma^4 }{2\sigma^2}\right] dx\\
&=e^{-\lambda ik + \frac12 i^2k^2\sigma^2}\int \frac1{\sqrt{2\pi\sigma^2}}\exp\left[-\frac{(x -(\lambda - ik\sigma^2))^2}{2\sigma^2}\right] dx\\
&= e^{-\lambda ik +\frac12 i^2k^2\sigma^2} \cdot 1\\
&= e^{-\lambda ik +\frac12  i^2k^2\sigma^2}
\end{align*}

Thus cumulant generating function is just $Q(k) = \ln \tilde{p}(k) = -\lambda ik + \frac12 i^2k^2\sigma^2$. If $-ik = y$, $Q(y) = y + \frac12 y^2\sigma^2$

Thus the cumulants are $\Braket{x^n}_C = (y + \frac12 y^2\sigma^2)^{(n)}$, giving us :

$\boxed{\Braket{x}_C = 1}$, $\boxed{\Braket{x^2}_C = \frac12\sigma^2}$, and for $n>2$, $\boxed{\Braket{x^n}_C = 0}$

\section*{Problem 6}

If we break T into $n$ intervals of $dt$ each ($dt = T/n$), probability of exactly $M$ of these having an event is (where $\lambda$ is the proportionality constant such that individual probability is $\lambda dt$):

$$P(M)_n = {n\choose M}(\lambda dt)^M (1-\lambda dt)^{n-M}$$

Assuming no simultaneous events, we can limit $n$ to infinity:
\begin{align*}
\lim_{n\to\infty} P(M)_n &= \lim_{n\to\infty} {n\choose M}(\lambda dt)^M (1-\lambda dt)^{n-M}\\
&= \lim_{n\to\infty} \frac{n(n-1)....(n-m+2)(n-m+1)}{M!}\left(\lambda \frac{T}{n}\right)^M \left(1-\lambda \frac{T}{n}\right)^{n-M}\\
&= \lim_{n\to\infty} \frac{n(n-1)....(n-m+2)(n-m+1)}{n^M}\frac{\left(\lambda T\right)^M}{M!} \left(1-\lambda \frac{T}{n}\right)^n\left(1-\lambda \frac{T}{n}\right)^{-M}\\
&=1\cdot   \frac{\left(\lambda T\right)^M}{M!} \cdot  e^{-\lambda T} \cdot 1\\
&= \frac{k^M e^{-k}}{M!}\qquad\qquad (k = T\lambda)
\end{align*}

Thus, the probability distribution, in terms of the proportionality constant $\lambda$ is:

$\boxed{P(M) = \frac{(T\lambda)^M e^{-T\lambda}}{M!}}$

The characteristic function can be calculated as  (rewriting $T\lambda$ as $\lambda$)
\begin{align*}
\tilde{P}(k) &= \sum_{M=0}^\infty \frac{\lambda^M e^{-\lambda}}{M!}e^{-ikM}\\
&= e^{-\lambda}\sum_{M=0}^\infty \frac{e^{(ln\lambda-ik) M}}{M!}\\
&= \exp{e^{ln\lambda-ik}-\lambda}
\end{align*}

Thus the cumulant generating function is $e^{ln\lambda-ik}-\lambda = \lambda (e^{y} - 1)$, giving us $\boxed{\Braket{x^n}_C = \lambda}$.
\end{document}

Course material/PH 304 - Statistical Physics/Assignment 1/assign1.tex


\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage[nodayofweek]{datetime}

% Set size of text area with total parameter
\usepackage[a4paper, total={155mm, 255mm}]{geometry}

\title{Polynomial Root Manipulation}
\author{Dyson}
\date{\today}

\newcommand{\ab}{\alpha\beta}
\newcommand{\bg}{\beta\gamma}
\newcommand{\ga}{\gamma\alpha}
\newcommand{\ag}{\alpha\gamma}

\newcommand{\sone}{\alpha + \beta + \gamma}
\newcommand{\stwo}{\alpha\beta + \beta\gamma + \gamma\alpha}
\newcommand{\abg}{\alpha\beta\gamma}

\newcommand{\Sone}{\Sigma_1}
\newcommand{\Stwo}{\Sigma_2}

\newtheorem{lemma}{Lemma}
\newtheorem{sublemma}{Lemma}[lemma]
\newtheorem{conjecture}{Conjecture}

\begin{document}

\maketitle

% Set paragraph spacing here to avoid messing with title
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\section{The Question}

Challenge question 2 in the mixed exercise at the end of chapter 4 of the Further Maths Core book says:

The cubic equation $x^3 + 2x^2 -3x - 5 = 0$ has roots $\alpha$, $\beta$, and $\gamma$. Without solving the equation, find an equation that has roots, $\alpha + \beta$, $\beta + \gamma$, and $\gamma + \alpha$.

This question is completely different to all the prior questions in the chapter. Most of these questions ask for a linear transformation of roots that can be done with simple substitution, but this question requires a full expansion of triple brackets, lots of algebra, and some very interesting problem solving at the end.

\section{The Answer}

\subsection{Establishing Lemmas}

Firstly, we want to establish some lemmas. All of these can be shown by expanding $(x - \alpha)(x - \beta)(x - \gamma)$, but we'll just take them as identities here.

For a cubic equation $ax^3 + bx^2 + cx + d = 0$, for $x \in \mathbb{C}$ and $a, b, c, d \in \mathbb{R}$ with roots $\alpha$, $\beta$, $\gamma$:

\begin{lemma}
$\sone \equiv -\dfrac{b}{a}$
\end{lemma}

\begin{lemma}
$\stwo \equiv \dfrac{c}{a}$
\end{lemma}

\begin{lemma}
$\abg \equiv -\dfrac{d}{a}$
\end{lemma}

We can express these with a more compact notation, $\sone = \Sone$, $\stwo = \Stwo$, representing the sum of single terms and the sum of pairs respectively.

We can evaluate these for our original equation and get $\Sone = -2$, $\Stwo = -3$, and $\abg = 5$.

\subsection{Expanding The New Roots}

We want roots of $\alpha + \beta$, $\beta + \gamma$, and $\gamma + \alpha$, so we have the expression $(x - \alpha - \beta)(x - \beta - \gamma)(x - \gamma - \alpha)$. This can be expanded as such:
\begin{gather*}
(x - \alpha - \beta)(x - \beta - \gamma)(x - \gamma - \alpha)\\[0.5em]
= (x - \alpha - \beta)(x^2 - \gamma x - \alpha x - \beta x + \bg + \ab - \gamma x + \gamma^2 + \ag)\\[0.5em]
= (x - \alpha - \beta)(x^2 - x\Sone + \Stwo - \gamma x + \gamma^2)\\[0.5em]
= x^3 - x^2\Sone + x\Stwo - \gamma x^2 + \gamma^2 x - \alpha x^2 + \alpha x\Sone - \alpha \Stwo + \ag x - \ag^2 - \beta x^2 + \beta x\Sone - \beta\Stwo + \bg x - \bg^2
\end{gather*}

After expanding the expression, we need to reorganise and simplify it.
\begin{gather*}
x^3  - x^2\Sone + \alpha x\Sone + \beta x\Sone+ x\Stwo - \alpha\Stwo - \beta\Stwo - \gamma x^2 - \alpha x^2 - \beta x^2 + \gamma^2 x + \ag x + \bg x - \ag^2 - \bg^2\\[0.5em]
= x^3  - x^2\Sone + \alpha x\Sone + \beta x\Sone+ x\Stwo - \alpha\Stwo - \beta\Stwo - x^2(\sone) + \gamma x(\sone) - \ag^2 - \bg^2\\[0.5em]
= x^3  - x^2\Sone + \alpha x\Sone + \beta x\Sone + x\Stwo - \alpha\Stwo - \beta\Stwo - x^2\Sone + \gamma x\Sone - \ag^2 - \bg^2\\[0.5em]
= x^3 - 2x^2\Sone + (\sone)x\Sone + x\Stwo - \alpha\Stwo - \beta\Stwo - \ag^2 - \bg^2\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo - \alpha\Stwo - \beta\Stwo - \ag^2 - \bg^2
\end{gather*}

It was at this point that I got stuck for about 15 minutes. If we had a $-\abg$ term at the end, we could factor it out and do
\begin{gather*}
x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo - \alpha\Stwo - \beta\Stwo - \ag^2 - \bg^2 - \abg\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -1(\alpha\Stwo + \beta\Stwo + \ag^2 + \bg^2 + \abg)\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -1(\alpha\Stwo + \beta\Stwo + \gamma(\ag + \bg + \ab))\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -1(\alpha\Stwo + \beta\Stwo + \gamma\Stwo)\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -\Stwo(\alpha + \beta + \gamma)\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo - \Sone\Stwo
\end{gather*}

We can then evaluate this and get a definitive equation to answer the original question. But, how do we get that $- \abg$ term at the end?

I spent ages just staring at my book, trying to work out what I'd done wrong and where I'd dropped this term. After thoroughly checking and making sure that I'd expanded everything correctly, I decided to just add the term myself.

\subsection{Adding New Terms}

We know that adding and subtracting a constant from an expression doesn't change its value. So, for any expression $E$, and any constant $k$, $E + k - k = E$.

So, we can add the $-\abg$ term and as long as we also add an extra $+\abg$ term, the value of the expression won't actually change. And we know the value of $\abg$ for our original equation, so we can evaluate it after the simplification.

Thus,
\begin{gather*}
x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo - \alpha\Stwo - \beta\Stwo - \ag^2 - \bg^2\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo - \alpha\Stwo - \beta\Stwo - \ag^2 - \bg^2 - \abg + \abg\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -1(\alpha\Stwo + \beta\Stwo + \ag^2 + \bg^2 + \abg) + \abg\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -1(\alpha\Stwo + \beta\Stwo + \gamma(\ag + \bg + \ab)) + \abg\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -1(\alpha\Stwo + \beta\Stwo + \gamma\Stwo) + \abg\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo -\Stwo(\alpha + \beta + \gamma) + \abg\\[0.5em]
= x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo - \Sone\Stwo + \abg
\end{gather*}

We can then evaluate this expression with the values for $\Sone$, $\Stwo$, and $\abg$ that we obtained from the coefficients of our original equation.
\begin{gather*}
x^3 - 2x^2\Sone + x\Sone^2 + x\Stwo - \Sone\Stwo + \abg\\[0.5em]
= x^3 + 4x^2 + 4x - 3x - 6 + 5\\[0.5em]
= x^3 + 4x^2 + x - 1
\end{gather*}

Therefore, our final equation is $x^3 + 4x^2 + x - 1 = 0$. This is correct, as per the answers in the book.

\end{document}


\section{Sturm-Liouville Theory}
\subsection{Review of Second-Order Linear ODEs}
For a general inhomogeneous ODE $\mathcal Ly=f(x)$ where
$$\mathcal Ly=\alpha(x)\frac{\mathrm d^2y}{\mathrm dx^2}+\beta(x)\frac{\mathrm dy}{\mathrm dx}+\gamma(x)y$$
In general, the homogeneous equation $\mathcal Ly=0$ has two linearly independent solutions $y_1,y_2$.
The complementary function $y_c(x)=Ay_1+By_2$ for constants $A,B$ is then the general solution to $\mathcal Ly=0$ by linearity.\\
If we can find a particular solution (aka particular integral) $y_p$ to $\mathcal Ly=f$, then $y_p+y_c=y_p+Ay_1+By_2$ for $A,B$ constants is the general solution to $\mathcal Ly=f$ again by linearity.
Two pieces of boundary data is then needed to determine the constants $A,B$.\\
There are several types of boundary conditions.
We sometimes get the Dirichlet condition of specifying the function's value at the endpoints, or the Neumann consitions of specifying the derivative's values at the endpoints.
Sometimes these two types of conditions are mixed.\\
The sort of conditions we often consider are homogeneous conditions, i.e. the function vanishes at the endpoints.
The reason of it is that it allows the superposition of solutions in a linear DE.
What if we come across a nonhomogeneous condition?
We can use the complementary solution to cancel stuff out.\\
Sometimes, we specify initial data of the function and its derivative as boundary conditions.\\
Another matter of interest is the general eigenvalue problem.
To solve $\mathcal Ly=f$ using eigenvalue decompositions like we did previously, we must first solve (subject to boundary conditions) the related eigenvalue problem
$$\mathcal Ly=\alpha(x)\frac{\mathrm d^2y}{\mathrm dx^2}+\beta(x)\frac{\mathrm dy}{\mathrm dx}+\gamma(x)y=-\lambda\rho(x)y$$
where $\rho$ is nonegative.
This form often occurs after seperation of variables in a PDE.
\subsection{Self-Adjoint Operators}
\begin{definition}
    For two functions $f,g:[a,b]\to\mathbb C$ we define their inner product to be
    $$\langle f,g\rangle=\int_a^bf^*(x)g(x)\,\mathrm dx$$
\end{definition}
We can guarantee to rewrite the original eigenvalue problem into the Sturm-Liouville form, i.e. $\mathcal Ly=\lambda wy$ where we are able to rewrite $\mathcal Ly=-(py^\prime)^\prime+qy$ and $w$ is a nonnegative wavefunction.
\footnote{The reason why there is a wavefunction there is just for convenience.}
How to convert a second order linear ODE to this form?
Simply multiply the diffential equation by an integrating factor $F$ that will be specified later and we can write
$$\frac{\mathrm d}{\mathrm dx}(F\alpha y^\prime)-F^\prime\alpha y^\prime-F\alpha^\prime y^\prime+F\beta y^\prime+F\gamma y=-\lambda F\rho y$$
So to eiminate the $y^\prime$ terms, we set
$$F(x)=\exp\left(\int\frac{\beta-\alpha^\prime}{\alpha}\,\mathrm dx\right)$$
which reduced the equation to
$$(F\alpha y^\prime)^\prime+F\gamma y=-\lambda F\rho y$$
Setting $p=F\alpha,q=F\gamma$ and $w=F\rho\ge 0$.
\begin{example}
    Consider the Hermite equation that appears in quantum mechanics
    $$y^{\prime\prime}-2xy^\prime+2ny=0$$
    Then $\alpha=1,\beta=-2x,\gamma=0,\lambda\rho=2n$, so the above procedure translates this to the Sturm-Liouville form
    $$\mathcal L=(-e^{-x^2}y^\prime)^\prime=2ne^{-x^2}y$$
\end{example}
\begin{definition}
    Let $\mathcal L:C\to C$ be an operator, where $C$ on a class of functions $[a,b]\to\mathbb C$ equipped with the inner product we defined previously.
    This operator $\mathcal L$ is self-adjoint if $\langle y_1,\mathcal Ly_2\rangle=\langle\mathcal Ly_1,y_2\rangle$ for any $y_1,y_2\in C$.
\end{definition}
If we let $\mathbb L$ be the operator in the Strum-Liouville form, then
\begin{align*}
    \langle y_1,\mathcal Ly_2\rangle-\langle\mathcal Ly_1,y_2\rangle&=\int_a^b[-y_1(py_2^\prime)^\prime+y_1qy_2+y_2(py_1^\prime)^\prime-y_2qy_1]\,\mathrm dx\\
    &=\int_a^b[-y_1(py_2^\prime)^\prime+y_2(py_1^\prime)^\prime]\,\mathrm dx\\
    &=\int_a^b[-(y_1(py_2^\prime)^\prime+y_1^\prime py_2^\prime)+(y_2(py_1^\prime)^\prime+y_2^\prime py_1^\prime)]\,\mathrm dx\\
    &=\int_a^b[-(py_1y_2^\prime)^\prime+(py_1^\prime y_2)^\prime]\,\mathrm dx\\
    &=[-py_1y_2^\prime+py_1^\prime y_2]_a^b
\end{align*}
So for this operator to be self-adjoint, we need some good enough boundary conditions so that enough stuff vanishes.
This includes homogeneous boundary condition $y(a)=y(b)=0$ or $y^\prime(a)=y^\prime(b)=0$ or mixed $y+ky^\prime=0$ etc..
We say a Sturm-Liouville problem is regular if the boundary conditions are homogeneous.
Periodic boundary conditions also work, where we can take $y(a)=y(b)$ and the derivatives are specified (or periodic) at the boundary.
There can also be singular points of this ODE, where $p(a)=p(b)=0$.
We can have combinations of above too.
\subsection{Properties of Self-Adjoint Operators}
\begin{definition}
    The inner product of $y_1,y_2:[a,b]\to\mathbb C$ with respect to weight $w:[a,b]\to\mathbb R_{\ge 0}$ is
    $$\langle f,g\rangle_w=\int_a^bwf^*g\,\mathrm dx=\langle wf,g\rangle=\langle f,wg\rangle$$
\end{definition}
Analogous to the finite dimensional case, we have
\begin{theorem}\label{self-adjoint}
    For a sufficiently nice self-adjoint operator $\mathcal L$ on a sufficiently nice space of functions:\\
    (a) Eigenvalues of $\mathcal L$ are real.\\
    (b) Eigenfunctions of it with different eigenvalues are orthogonal with respect to the weight $w$.\\
    (c) We can take the eigenfunctions as a set of basis for the function space, just like Fourier series.
\end{theorem}
\begin{proof}[Proof of (a)]
    1. If $\mathcal Ly=\lambda wy$, taking complex conjugate gives $\mathcal Ly^*=\lambda^*wy^*$.
    Hence as $\mathcal L$ is self-adjoint,
    $$0=\int_a^b(y^*\mathcal Ly-y\mathcal Ly^*)\,\mathrm dx=(\lambda-\lambda^*)\int_a^bw|y|^2\,\mathrm dx$$
    which means $\lambda=\lambda^*$, so $\lambda$ is real.
\end{proof}
If $\lambda$ is non-degenerate (simple), i.e. it has a one-dimensional eigenspace, then $y$ is guaranteed to be real.
Even if it has dimension $2$ (not more because the ODE is second order), we can still find two real functions as basis of the eigenspace.
Also, by considering $u\mathcal Lv-v\mathcal Lu=(-p(uv^\prime-u^\prime v))^\prime$, one can show that a regular Sturm-Liouville problem always has all eigenvalues simple.
\begin{proof}[Proof of (b)]
    Suppose $\mathcal Ly_m=\lambda_mwy_m$ and $\mathcal Ly_n=\lambda_nwy_n$, then
    $$0=\int_a^by_n\mathcal Ly_m-y_m\mathcal Ly_n\,\mathrm dx=(\lambda_m-\lambda_n)\int_a^bwy_ny_m\,\mathrm dx$$
    But $\lambda_m$ and $\lambda_n$ are distinct.
    The claim follows.
\end{proof}
As an aside, we do not really need the weight function in order to formulate Sturm-Liouville theory, since we can do the transformation $\tilde{y}=\sqrt{w}y$ and replace $\mathcal Ly$ by $(1/\sqrt{w})\mathcal L(\tilde{y}/\sqrt{w})$.
Yet the analytic property is generally simpler if we keep $w$.\\
What?
How about (c), you say?
Bold of you to assume we'll prove it.
We are just gonna take it (and several other properties we want it to have) as truth and do stuff with this idea.
\subsection{Eigenfunction Expansions}
So basically we just want to find an expansion
$$f=\sum_{n=1}^\infty a_ny_n$$
where $y_n$ is a set of eigenfunctions of some self-adjoint operator.
Theorem \ref{self-adjoint}(c) shows that we can do it.
To find the coefficients $a_n$, we can they use the orthogonality to get
$$\int_a^bwy_mf\,\mathrm dx=\sum_{n=1}^\infty a_n\int_a^bwy_ny_m\,\mathrm dx=a_m\int_a^bwy_n^2\,\mathrm dx$$
So
$$a_n=\left(\int_a^bwy_nf\,\mathrm dx\middle)\right/\left(\int_a^bwy_n^2\,\mathrm dx\right)$$
It's a common practice not to normalise the eigenfunctions as it is not really always clean.
Of course, if we want, we can always write down
$$Y_n=y_n\left/\sqrt{\int_a^bwy_n^2\,\mathrm dx}\right.$$
So we can get rid of the denominator in $a_n$ and the coefficients will have the expression
$$A_n=\int_a^bwy_nf\,\mathrm dx=a_n\int_a^bwy_n^2\,\mathrm dx$$
but it isn't that useful and can cause some messiness.
\begin{example}
    Recall the particular operator already in Sturm-Liouville form $\mathcal Ly=y^{\prime\prime}$, then (with appropriate boundary conditions) we can easily get the eigenvalues $\lambda_n=(n\pi/L)^2$ and eigenfunctions being the trigonometrics.
    This just reproduces the Fourier series.
\end{example}
\subsection{Completeness and Parseval's Identity}
We expand
\begin{align*}
    0&=\int_a^bw\left( f(x)-\sum_{n=1}^\infty a_ny_n \right)^2\,\mathrm dx\\
    &=\int_a^bw\left( f^2-2f\sum_{n=1}^\infty a_ny_n+\sum_{n=1}^\infty a_n^2y_n^2 \right)\,\mathrm dx\\
    &=\int_a^bwf^2\,\mathrm dx-\sum_{n=1}^\infty a_n^2\int_a^bwy_n^2\,\mathrm dx
\end{align*}
Hence we have
$$\int_a^bwf^2\,\mathrm dx=\sum_{n=1}^\infty a_n^2\int_a^bwy_n^2\,\mathrm dx=\sum_{n=1}^\infty A_n^2$$
which Parseval's identity in this general case.
Easily our previous Parseval's Theorem on Fourier series is a special case.\\
If some of the eigenfunctions are missing from the series, then this gives
$$\int_a^bwf^2\,\mathrm dx\ge\sum_{n=1}^\infty A_n^2$$
This is known as Bessel's Inequality.\\
Consider the partial sums $\sum_{n\le N}a_ny_n$, then we shall have $S_N\to f$ as $N\to\infty$ where we would like the style of convergence to be
$$\epsilon_N=\int_a^bw[f(x)-S_N(x)]^2\,\mathrm dx\to 0,N\to\infty$$
An interesting question is that, while we know (maybe) the series converges as we want, if we truncate the sequence in some $N$, would the coefficients $\{a_n\}_{n\le N}$ provide the best approxmation (with respect to the error defined in this way) of that particular partial sum, or a different set of partial coefficient will yield a better result?
To answer this, we evaluate
$$\frac{\partial\epsilon_N}{\partial a_n}=-2\int_a^bwy_n\left( f-\sum_{k=1}^Na_ky_k \right)\,\mathrm dx=-2\int_a^bwfy_n-a_nwy_n^2\,\mathrm dx$$
which is zero when $a_n$ is of the expression we got earlier.
We can see it is indeed a minimum by observing that
$$\frac{\partial^2\epsilon_N}{\partial a_n^2}=2\int_a^bwy_n^2\,\mathrm dx\ge 0$$
This answers our question.
\subsection{Legendre's Equation}
Take the usual spherical polar coordinate
$$\begin{cases}
    x=r\sin\theta\cos\phi\\
    y=r\sin\theta\sin\phi\\
    z=r\cos\theta
\end{cases}$$
where Laplace's equation $\nabla^2 u=0$ translates to
$$\frac{1}{r^2}\frac{\partial}{\partial r}\left( r^2\frac{\partial u}{\partial r} \right)+\frac{1}{r^2\sin\theta}\frac{\partial}{\partial\theta}\left( \sin\theta\frac{\partial u}{\partial\theta} \right)+\frac{1}{r^2\sin^2\theta}\frac{\partial^2u}{\partial\phi^2}=0$$
Seperation of variables $u=R(r)\Theta(\theta)\Phi(\phi)$ then gives
$$\frac{1}{\sin\theta}(\Theta^\prime\sin\theta)^\prime+\left( K-\frac{m^2}{\sin^2\theta} \right)\Theta=0$$
where $K,m$ are constants which essentially makes it an eigenvalue problem.
Now the transformation $x=\cos\theta\in[-1,1]$ and renaming $\Theta$ as $y$ then gives Legendre's Equation
$$(1-x^2)y^{\prime\prime}-2xy^\prime+\lambda y=0$$
where $\lambda$ is a constant which is again intepreted as an eigenvalue.
This is already in Strum-Liouville form by taking $p=1-x^2,q=0,w=1$.
Now $p=1-x^2$ vanishes at the boundary $\pm 1$, so this equation has to be self-adjoint.
We assume that $y$ is bounded near the boundary.\\
We now seek a power series solution to the problem.
If we set
$$y=\sum_{n=0}^\infty c_nx^n$$
Then substitution gives
$$(n+2)(n+1)c_{n+2}-n(n-1)c_n-2nc_n+\lambda c_n=0\implies c_{n+2}=\frac{n(n+1)-\lambda}{(n+1)(n+2)}c_n$$
The iteration steps by $2$, so we get two linearly independent solutions
\begin{align*}
    y_{\text{even}}&=c_0\left( 1+\frac{-\lambda}{2!}x^2+\frac{(6-\lambda)(-\lambda)}{4!}x^4+\cdots \right)\\
    y_{\text{odd}}&=c_1\left( x+\frac{2-\lambda}{3!}x^3+\cdots \right)
\end{align*}
Note that $c_{n+2}/c_n\to 1$, so the both series has radius of convergence $1$ but they diverges at $x=\pm 1$.
However, this is not the end of the world!
These series may not be infinite.
If $\lambda=l(l+1)$ for some $l\in\mathbb N$, then one of these two series will terminate and give a polynomial solution.
These polynomials are called Legendre polynomials $P_l(x)$ which are eigenfunctions of the Legendre equation.
Conventionally we normalise $P_l$ by requiring $P_l(1)=1$.
One can check that this restricts $P_l([-1,1])\subset [-1,1]$ and $|P_l(-1)|=1$.
By calculation we have
$$P_0(x)=1,P_1(x)=x,P_2(x)=\frac{3x^2-1}{2},P_3(x)=\frac{5x^3-3x}{2},\ldots$$
We easily observe that $P_l$ has $l$ roots in $[-1,1]$, also $P_l$ is odd if $l$ is odd, and even when $l$ is even.
By orthogonality and some calculation,
$$\forall n\neq m,\int_{-1}^1P_nP_m\,\mathrm dx=0,\int_{-1}^1P_n^2\,\mathrm dx=\frac{2}{2n+1}$$
There are several other ways to characterise Legendre polynomails.
One can prove that we have
$$P_n(x)=\frac{1}{2^nn!}\frac{\mathrm d^n}{\mathrm dx^n}(x^2-1)^n,\sum_{n=0}^\infty P_n(x)t^n=\frac{1}{\sqrt{1-2xt+t^2}}$$
We also have the recursions
$$l(l+1)P_{l+1}(x)=(2l+1)xP_l(x)-lP_{l-1}(x),(2l+1)P_l(x)=\frac{\mathrm d}{\mathrm dx}(P_{l+1}(x)-P_{l-1}(x))$$
If we take these $P_l$ as a set of eigenfunctions, then any well-behaved $f$ on $[-1,1]$ can be expressed as
$$f(x)=\sum_{l=0}^\infty a_lP_l(x),a_l=\frac{2l+1}{2}\int_{-1}^1f(x)P_l(x)\,\mathrm dx$$
\begin{example}
    We can verify that $f(x)=(15x^2-3)/2=P_0(x)+5P_2(x)$.
\end{example}
\begin{example}
    The odd equare wave with $f([0,1))=\{1\}$ has the expansion
    $$\sum_{m=1}^\infty (P_{2m}(0)-P_{2m+2}(0))P_{2m+1}(x)$$
\end{example}
\subsection{Inhomogeneous ODEs}
Consider the ODE $\mathcal Ly=f=wF$ (with homogeneous boundary conditions so that $\mathcal L$ is self-adjoint) where $w\ge 0$ is our wavefunction.
Given eigenfunctions $\{y_n\}$ satisfying $\mathcal Ly_n=\lambda_nwy_n$ for eigenvalues $\{\lambda_n\}$.
We now try to find a solution in the form $y=\sum_nc_ny_n$.
To do this, we expand $F=\sum_na_ny_n$ where
$$a_n=\left( \int_a^bwFy_n\,\mathrm dx\middle) \right/\left( \int_a^bwy_n^2\,\mathrm dx \right)$$
then
$$w\sum_na_ny_n=wF=\mathcal Ly=\mathcal L\sum_nc_ny_n=\sum_nc_n\mathcal Ly=w\sum_nc_n\lambda_ny_n$$
So take
$$y=\sum_n\frac{a_n}{\lambda_n}y_n$$
gives a particular solution, assuming everything is well-defined and converges nicely enough.\\
An aside:
The driving force $F$ sometimes induces a linear response term $\tilde\lambda wy$, so the solution is $\mathcal Ly-\tilde{\lambda}wy=f$.
Then our particular solution can be
$$y=\sum_{\lambda_n\neq\tilde{\lambda}}\frac{a_n}{\lambda_n-\tilde\lambda}y_n$$
Now back to theme.
If we expand the expression of $a_n$, we can get
\begin{align*}
    y(x)&=\sum_{n=1}^\infty\frac{a_n}{\lambda_n}y_n(x)\\
    &=\sum_{n=1}^\infty\frac{y_n(x)}{\lambda_nN_n}\int_a^bw(\xi)F(\xi)y_n(\xi)\,\mathrm d\xi,N_n=\int_a^bwy_n^2\,\mathrm dx\\
    &=\int_a^b\left( \sum_{n=1}^\infty\frac{y_n(x)y_n(\xi)}{\lambda_nN_n} \right)w(\xi)F(\xi)\,\mathrm d\xi\\
    &=\int_a^bG(x,\xi)f(\xi)\,\mathrm d\xi,G(x,\xi)=\sum_{n=1}^\infty\frac{y_n(x)y_n(\xi)}{\lambda_nN_n}
\end{align*}
This $G(x,\xi)$ is called the Green's function of this particular eigenvalue problem of that self-adjint operator.
Worth noting that $G$ does not depend on the forcing term $f$.
The Green's function also induces
$$\mathcal L^-(\phi)=\int_a^bG(x,\xi)\phi(\xi)\,\mathrm d\xi$$
which can be taken as kind of an inverse operator to $\mathcal L$ since $\mathcal L(\mathcal L^-(f))=f$.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Comparing Inverse Problems and Solutions}\label{sec:compare}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% The Bayesian framework poses a different question and seeks a different answer than the Data-Consistent one.
The objective of the Bayesian approach is to determine a single ``true'' parameter that explains all of the observed data \citep{Smith, Concrete, Complete, Stuart10, Tarantola_book}.
The philosophical underpinnings of Bayesian inference is akin to asking the following:

\begin{center}
  \emph{How does one incorporate collected data to shift prior beliefs about specific parameter values?}
\end{center}

% The motivations of Bayesian inference are distinct from the Data-Consistent framework, where we seek a pull-back measure: a description of the uncertainty set that explains the variation in the observations under a given description of error.
However, the Data-Consistent approach reflects the goal of constructing a distribution (or probability measure), which is akin to asking:

\begin{center}
  \emph{How does one update initial beliefs in such a way that the modified predictions match the description of uncertainty in observed data?}
\end{center}

We now develop a typical Bayesian inverse problem following the framework described in \cite{Stuart10, Smith}, in order to make a formal comparison to the Data-Consistent SIP.

\subsubsection{The Bayesian Inverse Problem}
Let $d$ denote the ``noisy'' data obtained on $Q(\paramref)$, which is often represented as
\begin{equation*}
	d = Q(\paramref) + \xi,
\end{equation*}
where $\xi$ is a random variable used to model the measurement error that is often assumed to follow a Gaussian distribution.
Then, the data-likelihood function, often written as a conditional density, $L_\dspace(\q \, |\, \param)$, is formed.
This describes the differences in relative likelihoods that the data could have been generated from a particular $\param$.
Ideally, the largest values of $L_\dspace(\q \, | \, \param)$ occur whenever $\param$ is a close approximation of the true parameter $\paramref$.
The data-likelihood function is distinct from the observed density used in the data-consistent framework.

The next step in constructing a Bayesian inverse problem is the specification of a prior density denoted by $\pi_\text{prior}(\param)$.
The prior describes the different relative likelihoods assumed for the true parameter before data are collected.
This is also distinct from the role of the {\em initial} density used in the data-consistent framework.
% We choose them to represent the set of feasible parameters, and rely on Monte Carlo sampling for both approaches\footnote{Priors in Bayesian inference are sometimes chosen for reasons related to Markov-Chain Monte Carlo algorithms in order to ensure their balancing of investigation and exploration, or convergence [TK - cite someone]}.

The posterior density (i.e., the formal solution to the Bayesian inverse problem) is given by a conditional density, denoted by $\pi_\text{post}(\param\, | \, d)$, proportional to the product of the prior and data-likelihood function \citep{Walpole, Berger, Complete, Smith}.
In other words,
\begin{equation*}
	\posterior(\param\, | \, \q) \propto \prior(\param)L_\dspace(\q\, | \, \param)
\end{equation*}
This form of the density follows from Bayes' rule (not from the Disintegration Theorem as with the updated density).
The posterior can be interrogated to assess the difference in relative likelihoods of a fixed parameter given the observed data.
Subsequently, the posterior is often used to produce a ``best'' estimate of the true parameter.
For example, the maximum a posteriori (MAP) point is the parameter that maximizes the posterior density.

Unlike the updated density, the posterior is often interrogated indirectly without knowledge of the normalizing constant $C$ required to represent it as a density.
In other words, the posterior is a density of the form

\begin{equation}\label{eq:sb_post}
    \posterior\lam := \prior\lam \frac{L_\dspace (\q | \param)}{ C },
\end{equation}

\noindent where we emphasize the use of $\posterior$ to distinguish the \emph{posterior} from the updated density $\updated$ in \eqref{eq:updated-pdf}.
Here, the denominator $C$ (known as the \emph{evidence} \cite{Smith}), ensures the posterior density integrates to one, and is given by
\[
C = \int_\pspace \prior\lam L_\dspace(\q | \param) \, d\param.
\]

Note that there are no constraints or requirements that likelihood function be a density.
In fact, $L_\dspace$ need not even be in $L^1(\pspace)$ since it is actually only the product $\prior(\param) L_\dspace (\q | \param)$ that is required to be in $L^1(\pspace)$ to form a posterior.
In other words, $L_\dspace (\q | \param)$ and $\observed(\qlam)$ can model completely different things with respect to uncertainty in the data.
As stated above, $L_\dspace (\q | \param)$ is used to assess the relative likelihood that a single parameter $\param\in\pspace$ explains all of the observed data, whereas $\observed(\qlam)$ describes the relative likelihood of a predicted datum associated with $\param\in\pspace$.
In the Bayesian framework, there is a different notion of consistency of solutions, referring to certain asymptotic properties of $\posterior$ in the limit of infinite data \citep{Barron, Silverman, starktenorio}.

%%%%%%%%%

\subsection{Comparison of Data-Consistent and Bayesian Inversion}\label{sec:bayesian}

We summarize the posterior and updated densities side-by-side in Table~\ref{tab:dens_comparisons} and comment on a few notable aspects not mentioned above.
Observe for the posterior density that the data-likelihood function appears in both the numerator and denominator.
In particular, the data-likelihood function informs the {normalizing constant}, commonly referred to as the evidence term, in the denominator.
This is in contrast to the denominator of the updated density, which is given by the predicted density, which is in general not a constant, and can be constructed independently of $\observed$.

\begin{table}[htbp]
\centering
\begin{tabular}{|c|c|}
\hline
 & \\
$\displaystyle \updated(\param) = \initial(\param) \frac{\observed(\q)}{\predicted(\q)}
$
&
$
	\displaystyle \pi_{\text{post}}(\param\,|\,\q) = \frac{\prior(\param)L_\dspace(\q \,|\,\param)}{\int_{\Lambda} L_\dspace(\q \, |\, \param)  \prior(\param) \, d\pmeas}
$
 \\ & \\ \hline
\end{tabular}
\caption{Updated density solving the SIP (left) and posterior density solving the Bayesian inverse problem (right).}
		\label{tab:dens_comparisons}
\end{table}

A practical implication of this difference is that the updated density only alters the structure of the initial density in what we refer to as the ``data-informed'' parameter directions.
Specifically, for a fixed $\q\in\dspace$, let $C_\q := \set{\param\in\pspace\, : \, \qlam=\q}$, i.e., $C_\q$ is a ``contour'' in parameter space.
Then, for any $\param\in C_\q$, we immediately have $\updated(\param)=r(\q)\initial(\param)$ where $r(\q)$ is a fixed constant of proportionality for all $\param\in C_\q$.
%Subsequently, using the Disintegration theorem on both the initial and updated densities produces exactly the same family of conditional densities on the contours in parameter space.
By contrast, while the posterior does not have to agree with the prior in any direction in parameter space, the prior does impact the structure of the posterior in all directions.

The previous paragraph is not\---and should not be interpreted as\---a criticism of the Bayesian inverse framework.
It is simply meant to highlight that the data-consistent and Bayesian frameworks formulate and solve inverse UQ problems from different perspectives and with different (although at times seemingly compatible) assumptions.
Consequently, the solutions for an inverse problem formulated under either framework may differ significantly.
As the example (adopted from \cite{BJW18a, BJW18b}) below demonstrates, this is true even if we arbitrarily force the inverse problems to appear as similar as possible.

\FloatBarrier