\chapter{Gauss-Seidel Solver Verification}
\label{app:solvers}

Below are the outputs of the Gauss-Seidel solvers. They are printed out in order of the nodes where the nodes are 2D flattened arrays of 3D arrays. These are 64 cells and therefore a \(5\times5\times5\) node structure. The first number, Rhs, stands for \(b_i\). The second, below, stands for the dot product of the stencil below that index times the potential below that index. Above is the dot product of the stencil above that index times the potential above that index. The next one, (u,u), is the value of the stencil at that index. Finally, phi is the electric potential at that index calculated through \(Rhs-below-above)/(u,u)\). \par

\indent The solvers show exactly the same calculations when given the same initial conditions. While this is hard to see in this format it is trivial when the logs are analyzed with a text comparison tool. \par

\textbf{SINATRA Solver}
\begin{verbatim}

Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:0 above:0 (u,u):-96 phi:-188
Rhs:1.81e+04 below:-3.02e+03 above:0 (u,u):-96 phi:-220
Rhs:1.81e+04 below:-3.52e+03 above:0 (u,u):-96 phi:-225
Rhs:0 below:-450 above:0 (u,u):-66 phi:-6.82
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.02e+03 above:0 (u,u):-96 phi:-220
Rhs:1.81e+04 below:-7.04e+03 above:0 (u,u):-96 phi:-262
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.52e+03 above:0 (u,u):-96 phi:-225
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-8.63e+03 above:0 (u,u):-96 phi:-278
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-450 above:0 (u,u):-66 phi:-6.82
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-43.3 above:0 (u,u):-36 phi:-1.2
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.02e+03 above:0 (u,u):-96 phi:-220
Rhs:1.81e+04 below:-7.04e+03 above:0 (u,u):-96 phi:-262
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-7.04e+03 above:0 (u,u):-96 phi:-262
Rhs:1.81e+04 below:-1.26e+04 above:0 (u,u):-96 phi:-319
Rhs:1.81e+04 below:-1.37e+04 above:0 (u,u):-96 phi:-332
Rhs:0 below:-978 above:0 (u,u):-66 phi:-14.8
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-1.37e+04 above:0 (u,u):-96 phi:-332
Rhs:1.81e+04 below:-1.51e+04 above:0 (u,u):-96 phi:-345
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-978 above:0 (u,u):-66 phi:-14.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-85.9 above:0 (u,u):-36 phi:-2.39
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.52e+03 above:0 (u,u):-96 phi:-225
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-8.63e+03 above:0 (u,u):-96 phi:-278
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-1.37e+04 above:0 (u,u):-96 phi:-332
Rhs:1.81e+04 below:-1.51e+04 above:0 (u,u):-96 phi:-345
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-8.63e+03 above:0 (u,u):-96 phi:-278
Rhs:1.81e+04 below:-1.51e+04 above:0 (u,u):-96 phi:-345
Rhs:1.81e+04 below:-1.66e+04 above:0 (u,u):-96 phi:-361
Rhs:0 below:-1.26e+03 above:0 (u,u):-66 phi:-19
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-1.26e+03 above:0 (u,u):-66 phi:-19
Rhs:0 below:-114 above:0 (u,u):-36 phi:-3.18
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-450 above:0 (u,u):-66 phi:-6.82
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-43.3 above:0 (u,u):-36 phi:-1.2
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-978 above:0 (u,u):-66 phi:-14.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-85.9 above:0 (u,u):-36 phi:-2.39
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-1.26e+03 above:0 (u,u):-66 phi:-19
Rhs:0 below:-114 above:0 (u,u):-36 phi:-3.18
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:-43.3 above:0 (u,u):-36 phi:-1.2
Rhs:0 below:-85.9 above:0 (u,u):-36 phi:-2.39
Rhs:0 below:-114 above:0 (u,u):-36 phi:-3.18
Rhs:0 below:-19.1 above:0 (u,u):-6 phi:-3.18
Iteration 0 with error of 5.29e+04

\end{verbatim}

\textbf{Verified Solver}

\begin{verbatim}
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:-0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:0 above:0 (u,u):-96 phi:-188
Rhs:1.81e+04 below:-3.02e+03 above:0 (u,u):-96 phi:-220
Rhs:1.81e+04 below:-3.52e+03 above:0 (u,u):-96 phi:-225
Rhs:0 below:-450 above:0 (u,u):-66 phi:-6.82
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.02e+03 above:0 (u,u):-96 phi:-220
Rhs:1.81e+04 below:-7.04e+03 above:0 (u,u):-96 phi:-262
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.52e+03 above:0 (u,u):-96 phi:-225
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-8.63e+03 above:0 (u,u):-96 phi:-278
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-450 above:0 (u,u):-66 phi:-6.82
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-43.3 above:0 (u,u):-36 phi:-1.2
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.02e+03 above:0 (u,u):-96 phi:-220
Rhs:1.81e+04 below:-7.04e+03 above:0 (u,u):-96 phi:-262
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-7.04e+03 above:0 (u,u):-96 phi:-262
Rhs:1.81e+04 below:-1.26e+04 above:0 (u,u):-96 phi:-319
Rhs:1.81e+04 below:-1.37e+04 above:0 (u,u):-96 phi:-332
Rhs:0 below:-977 above:0 (u,u):-66 phi:-14.8
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-1.37e+04 above:0 (u,u):-96 phi:-332
Rhs:1.81e+04 below:-1.51e+04 above:0 (u,u):-96 phi:-345
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-977 above:0 (u,u):-66 phi:-14.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-85.9 above:0 (u,u):-36 phi:-2.39
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-3.52e+03 above:0 (u,u):-96 phi:-225
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-8.63e+03 above:0 (u,u):-96 phi:-278
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-7.79e+03 above:0 (u,u):-96 phi:-270
Rhs:1.81e+04 below:-1.37e+04 above:0 (u,u):-96 phi:-332
Rhs:1.81e+04 below:-1.51e+04 above:0 (u,u):-96 phi:-345
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:0 above:0 (u,u):-66 phi:-0
Rhs:1.81e+04 below:-8.63e+03 above:0 (u,u):-96 phi:-278
Rhs:1.81e+04 below:-1.51e+04 above:0 (u,u):-96 phi:-345
Rhs:1.81e+04 below:-1.66e+04 above:0 (u,u):-96 phi:-361
Rhs:0 below:-1.26e+03 above:0 (u,u):-66 phi:-19
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-1.26e+03 above:0 (u,u):-66 phi:-19
Rhs:0 below:-114 above:0 (u,u):-36 phi:-3.18
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-450 above:0 (u,u):-66 phi:-6.82
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-43.3 above:0 (u,u):-36 phi:-1.2
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-648 above:0 (u,u):-66 phi:-9.82
Rhs:0 below:-977 above:0 (u,u):-66 phi:-14.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-85.9 above:0 (u,u):-36 phi:-2.39
Rhs:0 below:0 above:0 (u,u):-36 phi:-0
Rhs:0 below:-714 above:0 (u,u):-66 phi:-10.8
Rhs:0 below:-1.1e+03 above:0 (u,u):-66 phi:-16.7
Rhs:0 below:-1.26e+03 above:0 (u,u):-66 phi:-19
Rhs:0 below:-114 above:0 (u,u):-36 phi:-3.18
Rhs:0 below:0 above:0 (u,u):-6 phi:-0
Rhs:0 below:-43.3 above:0 (u,u):-36 phi:-1.2
Rhs:0 below:-85.9 above:0 (u,u):-36 phi:-2.39
Rhs:0 below:-114 above:0 (u,u):-36 phi:-3.18
Rhs:0 below:-19.1 above:0 (u,u):-6 phi:-3.18
1,5.287557e+04
\end{verbatim}


\documentclass{article}
\usepackage{amsmath,amsfonts,amsthm}
\usepackage{enumerate}

\usepackage[english]{babel}

\newtheorem{lemma}{Lemma}

\usepackage[active, tightpage]{preview}
\setlength\PreviewBorder{1cm}

% weird hack from https://tex.stackexchange.com/a/98214
% this is needed to get the paragraph indents to appear
\usepackage{etoolbox}
\edef\keptparindent{\the\parindent}
\patchcmd{\preview}
  {\ignorespaces} %%% \preview ends with \ignorespaces
  {\parindent\keptparindent\ignorespaces}
  {}{}

\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\arabic{section}. (\alph{subsection})}
\renewcommand{\thesubsubsection}{\thesection (\alph{subsection})(\roman{subsubsection})}

\begin{document}

\begin{preview}
\section{Example}
\subsection{Example 1}
This template is useful if every single homework question requires you to upload a separate pdf file or image. You may even upload 20 separate files/images just to hand in your homework!

Bonus 1: When you're uploading a pdf file, does the server split the pdf file into individual pages? Can you find a way to generate an image for every page in a pdf?

Bonus 2: This template has very little whitespace. Less scrolling is needed!
\end{preview}

\begin{preview}
\subsection{Example 2}
\begin{lemma}
If $x < y$ then $-y < -x$.
\end{lemma}

\begin{proof}
Here is the proof:
\begin{align*}
x &< y \\
x+(-x-y) &< y+(-x-y) \\
-y &< -x
\end{align*}

It was trivial.
\end{proof}
\end{preview}

\begin{preview}
\section{Longer example}
Let $F(1,b)=1$ and $F(a,1)=1$. Also, for $a>1$ and $b>1$, let $F(a,b) = F(a-1,b) + F(a,b-1)$.

We show that for all $a \ge 1$ and $b \ge 1$, any set of $F(a,b)$ people would satisfy at least one of these conditions:

\begin{itemize}
\item There exists a crew of size $a$ that know each other
\item There exists a crew of size $b$ that don't know each other
\end{itemize}

The case where $a=1$ or $b=1$ is easy. The set is size $1$. Pick this person from the set, and make a crew.

Let's solve the case where $a>1$ and $b>1$. Assume that $F(a-1,b)$ and $F(a,b-1)$ are already proven.

Ask the first person. Put all of the known people into a set $S$, and all of the unknown people into set $T$. Note that $F(a,b) = 1 + |S| + |T|$ and $F(a,b) = F(a-1,b) + F(a,b-1)$. So we have $|S| + |T| = F(a-1,b) + F(a,b-1) - 1$. By the pigeonhole principle, we have $|S| \ge F(a-1,b)$ or $|T| \ge F(a,b-1)$. So we have two cases.

\begin{itemize}
\item Case 1: $|S| \ge F(a-1,b)$. We can use $F(a-1,b)$ to create two cases.
\begin{itemize}
\item Case 1a: We can find $b$ people in $S$ that don't know each other. In this case, we are already done.
\item Case 1b: There are $a-1$ people in $S$ that know each other. The first person knows everyone in $S$, so we can form a crew with the first person and the $a-1$ people in $S$. Then there is a crew of $a$ people that know each other, and we are done.
\end{itemize}

\item Case 2: $|T| \ge F(a,b-1)$. This case is similar to case 1.
\end{itemize}

The last step is to use induction to finish off the proof. This step is easy and is left to the reader as a short exercise.

Note: You may notice that $F(a,b) = \dbinom{a+b-2}{a-1}$.
\end{preview}

\begin{preview}
\section{Example of a long page}
\newcount\linenum
\linenum0
\loop\ifnum\linenum < 300
Long page.

\advance\linenum by 1
\repeat
In practice, homework solutions can fit on a smaller page.
\end{preview}

\end{document}


\section{graphs and other tikz}
 \frame{\sectionpage}

\begin{frame}{Drawning within tikz}
    \tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,486); %set diagram left start at 0, and has height of 486

%Curve Lines [id:da9595099437611456]
\draw    (233.23,183.24) .. controls (252.87,215.34) and (288.86,227.45) .. (323.09,223.22) .. controls (353.65,219.45) and (382.81,202.65) .. (397.65,175.44) ;
%Curve Lines [id:da6932103982097759]
\draw    (244.67,197.26) .. controls (301.86,150.51) and (339.03,156.74) .. (383.35,191.03) ;
%Curve Lines [id:da7053828945347995]
\draw    (126,173.88) .. controls (131.72,222.2) and (184.62,311.04) .. (317.59,307.92) .. controls (450.55,304.8) and (507.74,212.85) .. (499.16,173.88) ;
%Curve Lines [id:da583602680611125]
\draw    (126,173.88) .. controls (174.61,52.32) and (437.68,50.76) .. (499.16,173.88) ;
%Curve Lines [id:da5190289437371578]
\draw [color={rgb, 255:red, 208; green, 2; blue, 27 }  ,draw opacity=1 ]   (126,173.88) .. controls (175,318) and (478,278) .. (499.16,173.88) ;
%Curve Lines [id:da5494113181101443]
\draw [color={rgb, 255:red, 74; green, 144; blue, 226 }  ,draw opacity=1 ]   (313,222) .. controls (294,238) and (299,291) .. (317.59,307.92) ;
%Curve Lines [id:da8828117501564781]
\draw [color={rgb, 255:red, 74; green, 144; blue, 226 }  ,draw opacity=1 ] [dash pattern={on 0.84pt off 2.51pt}]  (313,222) .. controls (330,233) and (336,298) .. (317.59,307.92) ;
%Shape: Parallelogram [id:dp02778297397005436]
\draw  [fill={rgb, 255:red, 144; green, 144; blue, 144 }  ,fill opacity=0.44 ] (145.57,94) -- (308.5,94) -- (238.68,242.38) -- (75.75,242.38) -- cycle ;
%Shape: Circle [id:dp8371213746664339]
\draw  [color={rgb, 255:red, 253; green, 1; blue, 1 }  ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 0; blue, 0 }  ,fill opacity=1 ] (195.13,164.19) .. controls (195.13,163.08) and (196.02,162.19) .. (197.13,162.19) .. controls (198.23,162.19) and (199.13,163.08) .. (199.13,164.19) .. controls (199.13,165.29) and (198.23,166.19) .. (197.13,166.19) .. controls (196.02,166.19) and (195.13,165.29) .. (195.13,164.19) -- cycle ;
%Straight Lines [id:da21346648436809335]
\draw [color={rgb, 255:red, 65; green, 117; blue, 5 }  ,draw opacity=1 ]   (197.13,164.19) -- (181.9,194.22) ;
\draw [shift={(181,196)}, rotate = 296.88] [color={rgb, 255:red, 65; green, 117; blue, 5 }  ,draw opacity=1 ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

% Text Node
\draw (501,122.4) node [anchor=north west][inner sep=0.75pt]    {$\ $};
% Text Node
\draw (478,109) node [anchor=north west][inner sep=0.75pt]   [align=left] {\(\mathbb{T}\)};
% Text Node
\draw (82,65) node [anchor=north west][inner sep=0.75pt]   [align=left] {\(T_x\mathbb{T}\)};
% Text Node
\draw (206,152) node [anchor=north west][inner sep=0.75pt]   [align=left] {\textcolor{red2}{{\footnotesize \(x\)}}};
% Text Node
\draw (191.06,183.09) node [anchor=north west][inner sep=0.75pt]   [align=left] {{\footnotesize \textcolor{green2}{\(v\)}}};

\end{tikzpicture}

\end{frame}

\begin{frame}{It's possible plotting graphs with pgfplots and tikz}

\centering
\begin{tikzpicture}
\begin{axis}
\addplot[color=yellow]{exp(x)};
\end{axis}
\end{tikzpicture}
%Here ends the 2D plot

%Here ends the 3D plot

\end{frame}

\begin{frame}{Plotting 3d}
%Here begins the 3D plot
\centering
\begin{tikzpicture}
\begin{axis}
\addplot3[
    surf,
]
{exp(-x^2-y^2)*x};
\end{axis}
\end{tikzpicture}
\end{frame}


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Homework}
\date{December 10, 2014}
\author{Jon Allen}
\maketitle
Section 5.1: 4
Section 5.2: 18
Section 5.3: 11, 17.
\renewcommand{\labelenumi}{5.\arabic{enumi}}
\renewcommand{\labelenumii}{\arabic{enumii}.}
\renewcommand{\labelenumiii}{(\alph{enumiii})}
\begin{enumerate}
\item
  \begin{enumerate}
  \setcounter{enumii}{3}
  \item
  Let $R=\{m+n\sqrt{2}:m,n\in \mathbb{Z}\}$
    \begin{enumerate}
    \item
    Show that $m+n\sqrt{2}$ is a unit in $R$ if and only if $m^2-2n^2=\pm 1.$

    {\em Hint}: Show that if $(m+n\sqrt{2})(x+y\sqrt{2})=1$ then $(m-n\sqrt{2})(x-y\sqrt{2})=1$ and multiply the two equations.

    Assume that $m+n\sqrt{2}$ is a unit in $R$. Then we can find some $x+y\sqrt{2}$ such that
    \begin{align*}
      (m+n\sqrt{2})(x+y\sqrt{2})=mx+\sqrt{2}(my+nx)+2ny&=1\\
      mx-2ny&=1
    \end{align*}
    Note that $my+nx$ has to be $0$ (the reals are an integral domain, and we have an integer [rational] result).
    \begin{align*}
      (m-n\sqrt{2})(x-y\sqrt{2})&=mx-\sqrt{2}(my+nx)+2ny\\
      &=mx+2ny=1\\
      (m-n\sqrt{2})(x-y\sqrt{2})(m+n\sqrt{2})(x+y\sqrt{2})&=1\\
      (m^2-2n^2)(x^2-2y^2)&=1\\
    \end{align*}
    And because we are dealing with integers, we know that $m^2-2n^2=x^2-2y^2=\pm 1$.

    Now $m^2-2n^2=\pm 1=(m+n\sqrt{2})(m-n\sqrt{2})$ and so $m+n\sqrt{2}$ has an inverse of either $m-n\sqrt{2}$ or $-m+n\sqrt{2}$.
    $\Box$
    \item
    Show that $1+2\sqrt{2}$ has infinite order in $R^\times$

    If $1+2\sqrt{2}$ doesn't  have infinite order, then there exists some $n$ such that $(1+2\sqrt{2})^n=1=(1+2\sqrt{2})(1+2\sqrt{2})^{n-1}$. I don't know what $(1+2\sqrt{2})^{n-1}$ is but if it exists, then it is the inverse of $1+2\sqrt{2}$ which would make $1+2\sqrt{2}$ a unit. And so we know $1^2-2\cdot 2^2=\pm 1$. Whoops, guess it's not a unit, and therefore has infinite order.
    \item
    Show that $1$ and $-1$ are the only  units that have finite order in $R^\times$

    We take a finite order element $(m+n\sqrt{2})$ and note that if it has finite order, then it has an inverse and so $m^2-2n^2=\pm 1$ and so $m^2=n^2+1$ or $n^2=m^2+1$. We assume that $m^2=n^2+1$. And so $n^2+1=m^2> n^2\therefore |m|\ge |n|+1>|n|$. Now $(|n|+1)^2=n^2+2|n|+1$ gives us $n^2+1\ge n^2+2|n|+1$ and $0\ge |n|$. So we know that $m^2=\pm 1$ and then $m=\pm 1$ as expected. Doing the same trick the other way around we get $0=m$ and then $-2n^2=\pm1$. Which means that $(\pm 2)^{-1}=n^2$. Obviously $\pm 2$ has no inverse in $\mathbb{Z}$ and $n^2\in \mathbb{Z}$ so the only finite order elements are $1$ and $-1$.
    \end{enumerate}
  \end{enumerate}
\item
  \begin{enumerate}
  \setcounter{enumii}{17}
  \item
  Define $\phi:\mathbb{Z}\to\mathbb{Z}_m\oplus\mathbb{Z}_n$ by $\phi(x)=([x]_m,[x]_n)$. Find the kernel and image of $\phi$. Show that $\phi$ is onto if and only if $\gcd(m,n)=1$.

  %It's fairly obvious that we have a homomorphism, and the question implies that we can take that for granted, but just to be sure, note that $[a+b]=[a]+[b]$ and $[ab]=[a][b]$.

  If $[x]_m=[0]_m$ then $m|x$ and similarly if $[x]_n=[0]_n$ then $n|x$. Then $\ker(\phi)=\{x\in \mathbb{Z}:m|x\text{ and }n|x\}$.

  Let $k=\gcd(m,n)$ and $m=ka, n=kb$. Then $[x]_k=[mq+[x]_m]_k=[kaq+[x]_m]_k=[[x]_m]_k$ and similarly $[x]_k=[[x]_n]_k$ and so $[[x]_m]_k=[[x]_n]_k$. So the image consists of $\{(x,y)\in \mathbb{Z}_m\oplus\mathbb{Z}_n:[x]_{\gcd(m,n)}=[y]_{\gcd(m,n)}\}$.

  Now if $\gcd(m,n)$ is one then there are no restrictions on the image and so it is onto. That is to say $[x]_1=[0]_1$ regardless of ones choice of $x$. If $\gcd(m,n)=k>1$ then $0\in\mathbb{Z}_m$ and $1\in \mathbb{Z}_n$. Now $k>1$ and so $[[0]_m]_k=[0]_k\ne[1]_k=[[1]_n]_k$. And so $([0]_m,[1]_n)\not\in\phi(\mathbb{Z})$ and then $\phi$ is not onto.
  \end{enumerate}
\item
  \begin{enumerate}
  \setcounter{enumii}{10}
  \item
  Let $R$ be a commutative ring, with $a\in R$. The {\bfseries annihilator} of $a$ is defined by
  \[\text{Ann}(a)=\{x\in R:xa=0\}\]
  Prove that $\text{Ann}(a)$ is an ideal of $R$
  \subsubsection*{proof}
  Let us take any $x,y\in \text{Ann}(a)$. Then $(x+y)a=xa+ya=0$ and so $x+y\in \text{Ann}(a)$. Similarly $(x-y)a=xa-ya=0$ and so $x\pm y\in \text{Ann}(a)$. Now if we take an arbitrary $r\in R$ and an arbitrary $x\in \text{Ann}(a)$ then $(rx)a=r(xa)=r0=0$ and so $rx\in \text{Ann}(a)$.
  $\Box$

  \setcounter{enumii}{16}
  \item
  Let $R$ be the set of all matrices $\left[\begin{array}{cc}a&b\\c&d\end{array}\right]$ over $\mathbb{Q}$ such that $a=d$ and $c=0$.

  So $\left[\begin{array}{cc}a&b\\0&a\end{array}\right]$
    \begin{enumerate}
    \item
    Verify that $R$ is a commutative ring.

    We get that addition is an abelian group for free because the elements of the matrices are in $\mathbb{Q}$ which is an abelian group.

    \begin{align*}
      \left[\begin{array}{cc}a_1&b_1\\0&a_1\end{array}\right]
      \left[\begin{array}{cc}a_2&b_2\\0&a_2\end{array}\right]
      &=\left[\begin{array}{cc}a_1a_2&a_1b_2+a_2b_1\\0&a_1a_2\end{array}\right]
    \end{align*}
    Because $\mathbb{Q}$ is commutative under multiplication and addition, it is easy to see that that above multiplication is also commutative (swapping the ones and twos doesn't change anything).
    Now changing $a_2$ to $a_2+a_3$ and likewise $b_2\Rightarrow b_2+b_3$ the above result becomes
    \begin{align*}
      \left[\begin{array}{cc}a_1(a_2+a_3)&a_1(b_2+b_3)+(a_2+a_3)b_1\\0&a_1(a_2+a_3)\end{array}\right]
      &=\left[\begin{array}{cc}a_1a_2&a_1b_2+a_2b_1\\0&a_1a_2\end{array}\right]
      +\left[\begin{array}{cc}a_1a_3&a_1b_3+a_3b_1\\0&a_1a_3\end{array}\right]
    \end{align*}
    Which give us distribution for multiplication, so we have a commutative ring.
    \item
    Let $I$ be the set of all such matrices for which $a=d=0$. Show that $I$ is an ideal of $R$.

    Obviously $\left[\begin{array}{cc}0&b_1\\0&0\end{array}\right]+\left[\begin{array}{cc}0&b_2\\0&0\end{array}\right]=\left[\begin{array}{cc}0&b_1+b_2\\0&0\end{array}\right]\in I$ and $\left[\begin{array}{cc}a&b_1\\0&a\end{array}\right]\left[\begin{array}{cc}0&b_2\\0&0\end{array}\right]=\left[\begin{array}{cc}0&ab_2\\0&0\end{array}\right]$. Because $ab_2\in \mathbb{Q}$ then $\left[\begin{array}{cc}0&ab_2\\0&0\end{array}\right]\in I$
    \item
    Use the fundamental homomorphism theorem for rings to show that $R/I\cong \mathbb{Q}$.

    $\phi:\left[\begin{array}{cc}a&b\\0&a\end{array}\right]\to a$

    \begin{align*}
      \phi\left(\left[\begin{array}{cc}1&0\\0&1\end{array}\right]\right)&=1\\
      \phi\left(\left[\begin{array}{cc}a_1&b_1\\0&a_1\end{array}\right]+\left[\begin{array}{cc}a_2&b_2\\0&a_2\end{array}\right]\right)&=a_1+a_2\\
      &=\phi\left(\left[\begin{array}{cc}a_1&b_1\\0&a_1\end{array}\right]\right)+\phi\left(\left[\begin{array}{cc}a_2&b_2\\0&a_2\end{array}\right]\right)\\
      \phi\left(\left[\begin{array}{cc}a_1&b_1\\0&a_1\end{array}\right]
      \left[\begin{array}{cc}a_2&b_2\\0&a_2\end{array}\right]\right)
      &=a_1a_2\\
      &=\phi\left(\left[\begin{array}{cc}a_1&b_1\\0&a_1\end{array}\right]\right)
      \phi\left(\left[\begin{array}{cc}a_2&b_2\\0&a_2\end{array}\right]\right)\\
      \phi\left(\begin{array}{cc}0&b\\0&0\end{array}\right)&=0
    \end{align*}

    So we see that $\phi$ is a homomorphism and $I$ is $\ker\phi$

    Clearly $\phi(R)=\mathbb{Q}$ as we have no restriction on the ``$a$'' element. And so by the fundamental homomorphism theorem for rings we have $R/I\cong\mathbb{Q}$
    \end{enumerate}
  \end{enumerate}
\end{enumerate}
\end{document}


\documentclass[main.tex]{subfiles}
\begin{document}

\section{GW energy}

\marginpar{Monday\\ 2021-5-31, \\ compiled \\ \today}

The thing that remains to clarify in this expression is what kind of energy we are talking about:
%
\begin{align}
\dv{E}{t} = \frac{G}{5 c^{5}} \expval{ \dot{\ddot{Q}}_{ij} \dot{\ddot{Q}}^{ij}}
\,.
\end{align}

If we try to do dimensional analysis, we find
%
\begin{align}
\dot{E} \sim \frac{G}{c^{5}} a^2 \Omega^{6} M^2 R^{4}
\,.
\end{align}

The term \(G / c^{5}\) has units of \([T] / [E]\), and it is the inverse of \(c^{5} / G \approx \SI{e52}{W}\).
Therefore, the expression has a very small number in front of it.

However, we can rewrite the expression in terms of \(c^{5} / G\):
%
\begin{align}
\dot{E} = a^2 \frac{c^{5}}{G} \qty( \frac{v}{c})^{6} \qty( \frac{GM}{c^2 R})
\,.
\end{align}

The first person who did this, Weber, was also the first to claim a detection of GW, with bar detectors.
This triggered the field of experimental GW detection.

If \(v/c \to 1\), and \(\sigma = GM / c^2R \sim 1/2\), then \(\dot{E} \sim \SI{e50}{W}\).

We expect such a source to be the most luminous in the Universe, in GWs at least!

Dyson predicted a ``flash'' of intense radiation as two NS merge.

The factor \(a\) is dimensionless --- what is its numerical value? It is \(32/ 5\). With this, the formula
%
\begin{align}
\dot{E}_{GW} = \frac{32}{5} \frac{G \mu^2}{c^{5}} R^{4} \Omega^3
\,
\end{align}
%
is actually correct.

Using Kepler's law, \(\Omega^2 = GM R^{-3}\), we can remove the radial dependence and calculate \(P = \dot{E}_{GW} = \Omega^{10/3}\).

The reservoir of energy is the orbital energy:
%
\begin{align}
E = \frac{1}{2} \mu (\Omega R)^2 - \frac{m \mu }{R} \sim - \Omega^{2/3}
\,.
\end{align}

So, as the energy decreases, the frequency increases.
We can keep approximating the orbits as circular, with ever smaller radii.
This is known as the adiabatic approximation, \(T _{\text{orbit}} \gg 1/ \nu_{GW} \sim 1/ 2 \Omega \).

Really, the orbit is not circular but instead an inspiral.

In the final stages, this is a runaway process: the merger.
This was demonstrated before the detection of GW, with the Hulse-Taylor pulsar.

Let us discuss frequency evolution according to radiation reaction uses these equations.

We have
%
\begin{align}
\dv{}{t} \log E = \dv{}{t} \log \Omega^{2/3}
\implies
\frac{2}{3} \frac{\dot{\Omega}}{\Omega } = \frac{\dot{E}}{E} = \frac{P _{\text{gw}}}{E}
\,.
\end{align}
%
Alternatively we could work with energy balance:
%
\begin{align}
- P _{\text{gw}} = \dot{E} = \dv{E}{\Omega } \dot{\Omega}
\,.
\end{align}

Keeping all the factors leads to
%
\begin{align}
\frac{\dot{\omega}}{\omega } = \frac{36}{5} \qty( \frac{1}{2} \frac{GM_c}{c^3} \omega )^{5/3} = \frac{96}{5} \nu \qty( \frac{1}{2} \frac{Gm}{c^3} \omega )^{5/3}
\,.
\end{align}

The frequency \(\omega = 2 \Omega \) is the GW frequency --- a general result from the quadrupole formula --- while \(M_c\) is the chirp mass.
Its expression is due to the combination of masses \(m_1 \), \(m_2 \) appearing in the quadrupole formula applied to a binary.

The quantity \(m = m_1 + m_2  \) is the total binary mass, while \(\nu = m_1 m_2 / m = \mu / m \) is the \emph{symmetric mass ratio}.

The equation holds under the following:
%
\begin{align}
\hat{\omega} \to m \omega \qquad \text{and} \qquad
t \to t / m
\,,
\end{align}
%
since \(\hat{\hat{\omega}} / \hat{\omega} \propto \hat{\omega}^{5/3}\).
This is a general feature of the two-body problem in GR (in vacuum, for point particles).

It is suggestive to have \(\dot{\omega} / \omega \) on the LHS of the equation: Kepler's law yields
%
\begin{align}
\dot{R} = - \frac{2}{3} \frac{\dot{\Omega}}{GM R^{-3}} R \Omega = - \frac{2}{3} \frac{\dot{\Omega}}{\Omega } \Omega R
\,,
\end{align}
%
so the quantity
%
\begin{align}
Q^{-1}_\omega = \frac{\dot{\omega}}{\omega^2} = - 3 \frac{\dot{R}}{R \Omega }
\,
\end{align}
%
is, up to a constant factor, the ratio between the radial velocity and the tangential velocity: it quantifies ``how much'' the motion is approximated by a circular orbit, ``how much'' the orbit is adiabatic.

If \(Q_\omega \gg 1\), we are in the adiabatic regime. This is called the \textbf{adiabaticity parameter}.

In terms of the chirp mas, we have
%
\begin{align}
\mathcal{M}_c = \frac{c^3}{G} \qty( \qty( \frac{5}{96})^{3} \pi^{-8} f^{-11} \dot{f}^{3})^{1/5}
\,.
\end{align}

If we have a detection of a very long signal, the frequency increases in a runaway process.

Therefore, if we measure the frequency evolution we can estimate the chirp mass. The signal \texttt{GW170817} was so long that the chirp mass was measured up to the fourth digit.

\section{Short wavelength approximation}

How do we define a GW on an arbitrary background? We want to use \(g = \eta + h\), where now \(\eta \) is not necessarily flat.

The questions are:
\begin{enumerate}
    \item How do we define the decomposition \(g = \eta + h\)?
    \item How do we interpret \(h\) as a GW in general?
\end{enumerate}

Rigorously speaking, this is \textbf{not possible} in general. We have one metric, we need to make some arbitrary choice.

There are situations in which one can attempt to identify different relevant scales.
There are situations in which one can attempt to identify different scales of variation, for example if the \(\eta \) metric varies with typical scale \(L\) and the \(h\) metric perturbation has a typical length \(\lambda\) in space.

We take GWs with \(\lambda = c/f\), and \(f \approx \SI{e3}{Hz}\), therefore \(\lambda \sim \SI{50}{km}\). Also, \(\abs{h} \sim \num{e-21}\).

On the Earth, \( \phi _{\oplus} \sim G M _{\oplus} / c^2 R_{\oplus} \sim \num{e-6}\).

Now, \(\phi _{\oplus}\) is not smooth at the scale \(\lambda \): it is \textbf{not possible} to distinguish \(\eta _\oplus\) from \(h\)!

How do we do it, then?
The Earth's gravitational field is quasi-static for frequencies \(f \ll f_{\text{gw}}\).
In this sense, it is possible to distinguish the background from the perturbation.

We assume that \(\abs{h} = \epsilon \) is very small, and that \(\lambda \ll L\) or \(f \gg F\), the maximum frequency of the evolution background.

We start from \(R_{\mu \nu } = 8 \pi \qty(T_{\mu \nu } - T g_{\mu \nu } /2) = 8 \pi \overline{T}_{\mu \nu }\). We then expand in \(\epsilon \):
%
\begin{align}
R_{\mu \nu } =
R_{\mu \nu  }^{(0)}+
R_{\mu \nu  }^{(1)}+
\order{\epsilon^2}
\,.
\end{align}
%

In terms of \(\epsilon \) and \(k = 1 / \lambda \) we will have
%
\begin{align}
\eta &\sim \order{\epsilon^{0}}  \\
\partial \eta &\sim \order{1/L}   \\
\partial^2 \eta &\sim \order{1/L}  \\
h^{n} &\sim \order{\epsilon^n} \\
\partial h^{1} &\sim \order{\epsilon k} \\
\partial^2 h^{1} &\sim \order{\epsilon k^2}
\,.
\end{align}

The term \(R^{(0)}_{\mu \nu } \sim \eta \partial^2 \eta \) is a long-wavelength one; the term \(R^{(1)}_{\mu \nu } \sim \eta \partial^2 \eta^{(1)} \order{\epsilon k^2}\) is a short wavelength one; the term
%
\begin{align}
R^{(2)}_{\mu \nu } \sim \eta \partial^2 h^{(2)} + h^{(1)} \partial^2 h^{(1)} \sim \order{\epsilon^2 k^2}
\,
\end{align}
%
has components that are both short and long wavelength.

We can then formally separate the EFE: the long-wavelength part reads
%
\begin{align}
R^{(0)}_{\mu \nu } = - \qty[ R^{(2)}_{\mu \nu }]^{\text{long}}
+ 8 \pi \qty[\overline{T}_{\mu \nu }]\text{long} \\
\,,
\end{align}
%
while the short wavelength part reads
%
\begin{align}
R^{(1)}_{\mu \nu } = - \qty[ R^{(2)}_{\mu \nu }]^{\text{short}}
+ 8 \pi \qty[\overline{T}_{\mu \nu }]\text{short} \\
\,.
\end{align}

The term \(- \qty[ R^{(2)}_{\mu \nu }]^{\text{long}}\) can be interpreted as \(\tau_{\mu \nu }\), the feedback of the GWs on the background curvature.

On the other hand, the short-wavelength part will describe the propagation of GWs on a generic background.

How do we separate the scales? As discussed by Brill and Hartle, as well as Isaacson, we use the averaging procedure:
%
\begin{align}
\expval{S_{\mu \nu }}&= \int \dd[4]{x} \eta^{\mu '}_\alpha (x, x') \eta^{\nu '}_{\beta } (x, x') S_{\mu ' \nu '} (x') f(x, x') \sqrt{\eta (x')}
\,,
\end{align}
%
where \(f\) is a filter function which vanishes for \(\lambda \gg L\); the functions \(\eta \) transport the \(S_{\mu \nu }\) around a point.

This is described in some detail in \cite[]{misnerGravitation1973}.
It generalizes the Isaacson tensor:
%
\begin{align}
\tau_{\alpha \beta } = - \qty[R_{\mu \nu }^{(2)}]^{\text{long}}
= - \expval{R_{\mu \nu }^{(2)}}
\,.
\end{align}

We have two expansion parameters: \(\epsilon \) and \(\lambda \), where \(\lambda / L \ll 1\).
(Note that I write \(\lambda \) but it should be a barred lambda).

The equation equates terms with different powers of \(\epsilon \): we need some \emph{consistency conditions}.

If \(\overline{T}_{\mu \nu } = 0\), the GWs contribute to the background metric: \(1 / L^2 \sim \epsilon^2 k^2 = \epsilon^2 / \lambda^2\).
Therefore, \(\epsilon = \lambda /L\).

With \(\qty[R^{(2)}_{\mu \nu }]^{\text{long}} \approx 0\), we have
%
\begin{align}
\frac{1}{L^2} \sim \epsilon^2 k^2 + \text{(matter)} \gg \epsilon^2k^2
\,,
\end{align}
%
so \(\epsilon \ll \lambda /L\).
In this sense we want \(\epsilon \) to be small. Note that for a flat background, \(1/L = 0 \) strictly!

So, no gravitational waves with finite amplitude exist as a perturbation of flat spacetime.

About the short wavelengths: GW propagation in general is given by
%
\begin{align}
0 &= \qty[R_{\mu \nu }^{(1)}]^{\text{short}} + \text{`matter terms'}  \\
&\approx \square_\eta \overline{h}_{\mu \nu } + \text{`matter terms'}
\,
\end{align}
%
in a ``generalized'' Hilbert gauge.

\end{document}


%!TEX root = ../PhD_thesis__Lilian_Besson

% First chapter begins here
\chapter{General Conclusion and Perspectives}
% \addcontentsline{toc}{chapter}{General Conclusion}
\label{chapter:conclusion}

% Write miniTOC just after the title
\graphicspath{{2-Chapters/6-Chapter/Images/}}
% ----------------------------------------------------------------------

% % \newpage
% \abstractStartChapter{}%
% %
% This last chapter concludes the document, first by summarizing the previous chapters, and by giving a general conclusion of the thesis.
% %
% We highlight what we consider to be the most important directions of future works, as well as some promising directions that were shortly studied during my PhD but not discussed in the manuscript.

% \minitocStartChapter{}

% ----------------------------------------------------------------------------
% ----------------------------------------------------------------------------
% \section{General Conclusion}
\subsection*{Conclusion on our contributions}

We started this manuscript by detailing the historical, scientific and technical contexts of our research during this PhD.
% which studied how decentralized low-cost machine learning technique can be used to automatically improve a certain aspect of wireless telecommunications.
%
We explained the problems that motivate and justify our works.
% and we presented the main contributions produced during the last three years.
%
The main question we studied was \emph{``Can we adapt the decision making tools, already successfully applied to Cognitive Radio for Opportunistic Spectrum Access, to the specific needs of CR for the (future) Internet of Things networks?''}
%
% This PhD manuscript
% is organized in two parts.
% It
We first gave a strong theoretical background on the reinforcement learning model considered in this thesis, that is the multi-armed bandit model.
We then focused on our problems of solving the spectrum scarcity issue in unlicensed bands, in the context of the future Internet of Things networks.
We worked on extending to the specificities of such IoT networks the ideas underlying the previously studied applications of machine learning to solve the spectrum scarcity issue in licensed networks.

Our main contribution to answer our problematic is a model of Internet of Things networks, based on an ALOHA-like protocol slotted in time and frequency, and that considers one IoT base station serving a large number of devices following the IoT constraints (low-cost, low duty cycle, long range etc).
In such a IoT network, we focused on many dynamically reconfigurable IoT end-devices, that are able to run low-cost and low-complexity decision making algorithms, embedded on each device using their limited computational and storage capacities.
%  (limited hardware)
We proposed two models, whether the considered IoT standard enforces the devices to try to retransmit a few times their up-link packet in case of a failed transmission (\ie, a collision with other devices),
or to drop their packet after a failed transmission (\ie, with or without retransmission).
Both models are realistic, and for both cases we proposed to use multi-armed bandit (MAB) algorithms, such as \UCB{} or Thompson sampling, in order that the numerous IoT devices improve their spectrum access scheme, on their own, by learning which of the $K$ frequency channels are the less occupied ones by the environmental traffic (in average).

The approach we thus advocate is to use low-complexity MAB algorithms such as \klUCB{} or Thompson sampling, or variants tuned to be robust in slowly-evolving non-stationary scenario (\eg, Sliding-Window \UCB, Discounted-Thompson, or actively adaptive algorithm such as the one of Chapter~\ref{chapter:6}, \GLR-\klUCB).
%
For a company that manufactures IoT end-devices, it is very simple and cheap in terms of both hardware and software costs to implement such MAB algorithms on the low-cost embedded processors, and equip all the produced IoT devices with this capacity of using online machine-learning for their spectrum access.
The embedded decision-making algorithm automatically improves the channel selection of each device, in a fully decentralized way.
It also increases the total number of successful up-link transmissions, and thus this increases the Quality of Service of the considered IoT application.
Finally, such algorithm also allows more devices to be served by the same IoT gateway.
%
Another consequence is a reduced energy consumption and an increased battery life for the IoT end-devices.
% , and thus the solution studied in this thesis can also be used to reduce the global energy consumption of the IoT networks.
% solve both the spectrum scarcity issue and the energy

The advocated approach also has the advantage of not requiring to change anything on the IoT standard, as the only modification happens on the device side, by letting it actively decide the channels it uses for up-link transmissions, instead of relying on a naive uniform channel access.
%
We also note that this approach can easily be used to allow the IoT devices to optimize by themselves other parameters of their wireless communications on the fly, as the multi-armed bandit framework is not restricted to be applied to the selection of frequency channel but can be applied to any exploration-exploitation problem with a finite set of possible options.
The solution we propose can thus be easily extended to also select dynamically other parameters such as the coding rate or spreading factor of a LoRa network (\eg, \cite{KerkoucheAlami18}), the emission power in a NOMA standard, or any other discrete-valued parameters that have an impact on the successful transmissions rates and can be optimized on the device's side by using reinforcement learning.

Moreover, from a theoretical point-of-view, even though it was found hard to propose a rigorous analysis of our model of IoT networks, because of the large number of devices having different random and unpredictable activation patterns, our contributions also include an analysis of two restricted models.
%
On the one hand, we considered a model where the devices have data to transmit at each time step, relaxing the hypothesis of a random activation process (with a small probability, as IoT devices have low duty cycles), and thus by restricting to the case of at most $M \leq K$ devices using a wireless standard with $K$ orthogonal frequency channels.
This first model is similar to the multi-player bandit model studied in the last $10$ years, and for stationary and stochastic environments we were able to propose an efficient algorithm, \MCTopM.
Our proposed algorithm performs very well in practice and we obtained interesting guarantees on its regret, as well as on the number of radio collisions and on radio reconfigurations that the devices will suffer if they all implement our solution.
%
On the other hand, we studied a model that focuses on only one device but relaxes the hypothesis of stationarity on the surrounding radio traffic, and considers that is can be stationary in consecutive intervals of time, of unknown durations. This second model is similar to the piece-wise stationary (or abruptly-changing) bandit model studied since the $2000$s, and we solved it by proposing a new actively adaptive bandit policy, for which we obtained state-of-the-art results, in terms of its regret and its false alarm probability and delay of detection.

Finally, from an application point-of-view, we also presented a realistic implementation of a proof-of-concept of our first model of IoT network, that was used to validate empirically the proposed approach.
We showed that the IoT devices can effectively use a multi-armed bandit algorithm to automatically learn to favor certain frequency channels over others, and finally to optimize their spectrum access, to reduce their number of failed transmissions.
%
Our proposed approach is to use decentralized reinforcement learning algorithms, directly embedded on the IoT end-devices, in order to improve their spectrum access and channel selection schemes.
We confirmed from both numerical simulations and a validation on real radio traffic and real hardware that our proposal is an excellent candidate to start to solve the spectrum scarcity issue for unlicensed bands, that is cheap and easy to deploy.

% % % \begin{itemize}
% %     % \item
% % The first half, Part~\ref{part:Introduction}, started by motivating our work and situating the context of this research.
% % % Chapter 2
% % In Chapter~\ref{chapter:2}, we presented the multi-armed bandit (MAB) models, the hypotheses we usually make on such models, and the most important algorithms that solve different kinds of MAB problems.
% % % Chapter 3
% % Then in Chapter~\ref{chapter:3} we showcased our open-source Python library SMPyBandits in details, developed to run numerical simulations of MAB problems.
% % %
% % Finally, we presented in Chapter~\ref{chapter:25} a first mathematical contribution, our algorithm \Aggr, as an empirically efficient answer to the online algorithm selection problem.

% %     % \item
% % The second half of this thesis, Part~\ref{part:MABIOT}, presented the main contributions.
% % % Chapter 4
% % In Chapter~\ref{chapter:4}, we first proposed models for realistic IoT wireless networks, in a discrete time and with no central coordination between end-devices.
% % In two different models, with or without retransmissions, we showed that end-devices can independently learn favor the less occupied radio channels, in order to increase their successful transmission rates in the network, by embedding low-cost decentralized MAB algorithms.
% % We also presented a proof-of-concept that implements such network on real radio hardware and validates the proposed model and algorithms.
% % % Chapter 5
% % Because the models proposed for realistic IoT networks were found to be too general to analyze from a theoretical point of view, mainly due to the large number of algorithms interacting at random times in an unpredictable environment,
% % we started to study a weaker but still interesting model in Chapter~\ref{chapter:5}.
% % We presented different variants of the multi-players MAB model, and we proposed the state-of-the-art algorithm for the variant with collision and spectrum sensing information (\MCTopM).
% % % Chapter 6
% % Finally, in Chapter~\ref{chapter:6}, we relaxed the stationary hypothesis on the single-player MAB problem, and we analyzed a new actively adaptive algorithm, for which we also proved state-of-the-art results (\GLRklUCB).
% % %
% % For the last two chapters, the proposed algorithms attain state-of-the-art performances both on numerical simulations and on the regret upper bounds obtained in their theoretical analyses.
% % % \end{itemize}

% % \paragraph{Summary of each chapter.}
% % A more precise summary of each chapter is given below.

% % % ----------------------------------------------------------------------------
% % \paragraph{Conclusion about \textbf{Chapter~\ref{chapter:1}}.}

% % ----------------------------------------------------------------------------
% % \paragraph{Conclusion about \textbf{Chapter~\ref{chapter:2}}.}

% We started in Chapter~\ref{chapter:2} by presenting the multi-armed bandit model, with a finite number of arms and real-valued rewards.
% Our focus is on one-dimensional exponential families of distributions, and on stochastic and stationary problems.
% The notations used in the manuscript were introduced by showcasing an interactive demonstration.
% % \footnote{See \href{https://perso.crans.org/besson/phd/MAB\_interactive\_demo/}{\texttt{perso.crans.org/besson/phd/MAB\_interactive\_demo/}}}.

% % ----------------------------------------------------------------------------
% % \paragraph{Conclusion about \textbf{Chapter~\ref{chapter:3}}.}

% Then we presented in Chapter~\ref{chapter:3} our Python library SMPyBandits \cite{SMPyBanditsJMLR,SMPyBandits}, by detailing
% its purpose and qualities, its organization, and an overview of its usage.
% %
% This library allows any researcher to easily implement numerical simulations of stochastic or piece-wise stochastic problems of single- or multi-players multi-armed bandits.
% SMPyBandits is distributed on GitHub and Pypi freely, under an open-source license (MIT License), and it is extensively documented (at \href{https://SMPyBandits.GitHub.io}{\texttt{SMPyBandits.GitHub.io}}).\\
% % Our library allows any researcher to easily run numerical simulations of different kinds of multi-armed bandit problems, requiring only a small knowledge of Python thanks to its documentation, its well-designed API, and many examples of simulation scripts and configuration files included.\\
% \indent
% We detailed how SMPyBandits is implementing arms, problems, algorithms, and how the library uses these components to implement a simulation loop, with various visualizations being performed after a simulation.
% Even if SMPyBandits is still restricted to the finite-arm case, it supports a wide range of arm distributions (and rested/restless Markov models).
% Different kinds of models are implemented, from stationary single-player to piece-wise stationary multi-players with different collision models.
% One of the main qualities of our library is that it is quite exhaustive, as all the main families of algorithms covering these different models have been implemented, even very recent algorithms from the literature.
% % We indeed followed actively the state-of-the-art research, since December $2016$ to June $2019$.
% More than $65$ algorithms (or variants) are implemented for the single-player case, $5$ for the experts aggregation problem, about $15$ for the multi-players case, and about $20$ for the piece-wise stationary case.
% The entire codebase is fully documented, and the library is using continuous integration to run automated tests on the code after every modification.
% %
% When comparing algorithms on a problem, the main performance measure is the regret, but the library also computes, stores and visualizes other measures, such as best-arm selection rate or mean cumulated reward, as well as real time and memory costs.
% %
% Our library is used to run numerical simulations in Chapters~\ref{chapter:2}, \ref{chapter:3}, \ref{chapter:5} and \ref{chapter:6}, and in other contributions such as our article \cite{Besson2018DoublingTricks}.

% % ----------------------------------------------------------------------------
% % \paragraph{Conclusion about \textbf{Chapter~\ref{chapter:25}}.}
% %
% This first part ends with Chapter~\ref{chapter:25} by presenting one of our first contributions \cite{Besson2018WCNC}.
% We tackle the question of how to select a particular bandit algorithm when a practitioner is facing a particular (unknown) bandit problem.
% Instead of always choosing her favorite algorithm, or running costly benchmarks before real-world deployment of the chosen algorithm, a third solution for a practitioner can be to select a few candidate algorithms, where at least one is expected to be very efficient for the given problem, and use online algorithm selection to automatically and dynamically decide the best candidate.
% We proposed an extension of the \ExpFour{} algorithm for this problem, that we named \Aggr, and illustrate its performance on some bandit problems.

% % ----------------------------------------------------------------------------
% % \paragraph{Conclusion about \textbf{Chapter~\ref{chapter:4}}.}

% Chapter~\ref{chapter:4} started the second part of the manuscript, Part~\ref{part:MABIOT}, and presents three main contributions.
% %
% First in Section~\ref{sec:4:firstModel}, we proposed a model of IoT networks,
% and an evaluation of the performance of applying low-cost and low-complexity decentralized MAB learning algorithms in such, directly on the end-devices sides.
% Our focus is the convergence of such algorithms, and the gain they can provide for the IoT devices, in terms of successful transmission rates.
% We restrict to the case of a protocol slotted in both time and frequency, and we assume a certain clock pre-agreement and time synchronisation between devices and the base station.
% We studied the behavior of the network when the proportion of intelligent dynamic devices changes.
% Concretely, increasing their successful transmission rates allows to insert more devices in the same network, while maintaining a good Quality of Service.
% Another way of viewing this result is the opposite point-of-view: if the number of devices remains constant, increasing the successful transmission rate directly improves the network QoS.
% %  as the base station receives more accurately the data sent by the end-devices since less transmissions failed.
% We show that \UCB{} and Thompson sampling algorithms both have near-optimal performance, even when their underlying \iid{} assumption (see Chapter~\ref{chapter:2}) is violated by the presence of many ``intelligent'' end-devices which all follow a random activation process.
% %
% This was both surprising and encouraging, as it shows that applying bandit algorithms tailored for a stochastic model is still useful in our broader setting.
% The fully \emph{decentralized} application of classic stochastic MAB algorithms are almost as efficient as the best possible centralized policy in this setting, after a short learning period, even though the dynamic devices \emph{cannot} communicate with each other, and \emph{do not} know the system parameters.
% \\
% %
% \indent
% We presented in Section~\ref{sec:4:gnuradio} a proof-of-concept, demonstrated in $2018$ at the ICT conference \cite{Besson2018ICT}, and further detailed in the companion paper \cite{Besson2019WCNC}.
% We gave all the necessary details on both the PHY and the MAC layer, as well as details on the User Interface developed for the demo.
% We discussed results obtained in practice, to highlight the interest of using learning algorithms for cognitive radio online optimization problems, and especially multi-armed bandit learning algorithms for IoT networks.
% %
% By using such low-cost algorithms, we confirmed empirically that a dynamically re-configurable device can learn on its own to favor a certain channel, if the environment traffic is not uniform between the $K$ different channels, by using only the acknowledgement (\Ack) feedback as a collision binary indicator sent from the base station.
% \\
% %
% \indent
% Finally in Section~\ref{sec:4:retransmissions}, we presented an extension of the previous model of Low-Power Wide-Area (LPWA) networks based on an ALOHA protocol, again under the hypothesis of a protocol slotted in time and frequency, and assuming a perfect synchronisation.
% % , in which dynamic IoT devices can again use machine learning algorithms, to improve their Packet Loss Ratio (PLR) when accessing the network.
% If the priority is the Quality of Service (QoS), for instance with renewable energy capabilities, this second model is more appropriate.
% We presented and evaluated heuristics that learn how to transmit and retransmit in a smarter way, by using the \UCB{} algorithm for channel selection for the first transmission (first-stage), and different proposals based on \UCB{} for the retransmissions upon collisions (second-stage).
% The main novelty of this model is to also learn the most efficient way to retransmit packets upon radio collision, by also using a MAB algorithm for this second-stage optimization problem.
% %
% Like for the first model, we showed that incorporating learning for the first transmissions allows to achieve optimal performance, with significant gains in terms of successful transmission rate in networks with a large number of devices (up-to $30\%$ in the example network).
% Our simulations showed that the proposed heuristics greatly outperform a naive random access scheme.
% Surprisingly, we showed that a simple \UCB{} learning approach, that simply retransmits in the same channel, turns out to perform almost as well as more complicated heuristics, that can change the channel used for retransmissions.
% \\
% %
% \indent
% Thus in Chapter~\ref{chapter:4}, we proposed two models of Internet of Things (IoT) networks, composed of many independent IoT end-devices,
% that can all use embedded low-cost RL (Reinforcement Learning) algorithms to learn to improve their spectrum access.
% %
% Decentralized RL for IoT lets the devices use the acknowledgement sent by their Base Station as a reward, instead of requiring some spectrum sensing capacity, like in the OSA case.
% We consider many independent ``dynamic'' devices, communicating with a small probability at every instant.
% The first model (without retransmission of packets),
% is interesting for its simplicity, and because considering no retransmission can improve the battery life of the IoT devices.
% % , at the cost of a lower Quality of Service (QoS).
% %
% However, in case of failed transmission of a message, a dynamic device can also retransmit it up-to a fixed number of retransmission.
% %
% The second model is more interesting if the main target is an improvement of the QoS, rather than a longer battery life.
% %
% \TODOL{Je dois clarifier les conclusions des deux modèles, est-ce que l'un est vraiment mieux pour améliorer la QoS mais coûte en batterie, et l'autre améliore la batterie mais coûte en QoS ? Pas très clair en ayant la tête dans le guidon là !...}
% %
% %
% To sum-up, we focused in this chapter on models of IoT networks, and we proposed to use classical stationary multi-armed bandit learning algorithms implemented in a selfish and decentralized manner by each of the dynamic devices in the IoT network.
% We presented two models of wireless IoT networks, without relying on the feedback provided by spectrum sensing, and inspired by the ALOHA protocol.
% % In both cases, we try to model the existing standards, like the LoRa standard, and we demonstrated the efficiency of the proposed MAB-based approach in both numerical simulations and empirical measurements on real wireless radio signals.
% %
% It was also quite surprising to be able to conclude that this learning-based approach can be as efficient as we showed,
% % , as it allows the IoT devices to automatically and independently increase their successful transmission rates.
% because it is based on applying stochastic MAB algorithms in a non-stationary environment.
% Unfortunately, it turned out to be of extreme difficulty to analyze the considered model with thousands of independent devices, all communicating and learning in their own (random) time scales.
% That is why we focus on two different simplifications of this model in the next two chapters, for which we are able to provide a clean theoretical analysis,
% either by restricting to $M \leq K$ devices with a transmission probability of $p=1$, or by restricting to a single player accessing a network which is assumed to be \emph{piece-wise stationary}.

% % ----------------------------------------------------------------------------
% % \paragraph{Conclusion about \textbf{Chapter~\ref{chapter:5}}.}

% The second chapter of Part~\ref{part:MABIOT} of this manuscript studied Multi-Players Multi-Arm Bandits models (Chapter~\ref{chapter:5}).
% %
% We present three variants of this model,
% with different level of feedback being available to the decentralized players, under which we proposed efficient algorithms.
% For the two easiest models (\ie, with sensing), our theoretical contribution \MCTopM-\klUCB{} improves the state-of-the-art regret upper-bounds.
% In the absence of sensing, we also provide some motivation for the practical use of the \Selfish{} heuristic, a simple index policy based on hybrid indices that are directly taking  into account the collision information.
% \Selfish{} corresponds to the heuristic used in the first model studied in Chapter~\ref{chapter:4}.
% %
% We also reviewed various variants of this model, and for some interesting variants we discussed the related literature, which has proven to be very active in the last two years.
% For some of these variants, we explained why our approach does not work efficiently without modifications, but we detailed and illustrated how to adapt \MCTopM{} to other settings.
% For example, it assumes to know the number of players $M$ before-hand, but we illustrated that a previously introduced technique to estimate $M$ can also be applied successfully to our proposal.
% %  and give satisfactory empirical performances.
% % Further works would be required to adapt the theoretical analysis to these various extensions.

% % ----------------------------------------------------------------------------
% % \paragraph{Conclusion about \textbf{Chapter~\ref{chapter:6}}.}

% In the last Chapter~\ref{chapter:6}, we were interested in relaxing the stationary hypothesis made on the bandit model presented in Chapter~\ref{chapter:2}.
% %
% We first describe the break-point (or change-point) detection problem, that we solve by the Bernoulli GLR change-point detector, and by analyzing its properties at finite-time.
% This sequential break-point detection test can be applied for bounded rewards, and we bound its false alarm probability as well as its detection delay.
% For the piece-wise stationary bandit model,
% we proposed a new efficient algorithm, \GLRklUCB, which combines the \klUCB{} algorithm with the Bernoulli GLR change-point detector.
% This actively adaptive method attains state-of-the-art regret upper-bounds when tuned with a prior knowledge of the number of changes $\Upsilon_T$, but without any other prior knowledge on the problem, unlike its two competitors \CUSUMUCB{} and \MUCB, that require to know a lower bound on the smallest magnitude of a change.
% We also gave numerical evidence of the efficiency of our proposal, which performs usually much better than all the passively adaptive approaches as well as better or comparably to the previous actively adaptive ones.

% ----------------------------------------------------------------------------
% \newpage

% ----------------------------------------------------------------------------
% ----------------------------------------------------------------------------
\subsection*{Perspectives}
% \subsection*{Future works}

% % As discussed at the end of each chapter,
% % All the models, simulations,
The works presented in each chapter suggest possible directions of future studies.

% ----------------------------------------------------------------------------
% \paragraph{Perspectives about \textbf{Chapter~\ref{chapter:1}}.}

% ----------------------------------------------------------------------------
% \paragraph{Perspectives about \textbf{Part~\ref{part:Introduction}}.}

% ----------------------------------------------------------------------------
% \paragraph{Perspectives about }.}

% As detailed in Chapter~\ref{chapter:2}, we focused in this thesis on MAB problems with a finite number of arms, and binary, bounded or real-valued rewards.
% Thus two possible directions of future research could be to extend our works
% to MAB models with either multi-dimensional rewards, like contextual bandits \cite{Li10,Luo18,ChenLeeLuoWei2019}, or infinite arms \cite{valko2016bandits,Combes17}, like Lipschitz bandits.
% The hypotheses we made were motivated by the target application, but these other models could also be used for cognitive radio applications.

% ----------------------------------------------------------------------------
% \paragraph{Perspectives about \textbf{Chapter~\ref{chapter:4}}.}

% Future works related to this chapter include the following directions.

% \paragraph{Possible extensions of the first model.}

\paragraph{For our models of IoT networks.}
%
The first model presented in Section~\ref{sec:4:firstModel} could easily be generalized with two probabilities $p_S$ and $p_D$, if the $S$ static and $D$ dynamic devices have different transmission patterns, and less easily with a different probability per device.
Also, other emission patterns could be considered, instead of a Bernoulli process for each user.
In this entire Chapter~\ref{chapter:4}, we prefer to consider that all the devices have the same activation probability, to keep the notations and the model as simple as possible.
%
Moreover, for the sake of simplicity we supposed that all devices use the same standard.
Future works could consider more realistic interference scenarios and IoT networks, with non-slotted time, more than one base station etc.
% \\
% \indent
Another extension could be to consider not a Bernoulli activation process (or any random process), but a fixed rate of transmission, \eg, one transmission a day.
In this case, additionally to deciding the channel for communication (\ie, \emph{where} to communicate), each device could thus also have to decide \emph{when} to communicate.
% This is another direction of research, that we will investigate in the future.
However, this clearly leads to a much larger action space, as there are many time slots in one day (for example), and thus we believe that as soon as the action space becomes too large in this extension, the simple MAB-based learning approach could be no longer appropriate.
It is well-known in the MAB literature that the larger the action space, the slower is the convergence speed of any stationary MAB algorithms.
Thus, it could be exciting to study the possible application of \emph{contextual} MAB \cite{Li10,Luo18} or structured MAB \cite{Combes17} models and algorithms for this extension.
%
% We will investigate this behavior in order to understand it better theoretically.
% We will also experiment more with adversarial algorithms, to confirm that they work less efficiently than stochastic bandit algorithms in our non-stochastic setting.
%
% \paragraph{Extensions of the demonstration.}
%
% Possible future extensions of our demonstration include the following points.
% We could consider more dynamic devices (\eg, $100$) but it would either cost more in terms of equipment, or in terms of software engineering to simulation more devices with the same card.
% We could also implement a real-world IoT communication protocol (like the LoRaWAN standard), which we prefer not to do as it would cost a significant effort of development.
% Finally, we could also study the interference in case of other gateways located nearby, and this could be done without needing a lot of new hardware (using one extra USRP card to simulate another gateway).
%
%
% \paragraph{Possible extensions for the second model.}
%
% Finally, the utility and impact of the proposed approaches for LPWA networks motivates us to address several subjects as future works. Among them, the non-stationarity of the channel occupancy caused by the learning policy employed by the IoT devices.
% %
% For that end, modifications of MAB algorithms have been proposed, such as Sliding-Window-\UCB{} or Discounted-\UCB{} \cite{Garivier11UCBDiscount}
% or more recently M-\UCB{} \cite{CaoZhenKvetonXie18},
% or more recently GLR-\UCB{} \cite{Besson2019GLRT} which is presented in Chapter~\ref{chapter:6},
% that nevertheless have not been explored for the targeted problem.
% \\
% \indent

% In order to validate our results in a realistic experimental setting and not only with simulations, future works should include a hardware implementation of the analyzed models, in order to complete our demonstration presented in Section~\ref{sec:4:gnuradio} \cite{Besson2018ICT,Besson2019WCNC}.
% %
% A hardware demonstrator could be also benefit to study other settings by relaxing some hypotheses, for instance by studying a similar model in non-slotted time.

% ----------------------------------------------------------------------------
% \paragraph{Perspectives about \textbf{Chapter~\ref{chapter:5}}.}

\paragraph{For multi-player bandits.}
%
The study on multi-players bandits in Chapter~\ref{chapter:5} suggests several further research directions.
First, one could investigate the notion of \emph{optimal algorithms} in the decentralized multi-players model with sensing information.
So far we provided the first matching upper and lower bound on the expected number of sub-optimal arms selections, which suggests some form of (asymptotic) optimality.
However, sub-optimal draws turn out to not be the dominant terms in the regret, both in our upper bounds and in practice.
Thus a promising future work is to identify some notion of \emph{minimal number of collisions}.
This could be similar to what a recent work \cite{wang2019distributed} studied for the minimal amount of communication needed to achieve logarithmic regret, in a similar model that authorizes direct communications between players.
% Similarly to what was done very recently in \cite{wang2019distributed} for the communications between players who collaborate with each other, it would be interesting to characterize the number of collisions needed to achieve logarithmic regret.
\\
\indent
We also presented many extensions of the multi-players bandit model in Section~\ref{sec:5:literatureReviewOtherModels},
and even if some have already been implemented,
an important future work is to implement the most interesting ones in SMPyBandits
(see tickets \href{https://github.com/SMPyBandits/SMPyBandits/issues/120}{120}, \href{https://github.com/SMPyBandits/SMPyBandits/issues/124}{124}, \href{https://github.com/SMPyBandits/SMPyBandits/issues/185}{185}).
From the point-of-view of the theoretical analysis, we are especially interested by first extending our proposed algorithm \MCTopM{} to the case of an unknown number of players.
Then we could also address the most interesting extension for the application to wireless networks, \ie, the ``dynamic case'' which allows for arrivals and departures of players in the multi-player bandit game.
%
% as well as extending our theoretical analyses for such extensions of the models considered in this thesis.

% ----------------------------------------------------------------------------
% \paragraph{Perspectives about \textbf{Chapter~\ref{chapter:6}}.}

\paragraph{Regarding non-stationary bandits.}
%
We believe that the new proof technique of Chapter~\ref{chapter:6} could be used to analyze \GLRklUCB{} under less stringent assumptions than the one made in this chapter (and in previous works), that would require only a few ``meaningful'' changes to be detected.
This promising research direction is left for future work,  but the hope is that the regret would be expressed in terms of the number of such meaningful changes, instead of the number of break-points $\Upsilon_T$.
We shall moreover investigate whether actively adaptive approaches can attain a $\cO(\sqrt{\Upsilon_T T})$ regret upper-bound without the knowledge of $\Upsilon_T$.
We also believe that combining change-point \emph{localization} with an efficient change-point detection algorithm, such as \GLRklUCB, could lead to an interesting class of more efficient algorithms.
% as suggested by \cite{Maillard2018GLR}.
% \\
% \indent
Another very interesting future work is to study possible extensions of our approach, especially to the slowly-varying model, as studied in \cite{Besbes14stochastic,Louedec16,WeiSrivastava18Abruptly}, or to other models such as the rotting bandit model \cite{Seznec2018}, which is interesting for many applications even if it does not seem directly usable for the cognitive radio setting.

% ----------------------------------------------------------------------------
% \paragraph{Perspectives about \textbf{Chapter~\ref{chapter:3}}.}

\paragraph{For our library SMPyBandits.}
%
A few tasks are left on SMPyBandits, a first one could be to implement new variants of the single-player stochastic models, as well as variants for the multi-players or the non-stationary cases.
For more details, see the issue tickets at \href{https://github.com/SMPyBandits/SMPyBandits/issues/}{\texttt{GitHub.com/SMPyBandits/SMPyBandits/issues/}}.
%
A second interesting task could be
% to extend the library for problems with non-finite arms, such as linear or contextual bandits (\href{https://github.com/SMPyBandits/SMPyBandits/issues/117}{ticket 117}),
to add support for the ``dynamic case'' of multi-players bandits to allow arrivals or departures of players (\href{https://github.com/SMPyBandits/SMPyBandits/issues/124}{ticket 124}).

% ----------------------------------------------------------------------------
% \subsection*{Other directions of future works}
\paragraph{Unifying multi-player and non-stationary bandits.}
%
%
A natural next step after this thesis is to study non-stationary distributed multi-players bandits, to unify the models from Chapter~\ref{chapter:5} and~\ref{chapter:6}.
A natural extension of the non-stationary model is to consider non-communicating players cooperating in a decentralized way to play the same bandit game, as it was proposed recently in \cite{WeiSrivastava18Distributed}.
%
We could also build on the proof technique used in this paper, even if we are interested in removing the hypothesis that player $j$ knows its ID $j\in[M]$ before starting to play.
%
A promising direction is to directly try to join our contributions from Chapter~\ref{chapter:5} and~\ref{chapter:6}, and propose an efficient algorithm using three parts:
\klUCB{} indexes for arm selection,
\MCTopM{} for orthogonalization (\ie, dealing with collisions),
and the Bernoulli GLR break-point detector for non-stationarity (\ie, dealing with abrupt changes).
The three parts should be inter-connected, the same way we built \MCTopM-\klUCB{} and \GLRklUCB, by connecting two of the three components together.
We propose a simple idea to incorporate the detected change-points by B-\GLR{} test in the orthogonalization procedure \MCTopM: whenever a change-point is detected, the player is no longer ``fixed'' on its chosen arm.
%
Even if we already obtained promising results on preliminary numerical simulations,
analyzing such a strategy that combines \MCTopM, \GLR{} and \klUCB{} is left as a challenging future work.

% \TODOL{Explain that we think the following approach can work very efficiently:

%     - Combine \MCTopM{} with \GLRklUCB{} instead of \klUCB,
%     - and incorporate also the detected change-points by B-\GLR{} test in the orthogonalization procedure: after any change-point, the player is not sitting anymore.
%     - Modification: only a change-point on the arm on which player is sitting can make him move? It's already the case: the \GLR{} test can only detect change-point on an arm that was played, and the \MCTopM{} orthogonalization procedure forces to play the same arm as long as the player is sitting.
% }

% Another question of highest interest is to look for
Finally, I would be very interested in looking at a unique ``unified'' algorithm that can be used in all the different settings studied in this thesis, and maybe others, and automatically adapt to the setting at hand.
For instance, even if \GLRklUCB{} is very efficient for piece-wise stationary problems, its forced exploration makes it sub-optimal for stationary problems.
Another example is for multi-players bandits, where \MCTopM-\klUCB{} performs sub-optimally on piece-wise stationary problems.
% if we consider the proposed extension of \MCTopM-\klUCB{} that estimates the number $M$ of players, i
One approach to obtain a unified ``master'' algorithm could be to use expert aggregation on the different state-of-the-art algorithms presented in this thesis, and as each one was proven to be efficient in one setting, the resulting aggregated algorithm would also be efficient in each of the different settings.
As this approach does not seem theoretically promising, as illustrated in Section~\ref{sec:25:theory},
a preferred approach could be to design a ``unified'' algorithm which adapts automatically to the kind of problem it is facing.

% % ----------------------------------------------------------------------------
% % ----------------------------------------------------------------------------
% \section{Personal Summary}

% I would like to highlight that from a personal point of view, this thesis was awesome blabla.

\vfill{}

\hr{}

\begin{small}
\begin{center}
    Je vous remercie d'avoir lu cette thèse. Merci de me signaler toute erreur par courriel ou sur GitHub :
    \\
    Thanks for reading this document. Please notify me about any mistake by e-mail or on GitHub:\\
    $\hookrightarrow$ \href{https://github.com/Naereen/phd-thesis/issues/new}{\texttt{GitHub.com/Naereen/phd-thesis/issues/new}}\\
    $\hookrightarrow$ \href{mailto:Lilian.Besson_at_Crans.org}{\texttt{Lilian.Besson}\texttt{@}$\{$\texttt{Crans.org}, \texttt{Inria.fr}, \texttt{live.fr}$\}$}
\end{center}
\end{small}

\hr{}

% \vfill{}

% https://fr.wikipedia.org/wiki/Liste_des_%C3%A9pisodes_de_Kaamelott

\begin{small}
\begin{quote}
    \emph{-- Les rêves, ça se compare pas\ldots}\\
    Le Roi Arthur, interprété par Alexandre Astier,\\
    \emph{Kaamelott}, Livre VI, Épisode 9, ``Dies Irae''.
    %  écrit par Alexandre Astier.
\end{quote}
\end{small}


\documentclass[12pt,a4paper,hidelinks]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{parskip}
\usepackage{hyperref}
\usepackage{graphicx}

\usepackage{algorithm,algpseudocode}

\usepackage{listings}
\lstset{
	breaklines=true,
	tabsize=4,
	numbers=left
}

\def\algorithmautorefname{Algorithm}

\author{Bert Peters --- s1147919}
\title{Social Network Analysis for Computer Scientists --- Assignment 1}
\begin{document}

\maketitle

\section{Neighbourhoods}

\begin{enumerate}
	\item This is true only for a complete graph, because for this to happen every node should be connected to every other node.

	\item This computes the centrality, with a lower number meaning a more central node.

	\item To define the reverse $k$ neighbourhood, we first define the reverse neighbourhood as follows:
	$$
		N'(W) = \{ w \in V : v \in W \land (v, w) \in E \}
	$$

	Then, after defining that, we modify that to use a $k$ reversed neighbourhood an define the following:
	\begin{align*}
		N_0'(W) & = W \\
		N_k'(W) & = N'(N_{k - 1}'(W) \cup N_{k - 1}'(W)
	\end{align*}

	\item Two nodes $v$ and $w$ are part of the same strongly connected component iff
	$$
		N_k(\{v\}) \cap N'_k(\{v\}) = N_k(\{w\}) \cap N'_k(\{w\})
	$$

	for some $k \geq 0$.

	\item The algorithm shown in \autoref{algo:components} shows how this could be done using the $N_k(W)$ method. After the algorithm is done, $n$ contains the number of components.
\end{enumerate}

\begin{algorithm}
\caption{Computing the number of connected components in an undirected network.}
\label{algo:components}

\begin{algorithmic}
	\State $n \gets 0$
	\While{$V \neq \emptyset$}
		\State Pick a random $v \in V$
		\State $p \gets 0$
		\While{$|N_{p + 1}(\{v\})| > |N_p(\{v\})|$}
			\State $p \gets p + 1$
		\EndWhile

		\State $n \gets n + 1$
		\State $V \gets V \setminus N_p(\{v\})$
	\EndWhile
\end{algorithmic}

\end{algorithm}

\section{Diameter computation}

I execute the BoundingDiameters\footnote{F.W. Takes and W.A. Kosters, Determining the Diameter of Small World Networks, in \textit{Proceedings of the 20th ACM International Conference on Information
and Knowledge Management} (CIKM), pp. 1191-1196, 2011} on the graph provided on paper. As this is rather complex to shown in \LaTeX, I illustrate the actions I perform in text.

\begin{enumerate}
	\item We start with selecting an initial node with the lowest lower bound. As there are no known bounds, we select the node with the highest degree. This is node $F$, as it has degree 6. The longest shortest path is from $F \rightarrow T$, of length 5. This produces the bounds as shown in \autoref{tab:it1}.

		\begin{table}
			\centering
			\begin{tabular}{l | r | r}
				Node & $\varepsilon_L$ & $\varepsilon_U$ \\
				\hline
				$A$ & 5 & 7 \\
				$B$ & 5 & 7 \\
				$C$ & 5 & 6 \\
				$D$ & 5 & 6 \\
				$E$ & 5 & 6 \\
				$F$ & 5 & 5 \\
				$G$ & 5 & 7 \\
				$H$ & 5 & 6 \\
				$I$ & 5 & 8 \\
				$J$ & 5 & 6 \\
				$K$ & 5 & 7 \\
				$L$ & 5 & 6 \\
				$M$ & 5 & 7 \\
				$N$ & 5 & 7 \\
				$P$ & 5 & 7 \\
				$Q$ & 5 & 8 \\
				$R$ & 5 & 8 \\
				$S$ & 5 & 9 \\
				$T$ & 5 & 10 \\
			\end{tabular}
			\caption{Eccentricity bounds after 1 iteration of the algorithm.}
			\label{tab:it1}
		\end{table}

	\item After this, we already have some interesting bounds.  Because we technically did select the lowest lower bound, we select the highest upper bound this time. This is node $T$, with an upper bound of 10. The longest path is $T \rightarrow I$, of length 8. After recomputing the bounds, we arrive at the bounds as shown in \autoref{tab:it2}.

		\begin{table}
			\centering
			\begin{tabular}{l | r | r}
				Node & $\varepsilon_L$ & $\varepsilon_U$ \\
				\hline
				$A$ & 7 & 7 \\
				$B$ & 7 & 7 \\
				$C$ & 6 & 6 \\
				$D$ & 6 & 6 \\
				$E$ & 6 & 6 \\
				$F$ & 5 & 5 \\
				$G$ & 7 & 7 \\
				$H$ & 6 & 6 \\
				$I$ & 8 & 8 \\
				$J$ & 6 & 6 \\
				$K$ & 7 & 7 \\
				$L$ & 5 & 6 \\
				$M$ & 5 & 7 \\
				$N$ & 5 & 7 \\
				$P$ & 5 & 7 \\
				$Q$ & 5 & 8 \\
				$R$ & 5 & 8 \\
				$S$ & 7 & 9 \\
				$T$ & 8 & 8 \\
			\end{tabular}
			\caption{Eccentricity bounds after 2 iteration of the algorithm.}
			\label{tab:it2}
		\end{table}

	\item Now, most bounds are already tight, and there is one single node that can still contribute to the diameter, node $S$, because it is the only node with an upper bound larger than 8. Intuitively, you can see that it will not, because all paths from $T$ go through $S$, but we are technically not done yet. Computing the actual eccentricity, we know it actually is 7, and that the diameter of the network is 8.
\end{enumerate}

The naive method would need to do a breadth first search starting from every node. As shown above, I have only done three.

\section{An Online Social Network}

\subsection{Number of edges}

As the file contains one link per line, the number of links can be determined by counting the number of lines. This does not require a program, but can be done with a little snippet of bash.

\lstinputlisting[language=bash]{edges.sh}

Or, rather, just use the \texttt{wc} utility. The results for this exercise are incorporated in \autoref{tab:counts}.

\subsection{Number of nodes}

Like for the previous exercise, a full fledged parser is still not necessary. Instead, I combine the two columns using \texttt{awk}, \texttt{sort} them, take unique rows, and finally count lines again. The exact code is shown in Listing \ref{script:nodes} and the results can be found in \autoref{tab:counts}.

\lstinputlisting[
	language=bash,
	caption=Node counter script.,
	label=script:nodes,
	float
]{nodes.sh}

The parameters for sort are slightly unusual. We do this to improve performance, so that this script can handle the \texttt{huge.in} network. The compress program allows us to use less disk space for temporaries, which is neccessary to prevent disk space issues, and we increase the buffer size to improve overall performance.

\begin{table}
\centering
\begin{tabular}{l | r | r | l | r}
Filename & {\centering $|E|$} & $|V|$ & Directed & Largest component\\
\hline
medium.in & 16631 & 2426 & Possibly & 2000 \\
large.in & 14855842 & 456626 & Yes & 456290 \\
huge.in & 892263106 & 8113017 & Yes & 8083964
\end{tabular}
\caption{Various counts for the network files}
\label{tab:counts}
\end{table}

\subsection{Degree distribution}

To compute the in or out degree for a node, we can simply count the number of times that a number occurs in the source or destination column. The code for this is shown in Listing \ref{script:degrees}.

\lstinputlisting[
	language=bash,
	caption=Script for computing the degree for all nodes.,
	label=script:degrees,
	float
]{degree.sh}

After we have computed the degree for various nodes, we can use this output to make a visualisation.

\begin{figure}
	\centering
	\includegraphics[scale=0.83]{degree-distributions}
	\caption{The degree distributions for all input files.}
	\label{fig:degrees}
\end{figure}

\subsection{Directedness}

To answer this question, we must agree upon the interpretation of the file. There are some cases which can lead us to an interpretation. The following statements determine this.

\begin{align}
\label{eq:somereflex} \exists u, v &: (u, v) \in E \land (v, u) \in E \\
\label{eq:allreflex} \forall u, v &: (u, v) \in E \implies (v, u) \in E \\
\label{eq:noreflex}\nexists u, v &: (u, v) \in E \land (v, u) \in E
\end{align}

If \ref{eq:allreflex} holds, we are clearly in an undirected graph, because every edge is reflexive.

If \ref{eq:somereflex} and holds and \ref{eq:allreflex} does not, we are clearly in a directed graph because there are some reflexive connections, but not all of them are.

If, however, \ref{eq:noreflex} holds, there are no reflexive edges. This means that we can interpret the graph as either undirected or directed, because we can interpret each edge as also going back.

Once again, we implement this in bash, as it is very simple. We use \texttt{awk} to put any edge listing $(u, v)$ in the file in asceding order, so that when we sort the file, edges and returning edges are next to each other. This allows us to remove duplicates, and then analyze the number of lines that remain. We can differentiate these counts in two categories.

\begin{align*}
2 \times & |E_{unique}| = |E| & \implies & \text{Network is undirected.} \\
|E| < 2 \times & |E_{unique}| < 2 \times |E| & \implies & \text{Network is directed} \\
& |E_{unique}| = |E| & \implies & \text{Network is possibly directed}
\end{align*}

The bash script in Listing \ref{script:directed} computes $|E|$ and $|E_{unique}|$ and prints out the category the network falls in.

\lstinputlisting[
	language=bash,
	caption=Code that computes whether or not a graph is directed,
	label=script:directed,
	float
]{directed.sh}

\subsection{Largest connected component}

For this section, we consider the largest connected component to be the largest weakly connected component. This helps us, because this removes the distinction between directed and undirected networks.

To compute the largest connected component, I could not come up with a \texttt{bash}-based solution, so I reverted to using \texttt{C++}.

The algorithm works as follows. First, we store our edges into a large edge array and sort them on $u, v$. After that, we attempt to make a coloring for each node. In this coloring, connected nodes are the same color. Finally, we determine the number of occurences for the most frequent color. This is our answer. The code for this algorithm can be found in \autoref{appendix:components}.

\subsubsection*{Coloring algorithm}

The coloring algorithm is more or less a breadth first search, as described in \autoref{algo:coloring}. We know that the complexity of a breadth first search is $O(|E|)$,\footnote{Technically, this is $|V|)$, but because we consider sparse networks, $|E| \approx |V|$ so we ignore $|E|$. This simplifies our formulae.} without accounting for the complexity of determining neighbours for nodes. Because we sorted our list of edges, we can access the neighbours of $u$ using binary search in $O(B + \log |E|)$, with $B$ the number of neighbours.

In the inner loop of our algorithm, the most complex task we potentially do, is recoloring all the nodes. The way we do this is enumerating all nodes and replacing the colors we have to. This is an $O(|V|)$ operation. This happens each time we find a new directed route into an existing component. However, this rarely happens. Most of the time, we find a connected component once, because the networks are very reflexive.

So, to summarize, our theorethical complexity is $O(|V|(\log |E| + |V|))$.\footnote{We ignore the $B$ in the complexity for accessing neighbours, because the rest of the loop gets executed just as often. Therefore, it is already part of the BFS complexity.} This works out to $O(|V|^2 + |V|\log|E|) \approx O(|V|^2)$. This complexity however includes the recoloring cost, so while it is the worst case, the average case is better, and runs in $O(|V| \log |E|)$.

\begin{algorithm}
\caption{Node coloring algorithm}
\label{algo:coloring}
\begin{algorithmic}

\ForAll{$u \in V$}
	\State initialize $color_u$ as 0
\EndFor
\\
\ForAll{$u \in V$}
	\If{$color_u = 0$}
		\State $todo \gets \{u\}$
		\While{$todo \neq \emptyset$}
			\State Pick a $v$ from $todo$
			\State $todo \gets todo \setminus \{v\}$
			\If{$color_v \neq u$}
				\If{$color_v = 0$}
					\State $color_v \gets u$
					\State Add all $w : w \in N_1(v) \land  color_w \neq u$ to $todo$.
				\Else
					\State Recolor all $w : color_w = color_v$ to $u$.
				\EndIf
			\EndIf
		\EndWhile
	\EndIf
\EndFor

\end{algorithmic}
\end{algorithm}

\subsection{Visualization}

To visualize \texttt{medium.in}, I used Gephi. I chose to interpret the network as an undirected network and to visualise only the largest connected component. That component contains over 80\% of the nodes in the network, and the remaining components are very small.\footnote{Most of the components are less than 10 nodes in size.}

Coloring of nodes is done using community detection, and sizing was done by degree. The nodes were grouped using the YifanHu Multilevel algorithm, with the default parameters, and manually making it slightly more compact. I decided not to show the links, as it is mostly a clustered mess. The groupings are visible this way, and it looks nicer.

Shown in \autoref{fig:visualisation} is the final visualisation. To me, it looks something like Australia, except with way too many people in the Outback.

\begin{figure}
	\centering
	\includegraphics[scale=0.55]{visualisation}
	\caption{\texttt{medium.in} visualized}
	\label{fig:visualisation}
\end{figure}

\subsection{Analyzing \texttt{huge.in}}

Analyzing the \texttt{huge.in} network required some memory management, to store all nodes in memory. Fortunately, the Linux shell tools \texttt{awk}, \texttt{wc}, \texttt{sort}, \texttt{gzip}, and \texttt{uniq} all require very little memory, so those programs worked just as well for the \texttt{huge.in} network as it did for the others.

Moreover, the most expensive operation being done in each of the bash script files, is sorting, which requires at most $O(|E| \log |E|)$ time and $O(|E|)$ disk storage. The disk storage requirement is then reduced using \texttt{gzip}, so the actual storage requirement is significantly less.\footnote{\texttt{sort} stores sorted chunks on disk. Sorted lists of numbers happen to contain a lot of repeating strings, so in some cases, \texttt{gzip} was able to reduce the files by up to 99\%.}

The only computationally heavy exercise left is computing the largest weakly connected component. The program uses two \texttt{int}s per edge, or 8 bytes. This means 6.6 GiB for the edges alone. Furthermore, a bit of memory is allocated to store what component a node is in, but that is neglegible. My initial program used a \texttt{std::queue} for the bread first search queue. Peaking at 3.5 GiB of storage (of \texttt{int}s representing nodes), this turned out to a bit much. Instead, I used \texttt{std::set} as a todo list, forcing only a single entry per node. This has some downsides, mostly being performance and using more memory per entry. It did actually help to brng the todo-list down to 1.5 GiB of memory, allowing the program to run on a machine with at least 8.1 GiB of memory, while only doubling the execution time.

The memory footprint can still be significantly improved. The memory usage for the edges can be slimmed down to $4 \times |E| + 8 \times |V|$ by using using two arrays. One storing the destinations for edges, and one storing for each node the number of edges it has, and its starting point in the first array. Even this can be slightly slimmed down to $4 \times |E| + 4 \times |V|$ by not storing the starting point, but instead inferring it from the number of nodes already passed.\footnote{Credits to Koen \textellipsis for suggesting I do this.} I did not implement such a strategy, as it complicates reading the files, requiring either pre-sorting the input or lots of relocations while reading.

\appendix

\section{Source listing for analyze.py}

\label{appendix:analyze}

Below is the source code for \texttt{analyze.py}. The code runs with Python 2.7 and requires matplotlib.

\lstinputlisting[
	language=python
]{analyze.py}

\section{Source listing for component.cpp}

\label{appendix:components}

Below is the source for \texttt{component.cpp}. The program was compiled using the makefile in \autoref{appendix:makefile}.

\lstinputlisting[language=c++]{component.cpp}

\section{Makefile}

\label{appendix:makefile}

\lstinputlisting[
	language={[gnu]make}
]{Makefile}

\end{document}