\section{Discussion}
Sending a satellite into space involves a good deal of planning. For the scope we have we will come up with a theory for orbital mechanics. Satellites are acted upon by many forces while in orbit. These forces are; \\
1. The gravitation of the Earth, Fe.\\
2. The gravitational force from the Sun, Fs.\\
3. The gravitation of nearby and large Jupiter, Fj.\\
4. The centripetal force, Fc.\\
5. The frictional force, Ff.\\
6. The gravitation of nearby satellites, Fsat.\\

It can be shown that forces 2-6 are negligible and the dominant force is that of force 1. This makes up an interesting problem which involves two bodies that attract each other due to gravitation. This problem is called the “Two Body Problem” in physics.

The Two-body problem was first described by Sir Isaac Newton in the year . It inquires,  “ given the positions and velocities of two bodies that act on each other by gravity, at a certain point in time, find the equations that describe the subsequent velocities and positions of the bodies.”
These equations have enabled the advent of mankind into outer space and as a result satellite communications. The satellites that orbit the earth are kept in accurate paths by their engineers. This is only achievable by a good understanding and application of the physics involved. For the scope of this project we will go about solving the two body problem only, this is because an introduction of a third body will complicate the system.\\

\vspace{4cm}
\section{Equations that determine satellite location at any given time, t}
\begin{figure}[h]
	\centering
	\includegraphics[scale=2.5, width=1\textwidth]{twobody}
	\caption{Two bodies with masses m1 and m2 seperated by a distance r.}
	\label{fig:two-body problem}
\end{figure}
We will now model the two body problem. Let us take a rectangular coordinate frame for the two body problem as shown in the figure above.
\\

The mutual distance apart is r;
\[ r^2 =  (x_2-x_1)^2 + (y_2-y_1)^2  ... \big(1)\]

The magnitude of gravity;
\[ F =  Gm_1m_2 / r^2 ... \big(2)\]
\\
Now the point P1 is attracted to P2 with the force of gravity, F, and can be resolved into the x and y components as;\\
1. along the OX AXIS
\[F_X = Gm_1m_2 / r^2\big(x_2-x_1/r) ... \big(3)\]
\\
2. along the OY AXIS
\[F_Y = Gm_1m_2 / r^2\big(y_2-y_1/r) ... \big(4)\]
Where, x2-x1/r and y2-y1/r are direct cosines.
\\
For point P2 this will be;\\
1. along the OX AXIS
\[F_X = Gm_1m_2 / r^2\big(x_1-x_2/r) ... \big(5)\]
\\
2. along the OY AXIS
\[F_Y = Gm_1m_2 / r^2\big(y_1-y_2/r) ... \big(6)\]
Where, x1-x2/r and y1-y2/r are direct cosines.
\\
From Newton’s 2nd Law of motion we have;
\[F=ma\]
\\
We can further work on equations 3) to 6) to obtain the following;\\
1. for particle 1
\[F_X = m_1\big(d^2x/dt^2)= Gm_1m_2 / r^2\big(x_2-x_1/r) ... \big(7)\]
\[F_Y = m_1\big(d^2y/dt^2)= Gm_1m_2 / r^2\big(y_2-y_1/r) ... \big(8)\]
2. for particle 2
\[F_X = m_2\big(d^2x/dt^2)= Gm_1m_2 / r^2\big(x_1-x_2/r) ... \big(9)\]
\[F_Y = m_2\big(d^2y/dt^2)= Gm_1m_2 / r^2\big(y_1-y_2/r) ... \big(10)\]
\\
Simplifying equations 7) to 10) respectively to obtain equations 11) to 14);\\
1. for particle 1
\[d^2x_1/dt^2= Gm_2 / r^2\big(x_2-x_1/r) ... \big(11)\]
\[d^2y_1/dt^2= Gm_2 / r^2\big(y_2-y_1/r) ... \big(12)\]
2. for particle 2
\[d^2x_1/dt^2= Gm_1 / r^2\big(x_1-x_2/r) ... \big(13)\]
\[d^2y_1/dt^2= Gm_1 / r^2\big(y_1-y_2/r) ... \big(14)\]
\\
Let us subtract equation 11) from equation 13);
\[\frac{d^2x_2}{dt^2} - \frac{d^2x_1}{dt^2}= \frac{Gm_1} {r^3}\big(\frac{x_1-x_2}{r}) - \frac{Gm_2} {r^3}\big(\frac{x_2-x_1}{r}) ... \big(15)\]

\[\frac{d^2\small(x_2-x_1)}{dt^2}= -\frac{G} {r^3}\bigg[\big(m_1+m_2)-\big(x_2-x_1)\bigg] ... \big(16)\]
Let  \(x = x_2-x_1 ... \big(17)\) and
\(\mu = G(m1+m2) ... \big(18)\)
then;
\[\frac{d^2x}{dt^2}+\frac{\mu x}{r^3}=0 ... \big(19)\]
\\
In a similar fashion for equations 12) and 14) we arrive at;
\[\frac{d^2y}{dt^2}+\frac{\mu y}{r^3}=0 ... \big(20)\]
where;
\[y = y_2-y_1 ... \big(21)\]

The solution of this is written as;
\[r = \frac{\frac{h^2}{\mu}}{1+e\cos\theta} ... \big(22)\]

where \(\theta\) is the true anomaly, h is a constant which is twice the rate of description of area by radius vector, e, is the eccentricity of the orbit.\\

To prove this, consider;
\[r^2 = \big(x_2-x_1)^2+\big(y_2-y_1)^2 ... \big(23)\]
equation 15) and 16) can be combined as;
\[\frac{d^2r}{dt^2}+\frac{\mu\vec{r}}{r^3}=0 ... \big(24)\]
\[\ddot{\vec{r}}+\frac{\mu\vec{r}}{r^3}=0 ... \big(25)\]
\[\ddot{\vec{r}}=-\frac{\mu\vec{r}}{r^3} ... \big(26)\]\\
crossing both side with \(\vec{r}\) we will have;
\[\vec{r}\times\ddot{\vec{r}}=-\vec{r}\times\frac{\mu\vec{r}}{r^3}\]
\[=0 ... \big(27)\]\\
the left hand side can be written as;
\[\vec{r}\times\ddot{\vec{r}}= \frac{d}{dt}\big(\vec{r}\times\dot{\vec{r}}) ... \big(28)\]\\
since the time derivative of \(\vec{r}\times\dot{\vec{r}}\) is equal to zero, the quantity itself must be a constant, i.e.; \(\vec{r}\times\dot{\vec{r}}=\vec{h}=constant\).\\
The vector \(\vec{h}\) is the angular momentum per unit mass. It is related to the angular momentum vector \(\vec{l}\) by;
\[\vec{l}= m\vec{h}\]
where \(m\) is the mass of the particle.\\

Considering by Kepler's second law, then the motion of this particle over a small time step \(\Delta t\), we have;
\[\Delta A = \frac{1}{2}\arrowvert r\times \dot{r}\Delta t\arrowvert ... \big(29)\]
\[=\frac{1}{2}\arrowvert\vec{h}\arrowvert\Delta t ... \big(30)\]

Therefore;
\[\vec{h}\times\ddot{\vec{r}}=-\frac{\mu\big(\vec{h}\times\vec{r})}{r^3}  ... \big(31)\]
\[=-\frac{\mu}{r^3}\big[\big(\vec{r}\times\dot{\vec{r}})\times\vec{r}  ... \big(32)\]
\[=-\frac{\mu}{r^3}\big[\dot{\vec{r}}\big(\vec{r}\cdot\vec{r})-\vec{r}\big(\vec{r}\cdot\vec{r})]  ... \big(33)\]

now since;
\[\frac{d}{dt}\bigg(\frac{\vec{r}}{r}\bigg)=\frac{1}{r}\dot{r}-\frac{\dot{r}}{r^2}\vec{r}  ... \big(34)\]
\[=\frac{1}{r^3}\big[\dot{\vec{r}}\big(\vec{r}\cdot\vec{r})-\vec{r}\big(\vec{r}\cdot\dot{\vec{r}})]  ... \big(35)\]

then;
\[\vec{h}\times\dot{r}=-\mu\frac{d}{dt}\bigg(\frac{\vec{r}}{r}\bigg)  ... \big(36)\]

integrating both sides with respect to time will yield;
\[\vec{h}\times\dot{r}= -\mu \frac{\vec{r}}{r}- \vec{A}  ... \big(37)\]

where A is determined by the initial position and velocity.\\

We multiply through by \(\vec{r}\);
\[\big(\vec{h}\times\dot{r})\times\cdot\vec{r}= -\mu \boldmath{r}- \vec{A}\cdot\vec{r}  ... \big(38)\]

If we introduce, \(\nu\), as the true anomaly, the angle between A and the position vector \(\vec{r}\), we obtain;
\[h^2=\mu r + Ar \cos \nu  ... \big(39)\]
since
\[\big(a\times b\big)\cdot c = -\big(c\times b\big)\cdot a  ... \big(40)\]
letting \(P=h^2/\mu \) and \(e = A/\mu \) then;
\[r=\frac{P}{1+e \cos \nu}  ... \big(41)\]
For the above equation for any conic section except a parabola we will have
\[P = a\big(1-e^2)   ... \big(42)\]

therefore;
\[r=\frac{a\big(1-e^2)}{1+e \cos \nu}   ... \big(43)\]

Now we will use this equation to get the position of the satellite in it's orbit from the central body. We still have the problem which is described as; what is the position of a satellite in it's orbit after an elapsed time, \(t-t_o\). We can further refine the problem as; how long does it take for the satellite to move from one point to another in its orbit.

Kepler was able to solve this problem by defining the Mean Anomaly, the part of the orbit form the centre which the satellites sweeps relative to the perigee. Perigee is the shortest point to the centre along the satellite's orbit.

The change in Mean Anomaly is defined as;
\[M-M_o = n(t-t_o)   ... \big(44)\]

where;
\[n=\sqrt{\frac{\mu}{a^3}}   ... \big(45)\]

We define a variable \(E\) called the eccentric anomaly which can be written as;
\[cos E = \frac{ae + r \cos \nu}{a}   ... \big(46)\]
\[ \cos E = \frac{e+\cos \nu}{1+e \cos \nu}   ... \big(47)\]

given the above we will have the mean anomaly as;
\[M= E-sinE   ... \big(48)\]
this is Kepler's equation.


\section{\texorpdfstring{Chordal graphs}{Chordal graphs}}
\vspace{5mm}
\large

\begin{definition}[Chordal graph]
	G is chordal if $\forall k \geq 4: C_k \not\leq_{ind} G$.
	Sometimes called triangulated graphs.
\end{definition}

\begin{definition}[Simplicial]
	A vertex $u \in V(G)$ is simplicial  if $G[N_G(u)]$ (reduction of graph to neighborhood of $u$) is a complete graph.
	Definition is independent from taking closed (includes $u$) or open neighborhood.
\end{definition}

\begin{lemma}[1]
	Every inclusion-wise minimal vertex cut in a chordal graph induces a clique.
\end{lemma}
\begin{proof}
	$G\setminus A$ has components $V_1, V_2, \ldots V_k, k \geq 2$.
	Then
	\[ \forall i \forall u \in A \exists w \in V_i: uw \in E(G) \]
	Pick some component $V_i$ and some edge in $A$ then there is an edge between them.
	On the contrary, if there is no edge, $u$ can be removed from $A$.
	Which contradicts with minimality of $A$.

	% TODO picture
	Now we take $u, v \in A$, by previous observation
	\[ \exists w_1, w_2 \in V_i: uw_1, vw_2 \in E(G) \]
	Then take $P_1$ shortest path between $w_1, w_2$.
	Similarly $w_3, w_4 \in V_j$ and the shortest path $P_2$ between $w_3, w_4$.

	$P_1 \cup P_2$ is an induced cycle unless $uv \in E(G)$.

	Also, there is no edge between $V_i$ and $V_j, i \ne j$ as otherwise $A$ is not a cut.

	As $P_1$ is shortest path $vw_1, uw_2 \notin E(G)$.

	To sum up, $uv \in E(G)$.
	Since $u,v$ were arbitrary, $A$ is a complete subgraph.
\end{proof}

\begin{lemma}[2]\label{chordal_lemma_2}
	A chordal graph is complete or it contains 2 non-adjacent simplicial vertices.
\end{lemma}
\begin{proof}
	By induction on $|V(G)|$.
	The first step is $G$ is a complete graph.

	Inductive step: $G$ is not complete.
	Take a minimal vertex cut $A$.
	Let $B$ be a connected component of $G\setminus A$ and $C = (V(G) \setminus A) \setminus B$.
	\[ G_1 = G[B \cup A] \]
	\[ G_2 = G[C \cup A] \]

	% TODO picture

	As $|V(G_1)| < |V(G)|$ we can apply induction on it.
	Note that induced subgraph of chordal graph is also chordal.
	By induction hypothesis $G_1, G_2$ are either complete or have 2 simplicial vertices.

	One of the simplicial vertices cannot be in $A$ because $A$ is complete graph and simplicial vertices are not adjacent.
	No edges can connect $B, C$ therefore both of the vertices are simplicial in $G$.
\end{proof}

\begin{corollary}
	Every nonempty chordal graphs has a simplicial vertex.
\end{corollary}

Sometimes it is easier to proof stronger statement, because we have more power in inductive step.

\begin{definition}[PES]
	Perfect elimination scheme - for graph $G$ is a \emph{linear ordering} of its vertices.
	\[ V(G) = u_1, \ldots, u_n\]
	Such that $\forall i: u_i$ is simplicial for $G[\{ u_1, \ldots u_i\}]$
\end{definition}

\begin{lemma}[Chordal has PES]
	Every chordal graph allows a PES.
\end{lemma}
\begin{proof}
	Take any simplicial vertices and move it to the right.
	Then delete vertex picked in previous step and repeat.

	Formally: by induction on $n$ using corollary.
\end{proof}

\begin{definition}[Perfect graph]
	$G$ is perfect if for every subgraph chromatic number is equal to clique number.
	\[ \forall H \leq G: \chi(H) = \omega(H) \]
\end{definition}

\begin{theorem}[Chordal is Perfect]
	A chordal graph is perfect.
\end{theorem}
\begin{proof}
	% TODO rewrite
	Take a PES for a graph, color from left to right by colors $ \in \{ 1, 2, 3, \ldots \}$ by \textbf{first fit method}.

	Take smallest number that was not taken by the neighbors.

	If we a forced to use color $k$ then neighbors of the vertex used $(k - 1)$ colors.
	Which implies existence of complete graph on $(k - 1)$ vertices on the left from current vertex.
\end{proof}

\begin{definition}[Clique-tree decomposition]
	Clique-tree decomposition of a graph $G$ is a tree $T$
	\[ T = (\Q, F): V(T) = \Q = \{\text{maximal cliques of G} \} \]
	and
	\[ \forall u \in V(G): T[ \{Q: u \in Q \in \Q \}] \text{ is connected} \]
\end{definition}

\begin{theorem}[Chordal equivalent statements]
	For any graph $G$ the following are equivalent:
	\begin{enumerate}
		\item $G$ is chordal
		\item $G$ has a PES
		\item $G$ allows a Clique-tree decomposition
		\item $G$ is an intersection graph of subtrees of a tree
	\end{enumerate}
\end{theorem}
\begin{proof}
	$1 \Rightarrow 2$ By induction on the number of vertices, using \cref{chordal_lemma_2}.
	Pick simplicial vertex, put it at the end of PES.
	Remove vertex from graph and continue.

	$2 \Rightarrow 3$ let we have a PES $\{ u_1, \ldots u_n \}$.
	$G$ has maximal cliques: $Q = \{ Q_1, \ldots, Q_k \}$, $T = (\Q, E(T))$.
	Remove last vertex in PES from graph
	\[ G^{'} = G \setminus u_n \]
	It has cliques: $Q^{'} = \{ Q_1^{'}, \ldots, Q_k^{'} \} \Rightarrow$ by i.h
	\[ \exists T^{'} = (\Q^{'}, E(T^{'}) \]
	Consider 2 cases: $N_G(u_n) \cup \{ u_n \}$ is a maximal clique.
	Then is a maximal clique in $G^{'}$.

	O/w $N_G(u_n)$ is not a maximal clique of $G^{'}$.
	$\Rightarrow \exists Q_i^{'} \in \Q^{'}: N_G(u_n) \subsetneq Q_i^{'}$.
	We connect $N_G(u_n)$ to $Q_i^{'}$.

	$3 \Rightarrow 4$ we want to find an intersection graph of subtrees in tree.
	\[ G \simeq IF(\{T_u: u \in V(G) \}) \]
	such that
	\[ V(T_u) = \{ Q_i: y \in Q_i \} \subseteq \Q \]

	Proving the equivalence:
	\[ uv \in E(G) \Rightarrow \exists Q_i \in \Q: u,v \in Q_i \Rightarrow Q_i \in V(T_u) \cap V(T_v) \neq \emptyset \]
	On the other hand
	\[ V(T_u) \cap V(T_v) \neq \emptyset \Rightarrow \exists Q_i \in V(T_u) \cap V(T_v) \Rightarrow u, v \in Q_i \Rightarrow uv \in E(G) \]

	$4 \Rightarrow 1$ Let we have a tree $T$ with a collection of subtrees.
	\[V_u \subseteq V(T), u \in V(G): T[V_u] \text{ is connected}: \forall u \ne v \in V(G): uv \in E(G) \iff V_u \cap V_v \ne \emptyset \]
	Assume by contradiction $G$ is not chordal.
	By definition $\exists k \geq 4 \in \N: C_k \leq_{ind} G$.
	Let the cycle be $\{ u_1, u_2, \ldots, u_k \}$.
	$u_k u_1 \in E(G)$ by the assumption, take
	\[ T_1 = T[V_{u_1}], T_2 = T[V_{u_2}], T_3 = T[V_{u_3}] \]
	$T_1$ should cross $T_2$, also $T_3$ should cross $T_2$ but not $T_1$.
	\[ V_{u_1} \cap V_{u_2} \ne \emptyset \land V_{u_1} \cap V_{u_3} = \emptyset \]
	Therefore
	\[ \exists e \in E(T_2): e \notin E(T_1), E(T_2) \]
	Removing 1 edge makes tree disconnect:
	% TODO disjoint union
	\[ T \setminus e = T_a \mathbin{\dot{\cup}} T_b, V_{u_1} \subseteq V(T_a), V_{u_3} \subseteq V(T_b) \]
	Proceed by induction
	\[ \forall j, j = 3 \ldots k: V(T_j) \subseteq T_b \]
	inductive step
	\[ V_{u_j} \subseteq V(T_b), V_{u_{j + 1}} \cap V(T_b) \neq \emptyset, V_{u_{j + 1}} \cap V_{u_2} \ne \emptyset \Rightarrow V_{u_{j + 1}} \subseteq V(T_b)\]
	Therefore
	\[ V_{u_k} \cap V_{u_1} = \emptyset \]
	which contradicts $u_k u_1 \in E(g)$.

	% TODO next lecture

\end{proof}


\subsection{Hash Map}
\definecolor{inkscapeNavy}{rgb}{0.0, 0.0, 0.5}
\definecolor{inkscapeGreen}{rgb}{0.0, 0.5, 0.0}
\definecolor{inkscapeMaroon}{rgb}{0.5, 0.0, 0.0}

\begin{frame}{Associative Arrays}{The Hash Map}
  \textbf{Idea:}
  \begin{itemize}
    \item
      Mapping the keys onto indices with a {\color{MainA}hash function}
    \item
      Store the values at the calculated indices in a normal array
  \end{itemize}
  \textbf{Example:}
  \begin{itemize}
    \item
      Key set: $x = \{3904433, 312692, 5148949\}$
    \onslide <2-> \item
      Hash function:
      {\color{MainA}$h(x) = x \;\mathrm{mod}\; 5$},
      in the range {\color{MainA} $[0, \ldots, 4]$ }
    \onslide <3-> \item We need an array {\color{MainA}T}
      with {\color{MainA}5} elements.\\
      A \enquote{hash table} with 5 \enquote{buckets}
    \onslide <4-> \item
      The element with the key {\color{MainA}x}
      is stored in {\color{MainA}$T[h(x)]$}
  \end{itemize}
\end{frame}

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

\begin{frame}{Associative Arrays}{The Hash Map}
  \textbf{Storage:}
  \vspace{0.1em}
  \begin{itemize}
    \setlength\itemsep{0.75em}
    \item<2->
    \small \texttt{insert(3904433,"A")}:
    $h(3904433) = 3 \hspace*{-0.1em} \Rightarrow$
    T[3] = {\color{inkscapeGreen}(3904433, "A")}
    \item<3->
    \small \texttt{insert(312692, "B")}:
    $h(312692) = 2 \hspace*{-0.1em} \Rightarrow$
    T[2] = {\color{inkscapeMaroon}(312692, "B")}
    \item<4->
    \small \texttt{insert(5148949, "C")}:
    $h(5148949) = 4 \hspace*{-0.1em} \Rightarrow$
    T[4] = {\color{inkscapeNavy}(5148949, "C")}
  \end{itemize}
  \vspace{0.1em}
  \begin{figure}
  \caption{Hash table T}
  \centering
\only<1-1>{\includegraphics[width=0.6\textwidth]{Images/Bucket1.pdf}}%
\only<2-2>{\includegraphics[width=0.6\textwidth]{Images/Bucket2.pdf}}%
\only<3-3>{\includegraphics[width=0.6\textwidth]{Images/Bucket3.pdf}}%
\only<4->{\includegraphics[width=0.6\textwidth]{Images/Bucket4.pdf}}
  \end{figure}
\end{frame}

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

%%%%% : TODO: Add the check step!
\begin{frame}{Associative Arrays}{The Hash Map}
  \textbf{Searching:}
  \small
  \begin{itemize}
     \setlength\itemsep{0.75em}
    \item<1->
      \texttt{search(3904433)}:
      $h(3904433) = 3 \hspace*{0.5em} \Rightarrow$
      T[3] $\rightarrow$ {\color{inkscapeGreen}(3904433, "A")}
    \item<2->
      \texttt{search(123459)}:
      $h(123459) = 4 \hspace*{0.5em} \Rightarrow$
      T[4] {}\\
      \vspace{0.75em}
      $\Rightarrow$ {\color{red}Value with key 123459 does not exist}
    \item<3->
      Search time for this example: {\color{MainA}$\mathcal{O}(1)$}
  \end{itemize}
  \vspace*{-1.0em}
  \begin{figure}
    \caption{Hash table T}
    \centering
    \includegraphics[width=0.6\textwidth]{Images/Bucket4.pdf}
  \end{figure}
\end{frame}

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

\begin{frame}{Associative Arrays}{Hash Collisions}
  \textbf{Further inserting:}
  \begin{itemize}
    \item<1->
      \texttt{insert(876543, "D")}:
      $\hspace*{0.5em} h(876543) = 3$\\
      \onslide <2->
      $\hspace*{0.5em} \Rightarrow$
      T[3] = (876543, "D")
      $\Rightarrow$ {\color{red}{Collision}}
    \item<3->
      This happens more often than expected
      \begin{itemize}
        \item
          \textbf{Birthday problem:}
          with 23 people we have the probability of $50\;\%$ that 2 of
          them have birthday at the same day
      \end{itemize}
  \end{itemize}
  \vspace*{-1.0em}
  \onslide <1->
  \begin{figure}
    \caption{Hash table T}
    \centering
       \includegraphics[width=0.6\textwidth]{Images/Bucket4.pdf}
  \end{figure}
\end{frame}

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

\begin{frame}{Associative Arrays}{Hash Collisions}
  \textbf{Problem:}
  \begin{itemize}
    \item
      Two keys are equal {\color{MainA} $h(x) = h(y)$} but not the values
      {\color{MainA} $x \neq y$}
  \end{itemize}
  \onslide<2->{\textbf{Easiest Solution:}}
  \begin{itemize}
    \item<3->
      Represent each bucket as list of key-value pairs
    \item<4->
      Append new values to the end of the list
  \end{itemize}
    \vspace*{-1.0em}
    \begin{figure}
    \onslide <3->\caption{Hash table T}
    \centering
    \only<1-3>{\includegraphics[width=0.6\textwidth]{Images/Bucket4.pdf}}
    \only<4-4>{\includegraphics[width=0.6\textwidth]{Images/Bucket5.pdf}}
  \end{figure}
\end{frame}

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

%% \begin{frame}{Associative Arrays}{Hash Collisions}
%%   \textbf{Example:}
%%   \begin{itemize}
%%     \item
%%     Key set: $k = \{3904, 3126, 5148, 4522\}$
%%     \item
%%     Hash function:
%%     $h(k) = k \;\mathrm{mod}\; 5 \hspace*{1.0em} \in \{0, \ldots, 4\}$
%%   \end{itemize}
%%   \textbf{Inserting:}
%%   \begin{itemize}
%%     \item
%%       \dots
%%     \item
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|insert(8769, "D")|:
%%       $\hspace*{0.5em} h(8769) = 4$
%%       $\hspace*{0.5em} \Rightarrow$
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|T[4].append((8769, "D"))|
%%     \item
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|search(8769)|:
%%       $\hspace*{0.5em} h(8769) = 4$\\
%%       $\hspace*{1.5em} \Rightarrow$
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|T[4]|
%%       $\Rightarrow$
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|[(3904, "A"), (8769, "D")]|
%%   \end{itemize}
%%   \vspace*{-1.0em}
%%   \begin{table}[!b]
%%     \caption{Hash table T}
%%     \label{tab:hash_table:example_linked}
%%     \begin{tabularx}{\textwidth}{l|ccccc}
%%       {} & 0 & 1 & 2 & 3 & 4\\
%%       \midrule
%%       Bucket &
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|[]| &
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|[(3126, "B")]| &
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|[]| &
%%       \lstinline[
%%         language=Python,
%%         style={python-idle-code},
%%         basicstyle=\small
%%       ]|[(5148, "C")]| &
%%       \begin{math}
%%         \left[\begin{array}{@{}l@{}}
%%           \lstinline[
%%             language=Python,
%%             style={python-idle-code},
%%             basicstyle=\small
%%           ]|(3904, "A"),|\\
%%           \lstinline[
%%             language=Python,
%%             style={python-idle-code},
%%             basicstyle=\small
%%           ]|(8769, "D")|
%%         \end{array}\right]
%%       \end{math}
%%     \end{tabularx}
%%   \end{table}
%% \end{frame}

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

\begin{frame}{Associative Arrays}{Expected Runtime}
  \begin{columns}
    \begin{column}{0.5\linewidth}
      {\color{MainA}Best case}:
      \begin{itemize}
        \item
          We have {\color{MainA}$n$} keys which are equally distributed over {\color{MainA}$m$} buckets
        \item
          We have {\color{MainA}$\approx \frac{n}{m}$} pairs per bucket
        \item
          The runtime for searching is nearly {\color{MainA}$\mathcal{O}(1)$}
          if \textbf{not} {\color{MainA}$n \gg m$}
      \end{itemize}
    \end{column}
    \begin{column}{0.5\linewidth}
      \begin{center}
        \textbf{Best case}\\
        \textbf{($m = 5, \, n = 10$)}\\[1em]
        \includegraphics[height=0.4\textheight]{Images/hash-uniform.pdf}
%        \label{tab:hash_table:runtime_best_case}
        %  \begin{tabularx}{\textwidth}{c|c}
        %   {} & Bucket\\
        %   \midrule
        %   0 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small,
        %     mathescape
        %   ]|[($\ldots$), ($\ldots$)]|\\
        %   1 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small,
        %     mathescape
        %   ]|[($\ldots$), ($\ldots$)]|\\
        %   2 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small,
        %     mathescape
        %   ]|[($\ldots$), ($\ldots$)]|\\
        %   3 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small,
        %     mathescape
        %   ]|[($\ldots$), ($\ldots$)]|\\
        %   4 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small,
        %     mathescape
        %   ]|[($\ldots$), ($\ldots$)]|
        % \end{tabularx}
      \end{center}
    \end{column}
  \end{columns}
\end{frame}

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

\begin{frame}{Associative Arrays}{Expected Runtime}
  \begin{columns}
    \begin{column}{0.4\linewidth}
      {\color{MainA}Worst case}:
      \begin{itemize}
        \item
          All {\color{MainA}$n$} keys are mapped onto the same bucket
        \item
          The runtime is {\color{MainA}$\Theta(n)$} for searching
      \end{itemize}
    \end{column}
    \begin{column}{0.5\linewidth}
      \begin{center}
        \textbf{Worst case}\\
        \textbf{($m = 5, \, n = 10$)}\\[1em]
        \includegraphics[height=0.4\textheight]{Images/hash-extreme.pdf}
        \label{tab:hash_table:runtime_worst_case}
        % \begin{tabularx}{\textwidth}{c|c}
        %   {} & Bucket\\
        %   \midrule
        %   0 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small
        %   ]|[]|\\
        %   1 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small
        %   ]|[]|\\
        %   2 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small,
        %     mathescape
        %   ]|[($\ldots$), ($\ldots$), $\;\ldots\;$, ($\ldots$)]|\\
        %   3 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small
        %   ]|[]|\\
        %   4 & \lstinline[
        %     language=Python,
        %     style={python-idle-code},
        %     basicstyle=\small
        %   ]|[]|
        % \end{tabularx}
      \end{center}
    \end{column}
  \end{columns}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{The basic concept of Fully Convolutional Network}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The main purpose of such approach is to automatically perform feature extraction by training a model using full wavefield images, hence, it will learn by itself to recognise the patterns and detect the delamination and localise it.
In our work we are using the fully convolutional network (FCN)~\cite{long2015fully}, which aims to perform pixel-wise segmentation by classifying every pixel of the input image as damaged or not.

The idea behind FCN is to stack a group of convolutional layers in an encoder-decoder style.
The encoder is capable for downsampling the input image through convolutions with strides, consequently, resulting in a compressed feature representation of the input image, and the decoder is capable to upsample the image with compressed features applying techniques like transposed convolution with strides and upsampling with interpolation (e.g. bilinear or nearest).

In order to reduce overfitting in the model, some techniques were applied such as adding dropouts to layers and batch normalization.

For the output layer, we have applied two activation functions in separate experiments, the first one is softmax and the second one is sigmoid.
The softmax function calculates the probability of the damage occurrence and the healthy state for every single pixel, hence, the summation of the two probabilities must equal one. Eq.~(\ref{softmax}) illustrates the softmax, where \(P(x)_{i}\) is the probability of each target class \(x_{j}\) over all possible target classes \(x_{j}\), C in our case are two classes  (damaged and undamaged).
To predict the output label of the detection (\(y_{pred}\)) which represent the probability of damaged and undamaged, we applied the \(\argmax\) function to select the maximum probability of the softmax activation function.
	\begin{equation}
		P(x)_{i} = \frac{e^{x_{i}}}{\sum_{j}^{C} e^{x_{j}}}
		\label{softmax}
	\end{equation}
	\begin{equation}
		y_{pred} = \argmax_{i}\left( P(x)_{i} \right)
		\label{argmax}
	\end{equation}

When using sigmoid in the output layer, it produces a vector of values between (\(0\) and \(1\)) indicating the damage weight for each pixel.
Low values indicate low damage probability and high output values indicate high damage probability. Eq.~(\ref{sigmoid}) illustrates the sigmoid function, where \(z\) is the summation of adjustable weights \(\{w_0,w_1,...,w_n \}\) multiplied by input variables (from the previous layer) \(\{x_0,x_1,_...,x_n\}\) and bias \(b\) as shown in Eq.~(\ref{z}).
	\begin{equation}
		\sigma(z) = \frac{1}{1+e^{-z}}
		\label{sigmoid}
	\end{equation}
	\begin{equation}
		z= \sum_{i=0}^{n}  w_i\, x_i +b
		\label{z}
	\end{equation}
Selecting the loss function is a crucial task in deep learning since it measures how good the model predicts.
We have applied two types of losses based on the used function in the final activation layer: a binary cross-entropy (BCE) loss function applied with a sigmoid activation function in the output layer and a categorical cross-entropy (CCE) loss function with a softmax activation in the output layer that is also called \enquote{softmax loss function}.
Eq.~(\ref{BCE}) illustrates the BCE, where \(\hat{Y}\) represents the predicted vector values and \(Y\) represents the ground truth vector values, when \(\hat{Y} \approx Y\) then the BCE will be almost \(0\) meaning that the model was able to predict the output, so, the aim is to reduce the loss function to the minimum value.
	\begin{equation}
		BCE = (1-Y)\log(1-\hat{Y})+Y\log(\hat{Y})
		\label{BCE}
	\end{equation}
Eq.~(\ref{CCE}) illustrates the CCE, where \( P(x)_{i}\) is the softmax value of the target class.
	\begin{equation}
	CCE = -\log\left( P(x)_{i} \right)
	\label{CCE}
	\end{equation}

Moreover, we have applied intersection over union (IoU) as our accuracy metric.
IoU is applied to find the intersection area between the ground truth value and the predicted value.
The IoU metric is defined as:
\begin{equation}
IoU = \frac{Intersection}{Union} = \frac{\hat{Y} \cap Y}{\hat{Y} \cup Y}
\label{IoU}
\end{equation}
The intersection between the predicted and the ground truth values is simply calculated through multiplying their values then summing the resulted values.
As we mentioned earlier the ground truth values are either \((0\) or \(1)\) thus only the predicted values larger than \(0\) multiplied by their ground truth label \(1\) will be counted, the rest values will equal to \(0\).
The union can be calculated by summing all values in both the predicted and the ground truth  vectors, then we subtract the intersection from their sum.
Our main goal is to maximize the IoU accuracy metric, since the higher the IoU, the higher the accuracy of the predicted delamination in terms of location, shape and size.

Furthermore, during training the model our focus is to minimize the loss and maximize the accuracy metric by converting it into an optimization problem.
The optimizer is responsible for updating the model learnable parameters such as filters weights and biases in a way the overall loss is minimized and the accuracy is maximized.
In the proposed approach, Adam optimizer was applied, which is considered as a combination of RMSprop and Stochastic Gradient Descent (SGD)~\cite{Kingma2015}.

In the next subsection, we are going to present an FCN model for pixel-wise semantic segmentation in order to detect and localise delaminations.


\documentclass{memoir}
\usepackage{notestemplate}
%\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}
%\institute{Rice University}
%\faculty{Faculty of Whatever Sciences}
%\department{Department of Mathematics}
%\title{Class Notes}
%\subtitle{Based on MATH xxx}
%\author{\textit{Author}\\Gabriel \textsc{Gress}}
%\supervisor{Linus \textsc{Torvalds}}
%\context{Well, I was bored...}
%\date{\today}

%\makeindex

\begin{document}

% \maketitle

% Notes taken on 06/03/21

\section{Group Representations and Free Groups}
\label{sec:group_representations_and_free_groups}
We revisit group representations by introducing some new concepts to incorporate, and see how that allows us to expand our theory.

\begin{defn}[Commutator]
	Let \(x,y \in G\) be elements of a group, and let \(A,B \subset G\) be nonempty subsetf of \(G\). The \textbf{commutator of \(x\) and \(y\)} is denoted by
	\begin{align*}
		[x,y] = x ^{-1}y^{-1}xy
	\end{align*}
	and the group generated by commutators of elements from \(A,B\) is denoted by
	\begin{align*}
		[A,B] = \langle [a,b] \mid a \in A, b \in B \rangle .
	\end{align*}
	We can also define a subgroup of \(G\) by the group generated by commutators of elements of \(G\):
	\begin{align*}
		G' = \langle [x,y] \mid x,y \in G \rangle
	\end{align*}
	We call this the \textbf{commutator subgroup} of \(G\).
\end{defn}
This terminology arises because the commutator of \(x,y\) is 1 if and only if \(x\) and \(y \) commute.

\begin{prop}[Properties of commutators]
	Let \(x,y \in G\) be elements of a group and let \(H\leq G\). Then
	\begin{itemize}
		\item \(xy = yx[x,y]\)
		\item \(H \triangleleft G\) if and only if \([H,G] \leq H\)
		\item \(\sigma [x,y] = [\sigma (x),\sigma (y)]\) for any automorphism \(\sigma \) of \(G\). Hence, \(G' \textrm{char}G\), and \(G / G'\) is abelian.
		\item If \(H \triangleleft G\) and \(G/H\) is abelian, then \(G' \leq H\). Conversely, if \(G' \leq H\), then \(H \triangleleft G\) and \(G / H\) is abelian.
		\item If \(\varphi :G\to H\) is a homomorphism of \(G\) into \(H\) and \(H\) is abelian, then \(G' \leq \textrm{Ker}\varphi \) and the following diagram commutes:
\begin{center}
			\begin{tikzpicture}
  \matrix (m)
    [
      matrix of math nodes,
      row sep    = 3em,
      column sep = 4em
    ]
    {
	    G & G / G' \\
	     & H            \\
    };
  \path
    (m-1-2) edge [->] node {} (m-2-2)
    (m-1-1.east |- m-1-2)
      edge [->] node {} (m-1-2)
      (m-1-1) edge [->] node [below] {$\varphi$} (m-2-2);
\end{tikzpicture}
\end{center}
	\end{itemize}
\end{prop}
The way to think about this is that by passing to the quotient by the commutator subgroup of \(G\), we collapse all commutators to identity. Hence, all elements in the quotient group commute. This is why we have such a strong property in that, if \(G' \leq H\), then \(G / H\) must be abelian.\\

One word of caution-- there can be elements of the commutator subgroup that \textit{cannot} be written as a single commutator \([x,y]\) for any \(x,y\). In other words, \(G'\) is not just the set of single commutators, but is the group generated by elements of that form.

\begin{prop}
	Let \(H,K \leq G\) be subgroups. The number of distinct ways of writing each element of the set \(HK\) in the form \(hk\), for some \(h \in H\), \(k \in K\), is \(\left| H \cap K \right| \).\\

	If \(H\cap K = 1\), then each element of \(HK\) can be written uniquely as a product \(hk\) for some \(h \in H\), \(k \in K\).
\end{prop}

\begin{thm}
	Let \(H,K\leq G\) be subgroups of \(G\) such that \(H,K \triangleleft G\) and \(H\cap K = 1\). Then
	\begin{align*}
		HK \cong H\times K
	\end{align*}
\end{thm}

\subsection{Free Groups}
\label{sub:free_groups}

The idea of the free group is to define a group \(F(S)\) to be generated by some set \(S\) with no relations on any of the elements of \(S\). For example, if \(S = \left\{ a,b \right\} \), then some elements of \(F(S)\) would be of the form \(a,aa,ab,abab,bab\), as well as the inverses of these elements. We call elements of a free group \textbf{words}. Then we can multiply elements in the free group simply by concatenation. Our goal will be to define this formally and show it indeed satisfies the necessary properties.

\begin{general}[Construction of Free Groups]
	Let \(S\) be a set, and let \(S^{-1}\) be a set disjoint from \(S\) such that there is a bijection from \(S\) to \(S^{-1}\). We denote the corresponding element for \(s \in S\) to be \(s\mapsto s^{-1}\in S^{-1}\), and furthermore we denote \((s^{-1})^{-1} = s\). Finally, we add a third singleton set disjoint from \(S,S^{-1}\) and call it \(\left\{ 1 \right\} \), and define it so \(1^{-1} = 1\). We also define that for any \(x \in S \cup S^{-1}\cup \left\{ 1 \right\} \), \(x^{1} = x\).\\

	A \textbf{word} on \(S\) is a sequence \((s_1,s_2,s_3,\ldots)\) where \(s_i \in S\cup S^{-1} \cup \left\{ 1 \right\} \), and \(s_i = 1\) for all \(i\geq N\) for some arbitrarily large \(N\) (so that words are "infinite", but not in practice). In order to get uniqueness of words, we say a word is \textbf{reduced} if
	\begin{align*}
		s_{i+1} \neq s_{i}^{-1} \quad \forall i, s_i \neq 1\\
		s_k = 1 \implies s_i = 1 \; \forall i \geq k
	\end{align*}
	We refer to the special word given by
	\begin{align*}
		(1,1,1,\ldots)
	\end{align*}
	to be the \textbf{empty word} and denote it by \(1\). Let \(F(S)\) be the set of reduced words on \(S\), and embed mKS into \(F(S)\) by
	\begin{align*}
		s \mapsto (s,1,1,1,\ldots)
	\end{align*}
	Hence we identify \(S\) with its image and consider \(S\subset F(S)\). Notie that if \(S = \emptyset\), \(F(S) = \left\{ 1 \right\} \).\\

	Now we simply introduce a binary operation on \(F(S)\), so that two words in \(F(S)\) are concatenated, then reduced to their reduced word form. We leave the details of defining this binary operation to the reader, but one can check that this operation is well-defined and satisfies all the properties of a group operation.
\end{general}

\begin{thm}
	\(F(S)\) is a group by the binary operation of word concatenation with reduction.
\end{thm}
Furthermore, free groups satisfy a special kind of universal property.
\begin{thm}
	Let \(G\) be a group, \(S\) a set, and \(\varphi :S\to G\) a set map. There is a unique group homomorphism \(\Phi :F(S) \to G\) such that the following diagram commutes:
\begin{center}
			\begin{tikzpicture}
  \matrix (m)
    [
      matrix of math nodes,
      row sep    = 3em,
      column sep = 4em
    ]
    {
	    S & F(S) \\
	     & G            \\
    };
  \path
	  (m-1-2) edge [->] node [right] {\(\Phi \)} (m-2-2)
    (m-1-1.east |- m-1-2)
    edge [->] node [above] {inclusion} (m-1-2)
      (m-1-1) edge [->] node [below] {$\varphi$} (m-2-2);
\end{tikzpicture}
\end{center}

\end{thm}
This further shows that \(F(S)\) is unique up to a unique isomorphism, which is the identity map on the set \(S\).

\begin{defn}[Free Group]
	The group \(F(S)\) is called the \textbf{free group} on the set \(S\). A group \(F\) is a \textbf{free group} if there is some set \(S\) such that \(F = F(S)\), in which case we call \(S\) a set of \textbf{free generators} of \(F\). The cardinality of \(S\) is called the \textbf{rank} of the free group.
\end{defn}

\begin{thm}
	Subgroups of a free group are free.
\end{thm}
Furthermore, if \(G\leq F\) are free and \([F:G] = m\), then
\begin{align*}
	\textrm{rank}(G) = 1 + m(\textrm{rank}(F)-1)
\end{align*}
Proving this requires a lot of other tools, such as covering spaces.

\subsection{Presentations}
\label{sub:presentations}

Notice that if we take \(S = G\), then we can view \(G\) as a homomorphic image of the free group \(F(G)\) onto \(G\). Moreover, if \(G= \langle S \rangle \), there is a unique surjective homomorphism from  \(F(S)\) onto \(G\) which is the identity on \(S\). This allows us to construct a more powerful construction of presentations, generators, and relations.

\begin{defn}
	A subset \(S\subset G\) \textbf{generates \(G\)} by \(G = \langle S \rangle \) if and only if the map \(\pi :F(S) \to G\) which extends the identity map of \(S\) to \(G\) is surjective.
\end{defn}
This is distinct but equivalent to our earlier notion for subsets generating a group. However, it is more flexible, so we will use this from here on out.

\begin{defn}[Presentations, Generators, and Relations]
	Let \(S\subset G\) be a subset of \(G\) such that \(G = \langle S \rangle \). A \textbf{presentation} for \(G\) is a pair \((S,R)\), where \(R\) is a set of words in \(F(S)\) such that
	\begin{align*}
		\textrm{ncl}_{F(S)}(\langle R \rangle ) = \textrm{Ker}(\pi )
	\end{align*}
	where \(\textrm{ncl}\) denotes the normal closure (the smallest normal subgroup containing \(\langle R \rangle \)). The elements of \(S\) are called \textbf{generators}, and the elements of \(R\) are called \textbf{relations} of \(G\).\\

	We say \(G\) is \textbf{finitely generated} if there is a presentation \((S,R)\) such that \(S\) is finite. Furthermore, \(G\) is \textbf{finitely presented} if \(R\) is also finite.
\end{defn}
A word of caution-- the kernel of the map \(F(S) \to G\) is \textit{not} \(\langle R \rangle \), but instead the union of all subsets conjugate to \(\langle R \rangle \) (including \(\langle R \rangle \) itself). Furthermore, even if \(S\) is fixed, a group will have many different presentations.\\

Finally, often when writing relations, if we have \(w_1w_2^{-1} = 1\), we might instead write \(w_1=w_2\), or vice versa.

\subsection{Applying presentations to find homomorphisms and automorphisms}
\label{sub:applying_presentations_to_find_homomorphisms_and_automorphisms}

Suppose \(G\) is presented by \((\langle a,b \rangle , \langle r_1,\ldots,r_k \rangle )\). Then if \(a',b' \in H\) are elements that satisfy \(r_1,\ldots,r_k\), then there is a homomorphism from \(G\) into \(H\). If \(\pi :F(\left\{ a,b \right\} )\to G\) is the presentation homomorphism, we can define
\begin{align*}
	\pi ':F(\left\{ a,b \right\} ) \to H\\
	\pi'(a) = a', \; \pi'(b) = b'.
\end{align*}
This works because \(\textrm{Ker}\pi \leq \textrm{Ker}\pi'\), and so \(\pi '\) factors through \(\textrm{Ker}\pi \) and we get
\begin{align*}
	G \cong F(\left\{ a,b \right\} ) / \textrm{Ker}\pi \to H
\end{align*}
Moreover, if \(\langle a',b' \rangle = H = G\), then this homomorphism is an automorphism of \(G\)(!!). In the other direction, any automorphism on a presentation must send a set of generators to another set of generators satisfying the same relations.

\begin{exmp}[Dihedral presentation]
	Consider \(D_8 = \langle a,b \mid a^2 = b^{4} =1, aba = b^{-1} \rangle \). Any pair of elements \(a',b'\) that are of order 2 and 4 (and \(a'\) is noncentral) must satisfy the same relations. There are four noncentral elements of order 2, and two elements of order 4, so \(D_8\) has 8 automorphisms.
\end{exmp}
Similarly, any distinct pair of elements of order \(4\) in \(Q_8\) that are not inverses of each other necessarily generate \(Q_8\) and satisfy its relations. There are \(24\) such pairs, so \(\left| \textrm{Aut}(Q_8) \right| =24\). As one can see, free groups are an incredibly useful tool to classify these maps.

% \printindex
\end{document}


\section{Vector representation of words}


% !TeX spellcheck = en_US
\documentclass[12pt,a4paper,DIV=calc]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage[english]{babel}
\usepackage{microtype}
\usepackage{enumitem}
\linespread{1.05}
\KOMAoptions{DIV=last}
\usepackage{mathtools}
\usepackage{physics}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[colorlinks,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}
\frenchspacing

\begin{document}

This document describes the mathematical formulas behind the \textsc{Quill} PIC code and how the formulas used in the lecture notes \cite{PukhovLectures} and the paper \cite{PukhovCERN} by Prof. Pukhov translate to the formulas used here.

\tableofcontents

\newpage

\section{Grid in Quill} \label{sec:grid}

Unlike the grid described in \cite{PukhovLectures, PukhovCERN}, where the charge was in the centers of the cells, in Quill, the charge is in the nodes.

\begin{figure}[h]
\centering
\begin{tikzpicture}
    \def\len{5};
    \def\ldx{2};
    \def\ldy{1};
    \coordinate (A) at (0,0);
    \coordinate (B) at (\len,0);
    \coordinate (C) at ({\len+\ldx},\ldy);
    \coordinate (D) at (\ldx,\ldy);
    \coordinate (A1) at (0,\len);
    \coordinate (B1) at (\len,\len);
    \coordinate (C1) at ({\len+\ldx},{\len+\ldy});
    \coordinate (D1) at (\ldx,{\len+\ldy});
    \draw (A) -- (B);
    \draw (B) -- (C);
    \draw [dashed] (C) -- (D);
    \draw [dashed] (A) -- (D);
    \draw (A) -- (A1);
    \draw (B) -- (B1);
    \draw (C) -- (C1);
    \draw [dashed] (D) -- (D1);
    \draw (A1) -- (B1);
    \draw (B1) -- (C1);
    \draw (C1) -- (D1);
    \draw (A1) -- (D1);
    \node at (A) {\textbullet};
    \node[anchor=north east] at (A) {$\rho^{i,j,k}$};
    \node at (C1) {\textbullet};
    \node[anchor=south west] at (C1) {$\rho^{i+1,j+1,k+1}$};
    \coordinate (AB) at ($(A)!0.5!(B)$);
    \node at (AB) {\textbullet};
    \node[anchor=north] at (AB) {$E_x^{i,j,k}$};
    \coordinate (AC) at ($(A)!0.5!(C)$);
    \node at (AC) {\textbullet};
    \node[anchor=west] at (AC) {$B_z^{i,j,k}$};
    \coordinate (AD) at ($(A)!0.5!(D)$);
    \node at (AD) {\textbullet};
    \node[anchor=south] at (AD) {$E_y^{i,j,k}$};
    \coordinate (AA1) at ($(A)!0.5!(A1)$);
    \node at (AA1) {\textbullet};
    \node[anchor=east] at (AA1) {$E_z^{i,j,k}$};
    \coordinate (AD1) at ($(A)!0.5!(D1)$);
    \node at (AD1) {\textbullet};
    \node[anchor=south] at (AD1) {$B_x^{i,j,k}$};
    \coordinate (AB1) at ($(A)!0.5!(B1)$);
    \node at (AB1) {\textbullet};
    \node[anchor=west] at (AB1) {$B_y^{i,j,k}$};
\end{tikzpicture}
\caption{Depiction of one cell of the grid used in Quill.}
\label{fig:cell}
\end{figure}

\section{Indices used in Quill}\label{sec:indices}
The papers \cite{PukhovLectures, PukhovCERN} use half-integer indices, which is impossible to do in the code.
Below is the table describing how to translate indices from Quill to the indices used in the papers for different fields.

\begin{tabular}{ l | l l | l l }
    Field & Quill &  Papers & Papers & Quill\\
    \hline
    $\rho$ & $i,j,k$ & $\lbrace i,j,k\rbrace-1/2$ & $\lbrace i,j,k\rbrace + 1/2$ & $\lbrace i,j,k\rbrace+1$ \\
    &&&&\\
    $j_x$, $E_x$ & $i,j,k$ & $i,j-1/2,k-1/2$ & $i,j+1/2,k+1/2$ & $i,j+1,k+1$ \\
    $j_y$, $E_y$ & $i,j,k$ & $i-1/2,j,k-1/2$ & $i+1/2,j,k+1/2$ & $i+1,j,k+1$ \\
    $j_z$, $E_z$ & $i,j,k$ & $i-1/2,j-1/2,k$ & $i+1/2,j+1/2,k$ & $i+1,j+1,k$ \\
    &&&&\\
    $B_x$ & $i,j,k$ & $i-1/2,j,k$ & $i+1/2,j,k$ & $i+1,j,k$\\
    $B_y$ & $i,j,k$ & $i,j-1/2,k$ & $i,j+1/2,k$ & $i,j+1,k$\\
    $B_z$ & $i,j,k$ & $i,j,k-1/2$ & $i,j,k+1/2$ & $i,j,k+1$
\end{tabular}

\section{Maxwell solver}

\subsection{The NDFX solver}

\subsubsection{Scheme}

Using the table from Sec.~\ref{sec:indices}, we write the formulas for the NDFX solver with indices used in the PIC code.
As the time scheme is of little interest here, the indices will be in superscripts.
\begin{align}
    \frac{\Delta B_x^{i,j,k}}{\Delta t} = &-\frac{1}{\Delta y}\big[b_z \left(E_z^{i,j+1,k} - E_z^{i,j,k} \right) + \nonumber \\
    &+a_z \left(E_z^{i,j+1,k+1} - E_z^{i,j,k+1} + E_z^{i,j+1,k-1} - E_z^{i,j,k-1}\right)\big] + \nonumber \\
    &+\frac{1}{\Delta z} \big[b_y \left(E_y^{i,j,k+1} - E_y^{i,j,k}\right) + \nonumber \\
    &+a_y \left(E_y^{i,j+1,k+1}-E_y^{i,j+1,k} + E_y^{i,j-1,k+1} - E_y^{i,j-1,k}\right)
\end{align}
\begin{align}
    \frac{\Delta B_y^{i,j,k}}{\Delta t} = &\frac{1}{\Delta x}\big[b_z \left(E_z^{i+1,j,k} - E_z^{i,j,k} \right) + \nonumber \\
    &+a_z \left(E_z^{i+1,j,k+1} - E_z^{i,j,k+1} + E_z^{i+1,j,k-1} - E_z^{i,j,k-1}\right) - \nonumber \\
    &-\frac{1}{\Delta z} \big[ b_x \left(E_x^{i,j,k+1} - E_x^{i,j,k}\right) + \nonumber \\
    &+a_x \left(E_x^{i+1,j,k+1} - E_x^{i+1,j,k} + E_x^{i-1,j,k+1} - E_x^{i-1,j,k}\right)
\end{align}
\begin{align}
    \frac{\Delta B_z^{i,j,k}}{\Delta t} = &\frac{1}{\Delta y}\big[b_x\left(E_x^{i,j+1,k} - E_x^{i,j,k} \right) + \nonumber \\
    &+a_x \left(E_x^{i+1,j+1,k} - E_x^{i+1,j,k} + E_x^{i-1,j+1,k} - E_x^{i-1,j,k}\right) \big] - \nonumber \\
    &-\frac{1}{\Delta x} \big[ b_y \left(E_y^{i+1,j,k} - E_y^{i,j,k}\right) + \nonumber \\
    &+a_y \left(E_y^{i+1,j+1,k} - E_y^{i,j+1,k} + E_y^{i+1,j-1,k} - E_y^{i,j-1,k} \right) \big]
\end{align}
\begin{align}
    \frac{\Delta E_x^{i,j,k}}{\Delta t} = &\frac{1}{\Delta y}\big[b_z \left(B_z^{i,j,k} - B_z^{i,j-1,k} \right) + \nonumber\\
    &+ a_z \left(B_z^{i,j,k+1} - B_z^{i,j-1,k+1} + B_z^{i,j,k-1} - B_z^{i,j-1,k-1}\right) \big] - \nonumber\\
    &- \frac{1}{\Delta z}\big[ b_y \left(B_y^{i,j,k}-B_y^{i,j,k-1}\right) + \nonumber\\
    &+ a_y \left(B_y^{i,j+1,k} - B_y^{i,j+1,k-1} + B_y^{i,j-1,k} - B_y^{i,j-1,k-1}\right) \big] - \nonumber\\
    &- j_x^{i,j,k}
\end{align}
\begin{align}
    \frac{\Delta E_y^{i,j,k}}{\Delta t} = &-\frac{1}{\Delta x}\big[b_z\left(B_z^{i,j,k} - B_z^{i-1,j,k}\right) + \nonumber \\
    &+ a_z \left(B_z^{i,j,k+1} - B_z^{i-1,j,k} + B_z^{i,j,k-1} - B_z^{i-1,j,k-1}\right)\big] + \nonumber \\
    &+ \frac{1}{\Delta z}\big[ b_x \left(B_x^{i,j,k} - B_x^{i,j,k-1}\right) + \nonumber \\
    &+ a_x\left(B_x^{i+1,j,k} - B_x^{i+1,j,k-1} + B_x^{i-1,j,k} - B_x^{i-1,j,k-1}\right)\big] - \nonumber \\
    &- j_y^{i,j,k}
\end{align}
\begin{align}
    \frac{\Delta E_z^{i,j,k}}{\Delta t} = &\frac{1}{\Delta x}\big[b_y\left(B_y^{i,j,k} - B_y^{i-1,j,k}\right) + \nonumber \\
    &+ a_y \left(B_y^{i,j+1,k} -B_y^{i-1,j+1,k} + B_y^{i,j-1,k} - B_y^{i-1,j-1,k} \right)\big] - \nonumber \\
    &- \frac{1}{\Delta y}\big[ b_x\left(B_x^{i,j,k} - B_x^{i,j-1,k}\right) + \nonumber \\
    &+ a_x \left(B_x^{i+1,j,k} - B_x^{i+1,j-1,k} + B_x^{i-1,j,k} - B_x^{i-1,j-1,k} \right)\big] - \nonumber \\
    &- j_z^{i,j,k}
\end{align}

The coefficients $b_\alpha$ and $a_\alpha$ must satisfy the condition
\begin{equation}
b_z + 2 a_z = 1
\end{equation}
for the scheme to be valid.

\subsubsection{Dispersion}
\label{sec:maxwell:ndfx:dispersion}

In order to find the dispersion of this scheme, we consider the fields as plane waves,
\begin{align}
    &E_x = E_{x,0} \exp(i \frac{k_x \Delta x}{2}) \exp(-i \omega t + i \vb{k} \vb{r}),\\
    &E_y = E_{y,0} \exp(i \frac{k_y \Delta y}{2}) \exp(-i \omega t + i \vb{k} \vb{r}),\\
    &E_z = E_{z,0} \exp(i \frac{k_z \Delta z}{2}) \exp(-i \omega t + i \vb{k} \vb{r}),\\
    &B_x = B_{x,0} \exp(i \frac{-\omega \Delta t + k_y \Delta y + k_z \Delta z}{2}) \exp(-i \omega t + i \vb{k} \vb{r}),\\
    &B_y = B_{y,0} \exp(i \frac{-\omega \Delta t + k_x \Delta x + k_z \Delta z}{2}) \exp(-i \omega t + i \vb{k} \vb{r}),\\
    &B_z = B_{z,0} \exp(i \frac{-\omega \Delta t + k_x \Delta x + k_y \Delta y}{2}) \exp(-i \omega t + i \vb{k} \vb{r}).
\end{align}
Here, we have taken into account the fact that the field components are displaced both on the grid and in time with respect to each other.

If we use this plane wave, the scheme becomes
\begin{alignat}{2}
    &-A_t B_{x,0} = &- A_y C_z E_{z,0} &+ A_z C_y E_{y,0},\\
    &-A_t B_{y,0} = & A_x C_z E_{z,0} &- A_z C_x E_{x,0},\\
    &-A_t B_{z,0} = & A_y C_x E_{x,0} &- A_x C_y E_{y,0},\\
    &-A_t E_{x,0} = & A_y C_z B_{z,0} &- A_z C_y B_{y,0},\\
    &-A_t E_{y,0} = & -A_x C_z B_{z,0} &+ A_z C_x B_{x,0},\\
    &-A_t E_{z,0} = & A_x C_y B_{y,0} &- A_y C_x B_{x,0},
\end{alignat}
where
\begin{align}
    &A_t = \frac{1}{\Delta t} \sin(\frac{\omega \Delta t}{2}),\\
    &A_\alpha = \frac{1}{\Delta \alpha} \sin(\frac{k_\alpha \Delta \alpha}{2}),\\
    &C_\alpha = b_\alpha + 2 a_\alpha \cos(k_\alpha \Delta \alpha) = 1 - 4 a_\alpha \Delta \alpha^2 A_\alpha^2.
\end{align}

The equality of the determinant of the system to zero gives us the dispersion relation
\begin{equation}
    A_t^2 = A_x^2 C_y C_z + A_y^2 C_x C_z + A_z^2 C_x C_y.
\end{equation}

\subsection{The FDTD solver}

\subsubsection{Scheme}

The simple FDTD solver is obtained from the NDFX solver by replacing $b_{x,y,z}$ with $1$ and $a_{x,y,z}$ with $0$ and is thus written as

\begin{align}
    &\frac{\Delta B_x^{i,j,k}}{\Delta t} =& -\frac{1}{\Delta y}\left(E_z^{i,j+1,k} - E_z^{i,j,k} \right) +\frac{1}{\Delta z} \left(E_y^{i,j,k+1} - E_y^{i,j,k}\right) \\
    &\frac{\Delta B_y^{i,j,k}}{\Delta t} =& \frac{1}{\Delta x}\left(E_z^{i+1,j,k} - E_z^{i,j,k} \right) - \frac{1}{\Delta z} \left(E_x^{i,j,k+1} - E_x^{i,j,k}\right) \\
    &\frac{\Delta B_z^{i,j,k}}{\Delta t} =& \frac{1}{\Delta y}\left(E_x^{i,j+1,k} - E_x^{i,j,k} \right) - \frac{1}{\Delta x} \left(E_y^{i+1,j,k} - E_y^{i,j,k}\right) \\
    &\frac{\Delta E_x^{i,j,k}}{\Delta t} = &\frac{1}{\Delta y}\left(B_z^{i,j,k} - B_z^{i,j-1,k} \right) - \frac{1}{\Delta z}\left(B_y^{i,j,k}-B_y^{i,j,k-1}\right) &- j_x^{i,j,k}\\
    &\frac{\Delta E_y^{i,j,k}}{\Delta t} =& -\frac{1}{\Delta x}\left(B_z^{i,j,k} - B_z^{i-1,j,k}\right) + \frac{1}{\Delta z}\left(B_x^{i,j,k} - B_x^{i,j,k-1}\right) &- j_y^{i,j,k}\\
    &\frac{\Delta E_z^{i,j,k}}{\Delta t} =& \frac{1}{\Delta x}\left(B_y^{i,j,k} - B_y^{i-1,j,k}\right) - \frac{1}{\Delta y}\left(B_x^{i,j,k} - B_x^{i,j-1,k}\right) &- j_z^{i,j,k}
\end{align}

\subsubsection{Dispersion}
\label{sec:maxwell:fdtd:dispersion}

By applying the dispersion relation in Sec.~\ref{sec:maxwell:ndfx:dispersion} to the FDTD scheme, we get
\begin{multline}
    \frac{1}{\Delta t^2}\sin^2\left(\frac{\omega \Delta t}{2}\right) \\
    = \frac{1}{\Delta x^2}\sin^2\left(\frac{k_x \Delta x}{2}\right) + \frac{1}{\Delta y^2}\sin^2\left(\frac{k_y \Delta y}{2}\right) + \frac{1}{\Delta z^2}\sin^2\left(\frac{k_z \Delta z}{2}\right).
\end{multline}
The FDTD scheme is stable if
\begin{equation}
    \frac{1}{\Delta t^2} \leq \frac{1}{\Delta x^2} + \frac{1}{\Delta y^2} + \frac{1}{\Delta z^2}.
\end{equation}

\section{Interpolation of magnetic field on E-field positions}

The magnetic field needs to be interpolated to the positions of the electric field to be used in the particle pusher.
The simplest interpolation (averaging over the 8 closest point) leads to
\begin{multline}
    \hat{B}_x^{i,j,k} = \frac{1}{8} \big(B_x^{i,j,k} + B_x^{i+1,j,k} + B_x^{i,j-1,k} + B_x^{i,j,k-1} + \\
    + B_x^{i+1,j-1,k} + B_x^{i+1,j,k-1} + B_x^{i,j-1,k-1} + B_x^{i+1,j-1,k-1} \big),
\end{multline}
\begin{multline}
    \hat{B}_y^{i,j,k} = \frac{1}{8} \big(B_y^{i,j,k} + B_y^{i-1,j,k} + B_y^{i,j+1,k} + B_y^{i,j,k-1} + \\
    + B_y^{i-1,j+1,k} + B_y^{i-1,j,k-1} + B_y^{i,j+1,k-1} + B_y^{i-1,j+1,k-1} \big),
\end{multline}
\begin{multline}
    \hat{B}_z^{i,j,k} = \frac{1}{8} \big(B_z^{i,j,k} + B_z^{i-1,j,k} + B_z^{i,j-1,k} + B_z^{i,j,k+1} + \\
    + B_z^{i-1,j-1,k} + B_z^{i-1,j,k+1} + B_z^{i,j-1,k+1} + B_z^{i-1,j-1,k+1}\big).
\end{multline}

\section{Shape function}
In PIC methods, the distribution function $f(\vb{r},\vb{p},t)$ is represented as a set of macroparticles
\begin{equation}
    f(\vb{r},\vb{p},t) = \sum_n W_n S(\vb{r} - \vb{r}_n) \delta(\vb{p} - \vb{p}_n).
\end{equation}
In Quill,
\begin{align}
    &S(\vb{r}) = S_x(x) S_y(y) S_z(z),\\
    &S_\alpha(\alpha) = \begin{cases}
        1,&\abs{\alpha} < \Delta \alpha/2,\\
        0,&\abs{\alpha} > \Delta \alpha/2.
    \end{cases}
\end{align}
Here, $\alpha$ can be $x,y,z$.

\section{Density deposition}

The density is calculated as
\begin{equation}
    \rho(\vb{r},t) = \int f(t, \vb{r}, \vb{p}) \dd{\vb{p}} = \sum_n W_n S(\vb{r} - \vb{r}_n).
\end{equation}
The interpolation of this density on the grid is made using the volume integration
\begin{multline}
    \rho^{i,j,k} = \frac{1}{\Delta x \Delta y \Delta z} \int_{x^i-\Delta x/2}^{x^i+\Delta x/2} \int_{y^j-\Delta y/2}^{y^j+\Delta y/2} \int_{z^k-\Delta z/2}^{z^k+\Delta z/2} \rho(\vb{r},t)\dd{t} = \\
    =\sum_n W_n S^{\rho}(\vb{r}^{i,j,k} - \vb{r}_n),
\end{multline}
where $\vb{r}^{i,j,k} = (x^i, y^j, z^k) = (i \Delta x, j \Delta y, k \Delta z)$,
\begin{align}
    &S^\rho(\vb{r}) = S_x^\rho(x) S_y^\rho(y) S_z^\rho(z),\\
    &S_\alpha^\rho(\alpha) = \frac{1}{\Delta \alpha} \int_{\alpha-\Delta \alpha/2}^{\alpha + \Delta \alpha/2} S_0(\alpha')\dd{\alpha'} = \begin{dcases}
        1 - \frac{\abs{\alpha}}{\Delta \alpha},& \abs{\alpha} < \Delta\alpha,\\
        0,& \abs{\alpha} > \Delta \alpha.
    \end{dcases}
\end{align}

Hence, a single particle located in the cell shown in Fig.~\ref{fig:cell} induces densities at 8 points
\begin{equation}
\begin{aligned}
    &\rho^{i,j,k} = W b_x b_y b_z, && \rho^{i,j,k+1} = W b_x b_y a_z,\\
    &\rho^{i,j+1,k} = W b_x a_y b_z, && \rho^{i,j+1,k+1} = W b_x a_y a_z,\\
    &\rho^{i+1,j,k} = W a_x b_y b_z, && \rho^{i+1,j,k+1} = W a_x b_y a_z,\\
    &\rho^{i+1,j+1,k} = W a_x a_y b_z, && \rho^{i+1,j+1,k+1} = W a_x a_y a_z,
\end{aligned}
\end{equation}
where $a_\alpha = (\alpha - \alpha^{i,j,k}) / \Delta \alpha$, $b_\alpha = 1 - a_\alpha$.
E.g., if the particle is located at $\vb{r}^{i,j,k}$, then all $a_\alpha = 1$, and the only non-zero density is $\rho^{i,j,k}$.

\section{Currents deposition}

Currents are calculated so that the charge is preserved.
For each current position on the grid, a plane perpendicular to the current direction is taken, and a the charge flow through a square with sides corresponding to the cell size is calculated.
For example, for $j_x$ we have
\begin{equation}
    j_x^{i,j,k} \delta t \Delta y \Delta z = \int_t^{t+\delta t} \dd{t'} \int_{y^j-\Delta y/2}^{y^j + \Delta y /2}\int_{z^k-\Delta z/2}^{z^k + \Delta z /2} \dd{y}\dd{z} v_x \sum_n W_n S(\vb{r}-\vb{r}_n),
\end{equation}
where $\vb{r} = (x^i+\Delta x /2, y, z)$, $\vb{r}_n = \vb{r}_n(t')$.
Now we can calculate the integrals in $y$ and $z$, getting
\begin{equation}
    j_x^{i,j,k} \delta t = \sum_n W_n \int_t^{t+\delta t} \dd{t'} v_x S_x(x^i + \Delta x/2 - x_n) S^\rho_y(y^j - y_n) S^\rho_z(z^k - z_n).
\end{equation}
Similar expressions are obtained for $j_y$ and $j_z$.

Up to that point, the trajectory $\vb{r}_n(t)$ does not matter.
For simplicity, we will consider a single macroparticle which does not leave the $(i,j,k)$ cell.
In a typical scheme, the motion of a particle on a timestep is linear, so that $\vb{r}(t') = \vb{r}_1 + \vb{v} (t'-t)$.
In this case, particle induces currents only in 12 points.
Let us rigorously calculate $j_x^{i,j,k}$, induced by such a particle.
First,
\begin{equation}
    S_x(x^i + \Delta x/2 - x(t')) = 1,
\end{equation}
because the particle never leaves the cell.
Also, $y^j - y(t') < 0$, $z^k - z(t') < 0$, so the answer is
\begin{multline}
    j_x^{i,j,k} \delta t = W \int_0^{\delta t} \dd{t'} v_x \left(1 - \frac{y_0+v_y t' - y^j}{\Delta y}\right)\left(1 - \frac{z_0+v_z t' - z^k}{\Delta z}\right) = \\
    = W \int_0^{\delta t}\dd{t'} v_x \left(a_y + \frac{v_y (t'-\delta t/2)}{\Delta y}\right)\left(a_z + \frac{v_z (t'-\delta t/2)}{\Delta z}\right) = \\
    = W \delta x \left( b_y b_z + \frac{\delta y\delta z}{12\Delta y \Delta z}\right),
\end{multline}
where
\begin{equation}
    b_y = 1 - \frac{y_0 + \delta y / 2 - y^j}{\Delta y},\quad b_z = 1 - \frac{y_0 + \delta z / 2 - z^k}{\Delta z}.
\end{equation}

Now we can write down all 12 currents generated by a macroparticle
\begin{equation}
\begin{aligned}
    j_x^{i,j,k} \delta t &= W \delta x (b_y b_z + A_{yz}), & j_x^{i,j+1,k} &= W \delta x (a_y b_z - A_{yz}),\\
    j_x^{i,j,k+1} \delta t &= W \delta x(b_y a_z - A_{yz}), & j_x^{i,j+1,k+1} &= W \delta x(a_y a_z + A_{yz}),\\
    j_y^{i,j,k} \delta t &= W \delta y (b_x b_z + A_{xz}), & j_y^{i+1,j,k} &= W \delta y (a_x b_z - A_{xz}),\\
    j_y^{i,j,k+1} \delta t &= W \delta y (b_x a_z - A_{xz}), & j_y^{i+1,j,k+1} &= W \delta y (a_x a_z + A_{xz}),\\
    j_z^{i,j,k} \delta t &= W \delta z (b_x b_y + A_{xy}), & j_z^{i+1,j,k} &= W \delta z (a_x b_y - A_{xy}),\\
    j_z^{i,j+1,k} \delta t &= W \delta z(b_x a_y - A_{xy}), & j_z^{i+1,j+1,k} &= W \delta z(a_x a_y + A_{xy}),
\end{aligned}
\end{equation}
where
\begin{equation}
    a_\alpha = \frac{\alpha - \alpha^{i,j,k} + 0.5 \delta \alpha}{\Delta \alpha},
    \quad b_\alpha = 1 - a_\alpha,
    \quad A_{\alpha \beta} = \frac{\delta\alpha \delta\beta}{12\Delta\alpha\Delta\beta}.
\end{equation}
If a particle leaves the cell, its trajectory should be separated into several pieces.

\section{Interpolation of fields on particles}
Fields need to be interpolated from the field on particles.
In Quill, the formulas should be
\begin{align}
    &E_x^p = E_x^{i,j+1,k+1} a_y a_z + E_x^{i,j,k+1} b_y a_z + E_x^{i,j+1,k} a_y b_z + E_x^{i,j,k} b_y b_z,\\
    &E_y^p = E_y^{i+1,j,k+1} a_x a_z + E_y^{i,j,k+1} b_x a_z + E_y^{i+1,j,k} a_x b_z + E_y^{i,j,k} b_x b_z,\\
    &E_z^p = E_z^{i+1,j+1,k} a_y a_x + E_z^{i+1,j,k} b_y a_x + E_z^{i,j+1,k} a_y b_x + E_z^{i,j,k} b_y b_x.
\end{align}
Here, $b_{x,y,z} = 1 - a_{x,y,z}$.

\begin{thebibliography}{9}
    \bibitem{PukhovLectures}
    A. Pukhov, Three-Dimensional Particle-in-Cell Simulations of Relativistic Laser-Plasma Interactions. Lecture Notes. (1999).

    \bibitem{PukhovCERN}
    A. Pukhov, Particle-In-Cell Codes for Plasma-based Particle Acceleration. \href{https://e-publishing.cern.ch/index.php/CYR/article/view/220}{\textit{CERN Yellow Rep.} \textbf{1}, 181 (2016)}.
\end{thebibliography}

\end{document}


\documentclass{amsart}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\title{Problem Set 2}
\author{Mark Ditsworth}

\begin{document}
	\maketitle
	\section{Problem 2.1}
	Given graph $G=(V,E,W)$ consider a random walk on V with transition probabilities $M_{ij} = P{X(t+1)=j | X(t)=i} = \frac{w_{ij}}{\text{deg}(i)}$.
	\\\\
	Partition the vertex set as $V = V_+ \cup V_- \cup V_*$. Suppose that every node in $V_*$ is connected to at least one node in either $V_+$ or $V_-$. Given a node $i \subset V$ let $g(i)$ be the probability that a random walker starting at $i$ reaches a node in $V_+$ before reaching one in $V_-$. If $i \in V_+$, then $g(i)=1$ and if $i \in V_-$, then $g(i)=0$. Find $g(i)$ for $i \in V_*$.
	\\\\
	\textbf{Solution:}
	There are two scenarios in which the random walker will reach a node in $V_+$ before one in $V_-$: Moving from $V_*$ to $V_+$ immediately, or moving from $V_*$ to $V_*$ repeatedly until moving to $V_+$. We essentially view leaving $V_*$ as an absorbing barrier, and want the probability that we end in $V_+$, which is the sum of all probabilities that will end in that scenario:
	\[
	\sum_{j \in V_+}M_{ij} + \sum_{j \in V_*}\sum_{k \in V_+}M_{ij}M_{jk} + \sum_{j \in V_*}\sum_{k \in V_*}\sum_{l \in V_+}M_{ij}M_{jk}M_{kl} + \dots
	\]
	Define $\mathbf{\nu_*} \in \mathbb{R}^n$, $n=|V|$ where the $j$th element is $1$ if $j \in V_*$, and $0$ otherwise. Similarly define $\mathbf{\nu_+} \in \mathbb{R}^n$ for the partition $V_+$. Let $\Psi_i \in \mathbb{R}^n$, $n=|V|$ have elements everywhere equal 0 except for the $i$th node that is the starting node. The probability that a random walker starting at node $i$ is absorbed in the $V_+$ partition at time-step $k$ is expressed as
	\[
	\Psi_i^T \left[ M\text{diag}\left(V_*\right) \right]^{(k-1)} MV_+
	\]
	The $\left[ M\text{diag}\left(V_*\right) \right]^{(k-1)}$ matrix expresses the probability of starting at node $i$, and ending at node $j$ after $k-1$ steps, discounting the intermediate nodes that would absorb the random walker earlier (nodes belonging to $V_+$ or $V_-$) For convenience, we will denote this matrix as $M_*$, as in only accounting for transitions within partition $V_*$. The resulting matrix is dotted with $M$ for the last transition time step, and then dotted with $V_+$ to attain the vector of probabilities end in partition $V_+$. $\Psi_i^T$ dotted with this vector selects the probability stemming from starting at node $i$. Thus, summing the probabilities across all $k$ yields
	\[
	\Psi_i^T \left[\sum_{k=0}^{\infty}\left( M_* \right)^k\right]MV_+
	\]
	With each element of $M_*$ less than $0$, and the summation across each row bounded above by $1$, it is clear that $\lim\limits_{n \rightarrow \infty} (M_*)^n = \mathbf{0}$. Thus, the infinite sum converges to $(I-M_*)^{-1}$. In conclusion, the probability that a random walker starting at node $i \in V_*$ will reach a node in $V_+$ before a node in $V_-$ is calculated by
	\[
	g(i) = \Psi_i^T\left( I - M_* \right)^{-1}MV_+.
	\]
	Note that for graphs with large $|V|$, the inverse operation can be quite expensive. Thus $g(i)$ should be approximated either via pseudo-inverse operations or monte carlo simulations. See the attached notebook \textsf{ps2.ipynb} for justification of this closed-form expression for $g(i)$.
	\\\\
	\section{Problem 2.2}
	For a graph $G$ let $h(G)$ denote its Cheeger constant and $\lambda_2(\mathcal{L}_G)$ the second-smallest eigenvalue of its normalized graph Laplacian ($\mathcal{L}_G = D - W$). The Cheeger inequality guarantees that
	\[
	\frac{1}{2}\lambda_2(\mathcal{L}_G) \le h_G \le \sqrt{2\lambda_2(\mathcal{L}_G)}
	\]
	This excercise shows that this inequality is tight (at least up to constants).

	1. Construct a family of graphs $\mathcal{G}$ for which $\lambda_2(\mathcal{L}_G) \rightarrow 0$ and for which there exists a constant $C>0$ for which
	\[
	\forall G \in \mathcal{G}, h_G \le C\lambda_2(\mathcal{L}_G)
	\]
	\\\\

	2. Construct a family of graphs $\mathcal{G}$ for which $\lambda_2(\mathcal{L}_G) \rightarrow 0$ and for which there exists a constant $c>0$ for which
	\[
	\forall G \in \mathcal{G}, h_G \ge c\sqrt{\lambda_2(\mathcal{L}_G)}
	\]
	\\\\

	\section{Problem  2.3}
	Given a graph $G$ show that the dimension of the nullspace of $\mathcal{L}_G$ corresponds to the number of connected components of $G$.
	\\\\
	\textbf{Solution:} The nullspace of $\mathcal{L}_G$ is the set of linearly independent vectors $\mathcal{X}$ such that $\forall \mathbf{x} \in \mathcal{X}$, $\mathcal{L}_G\mathbf{x} = \mathbf{0}$.
	By expanding $\mathcal{L}_G$ we can see that both $D$ and $W$ transform each $\mathbf{x}$ to equal vectors.
	\[
	\mathcal{L}_G \mathbf{x} = (D - W)\mathbf{x} = D\mathbf{x} - W\mathbf{x} = \mathbf{0}
	\]
	\[
	D\mathbf{x} = W\mathbf{x}
	\]
	Consider that graph $G = (V,E,W),~(|V|=n)$ has $k$ connected components. Let $\mathbf{x}^i$ be a vector where
	\[
	x^i_j =
	\begin{cases}
		1 & j \in \text{ component } i\\
		0 & \text{otherwise}
	\end{cases}
	\]
	Clearly, without loss of generality, $D\mathbf{x}^i$ is equal to a vector containing the degree of each node in $G$ that is in component $i$. $W\mathbf{x}^i$ is clearly the same since for each node, it will sum all weights of edges that connect to nodes in component $i$. Thus, there will be $k$ linearly independent vectors that are transformed to $\mathbf{0}$ by $\mathcal{L}_G$. All other vectors that do this will be linear combinations of $\mathcal{X} = \{\mathbf{x}^1,\dots ,\mathbf{x}^k\}$. Therefor, the cardinality of the nullspace of $\mathcal{L}_G$ is equal to the number of conneted components in graph $G$.
	\\\\
	\section{Problem 2.4}
	Given a connected unweighted graph $G = (V,E)$, its diameter is equal to
	\[
	\text{diam}(G) = \max_{u,v\in V} \min_{path p, u\rightarrow v} \text{len}(p)
	\]
	Show that
	\[
	\text{diam}(G) \ge \frac{1}{\text{vol}(G)\lambda_2(\mathcal{L}_G)}
	\]
	\\\\
	\section{Problem 2.5}
	Prove the Courant Fisher Theorem: Given a symmetric matrix $A\in \mathbb{R}^{n\times n}$ with eigenvalues $\lambda_1 \le \dots \lambda_n$, for $k \le n$,
	\[
	\lambda_k(A) = \min_{U:\text{dim}(U)=k} \left[ \max_{x\in U} \frac{x^TAx}{x^Tx} \right].
	\]
	\\
	Also show that
	\[
	\lambda_2(A) = \max_{y\in\mathbb{R}^n} \left[ \min_{x\in\mathbb{R}^n:x\perp y} \frac{x^TAx}{x^Tx} \right]
	\]
	\\\\
	\section{Problem 2.6}
	Given a set of points $x_1,\dots,x_n \in \mathbb{R}^p$ and a partition of them in $k$ clusters $S_1,\dots,S_k$ reca the k-means objective
	\[
	\min_{S_1,\dots,S_k}\min_{\mu_1,\dots,\mu_k}\sum_{l=1}^{k}\sum_{i\in S_l}\| x_i - \mu_l \|^2.
	\]
	Show that this is equivalent to
	\[
	\min_{S_1,\dots,S_k}\sum_{l=1}^{k}\frac{1}{S_l}\sum_{i,j\in S_l}\| x_i - x_j \|^2.
	\]
	\\
	\textbf{Solution:}
	\[
	\min_{S_1,\dots,S_k}\min_{\mu_1,\dots,\mu_k}\sum_{l=1}^{k}\sum_{i\in S_l}\| x_i - \mu_l \|^2 =
	\]
	\[
	\min_{S_1,\dots,S_k}\sum_{l=1}^{k}\sum_{i\in S_l}\|x_i - \frac{1}{|S_l|}\sum_{j\in S_l}x_j\|^2 =
	\]
	\[
	\min_{S_1,\dots,S_k}\sum_{l=1}^{k}\frac{1}{|S_l|}\sum_{i\in S_l}\| |S_l|x_i - \sum_{j\in S_l}x_j\|^2 =
	\]
	\[
	\min_{S_1,\dots,S_k}\sum_{l=1}^{k}\frac{1}{|S_l|}\sum_{i\in S_l}\sum_{j\in S_l}\| x_i - x_j\|^2 =
	\]
	\[
	\min_{S_1,\dots,S_k}\sum_{l=1}^{k}\frac{1}{|S_l|}\sum_{i,j\in S_l}\| x_i - x_j\|^2.
	\]

\end{document}


\documentclass[a4paper,11pt]{article}
%\documentclass[a4paper,11pt]{scrartcl}

\input{../preambles/preamble}
\input{../preambles/unicode}

\setmainlanguage{english}
\setotherlanguages{german,greek,russian}

\input{../preambles/math-single}
\input{../preambles/math-brac}
\input{../preambles/math-thm}
\input{../preambles/phys-chem}

\setromanfont[Mapping=tex-text]{Linux Libertine O}
% \setsansfont[Mapping=tex-text]{DejaVu Sans}
% \setmonofont[Mapping=tex-text]{DejaVu Sans Mono}

\usepackage[%style=authoryear-icomp,
			backend=biber]{biblatex}
\addbibresource{./exp-pot.bib}

\title{Non-relativistic Particle in an Exponential Potential}
\author{Yi-Fan Wang (王\ 一帆)}
%\date{}

\begin{document}
\maketitle

Consider the one-dimensional motion of a non-relativistic particle in an
exponential potential, the motion of which can be described by the Lagrangian
action
\begin{align}
S \coloneqq \int \dd t\,\cbr{\frac{m}{2}\dot{x}^2 - V\ee^{g x}},
\end{align}
where $g$ and $V$ are real quantities. One sees that when $V > 0$ ($< 0$), the
potential is bounded below (above), and the second case is potentially
problematic.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Canonical formalism}

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

The canonical Hamiltonian of the particle reads
\begin{align}
H = \frac{p^2}{2m} + V\ee^{g x}.
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Canonical quantisation}

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

Using the Laplace--Beltrami operator, the Hamiltonian ``operator'' reads
\begin{align}
\widehat{H} = -\frac{\phs^2}{2m}\partial_x^2 + V\ee^{g x}.
\label{eq:hamilt-optr-0}
\end{align}
Note that the domain of the unbounded operator has not been specified; hence
comes the quotation marks. In \cite[ch.\ 4]{Gitman2012}, it was suggested
that one could use \emph{operation} instead of ``operator'' to distinguish the
case, where only the action of an operator is described, whereas the domain is
not.

%%%%%%%%%%%%%%%%
\subsection{Spectrum and generalised eigenfunctions of the Hamiltonian}

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

The eigenvalue equation of the Hamiltonian, or the time-independent Schrödinger
equation, reads
\begin{align}
-\frac{\phs^2}{2m}\partial_x^2 \rfun{\psi}{x} + V\ee^{g x} \rfun{\psi}{x} =
E \rfun{\psi}{x}.
\label{eq:tise-0}
\end{align}

In order to solve \cref{eq:tise-0}, define
\begin{align}
\nu \coloneqq \frac{\sqrt{8m\vbr{E}}}{g\phs},
\end{align}
and transform the coordinate
\begin{align}
\xi \coloneqq \frac{\sqrt{8m\vbr{V}\ee^{g x}}}{g\phs},
\label{eq:trsf-x-xi-0}
\end{align}
so that the Hamiltonian ``operator'' reads
\begin{align}
\widehat{H} = \frac{g^2\phs^2}{8m}\rbr{-\xi^2\partial_\xi^2 - \xi\partial_\xi +
\mscrv \xi^2},\qquad \mscrv \coloneqq \sgn V,
\label{eq:hamilt-optr-1}
\end{align}
and \cref{eq:tise-0} transforms into the standard Besselian form
\begin{align}
\xi^2 \rfun{\psi''}{\xi} + \xi^1 \rfun{\psi'}{\xi} +
\rbr{-\mscrv \xi^2 + \mscre \nu^2} \rfun{\psi}{\xi} = 0,\qquad
\mscre \coloneqq \sgn E.
\label{eq:tise-1}
\end{align}
The solutions of \cref{eq:tise-1} can be classified into four cases
according to $\rbr{\mscrv, \mscre}$ and are listed in \cref{tab:tise-1}.
Because of the transformation in \cref{eq:trsf-x-xi-0}, the corresponding
representation space $\mbfF_\xi$ of the state vectors \cite[ch.\
5.1]{Kiefer2012} consists of the square-integrable functions on $\rbr{0,
+\infty}$ endowed with the inner product
\begin{align}
\rbr{\psi, \phi}_\xi \coloneqq \int_0^{+\infty}\frac{\dd \xi}{\xi}\,
\rfun{\psi^*}{\xi}\rfun{\phi}{\xi}.
\end{align}
\begin{table}
\begin{center}
\begin{tabular}{c||r@{, }l|r@{, }l}
\toprule
Sign & \multicolumn{2}{c|}{Solution 1} & \multicolumn{2}{c}{Solution 2} \\
\midrule
$\rbr{+,+}$ &
$\rfun{\BesselK_{\ii \nu}}{\xi}$ & D &
$\rfun{\BesselI_{\ii \nu}}{\xi}$ & U \\
$\rbr{-,-}$ &
$\rfun{\BesselK_{\nu}}{\xi}$ & U &
$\rfun{\BesselI_{\nu}}{\xi}$ & U \\
$\rbr{+,-}$ &
$\rfun{\BesselF_{\ii \nu}}{\xi}$ & D &
$\rfun{\BesselG_{\ii \nu}}{\xi}$ & D \\
$\rbr{-,+}$ &
$\rfun{\BesselJ_{\nu}}{\xi}$ & N &
$\rfun{\BesselY_{\nu}}{\xi}$ & U \\
\bottomrule
\end{tabular}
\end{center}
\caption{Local solutions of \cref{eq:tise-1} and their normalisability, where
sign means $\rbr{\mscrv, \mscre}$, N denotes normalisable, D
$\mupdelta$-normalisable, and U unnormalisable.
\label{tab:tise-1}}
\end{table}

Transforming
\begin{align}
\ee^y \coloneqq \xi = \frac{\sqrt{8m\vbr{V}\ee^{g x}}}{g\phs}
\end{align}
yields the Hamiltonian ``operator'' in terms of an alternative dimensionless
form
\begin{align}
\widehat{H} = \frac{g^2\phs^2}{8m}\rbr{-\partial_y^2 + \mscrv \ee^{2y}}.
\label{eq:hamilt-optr-2}
\end{align}
The solutions of the eigenvalue equation for \cref{eq:hamilt-optr-2} are the
ones listed in \cref{tab:tise-1} with $\xi$ replaced by $\ee^y$. The
representation space $\mbfF_y$ is comprised of the square-integrable functions
on $\rbr{-\infty, +\infty}$ endowed with the inner product
\begin{align}
\rbr{\psi, \phi}_y \coloneqq \int_{-\infty}^{+\infty}\dd y\,
\rfun{\psi^*}{y}\rfun{\phi}{y}.
\end{align}

%%%%%%%%%%%%%%%%
\subsection{Problem of self-adjointness}

%%%%%%%%%%%%%%%%
On a Hilbert space $\mbfH$ endowed with the inner product $\rbr{\cdot,\cdot}$,
An operator $A$ is characterised by its \emph{domain} $\rfun{\mathrm{Dom}}{A}$
and the operation on a vector in $\rfun{\mathrm{Dom}}{A}$. Physicists often skip
the discussion about the domain, which proves to be problematic in the current
case.

To be more specific, the following definitions are needed. $A$ is called
\emph{symmetric} if $\rbr{f, A g} \equiv \rbr{A f, g}$, $\forall f, g \in
\rfun{\mathrm{Dom}}{A}$. The \emph{adjoint} of $A$ is denoted as $A^\dagger$ and
satisfies $\rbr{A^\dagger f, g} \coloneqq \rbr{f, A g}$, $\forall g \in
\rfun{\mathrm{Dom}}{A}$. Finally, $A$ is \emph{self-adjoint} if $A^\dagger = A$,
which implies the identical operation $A^\dagger f \equiv A f$, $\forall f \in
\rfun{\mathrm{Dom}}{A}$ and the identical domain,
$\rfun{\mathrm{Dom}}{A^\dagger} equiv \rfun{\mathrm{Dom}}{A}$.

Note that in infinite dimensions, for an unbounded $A$, $\mbfH \supsetneq
\rfun{\mathrm{Dom}}{A^\dagger} \supseteq \rfun{\mathrm{Dom}}{A}$ \cite[ch.\
9]{Hall2013}, which is the main difference from the case in finite dimensions,
where $\mbfH = \rfun{\mathrm{Dom}}{A^\dagger} = \rfun{\mathrm{Dom}}{A}$.

The Hamiltonian in \cref{eq:hamilt-optr-2} is manifestly not self-adjoint for
some of the cases. If it were always self-adjoint, the (generalised)
eigenfunctions of different eigenvalues would necessarily be orthogonal. This
is obviously not the case for $\rbr{-,+}$, where
\begin{align}
\rbr{J_{\nu_1}, J_{\nu_2}}_y =
\end{align}

\printbibliography

\end{document}