text:
% Changing book to article will make the footers match on each page,
% rather than alternate every other.
\documentclass[10pt,twoside,twocolumn,openany]{book}
\usepackage[bg-letter]{dnd} % Options: bg-a4, bg-letter, bg-full, bg-print, bg-none.
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

% Start document
\begin{document}
\fontfamily{ppl}\selectfont % Set text font

% Your content goes here

\chapter{Chapter 1: The Dark \LaTeX}

\section{Main Section}
\lipsum[1] % filler text

\subsection{Fun with boxes}
\subsubsection{Even more fun!}

%\begin{commentbox}{Neat Green Box!}
%	\lipsum[1]
%\end{commentbox}

\subtitlesection{Weapon, +1, +2, or +3}
{Weapon (any), uncommon (+1), rare (+2), or very rare (+3)}

%\begin{quotebox}
%	As you approach this template you get a sense that the blood and tears of many generations %went into its making. A warm feeling welcomes you as you type your first words.
%\end{quotebox}

\newpage % Acts as columbreak because of twocolumn option; for pagebreak use \clearpage

% For more columns, you can say \begin{dndtable}[your options here}.
% For instance, if you wanted three columns, you could say
% \begin{dndtable}{XXX}. The usual host of tabular parameters are
% aailable as well.
\header{Nice table}
\begin{dndtable}
   	\textbf{Table head}  & \textbf{Table head} \\
   	Some value  & Some value \\
   	Some value  & Some value \\
   	Some value  & Some value
\end{dndtable}

%\begin{paperbox}{Do the Players need direction?}
%	\lipsum[1]
%\end{paperbox}

% You can optionally not include the background by saying
% begin{monsterboxnobg}
%\begin{monsterbox}{Monster Foo}
	%\textit{Small metasyntactic variable (goblinoid), neutral evil}\\
	%\hline
	%\basics[%
	%armorclass = 12,
	%hitpoints  = 16 (3d8 + 3),
	%speed      = 50 ft
	%]
	%\hline
	%\stats[
    %STR = \stat{12}, % This stat command will autocomplete the modifier for you
    %DEX = \stat{7}
	%]
	%\hline
	%\details[%
	%% If you want to use commas in these sections, enclose the
	% description in braces.
	% I'm so sorry.
	%languages = {Common Lisp, Erlang},
	%]
	%\hline \\[1mm]
	%\begin{monsteraction}[Monster-super-powers]
		%This Monster has some serious superpowers!
	%\end{monsteraction}
	%\monstersection{Actions}
	%\begin{monsteraction}[Generate text]
		%This one can generate tremendous amounts of text! Though only when it wants to.
	%\end{monsteraction}

	%\begin{monsteraction}[More actions]
    %See, here he goes again! Yet more text.
	%\end{monsteraction}
%\end{monsterbox}

% End document
\end{document}


text:
\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

% ---------- ---------- ---------- ---------- ---------- %
% Margins
% ---------- ---------- ---------- ---------- ---------- %

% \usepackage{showframe}
\usepackage[
	a4paper,
	top      = 20mm,
	bottom   = 20mm,
	right    = 40mm,
	left     = 30mm,
	footskip = 10mm
]{geometry}
\sloppy

% ---------- ---------- ---------- ---------- ---------- %
% Typography
% ---------- ---------- ---------- ---------- ---------- %

% \usepackage{newtxtext}
% \usepackage{helvet}
% \renewcommand{\familydefault}{\sfdefault}
\usepackage[sfdefault]{plex-sans}
\usepackage{plex-serif}
\usepackage{plex-mono}

% ---------- ---------- ---------- ---------- ---------- %
% Paragraphs
% ---------- ---------- ---------- ---------- ---------- %

\parindent=0pt
\usepackage[parfill]{parskip}
\usepackage[all]{nowidow}
\linespread{1.25}

% ---------- ---------- ---------- ---------- ---------- %
% Lists, listings, figures and tables
% ---------- ---------- ---------- ---------- ---------- %

\usepackage{listings}
\lstset{
	basicstyle   = \ttfamily\footnotesize,
	numberstyle  = \ttfamily\footnotesize,
	breaklines   = true,
	numbers      = left,
	xleftmargin  = .1\textwidth,
	xrightmargin = .07\textwidth,
	frame        = lrtb
}
\usepackage{float}
\usepackage{svg}
\usepackage{caption}
\usepackage{booktabs}

% ---------- ---------- ---------- ---------- ---------- %
% Footnotes
% ---------- ---------- ---------- ---------- ---------- %

\usepackage[hang, bottom, flushmargin]{footmisc}
\setlength{\footnotemargin}{3.5mm}
\interfootnotelinepenalty=10000
\setlength{\skip\footins}{7mm}

% ---------- ---------- ---------- ---------- ---------- %
% References
% ---------- ---------- ---------- ---------- ---------- %

\usepackage[
	backend = biber,
	style   = verbose-ibid
]{biblatex}
\bibliography{references}
\setlength\bibitemsep{\parskip}
\usepackage{xurl}

% ---------- ---------- ---------- ---------- ---------- %
% Misc
% ---------- ---------- ---------- ---------- ---------- %

\usepackage[hidelinks]{hyperref}
\usepackage{csquotes}
% \hyphenation{Settlement-risiken}
\usepackage{tabularx}

\begin{document}

	\input{titlepage}

	\pagenumbering{roman}
	%\pagenumbering{gobble}

	\chapter*{Abstract}
	\input{chapters/abstract}

	\renewcommand\contentsname{Table of contents}
	\tableofcontents

	\cleardoublepage
	\pagenumbering{arabic}

	\chapter{Introduction}
	\input{chapters/chapter-01-introduction}

	\chapter{Prerequisites}
	\input{chapters/chapter-02-prerequisites}

	\chapter{How is finality defined in the literature?}
	\input{chapters/chapter-03-finality-definition}

	\chapter{Can blockchain systems provide legal finality?}
	\input{chapters/chapter-04-legal-finality-of-blockchain}

	\chapter{Can blockchain systems provide technical finality?}
	\input{chapters/chapter-05-technical-finality-of-blockchain}

	\chapter{Conclusion}
	\input{chapters/chapter-06-conclusion}

	\printbibliography[
		heading = bibintoc,
		title   = {References}
	]

	\cleardoublepage
	\pagenumbering{gobble}

	\chapter*{Eidesstattliche Erklärung}
	\input{chapters/disclaimer}

\end{document}

ext: tex


text:
\newpage
\section[Continuity]{\hyperlink{toc}{Continuity}}

\subsection{Limits and Continuity}
\begin{definition}{Limits}{4.1}
    Let $X, Y$ be metric spaces. Let $E \subset X$, and let $f: E \mapsto Y$. Let $p \in X$ be a limit point of $E$. Then, we say that $\lim_{x\rightarrow p} f(x) = q$ or $f(x) \rightarrow q$ as $x \rightarrow p$ if there exists $q \in Y$ such that for all $\e > 0$, there exists $\delta > 0$ such that for all $x \in E$ with $0 < d_X(x, p) < \delta$ we have that $d_Y(f(x), q) < \e$.
\end{definition}
\begin{figure}[htbp]
    \centering
    \begin{tikzpicture}[scale=2]
        \draw[-latex,very thick] (0,0)--(2,0);
        \draw[-latex,very thick] (0,0)--(0,2);
        \draw[<->, thick] (0, 0) -- (1.75, 1.75);
        \draw[color = red] (1, 0) -- (1, 1);
        \draw[color = red, dashed] (0.5, 0) -- (0.5, 2);
        \draw[color = red, dashed] (1.5, 0) -- (1.5, 2);
        \draw[<->] (0.5, 0.1) -- (1, 0.1);
        \node[above] at (0.75, 0.1) {$\delta$};
        \draw[<->] (1, 0.1) -- (1.5, 0.1);
        \node[above] at (1.25, 0.1) {$\delta$};
        \draw[color = blue] (0, 1) -- (1, 1);
        \draw[color = blue, dashed] (0, 0.5) -- (2, 0.5);
        \draw[color = blue, dashed] (0, 1.5) -- (2, 1.5);
        \draw[<->] (0.1, 0.5) -- (0.1, 1);
        \node[right] at (0.1, 0.75) {$\e$};
        \draw[<->] (0.1, 1) -- (0.1, 1.5);
        \node[right] at (0.1, 1.25) {$\e$};
        \draw[fill = black] (0, 1) circle (1pt);
        \node[xshift = -0.25cm] at (0, 1) {$1$};
        \draw[fill = black] (1, 0) circle (1pt);
        \node[yshift = -0.25cm] at (1, 0) {$1$};
        \node[yshift = 0.25cm, xshift = 0.25cm] at (1.75, 1.75) {$f(x)$};
    \end{tikzpicture}
    \caption{Visualization of the limit $\lim_{x \rightarrow 1}f(x) = 1$ for $f(x) = x$. For any $\e > 0$, we can take $\delta = \e$ and then we have that $\abs{f(x) - 1} < \e$ if $\abs{x - 1} < \delta$.}
    \label{fig17}
\end{figure}
Note in the above definition that we do not care about $f(p)$, that is, the actual value of $f$ at $p$. In particular, if $p \notin E$, then $f(p)$ is not even necessarily defined. This distinction between the limit and the actual value of a function at a point becomes crucial later on when we want to define a derivative. Although we will discuss this in more detail in Chapter 5, the definition of a derivative of a function $g$ at a point $p \in \RR$ involves the function $f: \RR \rightarrow \RR$ such that:
\begin{align*}
    f(x) = \frac{g(x) - g(p)}{x - p}
\end{align*}
Evidently, the domain of $f$ does not contain the point $p$, but we are interested in the value of $f$ in the limit of $x \rightarrow p$ (which, if it exists, is the value of the derivative).

\begin{figure}[htbp]
    \centering
    \begin{tikzpicture}
        \draw[latex-latex,very thick] (-2,0)--(2,0);
        \draw[latex-latex,very thick] (0,-2)--(0,2);
        \draw[<->, thick] (-1.75, -1.75) -- (1.75, 1.75);
        \draw[fill = black] (0, 1) circle (1pt);
        \node[xshift = -0.25cm] at (0, 1) {$1$};
        \draw[fill = black] (1, 0) circle (1pt);
        \node[yshift = -0.25cm] at (1, 0) {$1$};
        \draw[fill = white] (1, 1) circle (2pt);
        \draw[fill = black] (1, 0.5) circle (2pt);
    \end{tikzpicture}

    \caption{Visualization of the function $f(x) = x$ for $x \in \RR \setminus \set{1}$, $f(x) = 0$ for $x = 1$. In this case, we have that $f(1) = 0$ but $\lim_{x \rightarrow 1} f(x) = 1$, demonstrating that the actual value of the function is irrelevant when defining the limit.}
    \label{fig18}
\end{figure}

\begin{theorem}{}{4.2}
    Let $X, Y$ be metric spaces. Let $E \subset X$ and $f:E \mapsto Y$. Suppose that for all sequences $\set{p_n} \subset E$ with $p_n \rightarrow p$ and $p_n \neq p$, we have that $f(p_n) \rightarrow q \in Y$. Then, this is equivalent to saying that $\lim_{x \rightarrow p} f(x) = q$.
\end{theorem}
\begin{nproof}
    \boxed{\implies} Suppose that $\lim_{x \rightarrow p} f(x) = q$, and let $\set{p_n}$ be a sequence in $E$ with $p_n \rightarrow p$ and $p_n \neq p$ for all $n$. We wish to show that $f(p_n) \rightarrow q$. Let $\e > 0$. We show that there exists $N \in \NN$ such that $d_Y(f(p_n), q) < \e$ for all $n \geq N$. Since $\lim_{x \rightarrow p} f(x) = q$, there exists $\delta > 0$ such that for all $x \in E$ with $d_X(p, x) < \delta$, $d_Y(f(x),q) < \e$. Since we know that $p_n \rightarrow p$, there exists some $N$ such that $0 < d(p_n, p) < \delta$ for all $n \geq N$, so we have that $d_Y(f(p_n), q) < \e$ as required.

    \boxed{\impliedby} We show the contrapositive. Suppose that $\lim_{x \rightarrow p} f(x) \neq q$. We wish to find a sequence $\set{p_n} \subset E$ with $p_n \rightarrow p$ and $p_n \neq p$ for all $n$ such that $f(p_n)$ does not converge to $q$. Since $\lim_{x \rightarrow p} f(x) \neq q$, then there exists $\e > 0$ such that for all $\delta > 0$, there exists $x \in E$ such that $0 < d_X(x, p) < \delta$ but $d_Y(f(x), q) \geq \e$. For each $\delta$ of the form $\frac{1}{n}$, let $p_n \in E$ be the corresponding value of $x$. Then, $p_n \rightarrow p$, $p_n \neq p$ for all $n$, and $f(p_n)$ does not converge to $q$ as $d(f(p_n), q) \geq \e$ for all $n$. \qed
\end{nproof}

\stepcounter{rudin}

\begin{theorem}{}{4.4}
    When $Y = \CC$ (i.e. the functions we consider are complex), then limits respect sums, differences, products, and functions. That is, let $X$ is a metric space, $E \subset X$, and $f, g: E \mapsto \CC$ with $p$ a limit point of $E$. If $\lim_{x \rightarrow p}f(x) = q$ and $\lim_{x \rightarrow p}g(x) = r$, then $\lim_{x \rightarrow p}(f+g)(x) = q + r$. The same holds for subtraction, multiplication, and division (provided we do not divide by zero).
\end{theorem}
\begin{nproof}
    By Theorem \ref{thm:4.2}, these properties of limits follow from the analogous properties of sequences (Theorem \ref{thm:3.3}).
\end{nproof}

\begin{definition}{Continuity}{4.5}
    Let $X, Y$ be metric spaces, and $E \subset X$. Let $p \in E$, and define $f: E \mapsto Y$. We say that $f$ is \textbf{continuous} at $p$ if for all $\e > 0$, there exists $\delta > 0$ such that for all $x \in E$ with $d_X(x, p) < \delta$, we have that $d_Y(f(x), f(p)) < \e$. Equivalently, $f(N_\delta^E(p)) \subset N_\e^Y(f(p))$. If $f$ is continuous at $p$ for all $p \in E$, we say that $f$ is continuous.
\end{definition}
\noindent Note that this definition of continuity is heavily reliant on the particular metric of $X$ and $Y$; in particular, there can be functions that are continuous for some choices of metric but not others.

Let us consider some examples of continuous functions (while thinking about different possible metric spaces).

First, let us take onsider $X = E = \ZZ$ and $Y = \RR$. What functions $f: E \rightarrow Y$ are continuous at $p = 0$? The answer turns out to be all functions! To see this, fix $n \in \ZZ$ and let $\e > 0$. We then have that if $\abs{n - m} < \frac{1}{2}$, then $\abs{f(n) - f(m)} < \e$ as the only point $m$ contained in $N_{1/2}^\ZZ(n)$ is $n$ itself (and hence $\abs{f(n) - f(m)} = \abs{f(n) - f(n)} = 0$). This argument applies to every $n \in \ZZ$ and hence all functions $f: \ZZ \mapsto \RR$ are continuous.

As further examples (that work for arbitrary metric spaces), If we have that $f: X \mapsto X$, $f(x) = x$, we have that $f$ is continuous (pick $\delta = \e$ in the definition of continuity). If we have that $f: X \mapsto Y$, $f(x) = c$ for some $c \in Y$, then $f$ is also continuous (pick any $\delta > 0$ in the definition).

Finally, the above definition doesn't make a distinction between limit points and isolated points. However, it turns out that according to the definition, if $p \in E$ is isolated, then every function $f$ with $E$ as its domain is continuous. To see this, consider that for any $\e > 0$, we can pick $\delta > 0$ such that the only point $x \in E$ for which $d_X(x, p) < \delta$ is $x = p$ (such a choice of $\delta$ is possible as $p$ is isolated). It then follows that $d_Y(f(x), f(p)) = 0 < \e$.

We now consider a Theorem which gives us a familiar notion of continuity (that may have been encountered in first year calculus).

\begin{theorem}{}{4.6}
    Suppose that $p$ is a limit point of $E$ in Definition \ref{def:4.5}. Then, $f$ is continuous at $p$ if and only if $\lim_{x \rightarrow p}f(x) = f(p)$.
\end{theorem}
\begin{nproof}
    The claim immediately follows by comparing Definitions \ref{def:4.1} and \ref{def:4.5}. \qed
\end{nproof}

\begin{theorem}{}{4.7}
    Let $X, Y, Z$ be metric spaces, and $E \subset X, F \subset Y$. Let $f: E \mapsto Y$, $g: F \mapsto Z$, and suppose $f(E) \subset F$. Let $p \in E$. If $f$ is continuous at $p$ and $g$ is continous at $f(p)$, then $g \circ f: E \mapsto Z$ is continuous at $p$.
\end{theorem}
\begin{nproof}
    Let $\e > 0$. Since $g$ is continuous at $f(p)$, there exists $\gamma > 0$ such that $d_Z(g(y), g(f(p))) < \e$ if $d_Y(y, f(p)) ,< \gamma$. Since $f$ is continuous at $p$, there exists $\delta > 0$ such that $d_Y(f(x), f(p)) < \gamma$ if $d_X(x, p) < \delta$. Hence, we have that $d_Z(h(x), h(p)) = d_Z(g(f(x)), g(f(p))) < \e$ if $d_X(x, p) < \delta$ and $x \in E$. We conclude that $h$ is continuous at $p$. \qed
\end{nproof}

\subsection{Topological Characterization of Continuity}
\begin{theorem}{}{4.8}
    Let $X, Y$ be metric spaces, and $f: X \mapsto Y$. Then, $f$ is continuous if and only if $f^{-1}(V) \subset X$ is open for every open set $V \subset Y$.
\end{theorem}
\begin{nproof}
    \boxed{\implies} Suppose $f$ is continuous, and $V \subset Y$ is open. Let $p \in f^{-1}(V)$, so $f(p) \in V$. $V$ is open, so it follows that $f(p)$ is an interior point of $V$. So, there exists $r > 0$ such that $N_r^Y(f(p)) \subset V$. Next, $f$ is continuous, so there exists $\delta > 0$ such that for all $x \in X$ with $d_X(x, p) < \delta$, $d_Y(f(x), f(p)) < r$. Hence, we obtain that $f(x) \in N_r^Y(f(p)) \subset V$. In particular, $N_\delta^X(p) \subset f^{-1}(V)$, so $p$ is an interior point of $f^{-1}(V)$. Hence every point of $f^{-1}(V)$ is an interior point, and $f^{-1}(V)$ is open.

    \boxed{\impliedby} Suppose $f^{-1}(V)$ is open for every open set $V \subset Y$. Let $p \in X$ and $\e > 0$. Let $V = N_\e^Y(f(p))$ which is open, so by assumption $f^{-1}(V)$ is open. $p \in f^{-1}(V)$, so $p$ is an interior point. Hence, there exists $\delta > 0$ such that $N_\delta^X(p) \subset f^{-1}(V)$. In other words, if $d_X(x, p) < \delta$, then $f(x) \in V$, so $d_Y(f(x), f(p)) < \e$. $f$ is then continuous by definition. \qed
\end{nproof}

\begin{ncorollary}{}{}
    $f: X \mapsto Y$ is continuous if and only if $f^{-1}(F) \subset X$ is closed for every closed set $F \subset Y$.
\end{ncorollary}
\begin{nproof}
    Let $V = F^c$ with $V$ open. Then, the above statement is equivalent to saying that a function $f: X \mapsto Y$ is continuous if and only if $f^{-1}(V^c) = \left(f^{-1}(V)\right)^c$ is closed for every open set $V \subset Y$. This is equivalent to the statement that $f^{-1}(V)$ is open for every open set $V \subset Y$, and the claim follows by the previous theorem. \qed
\end{nproof}

\noindent Note that the above topological characterization says properties of sets are preserved under taking the preimage; it does not say anything about preserving properties under the image. That is to say, images of open/closed sets are not necessarily open/closed.

\begin{nexample}{}{}
    Consider $X = \RR^+ = (0, \infty)$ and $Y = \RR$. Then, the function:
    \begin{align*}
        \fullfunction{f}{X}{Y}{x}{\frac{1}{x}}
    \end{align*}
    is continuous. Then defining $A = [1, \infty)$ we have that $A$ is closed, but $f(A) = (0, 1]$ is not closed.
\end{nexample}

\begin{theorem}{}{4.9}
    Let $f: X \mapsto \CC$ and $g: X \mapsto \CC$ be continous functions. Then, $f+g$, $fg$ are continuous, and $\frac{f}{g}$ is continuous if $g(x) \neq 0$.
\end{theorem}
\begin{nproof}
    At isolated points there is nothing to prove (as any choice of function that is defined at an isolated $p$ will be continuous there). For limit points, the claim follows from Theorems \ref{thm:4.4} and \ref{thm:4.6}. \qed
\end{nproof}

\begin{theorem}{}{4.10}
    \begin{enumerate}
        \item Let $f_1, f_2, \ldots, f_k: X \mapsto \RR$, and define $\v{f}: X \mapsto \RR^k$ by:
        \begin{align*}
            \v{f}(x) = (f_1(x), f_2(x), \ldots, f_k(x))
        \end{align*}
        Then, $\v{f}$ is continuous if and only if every $f_i$ is continuous.
        \item If $\v{f} = (f_1, \ldots f_k): X \mapsto \RR^k$ and $\v{g} = (g_1, \ldots g_k): X \mapsto \RR^k$ are continous, then the functions:
        \begin{align*}
            \v{f} + \v{g} = (f_1 + g_1, \ldots, f_k + g_k)
        \end{align*}
        \begin{align*}
            \v{f} \cdot \v{g} = f_1g_1 + \ldots + f_kg_k
        \end{align*}
        are continous.
    \end{enumerate}
\end{theorem}
\begin{nproof}
    \begin{enumerate}
        \item $\boxed{\implies}$ Suppose $\v{f}$ is continuous. Then, let $\e > 0$. For each $p \in X$, there exists $\delta > 0$ such that $d_X(x, p) < \delta$ implies $\abs{\v{f}(x) - \v{f}(p)} < \e$. We then observe that for any $i \in \set{1, \ldots k}$:
        \begin{align*}
            \abs{\v{f}(x) - \v{f}(p)} = \left(\sum_{j=1}^k \abs{f_j(x) - f_j(p)}^2\right)^{1/2} \geq \abs{f_i(x) - f_i(p)}
        \end{align*}
        Where the inequality follows by just keeping one term from the sum of non-negative terms. So for any $d_X(x, p) < \delta$ we therefore have that $\abs{f_i(x) - f_i(p)} < \e$, and hence each $f_i$ is continuous.

        $\boxed{\impliedby}$ Suppose each of $f_1, \ldots f_k$ is continuous. Then let $\frac{\e}{\sqrt{k}} > 0$. For each $p \in X$, there exists $\delta_i$ such that $d_X(x, p) < \delta_i$ implies that $\abs{f_i(x) - f_i(p)} < \frac{\e}{\sqrt{k}}$. Take $\delta = \min\set{\delta_1, \ldots \delta_k}$. Then, if $d_X(x, p) < \delta$, we have that:
        \begin{align*}
            \abs{\v{f}(x) - \v{f}(p)} = \left(\sum_{j=1}^k \abs{f_j(x) - f_j(p)}^2\right)^{1/2} < \left(\sum_{j=1}^k \left(\frac{\e}{\sqrt{k}}\right)^2\right)^{1/2} = \e
        \end{align*}
        So it follows that $\v{f}$ is continuous.
        \item The claim follows from (a) and Theorem \ref{thm:4.9}. \qed
    \end{enumerate}
\end{nproof}

\begin{example}{}{4.11}
    We will now explore some interesting examples of continuous functions.
    \begin{enumerate}
        \item For each index $i = 1, \ldots k$, define $\phi_i: \RR^k \mapsto \RR$ by $\phi_i(\v{x}) = x_i$. Then, $\phi_i$ is continuous.
        \begin{proof}
            Let $\e > 0$. Then, for $\v{p} \in \RR^k$, if $\abs{\v{x} - \v{p}} < \delta$ with $\delta = \e$, we have that:
            \begin{align*}
                \e > \abs{\v{x} - \v{p}} = \left(\sum_{j=1}^k \abs{x_j - p_j}^2\right)^{1/2} \geq \left(\abs{x_i - p_i}^2\right)^{1/2} = \abs{x_i - p_i}
            \end{align*}
            So for $\abs{\v{x} - \v{p}} < \delta$, we have that $\abs{\phi_i(\v{x}) - \phi_i(\v{p})} < \e$. We conclude that $\phi_i$ is continous.
        \end{proof}
        We could also use the topological characterization of continuity to prove this claim. If $V \subset \RR$ is open, then $\RR \times \RR \times \ldots \times V \times \RR \times \ldots \times \RR$ is open, showing again that $\phi_i$ is continuous (a much easier proof)!
        \item Let $f: \RR^k \mapsto \RR$ be given by $f(\v{x}) = x_1^{n_1}x_2^{n_2}\cdots x_k^{n_k}$ with $n_i \in \NN \cup \set{0}$. $f$ is continous, and hence so is any polynomial $P: \RR^k \mapsto \RR$.
        \item Rational functions $P/Q$ where $P, Q$ are polynomials are continous everywhere except where $Q$ is zero.
        \item $f: \RR^k \mapsto \RR$ given by $f(\v{x}) = \abs{\v{x}}$ is continous.
        \item Suppose $f: X \mapsto \RR^k$ is continous. Then so is $g: X \mapsto \RR^k$ with $g(x) = \abs{f(x)}$.
    \end{enumerate}
\end{example}

\subsection{Continuity and Compactness}

\setcounter{rudin}{13}
\begin{theorem}{}{4.14}
    Let $f: X \mapsto Y$ be continuous, and suppose $X$ is compact. Then, the image $f(X)$ is compact.
\end{theorem}
\begin{nproof}
    Let $\set{V_\alpha}$ be an open cover of $f(X)$. For each $\alpha$, Let $O_\alpha = f^{-1}(V_\alpha)$. Then, $\set{O_\alpha}$ is an open cover of $X$. to see this, we recognize that each $O_\alpha$ is open due to the continuity of $f$ (Theorem \ref{thm:4.8}) and each $p \in X$ satisfies $V_\beta$ for some $\beta$, so $p \in O_\beta$. $X$ is compact, so there exists a finite subcover $\set{O_{\alpha_1}, \ldots O_{\alpha_n}}$. But it then follows that $\set{V_{\alpha_1}, \ldots V_{\alpha_n}}$ is a finite subcover of $f(X)$. Hence $f(X)$ is compact. \qed
\end{nproof}
\noindent We previously discussed how an image of a closed set (under a continuous function) does not have to be closed. However, the above Theorem shows that the image of a compact set (under a continuous function) must be compact.

Taking a slight tangent, a question of interest may be to consider the topology of the extended real numbers; namely, $\RR \cup \set{\infty, -\infty}$ (where $-\infty < x < \infty$ for all $x \in \RR$). In particular, a natural question to ask is whether $[1, \infty) \cup \set{\infty}$ would be closed/compact.

We start then by defining a reasonable metric on $X = \RR \cup \set{\infty, -\infty}$. A ``reasonable'' definition of a metric will satify the requirement that $[1, \infty) \cup \set{\infty}$ is compact or not. We then define the metric:
\begin{align*}
    d(x, y) = \abs{\arctan(x) - \arctan(y)}
\end{align*}
where $\arctan(\infty) = \frac{\pi}{2}$ and $\arctan(-\infty) = -\frac{\pi}{2}$. We then have that $(X, d)$ is a metric space (check!)

Note that the extended reals have been made into a metric space here, but it is no longer a field; in particular, we have that $(-\infty + \infty) + \infty = 0 + \infty = \infty$ but $-\infty + (\infty + \infty) = -\infty + \infty = 0$ so associativity no longer holds.

With a reasonable metric defined on the extended reals, let us now return to our previous example in Section 4.2 where we considered the function $f(x) = \frac{1}{x}$. We now extend the domain of the function such that:
\begin{align*}
    \fullfunction{f}{X \setminus \set{0}}{\RR}{x}{\frac{1}{x}}
\end{align*}
With $f(\infty) = f(-\infty) = 0$. We leave it as an exercise to verify that $f$ is continuous on $X \setminus \set{0}$ using the continuity of the $\arctan$ function.

Now, consider $A = [1, \infty) \subset X$. $A$ is not closed, as $\infty$ is a limit point of $A$ (this can be verified by checking that for all $\e > 0$, there exists $x \in [1, \infty)$ such that $\abs{\arctan x - \arctan \infty} = \frac{\pi}{2} - \arctan x < \e$). However, we do have that $\overline{A} = [1, \infty]$ is closed and compact, and that $f(\overline{A}) = [0, 1]$ is compact as Theorem \ref{thm:4.14} states. In a sense, we have ``compactified'' the reals through our construction, as $X$ is compact while $\RR$ was not. We also have that $X$ is bounded (unlike $\RR$), as all distances between points are bounded by at most $\pi$. In particular, $\diam X = \pi$.

\setcounter{rudin}{12}
\begin{definition}{Bounded functions}{4.13}
    Let $X$ be a metric space, and $E \subset X$. We say that $f: E \mapsto Y$ is \textbf{bounded} if $f(E)$ is a bounded set. In particular, if $Y = \RR^k$, then $f$ is bounded if and only if there exists $M \in \RR$ such that $\abs{f(x)} \leq M$ for all $x \in E$.
\end{definition}

\setcounter{rudin}{14}
\begin{theorem}{}{4.15}
    Let $X$ be a compact metric space, and $f: X \mapsto Y$ be continuous. Then, $f(X)$ is bounded.
\end{theorem}
\begin{nproof}
    By Theorem \ref{thm:4.14}, we have that $f(X)$ is compact. $f(X)$ is therefore bounded (see discussion proceeding Theorem \ref{thm:2.41}). \qed
\end{nproof}
\noindent An interesting special case in the above theorem to think about is when $Y = \RR$; this yields the Extreme Value Theorem, below.

\begin{theorem}{Extreme Value Theorem}{4.16}
    Let $X$ be a compact metric space, and let $f: X \mapsto \RR$ be continuous. Then, there exist $p, q \in X$ such that $f(p) \leq f(x) \leq f(q)$ for all $x \in X$. In other words, $f$ attains its minimum (infimum) and maximum (supremum) on $X$.
\end{theorem}
\begin{nproof}
    By Theorems \ref{thm:4.15} and \ref{thm:4.16}, $f(X)$ is closed and bounded. In particular, $m = \inf f(X)$ and $M = \sup f(X)$ exist (as the set is bounded), and $m, M \in f(X)$ as $f(X)$ contains all of its limit points. Hence, there exist $p, q \in X$ such that $f(p) = m$, $f(q) = M$. \qed
\end{nproof}
\noindent We consider some examples which demonstrate the necessity of the compactness of the domain. Let $E = (0, 1) \subset \RR$ and consider $f: (0, 1) \mapsto \RR$. Let $f(x) = \frac{1}{x^2}$. $(0, 1)$ is bounded but not closed, and we observe that $f((0, 1)) = [1, \infty)$ which is unbounded (and hence $f$ does not attain a maximum). Instead let $f(x) = x$. Then, we have that $f((0, 1)) = (0, 1)$ which is bounded, but $f$ does not attain a maximum/minimum on its domain.

\begin{theorem}{}{4.17}
    Let $X$ be a compact metric space, and $f: X \mapsto Y$ be continuous and a bijection. Define $f^{-1}: Y \mapsto X$ by $f^{-1}(y) = x$ if $f(x) = y$ (this is well-defined due to the bijectivity of $f$). Then, $f^{-1}$ is continuous.
\end{theorem}
\begin{nproof}
    By Theorem \ref{thm:4.8}, it suffices to show that for every open set $V \subset X$, $\left(f^{-1}\right)^{-1}(V) = f(V)$ is open. By the openness of $V$, $V^c$ is closed, and hence compact (as closed subsets of compact sets are compact by Theorem \ref{thm:2.35}). So, $f(V^c) \subset Y$ is compact by Theorem \ref{thm:4.14}. Therefore, $f(V^c) = \left(f(V)\right)^c$ is closed (as compact sets are closed by Theorem \ref{thm:2.34}). Therefore, $\left(\left(f(V)\right)^c\right)^c = f(V)$ is open as desired. Hence $f^{-1}$ is continuous. \qed
\end{nproof}

\setcounter{rudin}{20}
\begin{example}{}{4.21}
    This example shows the necessity of compactness of $X$ in Theorem \ref{thm:4.17}. Let $S = [0, 2\pi)$ which is not closed and hence not compact (Heine Borel/Theorem \ref{thm:2.41}). Let $Y = \set{(x, y) \in \RR^2: x^2 + y^2 = 1}$. Define $f: X \mapsto Y$ where $f(\theta) = (\cos\theta, \sin\theta)$. $f$ is continuous and a bijection (check!) but $f^{-1}$ is not continuous. To see this is the case, consider first that $[0, \frac{\pi}{2}) \subset X$ is open in $X$. At everywhere except $0$ it should be evident that all points of $[0, \frac{\pi}{2})$ are interior to $X$, and at $0$, we have that $N_{1/2}(0) \subset [0, \frac{\pi}{2})$ showing that $0$ is also an interior point. But, $(f^{-1})^{-1}([0, \frac{\pi}{2})) = f([0, \frac{\pi}{2}))$ is not open, because not every point is an interior point; namely, $(1, 0) = f(0) \in f([0, \frac{\pi}{2}))$ is not an interior point. So, $f^{-1}$ is not continuous.
\end{example}

\begin{figure}[htbp]
    \centering
    \begin{tikzpicture}[scale=2]
        \foreach \i in {-2.95,-2.9,...,-2.5}{
            \draw[blue] (\i,0.05) -- (\i,-0.05);
            }
        \begin{scope}[shift={(0:2)}]
        \foreach \i [count=\j] in {0, 3, 6,...,87} {
            \draw[blue] (\i:1) -- (\i:1.11);
            }
        \end{scope}
        \draw[] (-3, 0) -- (-1, 0);
        \node[] at (-3, 0) {$[$};
        \node[] at (-1, 0) {$)$};
        \node[below] at (-3, -0.25) {$0$};
        \node[below] at (-1, -0.25) {$2\pi$};
        \draw[->, thick] (-0.5, 0) -- (0.5, 0);
        \node[above] at (0, 0) {$f$};
        \draw[] (2, 0) circle (30pt);
        \node[] at (-2.5, 0) {$)$};
        \node[below] at (-2.5, -0.25) {$\frac{\pi}{2}$};
        \node[rotate = 270] at (3.05, 0) {$]$};
        \node[] at (2, 1.05) {$($};
    \end{tikzpicture}

    \caption{Visual of the map $f$ which maps a point $\theta \in [0, 2\pi)$ to the point $(\cos\theta, \sin\theta)$ on the unit circle. Pictured is the map from $[0, \frac{\pi}{2})$ to $f([0, \frac{\pi}{2}))$, the former which is open in $[0, 2\pi)$, and the latter which is not open in $Y = \set{(x, y) \in \RR^2: x^2 + y^2 = 1}$.}
    \label{fig19}
\end{figure}

\subsection{Uniform Continuiity, Connectedness, and IVT}

\setcounter{rudin}{17}
\begin{definition}{Uniform Continuity}{4.18}
    Let $X, Y$ be metric spaces and $f: X \mapsto Y$. Then, $f$ is \textbf{uniformly continuous} if for all $\e > 0$, there exists $\delta > 0$ such that for all $p, q \in X$ with $d_X(p, q) < \delta$, we have that $d_Y(f(p), f(q)) < \e$. It is clear from the definition that every uniformly continuous function is continuous.
\end{definition}
\noindent Note that this definition is very similar to the definition of continuity, but with a difference in the quantifiers. With continuity, for each $\e$ there is a $\delta$ that we can find for a given point $p \in X$. For uniform continuity, we have that for each $\e$, there exists a $\delta$ that works uniformly for all $p$.

We now consider some examples to see the difference concretely. Take $X = (0, 1), Y = \RR$, and $f(x) = \frac{1}{x}$. We then have that $f$ is continuous, but not uniformly continuous, showing that in general continuity does not imply uniform continuity.

Next, consider $X = Y = \RR$ and $f(x) = \sin x$. Then, $f$ is uniformly continuous. Given any $\e$, we can pick $\delta = \e$ and this proof will work. The ``calclus-inspired'' proof would use that $\od{}{x}\sin x = \cos x$ and $\abs{\cos x} \leq 1$, so we can always pick $\delta = \e$ with the MVT. However, we have yet to define the derivative or prove the mean value theorem, so an alternate appraoch would be to invoke trigonometric identities.

Finally, let $X = [0, 10], Y = \RR$, and $f(x) = x^2$. Then, $f$ is uniformly continuous. However, if $X = Y = \RR$ and $f(x) = x^2$, then $f$ is not uniformly continuous. The uniform continuity of $f$ depends on the domain; in particular, $[0, 10]$ is closed/compact, while $\RR$ is not compact. This motivates our next theorem.

\begin{theorem}{}{4.19}
    Let $X, Y$ be metric spaces with $X$ compact. Let $f: X \mapsto Y$ be continuous. Then, $f$ is uniformly continuous.
\end{theorem}
\begin{nproof}
    Let $\e > 0$. By the continuity of $f$, for each $p \in X$, there exists $\delta_p  0$ such that for all $q \in X$ with $d_X(p, q)  <\delta_p$, we have that $d_Y(f(p), f(q)) < \frac{\e}{2}$. Define $U_p = N_{\delta_p/2}(p)$. We then have that $\set{U_p}_{p \in X}$ is an open cover for $X$. By the compactness of $X$, it has a finite subcover. Let $\set{U_{p_1}, \ldots, U_{p_n}}$ be a finite subcover. Let $\delta = \frac{1}{2}\min\set{\delta_{p_1}, \ldots, \delta_{p_n}} > 0$ (note the importance of taking the minimum over a \textit{finite} number of $\delta_{p_i}$s; if we took an infimum over an infinite number, it could be possible that the infimum could be zero). Then, take $p, q \in X$ with $d_X(p, q) < \delta$. Then, $p \in U_{p_i}$ for some $i$. So, $d_X(p, p_i) < \frac{\delta_{p_i}}{2}$, and then by the triangle inequality we have that:
    \begin{align*}
        d_X(q, p_i) \leq d_X(q, p) + d_X(p, p_i) < \delta + \frac{\delta_{p_i}}{2} \leq \frac{\delta_{p_i}}{2} + \frac{\delta_{p_i}}{2} = \delta_{p_i}
    \end{align*}
    Therefore, we have that:
    \begin{align*}
        d_Y(f(p), f(q)) \leq d_Y(f(p), f(p_i)) + d_Y(f(p_i), f(q)) < \frac{\e}{2} + \frac{\e}{2} = \e
    \end{align*}
    And we conclude that $f$ is uniformly continuous. \qed
\end{nproof}

\setcounter{rudin}{21}
\begin{theorem}{}{4.22}
    Let $X, Y$ be metric spaces, and let $f: X \mapsto Y$ be continuous. If $E \subset X$ is connected (see Definition \ref{def:2.45}) then its image $f(E)$ is also connected.
\end{theorem}
\begin{nproof}
    Suppose for the sake of contradiction that we can write $f(E) = A \cup B$ with $A, B \neq \emptyset$ and $A \cap \overline{B} = \overline{A} \cap B = \emptyset$ (i.e. $f(E)$ is not connected). Then, define $G = f^{-1}(A) \cap E$ and $H = f^{-1}(B) \cap E$. Then, $E = G \cup H$, with $G \neq \emptyset$, $H \neq \emptyset$, and $G \cap H = \emptyset$. We wish to show that $\overline{G} \cap H = G \cap \overline{H} = \emptyset$ as this will contradict the connectedness of $E$. Since $A \subset \overline{A}$, We have that $G \subset f^{-1}(A) \subset f^{-1}(\overline{A})$. $f$ is continuous, so by Theorem \ref{thm:4.8}, we have that $f^{-1}(\overline{A})$ is closed. Hence by Theorem \ref{thm:2.27} we have that $\overline{G} \subset f^{-1}(\overline{A})$. Since $f(H) = B$ and $\overline{A} \cap B = \emptyset$, we have that:
    \begin{align*}
        f(\overline{G}) \cap f(H) = \emptyset
    \end{align*}
    And therefore $\overline{G} \cap H = \emptyset$. By an identitcal argument, $G \cap \overline{H} = \emptyset$. Hence, $E = G \cup H$ is not connected, which is a contradiction. \qed
\end{nproof}

\begin{theorem}{Intermediate Value Theorem}{4.23}
    Let $f: [a, b] \mapsto \RR$ be continuous and $f(a) < f(b)$. Then, for all $\alpha \in (f(a), f(b))$, there exists $c \in (a, b)$ with $f(c) = \alpha$.
\end{theorem}
\begin{nproof}
    $[a, b]$ is connected, so by Theorem \ref{thm:4.22}, $f([a, b])$ is conected. Hence by \ref{thm:2.47}, it contains every point between $f(a)$ and $f(b)$. \qed
\end{nproof}

\begin{figure}[htbp]
    \centering
    \begin{tikzpicture}[scale=2]
        \draw[-latex, very thick] (-2.5, 0) -- (-2.5, 2);
        \draw[-latex, very thick] (-2.5, 0) -- (-0.5, 0);
        \draw [] (-2.25 , 0.5) to [ curve through ={(-2, 0.75)..(-1.75, 1.1)..(-1.5, 1.25)..(-1.25,1.6)}] (-1,1.5);
        \filldraw[] (-2.25, 0.5) circle (1pt);
        \filldraw[] (-1, 1.5) circle (1pt);
        \draw[dashed] (-2.5, 1.25) -- (-1.5, 1.25);
        \draw[] (-2.25, 0) -- (-2.25, -0.15);
        \node[below] at (-2.25, -0.16) {$a$};
        \draw[] (-1, 0) -- (-1, -0.15);
        \node[below] at (-1, -0.13) {$b$};
        \draw[] (-1.5, 0) -- (-1.5, -0.15);
        \node[below] at (-1.5, -0.17) {$c$};
        \node[left] at (-2.5, 1.25) {$\alpha$};
        \draw[-latex, very thick] (0.5, 0) -- (0.5, 2);
        \draw[-latex, very thick] (0.5, 0) -- (2.5, 0);
        \draw[] (0.75, 0.5) -- (1.375, 0.5);
        \draw[] (1.375, 1.5) -- (2, 1.5);
        \filldraw[] (0.75, 0.5) circle (1pt);
        \draw[fill = white] (1.375, 0.5) circle (1pt);
        \filldraw[] (1.375, 1.5) circle (1pt);
        \filldraw[] (2, 1.5) circle (1pt);
        \draw[] (0.75, 0) -- (0.75, -0.15);
        \node[below] at (0.75, -0.16) {$a$};
        \draw[] (2, 0) -- (2, -0.15);
        \node[below] at (2, -0.13) {$b$};
    \end{tikzpicture}

    \caption{Visualization of a function for which the IVT applies (left) and a function where it does not (right).}
    \label{fig20}
\end{figure}

As a closing remark for this chapter, consider that continuity over a closed interval implies the intermediate value theorem. Does this then imply that a connected space with the intermediate value theorem implies continuity? The answer turns out to be no. Consider discontinuities other than jumps (IVT only tells us a function does not ``jump'' on the domain of interest), that is, a discontinuity that arises from the non-existence of a limit. As an example, consider:
\begin{align*}
    \fullfunction{f}{\RR}{\RR}{x}{\begin{cases}
        \frac{1}{x} & x \neq 0
        \\ 0 & x = 0
    \end{cases}
    }
\end{align*}
This function is not continuous at $x = 0$ (the limit does not even exist there!) but satisfies the IVT.

\subsection{Topological Spaces}
Up until this point, we have been discussing metric spaces $(X, d)$, where $U \subset X$ is open if every point of $U$ is an interior point according to the metric $d$. In this picture, $\emptyset$ is open, $X$ is open, and if $\set{U_\alpha}$ are open, then $\bigcup_{\alpha} U_\alpha$ (arbitrary unions) and $\bigcap_{i=1}^n U_{\alpha_i}$ (finite intersections) are open. Although this metric space picture is the one we have been using (and will be using going forwards in the course), it could be interesting to take a temporary tangent, and consider a generalization of these notions to toplogical spaces:

\begin{ndef}{: Topological Spaces}{}
    A pair $(X, \tau)$ is a \textbf{topological space} if $\tau \subset \mathcal{P}(X)$ such that $\emptyset \in \tau$, $X \in \tau$, and if $\set{U_\alpha} \subset \tau$, then $\bigcup_{\alpha} U_\alpha \in \tau$ and $\bigcap_{i=1}^n U_{\alpha_i} \in \tau$. In this definition, $\tau$ is the set of ``open sets'' of $X$.
\end{ndef}
\noindent In metric spaces, we defined openness in terms of a metric, but in topological spaces, we throw away the metric.

If $(X, \tau)$ and $(Y, \rho)$ are topological spaces, how do we define a continuous function $f: X \mapsto Y$? Evidently, the $\e-\delta$ definition no longer makes sense (in the absense of a metric), but our topological characterization of continutiy still holds:

\begin{ndef}{: Continuity on Topological Spaces}{}
    Let $(X, \tau)$ and $(Y, \rho)$ be topological spaces. Then, $f: X \mapsto Y$ is \textbf{continuous} if for every $U \in \rho$, $f^{-1}(U) \in \tau$.
\end{ndef}

\noindent A natural question that arises given a topological space is whether it is possible or not to find a metric that gives us this topology.

\begin{ndef}{: Metriziability}{}
    Let $(X, \tau)$ be a topological space. If there exists a metric $d: X \times X \mapsto \RR$ such that every set $U \in \tau$ is open with respect to the metric $d$, then we say that $X$ is \textbf{metrizable}.
\end{ndef}
\noindent However, not all topological spaces are metrizable. For example, take $(X, \tau)$ with $\tau = \set{\emptyset, X}$. If $X$ has more than $1$ element, then there is no metric that gives rise to this trivial topology.

\begin{proof}
    We show the proof for the case of 2 elements (the proof for any finite $\abs{X}$ follows analogously, and the argument for the infinite case is left as an exercise). Let $X = \set{a, b}$ and $\tau = \set{\emptyset, X}$. if $d$ is a metric on $X$, then $d(a, b) = r > 0$. Then, let $0 < s < r$. Then, $N_{s}(a)$ has to be open, as does $N_{s}(b) = \set{b}$. The set of open sets of $X$ under $d$ is therefore $\set{X, \emptyset, \set{a}, \set{b}} \neq \tau$ and hence $(X, \tau)$ is not metrizable.
\end{proof}

The original definition we had of convergent sequences (and Cauchy sequences) also does not generalize well to topological spaces (as both invoke the notion of a metric). We can define convergence in topological spaces (in a way that does not explicitly use a metric) as follows:

\begin{ndef}{: Convergence in Topological Spaces}{}
    Let $(X, \tau)$ be a topological space, and suppose $\set{x_n} \subset X$. We say that $x_n$ \textbf{converges} to $x$ if for every set $U \in \tau$ such that $x \in \tau$, there exists $N$ such that $x_n \in U$ for all $n \geq N$.
\end{ndef}

Note that it is impossible to define the notion of a Cauchy sequence without a metric (it cannot be defined solely in terms of open sets). Convergence is topological, but the metric matters for Cauchy.

Recall that the compactness of a set $K$ was defined in terms of every cover having a finite subcover. The sequential compactness of a set $K$ can be defined by saying that every sequence in $K$ has a convergent subsequence. These definitions have no explicit reference to a metric given our above two definitions of open sets/convergence, so the definition of compactness holds in the same way in the picture of topological spaces. Note that in metric spaces, compactness and sequentially compactness are equivalent, but they can be different in topological spaces (this is another fact that tells us that there exist topological spaces that are not metrizable)!

So reviewing what we can define meaningfully in the picture of topological spaces, we see that we can define continuity, convergence, compactness, and sequential compactness; unfortunately, Cauchy sequences are left on the cutting room floor.


text:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Unit Test}

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

\begin{frame}
 \frametitle{Unit Test}
  \scriptsize
 \begin{description}
 \item [Automatic unit tests:] \hfill
  \begin{itemize}
  \item Test code in a specially designated area of the project
  \item Execution like \alert{Main methods} but tool support for:
  \begin{itemize}
    \item Comparison with expected behavior
    \item automatic execution of all tests
    \item Statistics on completed and failed tests
   \end{itemize}
\end{itemize}
\end{description}
 \pause

 \begin{description}
 \item [Pros:] \hfill
\begin{itemize}
   \item Separation of functionality and tests
   \item Tests are retained
   \item Tests can be run continuously, automatically\\
      $\rightarrow$ Regressions are identified
   \item Tests as \alert{quality gateway} for integration of new code into the master branch or master repository
\end{itemize}
\end{description}
\end{frame}

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

\subsection{Demo}

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

\begin{frame}[containsverbatim]{An Demo-function}
\scriptsize
\lstset{language=Java}
\begin{lstlisting}[frame=single]
package com.example.project;

public class Calculator {
	public int add(int a, int b) {
		return a - b;
	}
}
\end{lstlisting}
\begin{flushright}
Take a look at this in eclipse.
\end{flushright}
\end{frame}

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

\begin{frame}[containsverbatim]{An Demo-function}
\scriptsize
\lstset{language=Java}
\begin{lstlisting}[frame=single]
package com.example.project;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class MyTest {
	@Test
	@DisplayName("1 + 1 = 2")
	void addsTwoNumbers() {
	   Calculator calculator = new Calculator();
	   assertEquals(2, calculator.add(1, 1), "1 + 1 should equal 2");
	}
}
\end{lstlisting}
\begin{flushright}
\tiny \semitransp{https://github.com/junit-team/junit5-samples/}
\end{flushright}
\end{frame}

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

\subsection{Summary}

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

\begin{frame}
 \frametitle{Unit Test: Summary}

 \begin{description}
 \item [Evaluation:] \hfill
 \begin{itemize}
  \item Automatic tests cause few additional work!
  \item Help to recognize quality problems early.
\end{itemize}
\end{description}

\pause

 \begin{description}
 \item [Questions:] \hfill
\begin{itemize}
   \item How many tests should I write?
   \item Which parts of the software should be tested?
   \item And what sample data?
   \item From where do I know the  \glqq expected\grqq\ results?
\end{itemize}
\end{description}
\end{frame}

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

max_stars_repo_name: mardatade/Course-Software-Testing

max_issues_repo_name: mardatade/Course-Software-Testing

max_forks_repo_name: mardatade/Course-Software-Testing


text:
\section{1D DP}

%%%%%%%%%%%%%%%%%%%%
\begin{frame}{$f^{(S(n))} = 1$}
  \begin{exampleblock}{$f^{(S(n))} = 1$ (Problem 7.2)}
	\begin{displaymath}
	  f(n) = \begin{cases}
		n - 1 & \text{if } n \in \mathbb{Z}^{+} \\
		n / 2 & \text{if } n \% 2 = 0 \\
		n / 3 & \text{if } n \% 3 = 0
	  \end{cases}
	\end{displaymath}

	\centerline{$S(n):$ minimum number of steps taking $n$ to 1.}
  \end{exampleblock}

  \pause
  \[
	S(i): \text{minimum number of steps taking } i \text{ to } 1
  \]

  \pause
  \[
	S(i) = 1 + \min \set{S(i-1), S(i/2) (\text{if } n\%2 = 0), S(i/3) (\text{if } n\%3 = 0)}
  \]

  \[
	S(1) = 0
  \]
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{$f^{(S(n))} = 1$}
  Collatz ($3n+1$) conjecture:
  \begin{displaymath}
	f(n) = \begin{cases}
	  n / 2 & \text{if } n \% 2 = 0 \\
	  3n + 1 & \text{if } n \% 2 = 1
	\end{cases}
  \end{displaymath}

  \[
	f^{\ast}(n) = 1 ?
  \]

  \pause
  \vspace{0.50cm}
  \begin{quote}
	``Mathematics may not be ready for such problems.''\\
	\hfill --- Paul Erdős
  \end{quote}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Longest increasing subsequence}
  \begin{exampleblock}{Longest increasing subsequence (Problem 7.3)}
    \begin{itemize}
      \item Given an integer array $A[1 \ldots n]$
      \item To find (the length of) a longest increasing subseqence.
    \end{itemize}
  \end{exampleblock}

  \[
    5,2,8,6,3,6,9,7 \implies 2, 3, 6, 9
  \]
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Longest increasing subsequence}
  \begin{description}
	\item[Subproblem:] $L(i):$ the length of the LIS of $A[1 \ldots i]$
	\item[Goal:] $L(n)$
	  \pause
	\item[Make choice:] whether $A[i] \in LIS[1 \ldots i]$?
	\item[Recurrence:]
	  \[
		L(i) = \max \set{L(i-1), 1 + \max_{j < i \land A[j] \le A[i]} L(j)}
	  \]
	  \pause
	\item[Init:]
	  \[
		L(0) = 0
	  \]
	\item[Time:]
	  \[
		O(n^2) = \Theta(n) \cdot O(n)
	  \]
  \end{description}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Longest increasing subsequence}
  \fignocaption{width = 0.40\textwidth}{figs/LIS-example.png}

  \centerline{Longest path distance in the DAG!}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Maximum-sum subarray}
  \begin{exampleblock}{Maximum-sum subarray (Google Interview)}
    \begin{itemize}
      \item Array $A[1 \cdots n], a_{i} >=< 0$
      \item To find (the sum of) a maximum-sum subarray of $A$
    \end{itemize}

    \[
      A[-2,1 ,-3,4,-1,2,1,-5,4] \implies [4,-1,2,1]
    \]
  \end{exampleblock}

  \pause
  \begin{description}
	\item[Subproblem:] $\text{MSS}[i]$: sum of an $\text{MS}[i]$ of $A[1 \cdots i]$
	\item[Goal:] $\text{mss} = \text{MSS}[n]$
	\pause
	\item[Make choice:] Is $a_{i} \in \text{MS}[i]$?
	\item[Recurrence:]
	  \[
		\text{MSS}[i] = \max \set{\text{MSS}[i-1], \textcolor{red}{???}}
	  \]
  \end{description}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Maximum-sum subarray}
  \begin{description}
	\item[Subproblem:] $\text{MSS}[i]$: sum of an $\text{MS}[i]$ \textcolor{red}{\it ending with} $a_{i}$
	\item[Goal:] $\text{mss} = \max\limits_{1 \le i \le n} \text{MSS}[i]$
	\pause
	\item[Make choice:] Where does the $\text{MS}[i]$ start?
	\item[Recurrence:]
	  \[
		\text{MSS}[i] = \max \set{\text{MSS}[i-1] + a_{i}, a_{i}} \text{ \textcolor{red}{(Proof!)}}
	  \]
	\pause
	\item[Init:]
	  \[
		\text{MSS}[0] = 0
	  \]
	  \pause
	\item[Time:] $\Theta(n)$
  \end{description}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Maximum-sum subarray}
  \begin{columns}
	\column{0.40\textwidth}
	  \fignocaption{width = 0.60\textwidth}{figs/programming-pearls.jpg}
	\column{0.60\textwidth}
	  \begin{description}[<+->][Michael Shamos]
		\item[Ulf Grenander] $O(n^3) \implies O(n^2)$
		\item[Michael Shamos] $O(n \log n)$, onenight
		\item[Jon Bentley] Conjecture: $\Omega(n \log n)$
		\item[Michael Shamos] Carnegie Mellon seminar
		\item[Jay Kadane] $O(n)$, \uncover<6->{\textcolor{red}{$\le 1$ minute}}
	  \end{description}
  \end{columns}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}<beamer:0>{Maximum-sum subarray}
  \begin{columns}
	\column{0.55\textwidth}
	  \begin{algorithmic}
		\State $\text{MSS}[0] \gets 0$
		\ForAll{$i \gets 1 \dots n$}
		  \State $\text{MSS}[i] \gets \max\set{\text{MSS}[i-1] + a_i, 0}$
		\EndFor
		\State \Return $\max\limits_{i = 1 \dots n} \text{MSS}[i]$
	  \end{algorithmic}
	  \pause
	\column{0.50\textwidth}
	  \begin{algorithmic}
		\State $\text{mss} \gets 0$
		\State $\text{MSS} \gets 0$
		\ForAll{$i \gets 1 \dots n$}
		  \State $\text{MSS} \gets \max\set{\text{MSS} + a_i, 0}$
		  \State $\text{mss} \gets \max\set{\text{mss}, \text{MSS}}$
		\EndFor
		\State \Return $\text{mss}$
	  \end{algorithmic}
  \end{columns}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Maximum-product subarray}
  \begin{exampleblock}{Maximum-product subarray (Problem 7.4)}
	\begin{itemize}
	  \item Array $A[1 \dots n]$
	  \item Find maximum-product subarray of $A$
	\end{itemize}

	\begin{enumerate}[(1)]
	  \item $a_i \in \mathbb{N}$
	  \item $a_i \in \mathbb{Z}$
	  \item $a_i \in \mathbb{R}$
	\end{enumerate}
  \end{exampleblock}

  \pause
  \vspace{0.60cm}
  \centerline{sum \emph{vs.} product}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Maximum-product subarray}
  \centerline{Subproblem: $\text{MaxP}[i], \text{MinP}[i]$}

  \begin{table}
	\renewcommand{\arraystretch}{1.5}
	\centering
	\begin{tabular}{|L||C|C|C|C|C|C|C|}
	  \hline
	  &	& \frac{1}{2} & 4 & -2 & \textcolor{red}{5} & \textcolor{red}{-\frac{1}{5}} & 8 \\ \hline
	  \text{MaxP}[i] & 1	& \frac{1}{2} & 4 & -2 & 5 & 8 & 64 \\ \hline
	  \text{MinP}[i] & 1	& \frac{1}{2} & 2 & -8 & -40 & -1 & -8  \\ \hline
	\end{tabular}
  \end{table}

  \begin{align*}
	\text{MaxP}[i] &= \max\set{\text{MaxP}[i-1] \cdot a_i, \text{MinP}[i-1] \cdot a_i, a_i} \\
	\text{MinP}[i] &= \min\set{\text{MaxP}[i-1] \cdot a_i, \text{MinP}[i-1] \cdot a_i, a_i}
  \end{align*}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Reconstructing string}
  \begin{exampleblock}{Reconstructing string (Problem 7.9)}
    \begin{itemize}
      \item String $S[1 \cdots n]$
      \item Dict for \emph{lookup}:
		\begin{displaymath}
		  \text{dict}(w) = \left\{ \begin{array}{ll}
			\text{true} & \textrm{if } w \textrm{ is a valid word}\\
			\text{false} & \textrm{o.w.}
		  \end{array} \right.
		\end{displaymath}
	  \item Is $S[1 \cdots n]$ valid (reconstructed as a sequence of valid words)?
    \end{itemize}
  \end{exampleblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Reconstructing string}
  \begin{description}
	\item[Subproblem:] $V[i]$: Is $S[1 \cdots i]$ valid?
	\item[Goal:] $V[n]$
	\pause
	\item[Make choice:] Where does the last word start?
	\item[Recurrence:]
	  \[
		V[i] = \bigvee_{j = 1 \ldots i} (V[j-1] \land \text{dict}(S[j \cdots i]))
	  \]
	\pause
	\item[Init:]
	  \[
		V[0] = \text{true}
	  \]
	\item[Time:]
	  \[
		O(n^2) = \Theta(n) \cdot O(n)
	  \]
  \end{description}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Hotel along a trip}
  \begin{exampleblock}{Hotel along a trip (Problem 7.15)}
    \begin{itemize}
      \item Hotel sequence (distance): $a_{0} = 0, a_{1}, \cdots, a_{n}$
      \item $a_0 \leadsto a_n$
	  \item Stop at only hotels
      \item Cost: $(200 - x)^{2}$
      \item To minimize overall cost
    \end{itemize}
  \end{exampleblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Hotel along a trip}
  \begin{description}
	\item[Subproblem:] $C[i]$: minimum cost when the destination is $a_{i}$
	\item[Goal:] $C[n]$
	\pause
	\item[Make choice:] What is the last but one hotel $a_{j}$ to stop?
	\item[Recurrence:]
	  \[
		C[i] = \min_{0 \le j < i} \set{C[j] + (200 - (a_{i} - a_{j}))^{2}}
	  \]
	\pause
	\item[Init:]
	  \[
		C[0] = 0
	  \]
	\item[Time:]
	  \[
		O(n^2) = \Theta(n) \cdot O(n)
	  \]
  \end{description}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Highway restaurants}
  \begin{exampleblock}{Highway restaurants (Problem 7.16)}
	\begin{itemize}
	  \item Locations: $L[1 \dots n]$
	  \item Profits: $P[1 \dots n]$
	  \item Any two hotels should be $\ge k$ miles apart
	  \item To maximize the total profit
	\end{itemize}
  \end{exampleblock}

  \begin{description}
	\item[Subproblem:] $T[i]$: max profit achievable using only $L[1 \dots i]$
	\item[Goal:] $T[n]$
	  \pause
	\item[Make choice:] Whether to open a restaurant at $L_i$?
	\item[Recurrence:]
	  \begin{align*}
		T[i] &= \max\set{T[i-1], P_i + T[\text{prev}(i)]} \\
		\text{prev}(i) &= \max\set{j \mid j < i \land L_i - L_j \ge k}
	  \end{align*}
	  \pause
	\item[Init:] $T[0] = 0$
  \end{description}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Weighted interval/class scheduling}
  \begin{exampleblock}{Weighted interval/class scheduling (Problem 7.14)}
    \begin{itemize}
      \item Classes: $\mathcal{C} = \set{c_{1}, c_{2}, \cdots, c_{n}} \quad c_{i} \triangleq \langle g_{i}, s_{i}, f_{i} \rangle$
      \item Choosing non-conflicting classes to maximize your grades
    \end{itemize}
  \end{exampleblock}

  \fignocaption{width = 0.40\textwidth}{figs/weighted-interval.png}
  \centerline{\textcolor{red}{sort $\mathcal{C}$ by finishing time.}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Weighted interval/class scheduling}
  \centerline{Greedy algorithms fail:}

  \vspace{0.30cm}
  \begin{columns}
	\column{0.50\textwidth}
	  \fignocaption{width = 0.40\textwidth}{figs/weighted-interval-greedy-finish-time.pdf}{\centerline{By finishing time.}}
	  \pause
	\column{0.50\textwidth}
	  \fignocaption{width = 0.75\textwidth}{figs/weighted-interval-greedy-weights.pdf}{\centerline{By weights.}}
  \end{columns}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Weighted interval/class scheduling}
  \begin{description}
	\item[Subproblem:] $G[i]$: the maximal grades obtained from $\set{c_{1}, c_{2}, \cdots, c_{i}}$
	\item[Goal:] $G[n]$
	  \pause
	\item[Make choice:] Choose $c_{i}$ or not?
	\item[Recurrence:]
	  \begin{align*}
		G[i] &= \max \set{G[i-1], G[\text{prev}(i)] + g_{i}}  \\
		\text{prev}(i) &= \max\set{j \mid j < i \land c_{i} \cap c_{j} = \emptyset}
	  \end{align*}
	  \pause
	\item[Init:] $G[0] = 0$
	\item[Time:] $O(n \log n) + T(\text{prev}(i)) + O(n) \cdot O(1)$
  \end{description}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Weighted interval/class scheduling}
  Why is ordering necessary?
  \fignocaption{width = 0.50\textwidth}{figs/weighted-interval-unordered.pdf}

  \[
	G[7] = \max \set{G[6], G[\set{1,3,5}] + g_{7}}
  \]

  \begin{center}
	subproblems changed: all $O(2^{n})$ subsets
  \end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Weighted interval/class scheduling}
  What about sorting by starting time?
  \fignocaption{width = 0.50\textwidth}{figs/weighted-interval-starting-time-ordered.pdf}

  \[
	G[6] = \max \set{G[5], G[\set{2,3}] + g_{6}}
  \]

  \begin{center}
	subproblems changed: all $O(2^{n})$ subsets
  \end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%

max_stars_repo_name: hengxin/algorithm-ta-tutorial


text:
\section{Recap}

\frame{\tableofcontents[currentsection]}

\begin{frame}
    \frametitle{HTTP methods}

    \structure{Request types:}
    \begin{itemize}
        \item GET : request data from a resource
        \item POST : submit data to be processed to a specified resource
        \item PUT : replaces all current representations of the resource with the request payload.
        \item DELETE
        \item HEAD : identical as GET, but without response body
        \item OPTIONS : returns supported HTTP methods
        \item PATCH : update partial resources
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Idempotent methods}

    \structure{Definition}\\
    Methods that can be called many times without different outcomes.

    \vfill

    \structure{Example}\\
    \begin{itemize}
        \item elixir\_awesomeness = 42 -$>$ Idempotent
        \item elixir\_awesomeness++ -$>$ Not idempotent
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Safe methods}

    \structure{Definition}\\
    Methods that do not modify resources.

    \vfill

    \structure{Example}\\
    \begin{itemize}
        \item GET localhost:4000/users -$>$ doesn't modify resources
        \item POST / PUT / DELETE -$>$ modifies resources
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Overview}

    \begin{center}
        \begin{tabular}{||c c c||}
            \hline
            Method  & Idempotent & Safe \\ [0.5ex]
            \hline\hline
            GET     & Y          & Y    \\
            \hline
            POST    & N          & N    \\
            \hline
            PUT     & Y          & N    \\
            \hline
            DELETE  & Y          & N    \\
            \hline
            HEAD    & Y          & Y    \\
            \hline
            OPTIONS & Y          & Y    \\
            \hline
            PATCH   & N          & N    \\
            \hline
        \end{tabular}
    \end{center}
\end{frame}


text: \subsection{Olive oil}

max_stars_repo_name: adamdboult/nodeHomePage

max_issues_repo_name: adamdboult/nodeHomePage

max_forks_repo_name: adamdboult/nodeHomePage


text:
\section{Convex-Invariant IMEX Schemes}
\label{sec:imex}

In this section we discuss the class of IMEX schemes that are used for the realizability-preserving DG-IMEX method developed in Section~\ref{sec:realizableDGIMEX} (see also \ref{app:butcherTables} for additional details).
The semi-discretization of the moment equations with the DG method given by Eq.~\eqref{eq:semidiscreteDG} results in a system of ordinary differential equations (ODEs) of the form
\begin{equation}
  \dot{\vect{u}}
  =\vect{\cT}(\vect{u})+\f{1}{\tau}\,\vect{\cQ}(\vect{u}),
  \label{eq:ode}
\end{equation}
where $\vect{u}=\{\vect{u}_{\bK}\}_{\bK\in\mathscr{T}}$ are the degrees of freedom evolved with the DG method; i.e., for a test space spanned by $\{\phi_{i}(\vect{x})\}_{i=1}^{N}\in\bbV^{k}$, we let
\begin{equation}
  \vect{u}_{\bK}=\f{1}{|\bK|}\Big(\,\int_{\bK}\vect{\cM}_{h}\,\phi_{1}\,d\vect{x},\int_{\bK}\vect{\cM}_{h}\,\phi_{2}\,d\vect{x},\ldots,\int_{\bK}\vect{\cM}_{h}\,\phi_{N}\,d\vect{x}\,\Big)^{T}.
\end{equation}
Thus, for $\phi_{1}=1$, the first components of $\vect{u}_{\bK}$ are the cell averaged moments.
In Eq.~\eqref{eq:ode}, the transport operator $\vect{\cT}$ corresponds to the second and third term on the left-hand side of Eq.~\eqref{eq:semidiscreteDG}, while the collision operator $\vect{\cQ}$ corresponds to the right-hand side of Eq.~\eqref{eq:semidiscreteDG}.

Eq.~\eqref{eq:ode} is to be integrated forward in time with an ODE integrator.
Since the realizable set $\cR$ is convex, convex-invariant schemes can be used to design realizability-preserving schemes for the two-moment model.
\begin{define}
  Given sufficient conditions, a convex-invariant time integration scheme preserves the constraints of a model if the set of admissible states satisfying the constraints forms a convex set.
  \label{def:constraintPreserving}
\end{define}
As an example, high-order explicit strong stability-preserving Runge-Kutta (SSP-RK) methods form a class of convex-invariant schemes.

\subsection{Second-Order Accurate, Convex-Invariant IMEX Schemes}

In many applications, collisions with a background induce stiffness ($\tau\ll1$) in regions of the computational domain that must be treated with implicit methods.
Meanwhile, the time scales induced by the transport term can be treated with explicit methods.
This motivates the use of IMEX methods \cite{ascher_etal_1997,pareschiRusso_2005}.
Our goal is to employ IMEX schemes that preserve realizability of the moments, subject only to a time step governed by the explicit transport operator and comparable to the time step required for numerical stability of the explicit scheme.
We seek to achieve this goal with convex-invariant IMEX schemes.

Unfortunately, high-order (second or higher order temporal accuracy) convex-invariant IMEX methods with time step restrictions solely due to the transport operator do not exist (see for example Proposition~6.2 in \cite{gottlieb_etal_2001}, which rules out the existence of implicit SSP-RK methods of order higher than one).
To overcome this barrier, Chertock et al. \cite{chertock_etal_2015} presented IMEX schemes with a correction step.
These schemes are SSP but only first-order accurate within the standard IMEX framework.
The correction step is introduced to recover second-order accuracy.
However, the correction step in \cite{chertock_etal_2015} involves both the transport and collision operators, and we have found that, when applied to the fermionic two-moment model, realizability is subject to a time step restriction that depends on $\tau$ in a way that becomes too restrictive for stiff problems.
More recently, Hu et al. \cite{hu_etal_2018}, presented similar IMEX schemes for problems involving BGK-type collision operators, but with a correction step that does not include the transport operator.
In this case, the scheme is convex-invariant, subject only to time step restrictions stemming from the transport operator, which is more attractive for our target application.
These second-order accurate, $s$-stage IMEX schemes take the following form \cite{hu_etal_2018}
\begin{align}
  \vect{u}^{(i)}
  &=\vect{u}^{n}
  +\dt\sum_{j=1}^{i-1}\tilde{a}_{ij}\,\vect{\cT}(\vect{u}^{(j)})
  +\dt\sum_{j=1}^{i}a_{ij}\,\f{1}{\tau}\,\vect{\cQ}(\vect{u}^{(j)}),
  \quad i=1,\ldots,s, \label{imexStages} \\
  \tilde{\vect{u}}^{n+1}
  &=\vect{u}^{n}
  +\dt\sum_{i=1}^{s}\tilde{w}_{i}\,\vect{\cT}(\vect{u}^{(i)})
  +\dt\sum_{i=1}^{s}w_{i}\,\f{1}{\tau}\,\vect{\cQ}(\vect{u}^{(i)}), \label{imexIntermediate} \\
  \vect{u}^{n+1}
  &=\tilde{\vect{u}}^{n+1}-\alpha\,\dt^{2}\,\f{1}{\tau^{2}}\,\vect{\cQ}'(\vect{u}^{*})\,\vect{\cQ}(\vect{u}^{n+1}), \label{eq:imexCorrection}
\end{align}
where, as in standard IMEX schemes, $(\tilde{a}_{ij})$ and $(a_{ij})$, components of $s\times s$ matrices $\tilde{A}$ and $A$, respectively, and the vectors $\tilde{\vect{w}}=(\tilde{w}_{1},\ldots,\tilde{w}_{s})^{T}$ and $\vect{w}=(w_{1},\ldots,w_{s})^{T}$ must satisfy certain order conditions \cite{pareschiRusso_2005}.
The coefficient $\alpha$ in the correction step is positive, and $\vect{\cQ}'$ is the Fr{\'e}chet derivative of the collision term evaluated at $\vect{u}^{*}$.
For second-order accuracy, $\vect{\cQ}'$ can be evaluated using any of the stage values ($\vect{u}^{n}$, $\vect{u}^{(i)}$, or $\tilde{\vect{u}}^{n+1}$).
For second-order temporal accuracy, the order conditions for the IMEX scheme in Eqs.~\eqref{imexStages}-\eqref{eq:imexCorrection} are \cite{hu_etal_2018}
\begin{equation}
  \sum_{i=1}^{s}\tilde{w}_{i}=\sum_{i=1}^{s}w_{i}=1,
  \label{orderConditions1}
\end{equation}
and
\begin{equation}
  \sum_{i=1}^{s}\tilde{w}_{i}\,\tilde{c}_{i}
  =\sum_{i=1}^{s}\tilde{w}_{i}\,c_{i}
  =\sum_{i=1}^{s}w_{i}\,\tilde{c}_{i}
  =\sum_{i=1}^{s}w_{i}\,c_{i}-\alpha=\f{1}{2},
  \label{orderConditions2}
\end{equation}
where $\tilde{c}_{i}$ and $c_{i}$ are given in \ref{app:butcherTables}.
For globally stiffly accurate (GSA) IMEX schemes, $\tilde{w}_{i}=\tilde{a}_{si}$ and $w_{i}=a_{si}$ for $i=1,\ldots,s$, so that $\tilde{\vect{u}}^{n+1}=\vect{u}^{(s)}$ \cite{ascher_etal_1997}.
This property is beneficial for very stiff problems and also simplifies the proof of the realizability-preserving property of the DG-IMEX scheme given in Section~\ref{sec:realizableDGIMEX}, since it eliminates the assembly step in Eq.~\eqref{imexIntermediate}.

Hu et al. \cite{hu_etal_2018} rewrite the stage values in Eq.~\eqref{imexStages} in the following form
\begin{equation}
  \vect{u}^{(i)}
  =\sum_{j=0}^{i-1}c_{ij}\Big[\,\vect{u}^{(j)}+\hat{c}_{ij}\,\dt\,\vect{\cT}(\vect{u}^{(j)})\,\Big]
  +a_{ii}\,\dt\,\f{1}{\tau}\,\vect{\cQ}(\vect{u}^{(i)}),\quad i=1,\ldots,s,
  \label{eq:imexStagesRewrite}
\end{equation}
where $c_{ij}$, and $\hat{c}_{ij}=\tilde{c}_{ij}/c_{ij}$ are computed from $\tilde{a}_{ij}$ and $a_{ij}$ (see \ref{app:butcherTables}).
In Eq.~\eqref{eq:imexStagesRewrite}, $\vect{u}^{(0)}=\vect{u}^{n}$.
Two types of IMEX schemes are considered: \emph{type~A} \cite{pareschiRusso_2005,dimarcoPareschi2013} and \emph{type~ARS} \cite{ascher_etal_1997}.
For IMEX schemes of type~A, the matrix $A$ is invertible.
For IMEX schemes of type~ARS, the matrix $A$ can be written as
\begin{equation*}
  \left(
    \begin{matrix}
       0 & 0 \\
       0 & \hat{A}
    \end{matrix}
  \right),
\end{equation*}
where $\hat{A}$ is invertible.
In writing the stages in the IMEX scheme in the general form given by Eq.~\eqref{eq:imexStagesRewrite}, it should be noted that $\tilde{c}_{i0}=0$ for IMEX schemes of Type~A, and $c_{i1}=\tilde{c}_{i1}=0$ for IMEX schemes of Type~ARS \cite{hu_etal_2018}.
Type A schemes can be made convex-invariant by requiring
\begin{align}
  &a_{ii}>0, \quad c_{i0}\ge0, \quad \text{for} \quad i=1,\ldots,s, \nonumber \\
  &\text{and} \quad c_{ij},\tilde{c}_{ij}\ge0, \quad \text{for} \quad i=2,\ldots,s, \quad\text{and}\quad j=1,\ldots,s-1.
  \label{eq:positivityConditionsTypeA}
\end{align}
Similarly, type ARS schemes can be made convex-invariant by requiring
\begin{align}
  &a_{ii}>0, \quad c_{i0},\tilde{c}_{i0}\ge0, \quad \text{for} \quad i=2,\ldots,s, \nonumber \\
  &\text{and} \quad c_{ij},\tilde{c}_{ij}\ge0, \quad \text{for} \quad i=3,\ldots,s, \quad\text{and}\quad j=2,\ldots,i-1.
  \label{eq:positivityConditionsTypeARS}
\end{align}
Coefficients were given in \cite{hu_etal_2018} for GSA schemes of type A with $s=3$ and type ARS with $s=4$.
(It was also proven that $s=3$ and $s=4$ are the necessary number of stages needed for GSA second-order convex-invariant IMEX schemes of type A and type ARS, respectively.)

In Eq.~\eqref{eq:imexStagesRewrite}, the explicit part of the IMEX scheme has been written in the so-called Shu-Osher form \cite{shuOsher_1988}.
For the scheme to be convex-invariant, the coefficients $c_{ij}$ must also satisfy $\sum_{j=0}^{i-1}c_{ij}=1$.
Then, if the expression inside the square brackets in Eq.~\eqref{eq:imexStagesRewrite} --- which is in the form of a forward Euler update with time step $\hat{c}_{ij}\,\dt$ --- is in the (convex) set of admissible states for all $i=1,\ldots,s$, and $j=0,\ldots,i-1$, it follows from convexity arguments that the entire sum on the right-hand side of Eq.~\eqref{eq:imexStagesRewrite} is also admissible.
Thus, if the explicit update with the transport operator is admissible for a time step $\dt_{\mbox{\tiny Ex}}$, the IMEX scheme is convex-invariant for a time step $\dt\le c_{\Sch}\,\dt_{\mbox{\tiny Ex}}$, where
\begin{equation}
  c_{\Sch}=\min_{\substack{i = 2,\ldots,s \\
       j = 1,\ldots,i-1}}\,\f{1}{\hat{c}_{ij}} \quad \text{(Type A)}, \quad  c_{\Sch}=\min_{\substack{i = 2,\ldots,s \\
              j = 0,2,\ldots,i-1}}\,\f{1}{\hat{c}_{ij}} \quad \text{(Type ARS)}.
  \label{eq:imexCFL}
\end{equation}
Here, $c_{\Sch}$ is the CFL condition, relative to $\dt_{\mbox{\tiny Ex}}$, for the IMEX scheme to be convex-invariant.
It is desirable to make $c_{\Sch}$ as large (close to $1$) as possible.
Note that for $\vect{u}^{(i)}$ to be admissible also requires the implicit solve (equivalent to implicit Euler) to be convex-invariant.
In \cite{hu_etal_2018}, Hu et al. provide examples of GSA, convex-invariant IMEX schemes of type A (see scheme PA2 in \ref{app:butcherTables}) and type ARS.
In \ref{app:butcherTables}, we provide another example of a GSA, convex-invariant IMEX scheme of type A (scheme PA2+), with a larger $c_{\Sch}$ (a factor of about $1.7$ larger).

\subsection{Convex-Invariant, Diffusion Accurate IMEX Schemes}

Unfortunately, the correction step in Eq.~\eqref{eq:imexCorrection} deteriorates the accuracy of the IMEX scheme when applied to the moment equations in the diffusion limit.
The diffusion limit is characterized by frequent collisions ($\tau\ll 1$) in a purely scattering medium ($\xi=0$), and exhibits long-time behavior governed by (e.g., \cite{jinLevermore_1996})
\begin{equation}
  \pd{\cJ}{t} + \nabla\cdot\vect{\cH} = 0
  \quad\text{and}\quad
  \vect{\cH} = - \tau\,\nabla\cdot\vect{\cK}.
  \label{eq:diffusionLimit}
\end{equation}
Here the time derivative term in the equation for the particle flux has been dropped (formally $\cO(\tau^{2})$) so that, to leading order in $\tau$, the second equation in Eq.~\eqref{eq:diffusionLimit} states a balance between the transport term and the collision term.
Furthermore, in the diffusion limit, the distribution function is nearly isotropic so that $\vect{\cK}\approx\f{1}{3}\,\cJ\,\vect{I}$ and $\vect{\cH}\approx-\f{1}{3}\,\tau\,\nabla\cJ$.
The absence of the transport operator in the correction step in Eq.~\eqref{eq:imexCorrection}, destroys the balance between the transport term and the collision term.
We demonstrate the inferior performance of IMEX schemes with this correction step in the diffusion limit in Section~\ref{sec:smoothProblems}.
We have also implemented and tested one of the IMEX schemes in Chertock et al. \cite{chertock_etal_2015} (not included in Section~\ref{sec:smoothProblems}), where the transport operator is part of the correction step, and found it to perform very well in the diffusion limit.
However, we have not been able to prove the realizability-preserving property with this approach without invoking a too severe time step restriction.%
\footnote{\modified{For example in the pure absorption case, we find that there is a sufficient time step, proportional to $\sqrt{\tau|K|}$ (as opposed to $|K|$ without the correction step), which guarantees moment realizability.
In numerical experiments, we have observed for the homogeneous sphere problem in Section~\ref{sec:homogeneousSphere} that this approach breaks for stiff problems ($\tau\ll1$) when this restriction is violated.}}
We therefore proceed to design convex-invariant IMEX schemes without the correction step that perform well in the diffusion limit.
We limit the scope to IMEX schemes of type~ARS.
(It can be shown that IMEX schemes of type~A conforming to Definition~\ref{def:PD-IMEX} below do not exist; cf. \ref{app:noTypeA}.)

We take a heuristic approach to determine conditions on the coefficients of the IMEX scheme to ensure it performs well in the diffusion limit.
We leave the spatial discretization unspecified.
Define the vectors
\begin{equation}
  \vec{\cJ}=(\cJ^{(1)},\ldots,\cJ^{(s)})^{T}
  \quad\text{and}\quad
  \vec{\vect{\cH}}=(\vect{\cH}^{(1)},\ldots,\vect{\cH}^{(s)})^{T}.
\end{equation}
(The components of $\vec{\cJ}$ and $\vec{\vect{\cH}}$ can, e.g., be the cell averages evolved with the DG method.)
We can then write the stages of the IMEX scheme in Eq.~\eqref{imexStages} applied to the particle density equation as
\begin{equation}
  \vec{\cJ}=\cJ^{n}\,\vec{\vect{e}} - \dt\,\tilde{A}\,\nabla\cdot\vec{\vect{\cH}},
  \label{eq:numberDensityIMEX}
\end{equation}
where $\vec{\vect{e}}$ is a vector of length $s$ containing all ones, and the divergence operator acts individually on the components of $\vec{\vect{\cH}}$.
Similarly, for the particle flux equation we have
\begin{equation}
  \vec{\vect{\cH}}=\vect{\cH}^{n}\,\vec{\vect{e}}-\dt\,\big(\,\f{1}{3}\tilde{A}\,\nabla\vec{\cJ}+\f{1}{\tau}\,A\,\vec{\vect{\cH}}\,\big).
  \label{eq:numberFluxIMEX}
\end{equation}
In the context of IMEX schemes, the diffusion limit (cf. the second equation in \eqref{eq:diffusionLimit}) implies that the relation $A\,\vec{\vect{\cH}}=-\f{1}{3}\,\tau\,\tilde{A}\,\nabla\vec{\cJ}$ should hold.
Define the pseudoinverse of the implicit coefficient matrix for IMEX schemes of type~ARS as
\begin{equation*}
    A^{-1}
    =\left(
        \begin{matrix}
          0 & 0 \\
          0 & \hat{A}^{-1}
        \end{matrix}
      \right).
\end{equation*}
Then, for the stages $i=1,\ldots,s$,
\begin{equation}
  \vect{\cH}^{(i)}=-\f{1}{3}\,\tau\,\vec{\vect{e}}_{i}^{T}A^{-1}\tilde{A}\,\vec{\vect{e}}\,\nabla\cJ^{n}+\cO(\dt\,\tau^{2}),
\end{equation}
where $\vec{\vect{e}}_{i}$ is the $i$th column of the $s\times s$ identity matrix and we have introduced the expansion $\vec{\cJ}=\cJ^{n}\vec{\vect{e}}+\cO(\dt\,\tau)$.
For $\vect{\cH}^{(i)}$ to be accurate in the diffusion limit, we require that
\begin{equation}
  \vect{e}_{i}^{T}A^{-1}\tilde{A}\,\vect{e} = 1, \quad i=2,\ldots,s.
  \label{eq:diffusionCondition}
\end{equation}
(The case $i=1$ is trivial and does not place any constraints on the components of $A$ and $\tilde{A}$.)
If Eq.~\eqref{eq:diffusionCondition} holds, then
\begin{equation}
  \f{\cJ^{(s)}-\cJ^{n}}{\dt}
  =-\tilde{\vect{w}}^{T}(\nabla\cdot\vec{\vect{\cH}})
  =\f{1}{3}\tau\,\nabla^{2}\cJ^{n}+\cO(\dt\,\tau^{2}),
\end{equation}
which approximates a diffusion equation for $\cJ$ with the correct diffusion coefficient $\tau/3$.
(For a GSA IMEX scheme without the correction step, $\cJ^{n+1}=\cJ^{(s)}$.)

Unfortunately, the ``diffusion limit requirement" in Eq.~\eqref{eq:diffusionCondition}, together with the order conditions given by Eqs.~\eqref{orderConditions1} and \eqref{orderConditions2} (with $\alpha=0$), and the positivity conditions on $c_{ij}$ and $\tilde{c}_{ij}$, result in too many constraints to obtain a second-order accurate convex-invariant IMEX scheme.%
\footnote{It was shown in \cite{hu_etal_2018} --- without the diffusion limit requirement --- that the minimum number of stages for convex-invariant IMEX schemes of type~ARS is four.)
We are also concerned about increasing the number of stages, and thereby the number of implicit solves, since the implicit solve will dominate the computational cost of the IMEX scheme with more realistic collision operators (e.g., inelastic scattering).}
To reduce the number of constraints and accommodate accuracy in the diffusion limit, we relax the requirement of overall second-order accuracy of the IMEX scheme.
Instead, we only require the scheme to be second-order accurate in the streaming limit ($\vect{\cQ}=0$).
This gives the order conditions
\begin{equation}
  \sum_{i=1}^{s}\tilde{w}_{i}=1
  \quad\text{and}\quad
  \sum_{i=1}^{s}\tilde{w}_{i}\,\tilde{c}_{i}=\f{1}{2},
  \label{eq:orderConditionsEx}
\end{equation}
where the first condition (consistency condition) is required for first-order accuracy.
We then seek to design IMEX schemes of Type~ARS conforming to the following working definition
\begin{define}
  Let PD-IMEX be an IMEX scheme satisfying the following properties:
  \begin{enumerate}
    \item Consistency of the implicit coefficients
    \begin{equation}
      \sum_{i=1}^{s}w_{i}=1.
      \label{eq:implicitConsistency}
    \end{equation}
    \item Second-order accuracy in the streaming limit; i.e., satisfies Eq.~\eqref{eq:orderConditionsEx}.
    \item Convex-invariant; i.e. satisfies Eq.~\eqref{eq:positivityConditionsTypeARS}, with $\sum_{j=0}^{i-1}c_{ij}=1$, for $i=1,\ldots,s$, and $c_{\Sch}>0$.
    \item Well-behaved in the diffusion limit; i.e., satisfies Eq.~\eqref{eq:diffusionCondition}.
    \item Less than four stages ($s\le3$).
    \item Globally stiffly accurate (GSA): $a_{si}=w_{i}$ and $\tilde{a}_{si}=\tilde{w}_{i},\quad i=1,\ldots,s$.
  \end{enumerate}
  \label{def:PD-IMEX}
\end{define}
Fortunately, IMEX schemes of type~ARS satisfying these properties are easy to find, and we provide an example with $s=3$ (two implicit solves) in \ref{app:butcherTables} (scheme PD-ARS; see \ref{app:PD-ARS} for further details).
In the streaming limit, this scheme is identical to the optimal second-order accurate SSP-RK method \cite{gottlieb_etal_2001}.
It is also very similar to the scheme given in \cite{mcclarren_etal_2008} (see scheme PC2 in \ref{app:butcherTables}), which is also a GSA IMEX scheme of type ARS with $s=3$.
Scheme PC2 is second-order in the streaming limit, has been demonstrated to work well in the diffusion limit \cite{mcclarren_etal_2008,radice_etal_2013}, and satisfies the positivity conditions in Eq.~\eqref{eq:positivityConditionsTypeARS}.
However, $c_{\Sch}=0$ (our primary motivation for finding an alternative).
In Section~\ref{sec:numerical}, we show numerically that the accuracy of scheme PD-ARS is comparable to the accuracy of scheme PC2.

\subsection{Absolute Stability}

Here we analyze the absolute stability of the proposed IMEX schemes, PA2+ and PD-ARS (given in \ref{app:butcherTables}), following \cite{hu_etal_2018}.
As is commonly done, we do this in the context of the linear scalar equation
\begin{equation}
  \dot{u}=\lambda_{1}\,u+\lambda_{2}\,u,
  \label{eq:scalarODE}
\end{equation}
where $\lambda_{1}\in\mathbb{C}$ and $\lambda_{2}\le0$.
On the right-hand side of Eq.~\eqref{eq:scalarODE}, the first (oscillatory) term is treated explicitly, while the second (damping) term is treated implicitly.
The IMEX schemes can then be written as $u^{n+1} =P(z_{1},z_{2})\,u^{n}$, where $P(z_{1},z_{2})$ is the amplification factor of the scheme, $z_{1}=\dt\,\lambda_{1} = x +iy$, and $z_{2} = \dt\,\lambda_{2} \le 0$.
Stability of the IMEX scheme requires $|P(z_1,z_2)|\leq 1$.
The stability regions of PA2+ and PD-ARS are plotted in Figure~\ref{fig:AbsoluteStability}.
As can be seen from the figures, the absolute stability region of both schemes increases with increasing $|z_{2}|$ (increased damping).
For a given $|z_{2}|>0$, the stability region of PD-ARS is larger than that of PA2+.
In the linear model in Eq.~\eqref{eq:scalarODE}, a time step that satisfies the absolute stability for the explicit part of the IMEX scheme ($|z_2| = 0$) fulfills the stability requirement for the IMEX scheme as whole ($|z_2| \geq 0$).
This holds for all PD-ARS schemes with $\epsilon\in [0,0.5)$.
\begin{figure}[h]
  \centering
  \begin{tabular}{cc}
    \includegraphics[width=0.5\textwidth]{figures/AbsoluteStabilityPARSD}
    \includegraphics[width=0.5\textwidth]{figures/AbsoluteStabilityPA2+}
  \end{tabular}
   \caption{Boundary of the absolute stability region in the $xy$-plane ($x=\operatorname{Re}(z_{1})$, $y=\operatorname{Im}(z_{1})$) for different values of $z_2$ for PD-ARS (with $\epsilon = 0.1$; left panel) and PA2+ (right panel).  Contours of constant $z_{2}$ are included, and the stability region for a given $z_{2}$ is enclosed by the corresponding contour.}
  \label{fig:AbsoluteStability}
\end{figure}

max_stars_repo_name: srichers/thornado

max_issues_repo_name: srichers/thornado

max_forks_repo_name: srichers/thornado


text:
This section is intended to make the developer understand the inner workings of the Colletta frontend, and to allow him or her to add more functionality to the software package.
In order fully understand the contents below, the developer must have a certain degree of familiarity with React and Redux. If that's not the case, we strongly recommend the reader to at least acquire some basic knowledge on the topics.
\subsection{Frontend UML}
To help a better comprehension of the front-end architecture we created the following figure:
\begin{figure}
\centering
\includegraphics[width=15cm, height=18cm]{uml/reactredux.pdf}
\caption{React and Redux architecture}
\end{figure}
\subsection{Directory tree}
\begin{figure}[H]
\centering
\begin{forest}
  for tree={
    font=\ttfamily,
    grow'=0,
    child anchor=west,
    parent anchor=south,
    anchor=west,
    calign=first,
    inner xsep=7pt,
    edge path={
      \noexpand\path [draw, \forestoption{edge}]
      (!u.south west) +(7.5pt,0) |- (.child anchor) pic {folder} \forestoption{edge label};
    },
    before typesetting nodes={
      if n=1
        {insert before={[,phantom]}}
        {}
    },
    fit=band,
    before computing xy={l=15pt},
  }
[Frontend
	[src
		[actions
		]
		[assets
		]
		[constants
		]
		[helpers
		]
		[reducer
		]
		[store
		]
		[view
			[containers]
			[components]
		]
	]
]
\end{forest}
\caption{Frontend directory tree}
\label{fig:BackDir}
\end{figure}

Each folder contains a specific set of files:
\begin{itemize}
	\item \textbf{actions:} the modules in this folder are responsible for creating and dispatching the actions to the reducers;
	\item \textbf{assets:} static files like font and images;
	\item \textbf{constants:} data collections and constants used in various parts of the code, i.e. the label used for the translation;
	\item \textbf{helpers:} standard js functions or classes which have some use in the code, i.e. the label translator;
	\item \textbf{reducers:} all the reducers responsible for the creation of a new state;
	\item \textbf{store:} a single file creating and giving access to the centralized state;
	\item \textbf{view:} classes rendering the information in the store. They are divided in \textit{components} and \textit{containers}.	 The key point to bear in mind when talking about components and containers is the following: containers are "smart", they observe the store and can call actions; components, on the other hand, are basically just static functions.
\end{itemize}

\subsection{Modify or add features}
\subsubsection{Components}
Components extend the React \texttt{component} abstract class and implement the \texttt{render()} method. They can be viewed as a pure functions of the props passed by their father component or container. They do not have access to the store. When adding or modifying a component the following rules should be followed:
\begin{itemize}
	\item Since the global state of the application is managed by Redux, do not use or create the local state of the component. Instead, rely solely on the props;
	\item Helper functions may be defined in the component class, but none of them should call action creators or external resources such as API calls;
	\item All components must be placed in the \texttt{src/component} folder;
	\item Every component which needs to render some text must have a language prop to call to the translator module;
\end{itemize}
When adding a new component, one can start from the following snippet:
\begin{lstlisting}[language=JavaScript, frame=single]
import React, { Component } from 'react';
import _translator from '../../helpers/Translator';
class SampleComponent extends Component {

  render() {
    const { prop1,prop2,prop3 } = this.props;
    //Do stuff here
    return (
      <React.Fragment>
        {/* Stuff to render */}
      </React.Fragment>
    );
  }
}
export default SampleComponent;
\end{lstlisting}

\subsubsection{Containers}
Containers extend the React \texttt{component} abstract class and implement the \texttt{render()} method. They can read the store and alter its state via actions. Containers can also have props passed to them, just like a container. When adding or modifying a component the following rules should be followed:
\begin{itemize}
	\item Since the global state of the application is managed by Redux, do not use or create the local state of the container. Instead, rely solely on the props and on the store;
	\item The store and the actions should not be accessed directly for performance and readability reasons. Instead, they should be mapped to the props;
	\item All containers must be placed in the most appropriate \texttt{src/view/containers} sub-directory. Creation of new sub-directories is allowed if necessary.
\end{itemize}

When adding a new container, one can start from the following snippet:
\begin{lstlisting}[language=JavaScript, frame=single]
import React, { Component } from 'react';
import { connect } from 'react-redux';
import _translator from '../../../helpers/Translator';

class SampleContainer extends Component {

  render() {
    const { prop1, prop2, prop3, action1Prop, action2Prop } = this.props;
    // Do stuff
    return (
      // Stuff to render
    );
  }
}
const mapStateToProps = store => {
  return {
    prop1: store.object1,
    prop2: store.object2,
    prop3: store.object3
  };
};

const mapDispatchToProps = dispatch => {
  return {
    action1Prop: () => dispatch(action1()),
    action2Prop: () => dispatch(action2())
  };
};
//both action1 and action2 must be imported

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(SampleContainer);
\end{lstlisting}

\subsubsection{Rest API calls}
When implementing a new Rest API call (RAP from now on), the developer must stick to the following guidelines:
\begin{itemize}
	\item RAPs must be implemented inside an action creator and should not be put inside components or containers;
	\item RAPs must use the Axios module;
	\item RAPs must pass an authorization token (exception made for Log-in and Sign-up) which is kept in the store. The snippet below will show clarify how;
	\item If a RAP does not need additional data, the data field should be replaced by \texttt{\{\}}, otherwise the response will display a 403 error.
\end{itemize}
When adding a new RAP, one can start from the following snippet:
\begin{lstlisting}[language=JavaScript, frame=single]
export const sampleActionCreator = objectToSend => {
  return dispatch => {
    axios
      .post(
        'http://localhost:8081/sample-call',
        {
          ...objectToSend
        },
        {
          headers: {
            'content-type': 'application/json',
            Authorization: store.getState().auth.token
          }
        }
      )
      .then(response => {
        // Maybe do something
        dispatch({ type: 'SAMPLE-ACTION', dataToDispatch });
      })
      .catch(() => {/* Handle Error Here*/});
  };
};
\end{lstlisting}

\subsubsection{Interface Language}
The multiple languages of the application are implemented via the Translator module in the \texttt{src/helpers} folder. Every single piece of text shown to the user is stored in \texttt{src/constants/Label.js} in all the languages supported by Colletta. Each language is identified by its ISO 639-1 code.\\
Each string variable is composed as follow:
\begin{center}
context\_identifier
\end{center}
where:
\begin{itemize}
\item \textbf{Context} is the component or container in which the string is used. If it is used in more than one component or container, context should be \texttt{gen}. Context must start with a lowercase letter;
\item \textbf{Identifier} should sum up the function of the string. It must start with a lowercase letter.
\end{itemize}
The translated string can than be displayed with the following function:
\begin{center}
\texttt{\_translator('string\_variable', language)}
\end{center}
where:
\begin{itemize}
\item \textbf{String\_variable} is the name of the string you want to render. It must be surrounded by single quotes;
\item \textbf{Language} is a string containing the ISO 639-1 code of the language you want to render the string in.
\end{itemize}
Therefore, whenever one wants to add some new text to some component or container, he or she must add the string in all of the supported languages and render it with the translator module.\\
If instead one wants to implement a new language, the following steps need to be followed:
\begin{enumerate}
\item Every single string in \texttt{Label.js} must be translated and inserted with the ISO 639-1 code of the language;
\item The variable \texttt{UiLang} in \texttt{src/constants/Label.js} must be updated with the ISO 639-1 code of the language;
\item For every language in \texttt{Label.js}, a string in the format \texttt{gen\_xx} must be added, with xx being the ISO 639-1 code of the language. The string must contain the language name. For instance, in English \texttt{gen\_it} is Italian and \texttt{gen\_en} is English.
\end{enumerate}
The following snippet represents a slim-down example of \texttt{Label.js}:
\begin{lstlisting}[language=JavaScript, frame=single]
export const _label = {
  it: {
    account_yourData: 'I tuoi dati',
    dashboard_hiUser: 'Ciao, ',
    executionExercise_complete: 'Completa',
    gen_it: 'Italiano',
    gen_en: 'Inglese'
  },
  en: {
    account_yourData: 'Your data',
    dashboard_hiUser: 'Hello, ',
    executionExercise_complete: 'Submit solution',
    gen_it: 'Italian',
    gen_en: 'English',
  }
};
\end{lstlisting}

\subsubsection{Analysis Languages}
The process for enabling other analysis languages is a little bit more tedious, as it means having to work with the Freeling tagset.
Let's have a brief overview at what needs to be done:
\begin{enumerate}
\item A custom {JSON}\textsubscript{G} tagset must be created starting from the Freeling tagset;
\item The tagset created must be modified to accommodate some conditions;
\item The tagset must be placed in the correct folder.
\end{enumerate}
One can find the {Freeling}\textsubscript{G} tagsets and their description at: \href{https://talp-upc.gitbook.io/freeling-4-1-user-manual/tagsets}{freeling-4-1-user-manual}. Starting from the tables in the Freeling doc, the end result should look like this:
\begin{lstlisting}[language=JavaScript, frame=single]
const italian = {
  adjective: {
    text: { full: 'adjective', short: 'A' },
    attributes: [
      {
        attrName: 'type',
        choices: [
          { short: 'O', full: 'Ordinal' },
          { short: 'Q', full: 'Qualifying ' },
          { short: 'P', full: 'Possessive' }
        ],
        condition: null
      },
      {
        attrName: 'degree',
        choices: [
          { short: 'S', full: 'superlative' },
          { short: '0', full: 'none' }
        ],
        condition: { index: 1, short: 'Q' }
      },
      //...........
\end{lstlisting}
Let's break in down:
\begin{itemize}
\item The outermost level contains the categories of word in the language (i.e. adjective, noun, etc...);
\item Each category has a text value, a name, a condition, and a list of choices. Each choice represents a possible value for the attribute.
\item Choices and text objects of attributes contain two string:
	\begin{itemize}
	\item \textbf{Full}: the name of the choice or category (i.e. Adjective, Ordinal).
	\item \textbf{Short}: the letter corresponding to the choice or the category (i.e. Adjective is A, Ordinal is O.
	\end{itemize}
\end{itemize}
The modifications which have been made from the standard tagset are the following:
\begin{itemize}
\item \textbf{Conditions}: this field is needed to avoid showing the user choices that cannot be taken. For instance, it would make no sense to show the option to select the superlative option if the adjective selected has been marked as possessive. Thus, the condition states that the attribute at \texttt{index: 1} must have \texttt{short: Q}, so it must be qualifying. If no restriction applies, the condition field must be set to null;
\item \textbf{None fields}: looking at the code example above, one may notice the following choice: \texttt{\{ short: '0', full: 'none' \}}. It has been added to let the user to mark an adjective as not superlative. This choice must be added whenever an attribute is not strictly mandatory.
\end{itemize}
Adding conditions and none fields requires a decent understanding of the grammar of a language, and it is a process that must be executed very carefully.\\
Once the file is completed, it can be placed in the \texttt{src/constants} folder, named as \texttt{ger\_xx} where \texttt{xx} is the ISO 639-1 code of the language.\\
Disclaimer: Freeling documentation is not always reliable. The tagset might be incomplete or contain some errors.

max_stars_repo_name: SWEightgroup/Colletta

max_issues_repo_name: SWEightgroup/Colletta

max_forks_repo_name: SWEightgroup/Colletta


text:
\section{Conclusion}

The goal of this thesis has been to present and analyze different matching mechanisms and their properties for one-to-many matching scenarios with one-sided preferences. A variety of optimality criteria exist, but in the end, it is evident that none of the algorithms presented produce matchings that fulfill all of the optimality criteria.

The experiments conducted have shown that the resulting matchings vary greatly by algorithm and structure of the instance. In summary, the Hungarian algorithm usually outperformed all other algorithms on most metrics, but it also had by far the highest runtime. To improve the runtime, different algorithms can be used, such as Rank-Max, that also compute profile-based-optimal matchings. Another insight from the experiments is that Popular-CHA failed to find matchings for a majority of the instances; however, a simple modified version of the algorithm may produce better results than RSD and Max-PaCHA, while having a much lower runtime than the Hungarian algorithm. Still, according to the results of the experiments, popularity seemed to be a less-desirable optimality criterion, due to the fact that popular matchings often only optimize the match for a subset of the students, while leaving the other students with a bad or no match. Therefore, we can recommend the Hungarian or Rank-Max algorithm for the use case of student-seminar matching. To improve the resulting matchings and make strategic manipulation harder, a matching system could require students to supply at least $k$ preferences. This would also partially eliminate the Hungarian's algorithm biggest disadvantage, which is that students are encouraged to provide short preference lists.

As part of this thesis, we have also presented an interactive web-system that allows university administrations to manage and solve such matching problems. The system relies on the C++ algorithms that were used for the benchmark and should offer good performance for typical instances.

max_stars_repo_name: aaronoe/bachelorarbeit

max_issues_repo_name: aaronoe/bachelorarbeit

max_forks_repo_name: aaronoe/bachelorarbeit


text:
\documentclass[12pt]{mpllatex}
\usepackage{examples}

\begin{document}

\section*{Displaying long expressions}

This example uses a simple (though contrived) example of a Taylor series expansion of $1/(1+x)$ to demonstrate the problems that can arise when displaying very long expressions.

\vspace{12pt}

\begin{minipage}[t]{0.45\textwidth}
\begin{maple}
   f   := x -> 1/(1+x):
   ans := f(x):                    # mpl (ans.511,ans)
   ans := series(f(x),x=0, 10):    # mpl (ans.512,ans)
   ans := series(f(x),x=0, 20):    # mpl (ans.513,ans)
   ans := series(f(x),x=0, 23):    # mpl (ans.514,ans)
\end{maple}
\end{minipage}
\hskip 1cm
\begin{minipage}[t]{0.55\textwidth}
\begin{latex}
   \begin{dgroup*}[spread={5pt}]
      \begin{dmath*} f(x) = \Mpl*{ans.511} \end{dmath*}
      \begin{dmath*}    {}= \Mpl*{ans.512} \end{dmath*}
      \begin{dmath*}    {}= \Mpl*{ans.513} \end{dmath*}
      \begin{dmath*}    {}= \Mpl*{ans.514} \end{dmath*}
      \begin{dmath*}    {}= \Mpl*[\hskip 2cm]{ans.514} \end{dmath*}
   \end{dgroup*}
\end{latex}
\end{minipage}

\vspace{18pt}

The first four lines of the following output were set using {\tt\small\verb|\Mpl*|}
while the final line used {\tt\small\verb|\Mpl*[\hskip=2cm]|}. The last pair of lines displays
the output for the same tag {\tt\small ans.514} and clearly the formatting of the second
last line is not ideal as the text has overlapped the tag. This was corrected in the final
line by using the option argument {\tt\small\verb|[\hskip=2cm]|} in the call to {\tt\small\verb|\Mpl*|}.

\begin{dgroup*}[spread={5pt}]
   \begin{dmath*} f(x) = \Mpl*{ans.511} \end{dmath*}
   \begin{dmath*}    {}= \Mpl*{ans.512} \end{dmath*}
   \begin{dmath*}    {}= \Mpl*{ans.513} \end{dmath*}
   \begin{dmath*}    {}= \Mpl*{ans.514} \end{dmath*}
   \begin{dmath*}    {}= \Mpl*[\hskip 2cm]{ans.514} \end{dmath*}% LCB: do we need extra space for the tag?
\end{dgroup*}

\end{document}

max_stars_repo_name: leo-brewin/hybrid-latex

max_issues_repo_name: leo-brewin/hybrid-latex

max_forks_repo_name: leo-brewin/hybrid-latex