\chapter{Introduction}

The study of homotopy theoretic phenomena in the language of type theory \cite{hottbook} is
sometimes loosely called `synthetic homotopy theory' \cite{Brunerie16}.
Homotopy theory in type theory \cite{Awodey12} is only one of the
many aspects of homotopy type theory, which also includes the study of the
set theoretic semantics (models of homotopy type theory and univalence in a
meta-theory of sets or categories \cite{Awodey14,AwodeyWarren,BezemCoquandHuber,KapulkinLeFanuLumsdaine,Shulman15,Voevodsky15}), type theoretic semantics (internal models of homotopy type
theory), and computational semantics \cite{AngiuliHarperWilson}, as well as the study of various questions
in the internal language of homotopy type theory which are not necessarily
motivated by homotopy theory, or questions related to the development of
formalized libraries of mathematics based on homotopy type theory.
This thesis concerns the development of synthetic homotopy theory.

Homotopy type theory is based on Martin-L\"of's theory of dependent types \cite{MartinLof1984}, which
was developed during the 1970's and 1980's.
The novel additions of homotopy type theory are Voevodsky's univalence axiom \cite{Voevodsky06,Voevodsky10},
and higher inductive types \cite{Lumsdaine11Blog,Shulman11Blog,hottbook}. The univalence axiom characterizes the identity
type on the universe, and establishes the universe as an object classifier \cite{RijkeSpitters}.
Higher inductive types are a generalization of inductive types, in which both
point constructors (generators) and path constructors (relations) may be specified.
A simple class of higher inductive types, which includes most known higher inductive
types, are the homotopy pushouts. When the universe is assumed to be closed
under homotopy pushouts, it is also closed under homotopy coequalizers \cite{hottbook},
sequential colimits \cite{hottbook}, and propositional truncation \cite{vanDoorn2016}.
For instance, one way of obtaining the $n$-spheres \cite{Lumsdaine12Blog} using homotopy pushouts is by setting $\sphere{-1}\defeq\emptyt$ and
by inductively defining the $(n+1)$-sphere $\sphere{n+1}$ to be the pushout
of the span $\unit \leftarrow\sphere{n}\rightarrow\unit$.
Then we can attach $(n+1)$-cells to a type $X$.
Let $f:(\sm{a:A}B(a))\to X$ be a family of attaching maps
for some $\sphere{n}$-bundle $B:A\to\mathrm{BAut}(\sphere{n})$, where $\mathrm{BAut}(\sphere{n})$ is the type $\sm{X:\UU}\brck{\eqv{\sphere{n}}{X}}$ of types merely equivalent to the $n$-sphere. We
attach the $(n+1)$-disks indexed by $A$ to $X$ by taking the homotopy pushout
\begin{equation*}
\begin{tikzcd}
\sm{a:A}B(a) \arrow[r,"f"] \arrow[d,swap,"\pi_1"]  & X \arrow[d,"\inr"] \\
A \arrow[r,swap,"\inl"] & P. \arrow[ul,phantom,very near start,"\ulcorner"]
\end{tikzcd}
\end{equation*}
In this thesis we study dependent type theory with univalent universes that are closed under homotopy pushouts, further developing the program set out in \cite{hottbook} on synthetic homotopy theory. We will assume in this dissertation that every type family is classified by a univalent universe, and that all universes are closed under homotopy pushouts, as well as under the usual type constructors including identity types, $\Pi$- and $\Sigma$-types, and a natural numbers object. The model in cubical sets by Coquand et al. \cite{BezemCoquandHuber} is a constructive model for this setup, although the fact that it is closed under homotopy pushouts is currently unpublished. Furthermore, we will exclusively work with objects that can be described either as (dependent) types, or as their terms. In other words, the objects of our study are all `formalizable' in the sense that they can be encoded in computer implementations of our setup of dependent type theory. Existing implementations of dependent type theory, supporting univalent universes and homotopy pushouts, with libraries developing synthetic homotopy theory, include the proof assistants Agda \cite{agda}, Coq \cite{Coq,hcoq}, and Lean \cite{vDvRB2017HoTTLean}, and parts of the material in this theses are formalized in each of them.

%One of the most persisting open problems of synthetic homotopy theory is the problem of defining the type of simplicial objects, or even the type of semi-simplicial objects. Related open problems include the specifications of the types of weak $\infty$-categories, and weak $\infty$-groupoids. In all these problems, the task is to find a way of specifying in type theory the infinite coherence data that these objects come equipped with. Because of this problem, we have currently no way of exhibiting the universe of all small types, and functions between them, as a term in the type of weak $\infty$-categories; there is no way of presenting the suspension operation as a functor, beyond specifying its action on objects, on morphisms, and the composition laws for low dimensions; and there is no way of making precise the suspension-loop space adjunction beyond establishing the universal property of the adjunction. In other words, there are many examples of `categories', `functors', `natural transformations', and `adjunction' that we know \emph{ought to be} adjunctions, but we have no way (yet) of establishing them as such in a formalizable way, i.e.~by exhibiting them as a term of the types of categories, functors, natural transformations, or adjunctions, etc. This is an important limitation of synthetic homotopy theory that we currently have to deal with.

\section{Overview per chapter}
In \cref{chap:univalent} we will first establish notation, although we will mostly follow the notation from \cite{hottbook}\footnote{A difference of practice between \cite{hottbook} and this thesis is that \cite{hottbook} doesn't use the label `Proposition' for any results at all, whereas we use propositions for statements that might be of independent interest, but are not our main theorem. In this thesis, the label `Theorem' is reserved for the main results that were originally established in my thesis research, and is therefore used much more sparingly.}. Furthermore, we recall some of the most basic facts of homotopy type theory, and then we will show that the univalence axiom establishes any universe as an object classifier.

In \cref{chap:descent} we will first recall the most basic properties of homotopy pushouts, and then we will proceed to prove the descent property for pushouts, using the univalence axiom. Note that the coherence problem of type theory plays a role in this chapter: we would much rather have shown that the descent property holds for any homotopy colimit, but this task requires the definition of an internal $\infty$-category. Some solace will be offered in \cref{chap:equifibrant}, where we will prove a descent property for any modality.

In \cref{chap:rcoeq} we will study reflexive graphs and, most importantly, reflexive coequalizers in type theory. We take interest in reflexive graphs, because the topos of reflexive graphs (over sets) is cohesive over the topos of sets. The left-most adjunction is the reflexive coequalizer which is left adjoint to the discrete functor. We will construct the reflexive coequalizer as a pushout, so it exists under our assumptions, and we know in some cases how to compute them into previously known operations. Here we run again into the limitation of homotopy type theory, because we cannot establish the type of reflexive graphs as the type of objects of an $\infty$-category, and neither can we establish the reflexive coequalizer as an $\infty$-functor. However, to state and prove that the reflexive coequalizer satisfies the universal property of the left adjoint of the discrete functor, we only need composition of reflexive graph morphisms, and the action on morphisms of the operation equipping a type with the structure of a discrete graph. The universal property is indeed sufficient for many purposes. We then introduce the notion of fibrations for reflexive graphs, and show that the fibrations are right orthogonal to the same maps as the discrete reflexive graphs: morphisms between representables. It follows that a morphism is a fibration if and only if it is cartesian. Then we proceed to prove the descent property of reflexive coequalizers. We also note that diagrams over reflexive graphs are just left fibrations of reflexive graphs, so we also obtain a descent theorem for diagrams over graphs. Of particular interest in the present work is the descent property for sequential colimits. The contents of this chapter are joint work with Bas Spitters.

In \cref{chap:image} we will show that any function factors as a surjective function followed by an embedding, even though we only assume that the universe is closed under pushouts and the basic type constructors. Of course, it is of essential importance here that the universe contains a natural numbers object. Our construction of the image of a map proceeds by iteratively taking the fiberwise join of a map with itself, so we call it the join construction. It follows from our construction that the image of a map from an essentially small type into a locally small type (notions that are explained in \cref{chap:univalent}), is again essentially small. The join construction can be used to construct the quotient of a type by a $\prop$-valued equivalence relation (i.e.~an equivalence relation in the usual sense), and it can be used to construct the Rezk completion of a pre-category. The construction of set-quotients includes the construction of the set truncation, and the construction of the Rezk completion includes the construction of the $1$-truncation, and of Eilenberg-Mac Lane spaces of the form $K(G,1)$ \cite{FinsterLicata}. Following \cite{FinsterLicata}, the Eilenberg Mac-Lane spaces $K(G,n)$ for $G$ abelian and $n\geq 2$ can be constructed once we have constructed the $k$-truncation for any $k\geq -2$. We note that Eilenberg-Mac Lane spaces are important classifying spaces in higher group theory, and so are the connected components of the universe (which we show to be essentially small).

In \cref{chap:reflective} we consider general reflective subuniverses. Examples that we have at our disposal at this point are the $(-2)$-, $(-1)$-, $0$-, and $1$-truncations. Most examples of reflective subuniverses are obtained by localization at a family of maps. However, since the only assumed homotopy colimits are pushouts, we will construct localizations only in \cref{chap:compact}, and only of families between compact types, because we need more theory in order to establish the necessary basic results. Thus, in \cref{chap:reflective} we focus on general reflective subuniverses. We show that for any reflective subuniverse $L$, the subuniverse $L'$ of $L$-separated types (i.e.~types whose identity types are $L$-types) is again reflective. It follows at once that the subuniverse of $k$-truncated types is reflective, for any $k\geq -2$. Furthermore, we will study several classes of maps related to a reflective subuniverse. First of all, we study the $L$-equivalences, i.e.~the maps that become an equivalence by the functorial action of $L$, and second of all we study the $L$-connected maps, i.e.~ the maps with fibers that become trivial after applying $L$. Clearly, any $L$-connected map is also an $L$-equivalence, but the converse is one of the many characterizations of $L$ being lex given in \cite{RijkeShulmanSpitters}.
Furthermore, we study modalities. One of the characterizations of modalities is as reflective subuniverses that are $\Sigma$-closed, but we provide three more equivalent definitions of modalities. One particularly important alternative definition is that of a stable orthogonal factorization system, i.e.~a pair $(\mathcal{L},\mathcal{R})$ of two classes of maps such that every map factors as an $\mathcal{L}$-map followed by a $\mathcal{R}$-map; the class $\mathcal{L}$ is left orthogonal to the class $\mathcal{R}$; and the pullback of an $\mathcal{L}$-map is again a $\mathcal{L}$-map. For any modality $\modal$, the stable orthogonal factorization system associated to it consists of the $\modal$-connected maps as the $\mathcal{L}$-maps, and the $\modal$-modal maps as the $\mathcal{R}$-maps. A final topic for this chapter is the notion of accessibility for reflective subuniverses and accessible modalities.

The contents from this chapter are selected from \cite{RijkeShulmanSpitters} and \cite{ChristensenOpieRijkeScoccola}. I began to study reflective subuniverses with Mike Shulman and Bas Spitters, and continued to study them with my MRC teammates Morgan Opie and Luis Scoccola, under the lead of Dan Christensen.

In \cref{chap:equifibrant} we recall from \cite{WellenPhD} the notion of $\modal$-\'etale map for an arbitrary modality $\modal$. We prove a modal version of the descent theorem, which asserts that a maps into $\modal X$ from a $\modal$-modal type are equivalently described as \'etale maps into $X$. The $\modal$-\'etale maps form the right class of a second orthogonal factorization system associated to any modality: the \emph{reflective} factorization system. The left class of this factorization system is the class of $\modal$-equivalences. Using this factorization system we obtain that the universal cover of a type $X$ at a point $x_0$ is the left-right-factorization of the map $\unit\to X$.
We then proceed to study the \'etale maps for the modality of discrete reflexive graphs. Note that the type of all reflexive graphs isn't exactly a universe, so it is not possible to directly apply our previous observations about $\modal$-\'etale maps. Nevertheless, most arguments are practically the same. Thus, we treat our section on $\modal$-\'etale maps as a blue-print for our section of $\Delta$-\'etale maps, and do most arguments a second time. Such is the current state of homotopy type theory. What we get out is a generalized flattening lemma, which states that for any morphism $f:\mathcal{B}\to\mathcal{A}$ factors uniquely as an $\Delta$-equivalence followed by a fibration of graphs. We use this to show that the loop space of the suspension of a pointed type $X$ is the free H-space $G$ with a base-point preserving map $X\to_\ast G$. The generalized flattening lemma also applies to diagrams over reflexive graphs, and in particular to sequential colimits. Moreover, the equifibrant replacement can be constructed by a telescope construction. We show in this chapter that sequential colimits commute with $\Sigma$- and identity types, and therefore also with pullbacks. In particular, the sequential colimit operation sends sequences of fiber sequences to fiber sequences. Moreover, we show that sequential colimits commute with $k$-truncation for all $k\geq -2$, from which it follows that sequential colimits commute with $\pi_k$ for any $k\geq 0$. We expect to be able to use these results also in showing that the spectrification of a pre-spectrum is indeed a spectrum, but we haven't done that yet.

The idea of a modal version of the descent theorem first arose in unpublished work on reflexive graphs with Bas Spitters, in the spring of 2016. However, I only learned about $\modal$-\'etale maps much later from Felix Wellen, and many of the results presented in \cref{sec:modal_descent} came out of a discussion I had with Felix Wellen and Mike Shulman, who also brought my attention to the reflective factorization system of a modality, of which the classical case is due to \cite{chk:reflocfact}.
The material in \cref{sec:equifibrant_replacement} on the equifibrant replacement operation on reflexive graphs is joint work with Bas Spitters.
The material in \cref{sec:seqcolim_eqf} on sequential colimits is joint work with Floris van Doorn and Kristina Sojakova \cite{DoornRijkeSojakova}, and all the results concerning sequential colimits are formalized in the proof assistant Lean.

In \cref{chap:compact} we introduce the notion of (sequentially) compact types, in order to provide an application for the results in \cref{chap:equifibrant}. The most important basic result about compact types is that they are closed under pushouts, and in proving this fact we use that sequential colimits commute with pullbacks.
Our main purpose here, and the final main result of this dissertation, is to show that for any family $f$ of maps between compact types, the subuniverse of $f$-local types is reflective, thus providing a fairly large class of reflective subuniverses including types localized away from a prime \cite{ChristensenOpieRijkeScoccola}. It should be noted that all subuniverses of $f$-local types are reflective if enough higher inductive types are assumed. Furthermore, our result about $\omega$-compact types should in principle hold for $\kappa$-compact types for cardinals larger than $\omega$. However, we restrict to the case of $\omega$-compact types since we do not have a good theory of such larger cardinals available in homotopy type theory, while the natural numbers object is right there (by assumption).

\section{Acknowledgments\footnote{I gratefully acknowledge the support of the Air Force Office of Scientific Research through MURI grant FA9550-15-1-0053.}}
First and foremost, it is my pleasure to thank my advisor, professor Steve Awodey. I could not have done this PhD without his advice, support, and inspiration. I cherish the many pleasant discussions we had: over the blackboard, between us, with our many visitors, while visiting other places, or over a beer somewhere in Pittsburgh. I am very grateful for the guidance you offered in selecting a worthwhile research topic, and I feel honored to have had the privilege to work with you.

Then I would like to express my gratitude to the members of my committee: Jeremy Avigad for transmitting his enthusiasm for interactive theorem proving, and for his wisdom and unparalleled kindness; Ulrik Buchholz for his unabated energy to make large formalization projects possible, introducing me to many concepts of algebraic topology along the way; and Michael Shulman for shining a light on many beautiful subjects related to higher category theory, that would otherwise have remained obscure for me.

I would like to thank my other collaborators, the people I had projects with:
Simon Boulier, Dan Christensen, Floris van Doorn, Jonas Frey, Morgan Opie, Luis Scoccola, Kristina Sojakova, Bas Spitters, Nicolas Tabareau, Felix Wellen, and Alexandra Yarosh. I thank you for all your inspiration, insights, energy, and creativity.

I would also like to thank all the people who have generously invited me for a visit. I am deeply indebted to Joachim Kock, who has hosted me for half a year in 2013-2014 at the \textit{Departament de Matemàtiques} of the Universitat Autònoma de Barcelona and helped me finding my PhD position at CMU; I am grateful to Vladimir Voevodsky for inviting me to the Institute for Advanced Study in March 2015; Nicolas Tabareau and his students Kevin Quirin and Simon Boulier for hosting me at INRIA Nantes during the summers of 2015 and 2016; Andrej Bauer for hosting me at the \textit{Fakulteta za Matematiko in Fiziko} of the University of Ljubljana in January 2016; Lars Birkedal and Bas Spitters for hosting me at the Department of Computer Science of Aarhus University in February 2016; Marie-Françoise Roy for inviting me to speak in the Effective Geometry and Algebra seminar at the \textit{Institut de Recherche Mathématiques de Rennes} in June 2016; Dan Christensen and his student Luis Scoccola for hosting me at the University of Western Ontario in London, Ontario in October 2017; Guillaume Brunerie for hosting me at the Institute for Advanced Study in November 2017; Charles Rezk and his student Nima Rasekh for inviting me to speak in the Topology Seminar at the University of Illinois at Urbana-Champaign in December 2017; Tom Hales for inviting me to speak at the Algebra, Combinatorics, and Geometry seminar at the University of Pittsburgh in April 2018; and Pieter Hofstra for inviting me to speak for the Canadian Mathematical Society in Fredericton, New Brunswick, in June 2018. Tak, dankjewel, thank you, merci, danke sch\"on, spasibo, \v dankujem, hvala, gracias.

I would like to thank Karin Arnds for lending me her cabin along the Allegheny River, where I wrote and rewrote significant parts of this dissertation.

Finally, I thank my dear parents Mieke and Reinier for their unconditional support, and my siblings Jeroen, Sophie, and Fleur, whom I didn't get to see as much as I would have liked because I chose to study overseas. I miss you and I dedicate this thesis to you.\\[2em]

\noindent \hfill Pittsburgh, \today


\documentclass[letter]{article}
\renewcommand{\baselinestretch}{1.25}

\usepackage[margin=1in]{geometry}
\usepackage{physics}
\usepackage{amsmath}
\usepackage{graphicx}
%\usepackage{pythonhighlight}
\usepackage{hyperref}
\usepackage{fancyvrb}

% MATLAB Formating Code
\usepackage[numbered,framed]{matlab-prettifier}
\lstset{style=Matlab-editor,columns=fullflexible}
\renewcommand{\lstlistingname}{Script}
\newcommand{\scriptname}{\lstlistingname}

% Command for easier minimization problem def
\newcommand{\optpblm}[3][eq:default]{
	\begin{equation}\label{#1}
% Array method... more centered
%		\begin{array}{rl}
%			\text{minimize}  \hspace{0.2in} &#2 \vspace{5pt}\\
%			\text{subject to} \hspace{0.2in} &#3
%		\end{array}
% Aligned method... left aligned... idk if its better
		\begin{aligned}
			\text{minimize} \hspace{0.5in} &#2\vspace{5pt}\\
			\text{subject to \hspace{0.5in}} &#3
		\end{aligned}
	\end{equation}
}

\newcommand{\maxpblm}[3][eq:default]{
	\begin{equation}\label{#1}
		\begin{aligned}
			\text{maximize} \hspace{0.5in} &#2\vspace{5pt}\\
			\text{subject to \hspace{0.5in}} &#3
		\end{aligned}
	\end{equation}
}
\allowdisplaybreaks

\title{MECH 6327 - Homework 5}
\author{Jonas Wagner}
\date{2021, May 3}

\begin{document}

\maketitle

\tableofcontents

\newpage
\section{Control Design via SDP}
Consider the linearized model of a Cessna Citation Aircraft (at 5000m, at speed 128.2 m/s)
\begin{equation}
	\begin{aligned}
		\dot{x} &= \mqty[-1.2822 & 0 & 0.98 &0\\
						 0 & 0 &1 &0\\
						 -5.4293 &0 &-1.8366 &0\\
						 -128.2 &128.2 &0 &0] x
				+ \mqty[-0.3\\ 0\\ -17\\ 0] u
				+ \mqty[0\\ 0\\ 1\\0]w
		y		&= \mqty[0&1&0&0\\ 0&0&0&1\\ 0&0&0&0] x
				+ \mqty[0\\0\\1]u
	\end{aligned}
\end{equation}
with control input $u$ = elevator angle, states $x_1$ = angle of at-
tack, $x_2$ = pitch angle, $x_3$ = pitch rate, and $x_4$ = altitude (all
relative to nominal), performance output $y$, and pitch rate disturbance input $w$.\\

\noindent
\textbf{Problem:}
Use the SDP formulations discussed in class to compute the optimal state feedback controller to minimize both the $\mathcal{H}_2$- and $\mathcal{H}_\infty$-norm from disturbance input $w$ to output $y$.
Also provide the optimal value for the respective closed-loop system norms.

\subsection{$\mathcal{H}_2$-norm}
The procedure outlined in class was implimented in CVX as seen in \appendixname \ \ref{apx:matlab_pblm1}, which resulted with the following results:
\begin{Verbatim}
K_H2 =

	-44.6546   56.8903    1.7838    1.0000

Norm_H2 =

	0.5000
\end{Verbatim}

\subsection{$\mathcal{H}_\infty$-norm}
The procedure outlined in class was implimented in CVX as seen in \appendixname \ \ref{apx:matlab_pblm1}, which resulted with the following results:
\begin{Verbatim}
K_Hinfty =

	1.0e+05 *

	-0.9457    1.1643    0.0299    0.0281

Norm_Hinfty =

	0.1330
\end{Verbatim}

\newpage
\section{Model Predictive Control (MPC)}
Suppose the elevator angle input is limited to $\pm0:262$rad ($\pm 15$ degrees), the elevator angle rate is limited to $\pm0:524$rad/s ($\pm 30$ degrees/s), and we would like to limit the pitch angle to $\pm 0.349$ rad ($\pm 20$ degrees). Consider the time discretized system with sampling period dt = 0:25s, and discrete-time dynamics matrices $A = e^{A_c \dd{t}}, B = \dd{t} B_c + \frac{1}{2} \dd{t} A_c B_c + \frac{1}{6} \dd{t}^2 A_c^2 B_c$, where $A_c$ and $B_c$ are the
above continuous time state space matrices.

\subsection{LQR Implementation}
\textbf{Problem:}
Compute the optimal infnite-horizon LQR controller by solving the discrete-time algebraic Riccati equation with $Q = I$ and $R = 10$.
Simulate the closed-loop system from initial state $x0 = \mqty[0 &0 &0 &10]^T$ but saturate the LQR controller to the input (magnitude and rate) constraints.\\

\noindent
\textbf{Solution:}
The calculation of an LQR controller gain was computed in MATLAB (\appendixname \ \ref{apx:matlab_pblm2}) and resulted in the following controller gain:
\begin{Verbatim}
K_LQR =

	2.6795   -3.6639   -0.1890   -0.0447
\end{Verbatim}

This was then simulated with the required saturation constraints as can be seen in \figurename \ \ref{fig:pblm2lqr}.

It is clear that the LQR controller had difficulty stabilizing the system given the saturation requirements on the elevator position and rate. It is not only clear that the control signal was saturated and limited by the maximum rate requirements, but that state $x_2$ is well outside of the desired bounds. (It is also just obvious that the system is unstable and will likely continue with increasing magnitudes periodic movements)

\begin{figure}[p]
	\centering
	\includegraphics[width=\linewidth]{fig/pblm2_LQR_sys_response}
	\includegraphics[width=\linewidth]{fig/pblm2_LQR_ctrl_signal}
	\caption{System response and control signal for the implementation of an infinite time LQR controller.}
	\label{fig:pblm2lqr}
\end{figure}

\newpage
\subsection{MPC Implementation}
\textbf{Problem:}
Implement a model predictive controller with horizon $T_h = 10$ sample periods and constant quadratic cost parameters $Q = I$ and $R = 10$ that explicitly accounts for the elevator angle and pitch constraints.
Simulate the closed-loop system from initial state $x0 = \mqty[0 &0 &0 &10]^T$ and compare to the LQR controller.
Determine using your implementation how short the MPC planning horizon can be reduced before stability problems arise.\\

\noindent
\textbf{Solution:}
The MPC was implimentated in MATLAB (\appendixname \ \ref{apx:matlab_pblm2}) and was then tested for multiple time horizons.

\subsubsection{$T_h = 10$}
In the original implementation (\figurename \ \ref{fig:pblm2mpcT10}), the controller is very effective (especially in comparison to the LQR controller). It is clear that the MPC implementation was able to intrinsically limit itself to the control limitations while also stabilizing the system effectively and within the desired timeframe while also staying within the ranges of $x_2$ dictated by the design goals.

\begin{figure}[p]
	\centering
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T10_sys_response}
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T10_ctrl_signal}
	\caption{System response and control signal for the implementation of an MPC with $T_h = 10$.}
	\label{fig:pblm2mpcT10}
\end{figure}

\subsubsection{$T_h = 5$}
The MPC implementation for $T_h = 5$ (\figurename \ \ref{fig:pblm2mpcT5}) was also effective. Compared to the longer time-horizon implementations, the system appears to have slightly larger control-signal magnitudes as well as a faster, yet more volatile, response for the individual state responses.

\begin{figure}[p]
	\centering
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T5_sys_response}
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T5_ctrl_signal}
	\caption{System response and control signal for the implementation of an MPC with $T_h = 5$.}
	\label{fig:pblm2mpcT5}
\end{figure}

\subsubsection{$T-h = 3$}
The MPC implementation for $T_h = 3$ (\figurename \ \ref{fig:pblm2mpcT3}) the system no longer stabalizable. Compared to the longer time-horizon implementations, the system has a troublesome appearance of uncontrolled ossilations that untimely cause state $x_2$ to reach outside of the desired bounds.

\begin{figure}[p]
	\centering
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T3_sys_response}
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T3_ctrl_signal}
	\caption{System response and control signal for the implementation of an MPC with $T_h = 3$.}
	\label{fig:pblm2mpcT3}
\end{figure}

\subsubsection{$T-h = 20$}
A very different result occurs when the time-horizon is increased, as opposed to decreased. The MPC implementation for $T_h = 20$ (\figurename \ \ref{fig:pblm2mpcT20}) is even more effective then the original $T_h = 10$ implementation. All of the states quickly stabalized and are then maintained with very little control effort.

\begin{figure}[p]
	\centering
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T20_sys_response}
	\includegraphics[width=\linewidth]{fig/pblm2_MPC_T20_ctrl_signal}
	\caption{System response and control signal for the implementation of an MPC with $T_h = 20$.}
	\label{fig:pblm2mpcT20}
\end{figure}

\newpage
\appendix
\section{MATLAB Code:}\label{apx:matlab}
All code I write in this course can be found on my GitHub repository:\\
\href{https://github.com/jonaswagner2826/MECH6337}{https://github.com/jonaswagner2826/MECH6327}
\lstinputlisting[caption={MECH6327\_HW5},label={script:HW5}]{MECH6327_HW5.m}
\newpage
\subsection{Problem 1 Code}\label{apx:matlab_pblm1}
\lstinputlisting[caption={MECH6327\_HW5\_pblm1},label={script:HW5_pblm1}]{MECH6327_HW5_pblm1.m}
\newpage
\subsection{Problem 2 Code}\label{apx:matlab_pblm2}
\lstinputlisting[caption={MECH6327\_HW5\_pblm2},label={script:HW5_pblm2}]{MECH6327_HW5_pblm2.m}

\end{document}


\section{Introduction}
\label{sec:intro}

In Section \ref{sec:method}, we \ldots

\section{Method}
\label{sec:method}

\begin{equation}
\label{eq:euler}
e^{i\pi} + 1 = 0
\end{equation}

By \eqref{eq:euler} on page
\pageref{eq:euler}, we have \ldots


\section{Cryptographic hash algorithms}
\label{sec:hashalgs}
%
\index{Preimage resistance}
\index{Second-preimage resistance}
\index{Collision resistance}
A hash algorithm is a function assigning a given key to a value of fixed width $n$. Formally we define a hash function as $h: \{0, 1\}^* \rightarrow \{0, 1\}^n$. Hash functions in cryptography have to fulfill three requirements%
~\cite[2]{Cry02}:
%
\begin{description}
  \item[Preimage resistance.] It is computationally infeasible to find a preimage
    $x$ for any given $y$ such that $h(x) = y$.
  \item[Second-preimage resistance.] It is computationally infeasible to find a
    second preimage $x'$ for any given $x$ such that $h(x) = h(x')$ with $x \neq x'$.
  \item[Collision resistance.] It is computationally infeasible to find two preimages
    $x$ and $x'$ such that $h(x) = h(x')$ with $x \neq x'$.
\end{description}

\section{SAT-based attacks}
\label{sec:sat_attacks}
%
% REMARK: https://github.com/vegard/sat2013-cryptocompo
Every year, new \gls{sat} solvers in the \gls{sat} competition~\cite{Sat21} emerge and use new techniques to improve upon solving problems in three categories: real-world applications, combinatorial hard and random problems.

SAT-based attacks on cryptographic hash functions describe the approach to represent a hash function in \gls{cnf} and solve the equation system with a \gls{sat} solver to look for preimages and collisions. Prior work in this field was done including:

\index{XOR clauses}
\begin{itemize}
  \item
Ekawat Homsirikamol, Paweł Morawiecki, Marcin Rogawski and Marian Srebrny~\cite{Cry04} evaluated the security margin of SHA-3 candidates. On the one hand they applied brute-force attacks to perform preimage attacks\footnote{The authors point out that an easy modification leads to a second preimage or collision attack.} and on the other hand they compare the number of broken rounds to the total number of rounds in the given cryptographic system. The first task can be subdivided into 3 parts: Generation of the CNF formula, fixing the hash and its padding bits in the formula and running a \gls{sat} solver on the generated CNF. They conclude that all five SHA-3 contest finalists have substantially bigger security margins than the SHA-256 and SHA-1 standards in regards of SAT-based attacks.
  \item
A paper ``Extending SAT Solvers to Cryptographic Problems'' by Mate Soos, Karsten Nohl and Claude Castelluccia~\cite{Cry06} builds the foundation of \cmsat{}; the \gls{sat} solver used in this bachelor's thesis. It describes a possible extension of the input algebra for XOR operations. Cryptographic primitives often use XOR operations and the authors expect performance improvements for SAT-based attacks using Gaussian elimination. \cmsat{}~2.9.10 was used in our implementation which natively uses \emph{XOR clauses}. \cmsat{} release~3.0 discarded XOR clauses, but they returned in release 4.0.
  \item
Dejan Jovanović and Predrag Janičić~\cite{Sat03} described a framework to transform a hash algorithm implementation into a SAT problem instance. They use C++'s operator overloading to replace the semantics of the operators with the corresponding boolean ones. When transforming the problem into a CNF, they used Tseitin's Definitional Normal Form with linear growth of size rather than an exponential approach which is taken in this thesis. They concluded that a whole MD4 or MD5 instance cannot be evaluated with their implementation, but the problem can be scaled down by reducing the size of the input message or reducing the number of rounds. The paper has a very similar motivation, but this thesis targets differential cryptanalysis.
  \item
Gaëtan Leurent, Nicky Mouha and Bart Preneel~\cite{Sat10}\cite{Sat11} use the same differential characteristics theory used throughout this document. Gaëtan Leurent describes his design for a similar automated search; this document uses the one described in~\cite{Cry07}. Nicky Mouha and Bart Preneel also explain their own search strategies. In their usecase they try to increase the ``weight'' of differential characteristics. A SAT solver is used to determine whether a particular differential characteristic of a given weight exists. The encoding was not discussed explicitly and a Simple Theorem Prover solved their problem to create a CNF for a given equation. These papers are especially interesting to discuss search strategies and encoding approaches for hash algorithms.
\end{itemize}

\section{Differential cryptanalysis}
\label{sec:differential}
\index{Differential cryptanalysis}
%
\index{Evaluation instances}
In \emph{differential cryptanalysis} we consider the difference between \emph{evaluation instances}. We call an evaluation instance a hash function $f$ mapping some given input $M$ (derived from two parameters $A$ and $B$) to some output $C$. Now consider two evaluation instances. The difference between those instances in every step of the evaluation of the function $f$ is of interest for us. In Figure~\ref{fig:diff_cryptanalysis} an example with two instances $M$ and $M^*$ is illustrated.

Xiaoyun Wang successfully reduced the complexity of MD4, the original RIPEMD design and MD5 in 2005~\cite{Cry10} which made differential cryptanalysis popular in the research community.

In our thesis we want to discuss how differential characteristics can be encoded in boolean algebra. Fabio Massacci was the first to apply SAT research to cryptographic problems and coined the name \emph{logical cryptanalysis}~\cite{Cry05b}. Our implementation specifically combines the fields of differential cryptanalysis and logical cryptanalysis.

In all following sections we always assume \emph{two} existing evaluation instances.
%
\begin{figure}[h]
  \begin{center}
    \includegraphics{img/diff_cryptanalysis.pdf}
    \caption{Two evaluation instances in differential cryptanalysis and their difference.}
    \label{fig:diff_cryptanalysis}
  \end{center}
\end{figure}

\subsection{Differential characteristics}
\label{sec:differential-characteristic}
%
In the following we want to describe a notation introduced by Christophe De Cannière and Christian Rechberger in their paper ``Finding SHA1-Characteristics: General Results and Applications''~\cite{Cry01}.

\index{Bit condition}
This notation allows us to represent the difference between two bits. In general we have to distinguish four cases, but we also want to model uncertainty, meaning that for example two of these four cases are \emph{possible}. Table~\ref{tab:bitconditions} lists all 16 possible so-called \emph{bit conditions}.

Let's consider bit condition symbol ``\bc{C}''. If the difference between two bits is specified with \bc{C}, 2 out of 4 cases are allowed for the two bits\footnote{Recognize that two configurations in Table~\ref{tab:bitconditions} are checked for the symbol \bc{C}.}. The first bit is zero or one, but the second bit has to be one. Another popular example are the difference bit conditions \bc{x} and \bc{\textendash}. If the difference is specified with \bc{x}, the two bits must have different values. In case of a bit condition \bc{\textendash} the values have to be equivalent.

\index{Free bit condition}
\index{Contradiction}
There are also two special bit conditions. The bit condition \bc{?} is called the \emph{free bit condition}, because nothing can be said about the state of any bit. The bit condition \bc{\#} is called \emph{contradiction} because no state is possible for both bits which immediately leads to a detected contradiction within the differential system.

We will use this notation throughout the document to denote the difference between bits in each evaluation instance. The superset relation between the bit conditions can be retrieved from the Galois lattice given in Figure~\ref{fig:bitconditions-lattice}.

\begin{table}[p]
 \begin{center}
  \begin{tabular}{ccccc}
   \hline
    $(X_i, X_i^*)$ & (0, 0) & (1, 0) & (0, 1) & (1, 1) \\
   \hline \hline
         ?         & \yes   & \yes   & \yes   & \yes   \\
         -         & \yes   & \no    & \no    & \yes   \\
         x         & \no    & \yes   & \yes   & \no    \\
         0         & \yes   & \no    & \no    & \no    \\
         u         & \no    & \yes   & \no    & \no    \\
         n         & \no    & \no    & \yes   & \no    \\
         1         & \no    & \no    & \no    & \yes   \\
         \#        & \no    & \no    & \no    & \no    \\
         3         & \yes   & \yes   & \no    & \no    \\
         5         & \yes   & \no    & \yes   & \no    \\
         7         & \yes   & \yes   & \yes   & \no    \\
         A         & \no    & \yes   & \no    & \yes   \\
         B         & \yes   & \yes   & \no    & \yes   \\
         C         & \no    & \no    & \yes   & \yes   \\
         D         & \yes   & \no    & \yes   & \yes   \\
         E         & \no    & \yes   & \yes   & \yes   \\
   \hline
  \end{tabular}
  \caption[Bit conditions table]{Bit conditions table (most-left column specifies symbol).}
  \label{tab:bitconditions}
 \end{center}
\end{table}
\begin{figure}[p]
 \begin{center}
  \includegraphics{img/bit_condition_lattice.pdf}
  \caption{Galois lattice of bit conditions.}
  \label{fig:bitconditions-lattice}
 \end{center}
\end{figure}

\index{Differential characteristic}
\index{Bitslice}
\index{Differential word}
In conclusion we introduced a notation to describe which bit configurations for two bits are possible in a certain state. A \emph{differential characteristic} represents a certain state of a hash algorithm in differential cryptanalysis. It is a list of bit conditions often represented as a matrix for better readability. A \emph{bitslice} is a column in a given differential characteristic. Analogously a \emph{differential word} is a row in a given differential characteristic.

\section{Evaluating differential characteristics}
\label{sec:diffchar-examples}
%
Several popular hash algorithms are built using the ARX architecture\footnote{The MD5, SHA-1 and SHA-2 hash algorithms follow the ARX design principle.}. One of the letters in the name refers to the XOR operation taking two or more arguments. The XOR operator returns true iff the number of arguments with value true is odd. The hash algorithm specification states which arguments an operation is applied to.

As an example we assume a simple algorithm which applies XOR bitslice-by-bitslice. Therefore we have 3 differential words with 2 words as input arguments and 1 word as output. We take a simple example:
\begin{center}
  \begin{diffchar}
    A: 1111 \\
    A: 0010 \\
    S: 1101
  \end{diffchar}
\end{center}
XOR is defined by the formula $S = A_0 \oplus A_1$. We evaluate the first (right-most) bitslice. Substituting the variables of the formula with the values leads to a valid equation which shows that no contradiction was found. We consecutively apply the formula to the other bitslices. All four bitslices define a valid equation, which shows that this differential characteristic is satisfied. Be aware that 0 and 1 describe bit conditions and therefore describe the state of 2 evaluation instances, but for this particular bit conditions the values in both instances are the same.

Let's take the second bitslice from Figure~\ref{dc:xor4}. In this case the equation $x = x \oplus \mbox{--}$ is given. To evaluate this equation, we have to iterate over all possible bit configurations. We denote a zero as first bit and one as second bit as $(0, 1)$. Given $(0, 1) = (0, 1) \oplus (0, 0)$ the equation is valid, because $0 = 0 \oplus 0$ and $1 = 1 \oplus 0$ are valid statements. We list all possible configurations and compute the left side as result of the right-hand side formula:
\begin{align*}
    (0, 1) &= (0, 1) \oplus (0, 0) \\
    (1, 0) &= (1, 0) \oplus (0, 0) \\
    (1, 0) &= (0, 1) \oplus (1, 1) \\
    (0, 1) &= (1, 0) \oplus (1, 1)
\end{align*}
As we can observe in this exhaustive list, the left-hand side can always be described with a difference between the two bits; thus bit condition \bc{x}. Whenever this derived bit condition is a superset of the bit condition in the output argument, satisfiability is given.

Figure~\ref{dc:xor-examples} shows examples for satisfiable differential characteristics. If we apply the XOR operation on each bitslice, the output value corresponds to the given bit condition. Correspondence here means that any possible outcome of the function is part of the specified output argument.
%
\begin{figure}[t]
  \begin{center}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: 1 \\
        A: 0 \\
        S: 1
      \end{diffchar}
      \caption{SAT}
      \label{dc:xor1}
    \end{subfigure}%
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: 1 \\
        A: 0 \\
        S: ?
      \end{diffchar}
      \caption{SAT}
      \label{dc:xor2}
    \end{subfigure}%
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: 0001 \\
        A: 1010 \\
        S: 1011
      \end{diffchar}
      \caption{SAT}
      \label{dc:xor3}
    \end{subfigure}%
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: C\textendash{}\textendash{}? \\
        A: 3xx0 \\
        S: x?x?
      \end{diffchar}
      \caption{SAT}
      \label{dc:xor4}
    \end{subfigure}
    \caption{Examples for satisfiable differential characteristics (XOR operation).}
    \label{dc:xor-examples}
  \end{center}
\end{figure}
\begin{figure}[t]
  \begin{center}
    \begin{diffchar}
      A: BC0 \\
      A: 501 \\
      S: \textendash{}10
    \end{diffchar}
    \caption{An unsatisfiable differential characteristic (XOR operation).}
    \label{dc:xor-faulty}
  \end{center}
\end{figure}

In Figure~\ref{dc:xor1} a one as result in both instance is satisfiable for the XOR operation. In Figure~\ref{dc:xor2} we also have a satisfiable result, because \bc{?} is a superset of \bc{1}. Figure~\ref{dc:xor3} just illustrates the simultaneous application of the XOR operation to each bitslice of the differential characteristic. Figure~\ref{dc:xor4} provides more complex examples. For the second bitslice (from the right) the XOR operation applied to an input argument of equal values in both instances and an input argument with different values, the result will always be a difference between both instances. The third bitslice shows again a superset relation between \bc{?} and \bc{x}. In the fourth bitslice we also have to distinguish 4 cases (\bc{C} and \bc{3} can be 2 cases each) and if we evaluate the result, the bits in both instances will always be different.

A bit condition taken twice as input arguments to XOR is always \bc{0}. If a contradiction occurs in an input argument, the result is a contradiction. In Figure~\ref{dc:xor-faulty} an unsatisfiable differential characteristic is given. It is unsatisfiable, because some application of the XOR operation does not result in the specified bit condition; actually all applications will fail. The second bitslice is unsatisfiable, because if \bc{C} represents a 0 in the first instance and a 1 in the second instance, the application of XOR will return a 0 and 1 in each instance respectively which is not covered by the bit condition \bc{1}. The third bitslice has two input arguments which actually allows any possible result and relation between the values in each instance. Thus the bit condition \bc{-} is too strict.

Evaluating the satisfiability of a differential characteristic is the main requirement to enable our automated search.

\section{\nltool}
\label{sec:nltool}
%
\nltool{} is a framework for differential cryptanalysis. It provides various hash algorithm implementations and also allows to run partial subsets (like steps or rounds as defined by the particular hash algorithm). It implements a search algorithm trying to derive knowledge about some differential state of the hash algorithm evaluation. This propagation is a crucial task of the tool and this implementation improves upon existing ones. The tool and the details of the search got introduced in the paper~\cite[293]{Cry07}. For our implementation it is important to distinguish between two states within the search:

\begin{description}
  \item[Initialization.]
    At initialization the hash algorithm (to be used) is known and the structure of the differential characteristic can be retrieved. The value of any bit condition is not yet available.
  \item[Update BitCondition.]
    In the update step the values of the differential characteristic are provided and the final decision about satisfiability of the characteristic can be made.
\end{description}

Finding the best paths to derive new knowledge about the state is an open research topic. Differential paths are described in the master thesis ``Cryptanalysis of MD4'' by Martin Schläffer~\cite{Cry15} and an attack is given in the paper ``Collision Attacks on the Reduced Dual-Stream Hash Function RIPEMD-128''~\cite{Cry08}.

\section{Automated search}
\label{sec:automated-search}
%
The search strategy applied to SHA-256 is a more sophisticated version than the one proposed by~\cite[10]{Cry01} and was proposed in the paper ``Finding SHA-2 Characteristics: Searching Through a Minefield of Contradictions''~\cite[298]{Cry07}:
\begin{quote}
Let \emph U be the set of all \texttt{`?'} and \texttt{`x'}, then repeat the following until U is empty.
\begin{enumerate}
  \item Pick randomly a bit in \emph U.
  \item Impose a \texttt{`-'} for a \texttt{`?'} or randomly a sign (\texttt{`u'} or \texttt{`n'}) for \texttt{`x'}.
  \item Compute the propagation.
  \item If a contradiction is detected start backtracking, else apply additional checks.
  \item Continue with step 1 if all checks passed, if not start backtracking.
  \item If the decision bit is \texttt{`x'} try the second choice of the sign or if the decision bit \texttt{`?'} impose a \texttt{`x'}
  \item If a contradiction still occurs, mark bit as critical.
  \item Jump back until the critical bit can be resolved.
  \item Continue with step 1.
\end{enumerate}
\end{quote}

\index{Overlapping bits}
The interesting point here is that the SAT solver implementation provides better propagation results. In the initialization step the reused values are known and the SAT solver implementation only creates boolean variables for values whenever they occur the first time. \emph{Overlapping bit} detection for two-bit conditions (as mentioned in \cite[296]{Cry07}) is an improvement of \nltool{} provided in this implementation. Overlapping bits are bit conditions which are used twice in a differential characteristic (and thus within the hash algorithm). So they always have the same value.

\section{Testcases for the Addition and Sigma function}
\label{sec:add-sigma-testcases}
%
Tables~\ref{dc:tcs-addition} and \ref{dc:tcs-sha2} list various testcases for the Addition and Sigma function and their satisfiability state.

\begin{itemize}
  \item The Addition function uses carry bits\footnote{Denoted by a differential word C.} whose values are used in the next bitslice and is defined by \\
    \index{Addition function}
    \begin{minipage}{0.48\textwidth}
      \begin{align*}
        s_0 &= a_0 \oplus b_0 \\
        c_1 &= a_0 \land b_0 \\
        s_1 &= a_1 \oplus b_1 \oplus c_1 \\
        c_2 &= (a_1 \land b_1) \lor (b_1 \land c_1) \lor (c_1 \land a_1)
      \end{align*}
    \end{minipage}
    \begin{minipage}{0.48\textwidth}
      \begin{align*}
        s_2 &= a_2 \oplus b_2 \oplus c_2 \\
        c_3 &= (a_2 \land b_2) \lor (b_2 \land c_2) \lor (c_2 \land a_2) \\
        s_3 &= a_3 \oplus b_3 \oplus c_3
      \end{align*}
    \end{minipage}

  \item The Sigma function is defined by
    \index{Sigma function (SHA-2)}
    \begin{align*}
        A: b_0 &= a_1 \oplus a_2 \oplus a_3 \\
        B: b_1 &= a_2 \oplus a_3 \oplus a_0 \\
        C: b_2 &= a_3 \oplus a_0 \oplus a_1 \\
        S: b_3 &= a_0 \oplus a_1 \oplus a_2
    \end{align*}
\end{itemize}

$a_0$ refers to the most-right value of the differential word A using zero-based indexing. $a_1$, $b_0$ and others are defined respectively.

So in conclusion both functions above reuse bits of the previous bitslice. Previous implementations in our \nltool{} could not detect such \emph{overlapping bits} and this detection provides a better propagation result in the automated search, because cases where the overlapping bit condition differs must not be tested.

%Figure~\ref{fig:sigma-vis} tries to visualize the reuse of the values in the function with colors.
%
%\begin{figure}[t]
%  \begin{center}
%    \includegraphics{img/sigma.pdf}
%    \caption{Values of the Sigma function visualized.}
%    \label{fig:sigma-vis}
%  \end{center}
%\end{figure}

\begin{figure}[p]
  \begin{center}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: 0011 \\
        B: 0101 \\
        S: 1000
      \end{diffchar}
      \caption{SAT}
      \label{dc:tcs-addition-1}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: 0011 \\
        B: 0101 \\
        S: 0000
      \end{diffchar}
      \caption{UNSAT}
      \label{dc:tcs-addition-2}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
       A: \textendash{}\textendash{}\textendash{}x \\
       B: \textendash{}\textendash{}\textendash{}x \\
       S: ???x
      \end{diffchar}
      \caption{UNSAT}
      \label{dc:tcs-addition-3}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: \textendash{}\textendash{}\textendash{}x \\
        B: \textendash{}\textendash{}\textendash{}x \\
        S: ???\textendash{}
      \end{diffchar}
      \caption{SAT}
      \label{dc:tcs-addition-4}
    \end{subfigure}
  \end{center}%

  \begin{center}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: \textendash{}\textendash{}\textendash{}x \\
        B: \textendash{}\textendash{}\textendash{}x \\
        S: ????
      \end{diffchar}
      \caption{SAT}
      \label{dc:tcs-addition-5}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: \textendash{}\textendash{}\textendash{}\textendash{} \\
        B: \textendash{}\textendash{}\textendash{}x \\
        S: x\textendash{}??
      \end{diffchar}
      \caption{UNSAT}
      \label{dc:tcs-addition-6}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: \textendash{}\textendash{}\textendash{}x \\
        B: \textendash{}\textendash{}\textendash{}x \\
        S: x???
      \end{diffchar}
      \caption{SAT}
      \label{dc:tcs-addition-7}
    \end{subfigure}
  \end{center}
  \caption{Testcases for the ADD2 function (addition with 2 input arguments).}
  \label{dc:tcs-addition}
\end{figure}

\begin{figure}[p]
  \begin{center}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: \textendash{}\textendash{}\textendash{}\textendash{} \\
        S: 0000
      \end{diffchar}
      \caption{SAT}
      \label{dc:tcs-sigma-1}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: 7C\textendash{}3 \\
        S: \textendash{}3u?
      \end{diffchar}
      \caption{SAT}
      \label{dc:tcs-sigma-2}
    \end{subfigure}
  \end{center}

  \begin{center}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: \textendash{}\textendash{}\textendash{}x \\
        S: 0000
      \end{diffchar}
      \caption{UNSAT}
      \label{dc:tcs-sigma-3}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: xxxx \\
        S: 0000 \\
      \end{diffchar}
      \caption{UNSAT}
      \label{dc:tcs-sigma-4}
    \end{subfigure}
    \begin{subfigure}[b]{0.23\textwidth}
      \begin{diffchar}
        A: 0uCD \\
        S: ADC7 \\
      \end{diffchar}
      \caption{SAT}
      \label{dc:tcs-sigma-5}
    \end{subfigure}
  \end{center}
  \caption{Testcases for the SHA-2 Sigma function.}
  \label{dc:tcs-sha2}
\end{figure}

We will discuss the differential characteristic~\ref{dc:tcs-addition-4} in more detail as an example. We have two evaluation instances and the first bitslice claims that the two input arguments for the Addition function are different between the instances. In this case we claim that the output arguments are equal. Table~\ref{tab:tcs-addition-4-first-bitslice} lists all possible cases for the given characteristic. To verify that we can check that the column $s_0$ always indicates that the values in both instances are equal. As far as this list is exhaustive, the questions is whether we can make stronger statements for this characteristic. No, we derived some information for the carry bit, but more specific bit conditions cannot be taken. Also no contradiction occurs. Bit conditions don't contradict with the operation rendering this differential characteristic valid, ie. satisfiable.

\begin{table}[t]
  \begin{center}
    \begin{tabular}{l|cccc}
     \hline \hline
                 & $a_0$ & $b_0$ & $s_0$ & $c_1$ \\
     \hline
      instance 1 &   0   &   0   &   0   &   0  \\
      instance 2 &   1   &   1   &   0   &   1  \\
     \hline
      instance 1 &   0   &   1   &   1   &   0  \\
      instance 2 &   1   &   0   &   1   &   0  \\
     \hline
      instance 1 &   1   &   0   &   1   &   0  \\
      instance 2 &   0   &   1   &   1   &   0  \\
     \hline
      instance 1 &   1   &   1   &   0   &   1  \\
      instance 2 &   0   &   0   &   0   &   0  \\
     \hline \hline
    \end{tabular}
    \caption{List of possibilities for the bits of the first bitslice in Figure~\ref{dc:tcs-addition-4}.}
    \label{tab:tcs-addition-4-first-bitslice}
  \end{center}
\end{table}


% !TeX program = pdflatex
% !BIB program = biber

\section{Put More Complicated Derivations and Proofs Here}
\label{sec:app:derivations}

\subsection{Appendix Subsection}
\label{sec:app:derivations:one}

\blindmathtrue
\Blindtext[1]

\blindlistlist[3]{enumerate}[4]

\def\Pr{\ensuremath{\mathbb{P}}}
\def\rmd{\mathup{d}}
The typeset math below follows the ISO recommendations that only variables be set in italic. Note the use of upright shapes for ``$\rmd$,'' ``$\mathup{e}$,'' and ``$\piup$.'' (These are entered as \texttt{\textbackslash mathup\{d\}}, \texttt{\textbackslash mathup\{e\}}, and \texttt{\textbackslash mathup\{\textbackslash pi\}}, respectively.)

\begin{theorem}[Simplest form of the \emph{Central Limit Theorem}]
	Let $X_1, X_2, \cdots$ be a sequence of i.i.d. random variables with mean $0$
	and variance $1$ on a probability space $(\Omega,\mathcal{F},\Pr)$. Then
	\[\Pr\left(\frac{X_1+\cdots+X_n}{\sqrt{n}}\le y\right)\to\mathfrak{N}(y) \coloneqq
	\int_{-\infty}^y \frac{\mathup{e}^{-v^2/2}}{\sqrt{2\mathup{\pi}}}\,
	\mathup{d}v\quad\mbox{as $n\to\infty$,}\]
	or, equivalently, letting $S_n \coloneqq \sum_1^n X_k$,
	\[\mathbb{E} f\left(S_n/\sqrt{n}\right)\to \int_{-\infty}^\infty f(v)
	\frac{\mathup{e}^{-v^2/2}}{\sqrt{2\mathup{\pi}}}\,\mathup{d}v
	\quad\mbox{as $n\to\infty$, for every $f\in\mathup{b}
	\mathcal{C}(\mathbb{R})$.}\]
\end{theorem}

\subsection{Salience}
\label{sec:app:salience}

Salience theory \citep{Bordalo2012, Bordalo2013} represents a~behavioral model according to which the most distinctive features of the available alternatives receive a~particularly large share of attention and are therefore over-weighted. More precisely, a~particular attribute out of all attributes of an~alternative becomes the more salient, the more it differs from that attribute's average level over all available alternatives.

Formally, alternatives are assumed to be uniquely characterized by the values they take in ${T \geq 1}$ attributes (or, ``dimensions''). Utility is assumed to be additively separable in attributes, and salience attaches a~decision weight to each attribute of each good which indicates how salient the respective attribute is for that good. Suppose an agent chooses one alternative from some finite choice set $\CS$. Let $t$ index the $T$~different attributes, and let $k$ index the $K$~available alternatives. Let $u_t(\cdot)$ denote the function which assigns utility to values in dimension~$t$.
Denote by $a^k_{t}$ the level of attribute $t$ of good $k$ and define ${u^k_t \coloneqq u_t(a^k_t)}$ as the utility that dimension $t$ of good~$k$ yields. Let $\overline{u}_t$ be the average utility level, across all $K$~goods, of dimension~$t$. The salience of each dimension of good~$k$ is determined by a~symmetric and continuous salience function ${\sigma(\cdot, \cdot)}$ that satisfies the following two properties:
\begin{enumerate}
\item \emph{Ordering.} Let ${\mu \coloneqq \mathrm{sgn}(u^k_t - \overline{u}_t)}$. Then for any ${\epsilon,\epsilon' \geq 0}$ with ${\epsilon + \epsilon' > 0}$, it holds that~
\begin{equation}
	\sigma(u^k_t + \mu\,\epsilon, \overline{u}_t - \mu\,\epsilon') > \sigma (u^k_t,\overline{u}_t).
\end{equation}
\item \emph{Diminishing sensitivity.} For any ${u^k_t, \overline{u}_t \geq 0}$ and all ${\epsilon > 0}$, it holds that
\begin{equation}
	\sigma(u^k_t + \epsilon, \overline{u}_t + \epsilon) < \sigma(u^k_t,\overline{u}_t).
\end{equation}
\end{enumerate}

Following the smooth salience characterization proposed in \cite[p.\,1255]{Bordalo2012}, each dimension $t$ of good $k$ receives weight $\Delta^{-\sigma(u^k_t, \overline{u}_t)}$, where ${\Delta \in (0, 1]}$ is a~constant that captures an~agent's susceptibility to salience. ${\Delta = 1}$ gives rise to a~rational decision maker, and the smaller $\Delta$, the stronger is the salience bias. We call an~agent with ${\Delta < 1}$ a~salient thinker.

A~reference with a~large number of authors is \cite{Henrich2005}.


\section{Introduction}

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{figures/overview.png}
\caption{Optimization Overview}
\end{figure}

There are two fundamental types of Optimization
\begin{itemize}
    \item Continuous Optimization
    \begin{itemize}
        \item \textbf{Infinitely} many solutions, represented by continuous variables
        \item Main body of this theory is the \textbf{local optimization}
        \item Usually based on differential information
        \item E.g. using the gradient (1st derivative), which points in the direction of maximal function increase ("steepest ascent")
    \end{itemize}
    \item Discrete Optimization
    \begin{itemize}
        \item Only \textbf{finitely} many solutions, represented by integer variables
        \item Possibility of solving real-world problems
        \item Goal is to solve a specific problem in a reasonable time with a "good" algorithm
    \end{itemize}
\end{itemize}

\subsection{Complexity Theory}

Die Komplexitäts-Theorie beschreibt mit Hilfe der Zeit, die ein Algorithmus benötigt, um ein spezifisches Problem zu lösen, die Effektivität dieses Algorithmus.

\begin{itemize}
    \item Runtime depends on the size of the problem
    \item Best complexity is a linear growth of the runtime
    \item Size of the problem is somehow the number of bits for the parameters
    \item To make it HW \& SW independent, we focus on elementary operations in the code (e.g. addition, substraction, ...)
    \item We go for the most difficult instance of a given size n $\Rightarrow$ Worst Case
    \item Big O-Notation, $O(g(n))$, Big O of g.
    \item An algorithm is good, if his runtime is polynomial
    \item An algorithm is bad, if his runtime is exponential
\end{itemize}

\clearpage


%
% Last Revision: $Rev$
% Revision date: $Date$
% Author: $Author$
%
%\documentclass[10pt, openany]{report}
\documentclass[10pt, openany]{article}

\usepackage{fancyhdr}
\usepackage{multind}
\usepackage{geometry}
\usepackage{longtable}
\usepackage{color}
\usepackage[english]{isodate}
\geometry{letterpaper}
%
% Rules to allow import of graphics files in EPS and PDF format
%
\usepackage{pstricks}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.eps}
\DeclareGraphicsRule{.eps}{eps}{.eps}{}
\DeclareGraphicsExtensions{.pdf}
\DeclareGraphicsRule{.pdf}{pdf}{.pdf}{}
\DeclareGraphicsExtensions{.png}
\DeclareGraphicsRule{.png}{png}{.png}{}
%
% Rules to add a "DRAFT" watermark to the output.
%
\usepackage{graphicx}
\usepackage{type1cm}
\usepackage{eso-pic}
\makeatletter
\newcommand{\watermark}[1]{
\AddToShipoutPicture{%
            \setlength{\@tempdimb}{.5\paperwidth}%
            \setlength{\@tempdimc}{.5\paperheight}%
            \setlength{\unitlength}{1pt}%
            \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){%
        \makebox(0,0){\rotatebox{45}{\textcolor[gray]{0.75}%
        {\fontsize{6cm}{6cm}\selectfont{#1}}}}%
            }%
}}
\makeatother
%\watermark{Draft}
%
% Other commands
%
\newcommand{\comment}[1]{\color{red}#1}
%
% Setup page headers and footers
%
\fancypagestyle{plain}
{
  \fancyhf{}
  \fancyhead[L]{Air Pressure Gradient in a Rotating Space Station}
  \chead{}
  \rhead{}
  \fancyfoot[L]{Personal Investigation}
  \fancyfoot[R]{Page \thepage}
  \renewcommand{\headrulewidth}{0.4pt}
  \renewcommand{\footrulewidth}{0.4pt}
}

\pagestyle{fancy}
\fancyhead{}
\lhead{Air Pressure Gradient in a Rotating Space Station}
\chead{}
\rhead{}
\lfoot{Personal Investigation}
\cfoot{Brent Seidel}
\rfoot{Page \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
%
% Front Matter
%
\title{Air Pressure Gradient in a Rotating Space Station}
\author{Brent Seidel}
\date{ \today }
%========================================================
%%% BEGIN DOCUMENT
\begin{document}
\maketitle
\begin{abstract}
A formula for computing the air pressure at various distances from the center of a rotating space station is developed.
\end{abstract}
\tableofcontents
\listoffigures
\addcontentsline{toc}{section}{List of Figures}
\listoftables
\addcontentsline{toc}{section}{List of Tables}
%========================================================
\section{Introduction}

Artificial gravity in a radially symmetric space station can be created by rotating it around its axis.  From this, it is theoretically possible to construct a space station with roughly earth-like conditions on the inside surface.  This idea has been explored in fiction, most notably \emph{2001: A Space Odyssey}\cite{Kubrick:1968ve} and \emph{Babylon 5}\cite{:1993dq}.  The book \emph{Eon}\cite{Bear:1985fj}, describes a hollowed out asteroid rotating to produce artificial gravity.  In this case the air pressure is less than earth normal and the rotation produces about 0.6 of earth's gravity.  Larry Niven's \emph{Ringworld}\cite{Niven:1977rz} is perhaps the ultimate expression of a rotating cylinder space station with a radius equal to about one AU.

A formula giving the air pressure at any distance from the center of a rotating space station is desired.

%========================================================
\section{Development}
The coordinates in the space station are $x$, the distance along the axis, $r$, the distance from the axis of rotation, and $\theta$, the angle from a fixed reference point.  Note that this coordinate system is rotating.  A number of parameters and constants are defined in Table~\ref{tbl:Param}.

\begin{table}[ht]
\centering
\caption{Definition of Parameters}
\vspace{1ex}
\label{tbl:Param}
\begin{tabular}{|l|l|l|l|}
\hline
Parameter & Description & Value & Dimensions\\ \hline
$r$ & Distance from axis of rotation & & $m$\\ \hline
$R_{1}$ & Radius of space station & & $m$\\ \hline
$A_{0}$ & Acceleration at $R_{1}$ & 9.8 & $m \times s^{-2}$\\ \hline
$\Delta V$ & Small volume & $r \times \Delta x \times \Delta r \times \Delta\theta$ & $m^{3}$\\ \hline
$\omega_{0}$ & Angular velocity of space station & $\sqrt{\frac{A_{0}}{R_{1}}}$ & $radians^{2}$\\ \hline
$p$ & Air pressure & & $kPa$\\ \hline
$P_{1}$ & Air pressure at outside inner surface & 101.325 & $kPa$\\ \hline
$V$ & Volume & & $m^{3}$\\ \hline
$n$ & Number of molecules & & $mol$\\ \hline
$R$ & Ideal gas constant & 8.314472 & $J \times K^{-1} \times mol^{-1}$\\ \hline
$T$ & Temperature & 293.15 & $K$\\ \hline
$M$ & Molar mass of the gas & & $g \times mol^{-1}$\\ \hline
$M_{air}$ & Approximate molar mass of air & 0.029 & $kg \times mol^{-1}$\\ \hline
\end{tabular}
\end{table}

The centripetal force is given by:
\begin{equation}\label{eq:Force}
F=mr\omega^2
\end{equation}

With some manipulation of (\ref{eq:Force}), the angular velocity can be determined to be:
\begin{equation}\label{eq:Angular}
\omega_{0} = \sqrt{\frac{A_{0}}{R_{1}}}
\end{equation}

The ideal gas law is:
\begin{equation}\label{eq:Gas}
pV=nRT
\end{equation}

The mass of a quantity of gas is given by:
\begin{equation}\label{eq:Mass}
m = nM
\end{equation}

Assuming that air consists of 75\% Nitrogen and 25\% Oxygen, we have a molar mass of air ($M_{air}$) approximately 29 g/mol.

Substituting (\ref{eq:Mass}) into (\ref{eq:Gas}) and solving for mass gives:
\begin{equation}\label{eq:MassGas}
m=\frac{pVM_{air}}{RT}
\end{equation}

Substituting (\ref{eq:MassGas}) into (\ref{eq:Force}) gives the force (weight) of a small volume of gas:
\begin{equation}\label{eq:ForceGas}
F = \frac{p\Delta VM_{air}r\omega^2}{RT}
\end{equation}

Since pressure is force divided by area, we can obtain the pressure contribution of this small volume as:
\begin{equation}\label{eq:Press1}
\Delta p = \frac{\Delta F}{\Delta x \times r\Delta\theta} = \frac{pM_{air}\omega^{2}}{RT} \times \frac{r \times \Delta x \times \Delta r \times r\Delta\theta}{r \times \Delta x \times \Delta\theta}
\end{equation}

Simplifying and canceling (\ref{eq:Press1}) and substituting the angular velocity from \ref{eq:Angular} gives:
\begin{equation}\label{eq:Press2}
\Delta p =  \frac{pM_{air}A_{0}}{RTR_{1}} r\Delta r
\end{equation}

Since $M_{air}$, $A_{0}$, $R$, $T$, and $R_{1}$ are constants and $p$ is a function of $r$, (\ref{eq:Press2}) can be rewritten as:
\begin{equation}\label{eq:Press3}
\Delta p = k p(r) r\Delta r
\end{equation}

Where
\begin{equation}\label{eq:Constants}
k = \frac{M_{air}A_{0}}{R_{1}RT}
\end{equation}

Plugging in known values and canceling units in (\ref{eq:Constants}) gives:
\begin{equation}\label{eq:ConstNum}
k = \frac{0.029 \frac{kg}{mol} \times 9.8 \frac{m}{s^{2}}}{R_{1} \times 8.314472 \frac{J}{K \times mol} \times 293.15 K} = \frac{1.662 \times 10^{-4}}{R_{1}}\times m^{-1}
\end{equation}

Taking the limit of (\ref{eq:Press3}) as $\Delta r$ approaches zero give the differential equation:
\begin{equation}\label{eq:Press4}
dp = kp rdr
\end{equation}

This has a solution of the form:
\begin{equation}\label{eq:Solution}
p(r) = Ce^{\frac{kr^{2}}{2}}, p(R_{1}) = P_{1}
\end{equation}

The value of the constant $C$ can now be determined as:
\begin{equation}\label{eq:SolConst}
C=\frac{P_{1}}{e^{\frac{M_{air}A_{0}R_{1}}{2RT}}}
\end{equation}

Note that both constants, $k$ and $C$ are both functions of the size, $R_{1}$ of the space station, which gives a formula
\begin{equation}\label{eq:SolR1r}
p(R_{1}, r) = \frac{P_{1}}{e^{\frac{M_{air}A_{0}R_{1}}{2RT}}} \times e^{\frac{M_{air}A_{0}r^{2}}{2R_{1}RT}}
\end{equation}

This can be rewritten as:
\begin{equation}\label{eq:SolMod}
p(R_{1}, r) = P_{1}e^{\frac{M_{air}A_{0}(r^{2}-R_{1}^{2})}{2R_{1}RT}}
\end{equation}

Putting in numbers where possible gives (note that $R_{1}$ and $r$ are in meters):
\begin{equation}\label{eq:SolNum}
P(R_{1}, r) = 101.325kPa\times e^{\frac{5.83 \times 10^{-5}(r^{2}-R_{1}^{2})}{R_{1}}}
\end{equation}

A contour plot of this function is shown in Figure~\ref{fig:PressContour}.  The air pressures are given in kPa, where standard atmospheric pressure is slightly greater than 100 kPa.  Figure~\ref{fig:PressAxis} shows the air pressure at the axis of the station for various sizes of the station.  For comparison, elevations for some air pressures are given in Table~\ref{tbl:AirPress}.

\begin{figure}[!ht]
  \centering
  \includegraphics[scale=0.7]{fig1.pdf}
  \vspace{1ex}
  \caption{Air Pressure Curves for Various Space Station Sizes}
  \label{fig:PressContour}
\end{figure}

\begin{figure}[!ht]
  \centering
  \includegraphics[scale=0.7]{fig2.pdf}
  \vspace{1ex}
  \caption{Air Pressure at Axis for Various Space Station Sizes}
  \label{fig:PressAxis}
\end{figure}

\begin{table}[ht]
\centering
\caption{Air Pressure per Elevation on Earth}
\vspace{1ex}
\label{tbl:AirPress}
\begin{tabular}{|l|l|}
\hline
Pressure (kPa) & Altitude (ft\\ \hline
100 & Sea Level\\ \hline
80 & 6600\\ \hline
60 & 14500\\ \hline
40 & 24750\\ \hline
20 & 41000\\ \hline
\end{tabular}
\end{table}

%========================================================
\section{Conclusions}
The air at the center of a rotating space station should be easily breathable for stations up to about 4000 meters in radius.  People would be able to acclimatize to the air pressure at the center of a 9000 meters radius station.

For a sufficiently large station, the decrease in pressure would reduce the need for pressure sealing along the axis.  Larry Niven's \emph{Ringworld}\cite{Niven:1977rz} is a rather extreme example of this situation.

Note that the pressures given should be considered an approximation.  There will no doubt be fluctuations due to weather and similar effects.  Also, temperature has been assumed to be constant.  Further investigation could be done to consider the effects of temperature varying with altitude.
%
% Setup bibliography
%
\clearpage
%========================================================
\addcontentsline{toc}{section}{References}
\bibliography{Bibleography}
\bibliographystyle{alpha}

\end{document}


\section{Derivations}
\noindent
We can use the definition of the Laplace transform and the fact that the Laplace transform is a linear operator to find the Laplace transform of some common functions.

% constant
\input{./laplaceTransforms/derivations/constant.tex}
% exponential
\input{./laplaceTransforms/derivations/exponential.tex}
% sin and cos
\input{./laplaceTransforms/derivations/sincos.tex}
% nth derivative
\input{./laplaceTransforms/derivations/nthDerivative.tex}
% polynomial
\input{./laplaceTransforms/derivations/polynomial.tex}
% translation
\input{./laplaceTransforms/derivations/translation.tex}
% derivative of laplace transforms
\input{./laplaceTransforms/derivations/derivativeOfLaplace.tex}
% Examples
\input{./laplaceTransforms/derivations/laplace_examples.tex}

\noindent
The Laplace transforms of these common functions are summarized in the appendix.


% -*-latex-*-

\title{Orbiter Technical Notes: Dynamic state vector propagation}
\author{Martin Schweiger}
\date{June 10, 2006}

\documentclass[a4paper]{article}
\usepackage[dvips]{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{times}
\usepackage{cite}
\usepackage{epstopdf}

\begin{document}
\bibliographystyle{unsrt}

\newcommand{\ACC}{\ensuremath\mathrm{A}}
\newcommand{\AACC}{\ensuremath\mathrm{T}}
\newcommand{\Euler}{\ensuremath\mathrm{E}}

%\renewcommand{\vec}[1]{\ensuremath{\mathbf{#1}}}

\newcommand{\vR}[1]{\ensuremath{\vec{R}_{#1}}}
\newcommand{\nR}[1]{\ensuremath{|\vR{#1}|}}

\maketitle

\section{Introduction}
This document describes the numerical integration methods used by Orbiter to propagate vessel state vectors from one time point to the next. The time step intervals can vary over a large range, both due to variations in the computational complexity of rendering a frame for the 3D scenery, and due to support for ``time compression'' up to $10^5 \times$ real time.
To avoid the accumulation of numerical errors during the simulation, integration schemes of adequate accuracy must be chosen.
Where the time intervals become too large to allow sufficiently accurate numerical integration of the state vectors, Orbiter can switch to ``orbit stabilisation'', a variant of \emph{Encke's method}, where only the perturbations on top of a base line 2-body orbit defined by its osculating elements are integrated numerically.

\section{Polynomial interpolation methods}
Let $\vec{r}_n$ and $\vec{v}_n$ be the state vectors of a vessel at time $t_n$, given in some coordinate system. Let the interval to the next step $t_{n+1}$ be given by $\Delta t_n = t_{n+1}-t_n$.
 In the following, we assume that the gravitational acceleration $\vec{a}_g$ at any position $\vec{r}$ and any time $t$ between $t_n$ and $t_{n+1}$ can be computed. Further we assume that any additional forces $\vec{a}_0$ (thrust, atmospheric drag, etc.) are constant between $t_n$ and $t_{n+1}$.
\begin{equation*}
\vec{a}(t) = \vec{a}_g(t,\vec{r}(t)) + \vec{a}_0 \equiv \ACC(t,\vec{r}),\qquad t \in [t_n, t_{n+1}]
\end{equation*}
where operator $\ACC$ formally denotes the function call providing the forces acting on the vessel at an arbitrary time within $[t_n, t_{n+1}]$.
This will generally involve the summation of numerically calculated gravitational potentials from relevant celestial bodies.
The equation of motion is then given by the 2nd order differential equation
\begin{equation}\label{eq:motion}
\ddot{\vec{r}} = \ACC(t,\vec{r})
\end{equation}
The following sections describe methods used in the Orbiter code to solve the initial value problem of propagating $(\vec{r}_n,\vec{v}_n)$ to $(\vec{r}_{n+1},\vec{v}_{n+1})$.

\subsection{Linear interpolation, single pass [L/s]}
Given state vectors ($\vec{r}_n$, $\vec{v}_n$) and $\vec{a}_n = \ACC(t_n,\vec{r}_n)$, and interval $h=\Delta t_n$, calculate $(\vec{r}_{n+1},\vec{v}_{n+1})$ using a predictor-corrector method with a linear interpolation of $\vec{a}$.
Let
\begin{equation*}
\vec{r}_{n+1}^{(0)} = \vec{r}_n + h\vec{v}_n + \frac{1}{2} h^2\vec{a}_n
\end{equation*}
be the predicted new position under the assumption of constant $\vec{a}(t) = \vec{a}_n$. (Zero-th order approximation).
Recalculate the acceleration at the predicted position:
\begin{equation*}
\vec{a}_{n+1}^{(0)} = \ACC(t_{n+1},\vec{r}_{n+1}^{(0)})
\end{equation*}
Assume a linear interpolation of $\vec{a}$ between $t_n$ and $t_{n+1}$:
\begin{equation*}
\vec{a}(t) = \vec{a}_n + (\vec{a}_{n+1}^{(0)}-\vec{a}_n)\frac{t-t_n}{h},
\qquad t \in [t_n, t_{n+1}].
\end{equation*}
Then the state vector updates are given by
\begin{equation}
\begin{split}
\Delta\vec{v}^{(0)} &= \int_{t_n}^{t_{n+1}} \vec{a}(t) dt = \frac{1}{2}h (\vec{a}_n+\vec{a}_{n+1}^{(0)}) \\
\Delta\vec{r}^{(0)} &= \int_{t_n}^{t_{n+1}} \vec{v}(t) dt = \int_{t_n}^{t_{n+1}} \vec{v}_n + \vec{a}(t)t dt = h\vec{v}_n + \frac{1}{2}h\Delta\vec{v}^{(0)} \label{eq:lin_pos_upd}
\end{split}
\end{equation}
and thus
\begin{equation*}
\begin{split}
\vec{r}_{n+1} &= \vec{r}_n + \Delta\vec{r}^{(0)} \\
\vec{v}_{n+1} &= \vec{v}_n + \Delta\vec{v}^{(0)}
\end{split}
\end{equation*}

\subsection{Linear interpolation, double pass [L/d]}
The above method can be iterated further to provide a second correction. Given the position update of Eq.~\ref{eq:lin_pos_upd}, re-calculate the gravitational acceleration
\begin{equation*}
\vec{a}_{n+1}^{(1)} = \ACC(t_{n+1},\vec{r}_n+\Delta\vec{r}^{(0)})
\end{equation*}
and use the new acceleration estimate for the interpolation:
\begin{equation*}
\begin{split}
\Delta\vec{v}^{(1)} &= \frac{1}{2}h (\vec{a}_n+\vec{a}_{n+1}^{(1)}) \\
\Delta\vec{r}^{(1)} &= h\vec{v}_n + \frac{1}{2}h\Delta\vec{v}^{(1)}
\end{split}
\end{equation*}
and
\begin{equation*}
\begin{split}
\vec{r}_{n+1} &= \vec{r}_n + \Delta\vec{r}^{(1)} \\
\vec{v}_{n+1} &= \vec{v}_n + \Delta\vec{v}^{(1)}
\end{split}
\end{equation*}

\subsection{Quadratic interpolation, single pass [Q]}
To use a second-order interpolation of $\vec{a}(t)$ between $t_n$ and $t_{n+1}$, we first propagate the position by a half-step,
\begin{equation*}
\vec{r}_{n+\frac{1}{2}}^{(0)} = \vec{r}_n + \frac{h}{2} \vec{v}_n + \frac{1}{2}\left(\frac{h}{2}\right)^2\vec{a}_n
\end{equation*}
and find the mid-point acceleration,
\begin{equation}
\vec{a}_{n+\frac{1}{2}}^{(0)} = \ACC\left(t_n+\frac{h}{2},\vec{r}_{n+\frac{1}{2}}^{(0)}\right)\label{eq:acc_quad_half}
\end{equation}
which is then used to propagate across the full step,
\begin{equation*}
\vec{r}_{n+1}^{(0)} = \vec{r}_n + h\vec{v}_k + \frac{1}{2}h^2\vec{a}_{n+\frac{1}{2}}^{(0)}
\end{equation*}
and
\begin{equation}
\vec{a}_{n+1}^{(0)} = \ACC(t_{n+1},\vec{r}_{n+1}^{(0)})\label{eq:acc_quad_full}
\end{equation}
We now assume a quadratic behaviour of $\vec{a}(t)$ between $t_n$ and $t_{n+1}$:
\begin{equation*}
\vec{a}(t) = \vec{a}_n + \vec{c}_1 (t-t_n) + \vec{c}_2 (t-t_n)^2
\qquad t \in [t_n, t_{n+1}].
\end{equation*}
With Eqs.~\ref{eq:acc_quad_half} and \ref{eq:acc_quad_full} we can determine
$\vec{c}_1$ and $\vec{c}_2$ as
\begin{equation*}
\begin{split}
\vec{c}_1 &= \frac{-3\vec{a}_n - \vec{a}_{n+1}^{(0)} + 4\vec{a}_{n+\frac{1}{2}}^{(0)}}{h} \\
\vec{c}_2 &= \frac{2(\vec{a}_n + \vec{a}_{n+1}^{(0)} - 2 \vec{a}_{n+\frac{1}{2}}^{(0)})}{h^2}
\end{split}
\end{equation*}
and again integrate for obtaining the state vector updates:
\begin{equation*}
\begin{split}
\Delta\vec{v}^{(0)} &= \int_{t_n}^{t_{n+1}} \vec{a}(t) dt = h\vec{a}_n + \frac{h^2}{2} \vec{c}_1 + \frac{h^3}{3} \vec{c}_2 \\
\Delta\vec{r}^{(0)} &= \int_{t_n}^{t_{n+1}} \vec{v}(t) dt = h\vec{v}_n + \frac{h^2}{2}\vec{a}_n + \frac{h^3}{6}\vec{c}_1 + \frac{h^4}{12}\vec{c}_2
\end{split}
\end{equation*}

\section{Runge-Kutta methods [RK]}\label{sec:rk}
Given the first-order differential equation
\begin{equation}\label{eq:firstorder}
\dot{y} = f(t,y(x))
\end{equation}
the step from $y_n$ to $y_{n+1}$ can be developed by a Taylor series expansion
\begin{equation*}
y_{n+1} = y_n + \frac{dy}{dt}\frac{h}{1!} + \frac{d^2y}{dt^2}\frac{h^2}{2!} + \frac{d^3y}{dt^3}\frac{h^3}{3!} + \ldots
\end{equation*}
By truncating at order $N$, the formal development scheme for Runge-Kutta solvers of order $N$ is given by a series of $R$ terms ($R \geq N$):
\begin{equation}\label{eq:rk_term}
\begin{split}
k_1 &= h f(t,y) \\
k_2 &= h f(t+\alpha_1 h, y+\beta_{11} k_1) \\
k_3 &= h f(t+\alpha_2 h, y+\beta_{21} k_1+\beta_{22} k_2) \\
k_{j+1} &= h f(t+\alpha_j h, y+\beta_{j1} k_1 + \beta_{j2} k_2 + \ldots + \beta_{jj} k_j) \\
\ldots \\
k_R &= h f(t+\alpha_{R-1} h, y+\beta_{R-1,1} k_{R-1} + \ldots + \beta_{R-1,R-1} k_{R-1})
\end{split}
\end{equation}
such that
\begin{equation*}
y_{n+1} = y_n + \sum_{j=1}^R \gamma_j k_j
\end{equation*}
where $\alpha_j$, $\beta_{ji}$ and $\gamma_j$ define a set of coefficients for a given scheme.
Two choices of parameters for a 2-stage second-order Runge-Kutta scheme (RK2) are

\begin{quote}
a) \begin{tabular}{c|cc}
$\alpha$ & & $1$ \\ \hline
$\beta$ & & $1$ \\ \hline
$\gamma$ & $\frac{1}{2}$ & $\frac{1}{2}$
\end{tabular}\qquad
b) \begin{tabular}{c|cc}
$\alpha$ & & $\frac{1}{2}$ \\ \hline
$\beta$ & & $\frac{1}{2}$ \\ \hline
$\gamma$ & $0$ & $1$
\end{tabular}
\end{quote}
A common choice for a 4-stage 4-th order scheme (RK4) is,
\begin{quote}
\begin{tabular}{c|cccc}
$\alpha$ & & $\frac{1}{2}$ & $\frac{1}{2}$ & $1$ \\ \hline
$\beta$ & & $\frac{1}{2}$ & & \\
        & & $0$ & $\frac{1}{2}$ & \\
        & & $0$ & $0$ & $1$ \\ \hline
$\gamma$ & $\frac{1}{6}$ & $\frac{1}{3}$ & $\frac{1}{3}$ & $\frac{1}{6}$
\end{tabular}
\end{quote}
Various parameter sets for higher-order schemes (RK5, RK6, RK7, RK8 ...) can be found in the literature.
It should be noted that Euler's method
\begin{equation*}
y_{n+1} = y_n + h f(t,y)
\end{equation*}
can in this context be regarded as a first-order Runge-Kutta method with $\gamma_1 = 1$.

To adapt the RK solvers for the 2-nd order problem of Eq.~\ref{eq:motion}, we need to recast it in the first-order form of Eq.~\ref{eq:firstorder} by introducing the velocity $\vec{v}$ as an auxiliary variable, and simultaneously solving a system of two coupled first-order problems:
\begin{equation*}
\begin{split}
\dot{\vec{r}} &= f_1(t,\vec{r},\vec{v}) = \vec{v} \\
\dot{\vec{v}} &= f_2(t,\vec{r},\vec{v}) = \ACC(t,\vec{r})
\end{split}
\end{equation*}
Then each of the terms in (\ref{eq:rk_term}) must be calculated for both state vectors. For example, RK4 then becomes
\begin{equation*}
\begin{split}
\vec{k}_1 &= h\vec{v}_n \\
\vec{l}_1 &= h\ACC(t_n, \vec{r}_n) \\
\vec{k}_2 &= h(\vec{v}_n+\vec{l}_1/2) \\
\vec{l}_2 &= h\ACC(t_n+h/2, \vec{r}_n+\vec{k}_1/2) \\
\vec{k}_3 &= h(\vec{v}_n+\vec{l}_2/2) \\
\vec{l}_3 &= h\ACC(t_n+h/2, \vec{r}_n+\vec{k}_2/2) \\
\vec{k}_4 &= h(\vec{v}_n + \vec{l}_3) \\
\vec{l}_4 &= h\ACC(t_n+h, \vec{r}_n+\vec{k}_3)
\end{split}
\end{equation*}
leading to state vector updates
\begin{equation*}
\begin{split}
\vec{r}_{n+1} &= \vec{r}_n + \frac{1}{6}(\vec{k}_1 + 2\vec{k}_2 + 2\vec{k}_3 + \vec{k}_4) \\
\vec{v}_{n+1} &= \vec{v}_n + \frac{1}{6}(\vec{l}_1 + 2\vec{l}_2 + 2\vec{l}_3 + \vec{l}_4)
\end{split}
\end{equation*}

\section{Symplectic integrators [SY]}
A popular choice for long-term numerical integration of celestial trajectories is the family of \emph{symplectic integrators} for Hamiltonian systems which have the property of preserving the total energy of the problem. This is reflected in the excellent stability of the semi-major axis shown in the numerical tests in Section~\ref{sec:results}. Note however that other orbital elements may not show a similar improvement of accuracy over non-symplectic integrators.

A discussion of the theory of symplectic integrators is beyond the scope of this document, but a rich literature is available on the subject. For the implementation of symplectic integrators of orders 4, 6 and 8 in Orbiter, the paper by Yoshida \cite{yoshida1990} was followed.

\section{Rotational state propagation}
The propagation of the linear state vectors $(\vec{r},\vec{v})$ discussed in the previous sections can now be extended to the angular state vectors of orientation and angular velocity, $(\vec{\rho},\vec{\omega})$. In analogy to the linear case, this requires the propagation of $(\vec{\rho}_n,\vec{\omega}_n)$ at time $t_n$ to $(\vec{\rho}_{n+1},\vec{\omega}_{n+1})$ at time $t_{n+1}$, given a time-dependent torque $\vec{\tau}(t)$.
The equations of motion in this case can be stated as
\begin{equation}
\begin{split}
\dot{\vec{\rho}} &= \vec\omega \\
\dot{\vec{\omega}} &= \Euler^{-1}(\vec\tau,\vec\omega)
\end{split}
\end{equation}
where operator $\Euler^{-1}$ formally denotes the solution of Euler's equations of rigid body motion:
\begin{equation}
\Euler(\vec\omega,\dot{\vec\omega}) \equiv \vec\tau =
\dot{\vec{L}}+\vec\omega \times \vec{L} =
\left[
\begin{array}{ccc}
I_1\dot\omega_1 - \omega_2\omega_3(I_2-I_3) \\
I_2\dot\omega_2 - \omega_3\omega_1(I_3-I_1) \\
I_3\dot\omega_3 - \omega_1\omega_2(I_1-I_2)
\end{array}
\right]
\end{equation}
where $\vec{L}$ is the angular momentum measured in the frame of the rotating body, and $(I_1,I_2,I_3)$ are the principal moments of inertia of the body (assuming that the frame is the principal axis frame, with diagonal inertia tensor).

We now consider $\vec\tau(t)$ to be composed of a time-dependent \emph{gravity gradient} component $\vec\tau_g$ (cf. \emph{Orbiter Technotes: Distributed Vessel Mass}) and a term $\vec\tau_0$ containing all other torque components (atmospheric effects, engine thrust, etc.) which is assumed to be constant in the interval $[t_n, t_{n+1}]$:
\begin{equation}
\vec\tau(t,\vec{r},\vec\rho,\vec\omega) = \vec\tau_g(t,\vec{r},\vec\rho,\vec\omega) + \vec\tau_0 \equiv \AACC(t,\vec{r},\vec\rho,\vec\omega), \qquad t \in [t_n, t_{n+1}]
\end{equation}
Note the additional dependencies of $\vec\tau_g$ on position $\vec{r}$, orientation $\vec\rho$ and angular velocity $\vec\omega$. (The $\vec\omega$ dependency arises from the inclusion of a damping term).
We assume that the gravity gradient torque can be computed at any time between $t_n$ and $t_{n+1}$, and represent the resulting torque function by operator $\AACC$.

The $\vec{r}$ dependency of $\AACC$ (and hence $\dot{\vec\omega}$) couples the angular and linear state vectors. This means that the angular state can not be propagated independently from the linear state. Instead we need to solve a system of four coupled equations simultaneously:
\begin{equation}
\begin{split}
\dot{\vec{r}} &= f_1(t,\vec{r},\vec{v},\vec\rho,\vec\omega) = \vec{v} \\
\dot{\vec{v}} &= f_2(t,\vec{r},\vec{v},\vec\rho,\vec\omega) = \ACC(t,\vec{r}) \\
\dot{\vec{\rho}} &= f_3(t,\vec{r},\vec{v},\vec\rho,\vec\omega) = \vec\omega \\
\dot{\vec{\omega}} &= f_4(t,\vec{r},\vec{v},\vec\rho,\vec\omega) = \Euler^{-1}[\AACC(t,\vec{r},\vec\rho,\vec\omega),\vec\omega]
\end{split}
\end{equation}
The integration of this system into the Runge-Kutta mechanism and other integrators is straightforward. As a simple example, consider version b) of the RK2 scheme in Section~\ref{sec:rk}.
Given the initial state $(\vec{r}_n, \vec{v}_n, \vec\rho_n, \vec\omega_n)$ at $t_n$,
the two stages of RK2 are
\begin{equation}
\begin{split}
\vec{k}_1 &= h\vec{v}_n \\
\vec{l}_1 &= h\ACC(t_n, \vec{r}_n) \\
\vec{\kappa}_1 &= h\vec\omega_n \\
\vec{\lambda}_1 &= h \Euler^{-1}[\AACC(t_n,\vec{r}_n,\vec\rho_n,\vec\omega_n),\vec\omega_n] \\
\vec{k}_2 &= h(\vec{v}_n+\vec{l}_1/2) \\
\vec{l}_2 &= h\ACC(t_n+h/2, \vec{r}_n+\vec{k}_1/2) \\
\vec\kappa_2 &= h(\vec\omega_n + \vec{\lambda}_1/2) \\
\vec\lambda_2 &= h\Euler^{-1}[\AACC(t_n+h/2,\vec{r}_n+\vec{k}_1/2,\vec\rho_n+\vec\kappa_1/2,\vec\omega_n+\vec\lambda_1/2),\vec\omega_n+\vec\lambda_1/2]
\end{split}
\end{equation}
leading to updates
\begin{equation}
\begin{split}
\vec{r}_{n+1} &= \vec{r}_n + \vec{k}_2 \\
\vec{v}_{n+1} &= \vec{v}_n + \vec{l}_2 \\
\vec\rho_{n+1} &= \vec\rho_n + \vec\kappa_2 \\
\vec\omega_{n+1} &= \vec\omega_n + \vec\lambda_2
\end{split}
\end{equation}
Note that the formal sum operator for the orientation $\vec\rho$ represents a rotation. Its actual implementation depends on the representation of body orientation. Orbiter uses a quaternion representation. Other choices are rotation matrices, Euler angles or axis-angle representations.

\section{Numerical simulations}\label{sec:results}
Figure~\ref{fig:1day_err} shows the mean drift and standard deviation of the semi-major axis of a low Earth orbit (mean altitude 217\,km) over a 10-day period for the different integration schemes as a function of step interval. For these simulations, the interval lengths were kept constant (during an actual Orbiter simulation run, step lengths will normally vary as a function of scenery complexity and time compression).

It can be seen that the standard deviations of all methods converge at approximately $5\cdot 10^{-3}$\,km, defined by the noise level due to rounding errors and ``true'' orbit perturbations. The step lengths up to which this maximum accuracy level is maintained vary widely between the different methods. Of the polynomial interpolation schemes described above, the quadratic scheme compares favourably to the Runge-Kutta methods, providing better accuracy than RK4, while requiring fewer function evaluations.

The graphs also show that the parameter drift is monotonous for the even-order RK methods and polynomial methods, but oscillatory with a zero crossing for odd-order RK methods.

Compared to Runge-Kutta integrators, the symplectic methods deliver a significantly improved stability of the orbit energy at the same order of accuracy. The top graph of Fig.~\ref{fig:symp_err} shows the SMa standard deviation for 2nd, 4th, 6th and 8th order symplectic integrators. It can be seen that for 2nd to 8th order, the symplectic methods provide superior results compared to their Runge-Kutta counterparts of the same order. SY8 however does not provide a significant improvement over SY6 for the problem considered here.

In the bottom graph, the standard deviation of perigee distance is shown. While still superior to the RK solutions of the same order except for SY8, the improvement is not as striking as for the semi-major axis.

Since higher-order methods require more evaluations of the function $\ACC(t,\vec{r})$ and are therefore compuationally more expensive, the propagation method should be determined by balancing the required accuracy and computational cost.

\begin{table}\centering
\begin{tabular}{l|rr}
Method & stages & runtime [$\mu$s] \\ \hline
RK2 & 2 & 9.7 \\
RK3 & 3 & 14.8 \\
RK4 & 4 & 16.2 \\
RK5 & 6 & 30.5 \\
RK6 & 8 & 38.0 \\
RK7 & 11 & 49.1 \\
RK8 & 13 & 57.8 \\ \hline
L/s & 2 & 11.3 \\
L/d & 3 & 13.1 \\
Q & 3 & 19.8 \\ \hline
SY2 & 2 & 10.1 \\
SY4 & 4 & 20.2 \\
SY6 & 8 & 32.3 \\
SY8 & 16 & 51.5
\end{tabular}
\caption{Computational cost of the time propagation methods for the example of low Earth orbit. 3 gravitational point sources (Sun, Earth, Moon) were considered. Run times are for propagation evaluation only (no graphics processing), measured on an Athlon 900 PC.}
\end{table}

\begin{figure}\centering
\includegraphics[width=0.99\textwidth]{sma_dev}\\
\includegraphics[width=0.99\textwidth]{sma_std}
\caption{Mean drift (top) and standard deviation (bottom) in semi-major axis for a low Earth orbit (mean altitude 217\,km) over a period of 10 days, as a function of time step length. Shown are the interpolation and Runge-Kutta families of integrators used in the Orbiter code.}
\label{fig:1day_err}
\end{figure}

\begin{figure}\centering
\includegraphics[width=0.99\textwidth]{sma_symp_std}
\includegraphics[width=0.99\textwidth]{pea_symp_std}
\caption{Standard deviation in semi-major axis (top) and perigee altitude (bottom) for the 2nd, 4th, 6th and 8th order symplectic integrators available in Orbiter. For comparison, the 2nd, 4th, 6th and 8th order Runge-Kutta results are shown as dashed lines.}
\label{fig:symp_err}
\end{figure}

Note that with default parameters, Orbiter will switch to ``stabilised'' orbit calculation for steps that involove a change in mean anomaly of more than $10^{-3} \cdot 2\pi$. In low Earth orbit with period $T\approx5400\,s$, this corresponds to a time interval of 5.4\,s.

For comparison, with a typical frame rate of 50\,fps and at a selected time compression of $1000\times$, the step interval is 20\,s. During normal simulation runs, the main problem are however isolated long steps, caused for example by disc I/O. During such steps, the orbit stabilisation mode keeps orbits from deteriorating.

\bibliography{../ref}

\end{document}


\documentclass{article}
\newsavebox{\oldepsilon}
\savebox{\oldepsilon}{\ensuremath{\epsilon}}
\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit
\renewcommand*{\epsilon}{\usebox{\oldepsilon}}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx} % For .eps inclusion
%\usepackage{indentfirst} % Controls indentation
\usepackage[compact]{titlesec} % For regulating spacing before section titles
\usepackage{adjustbox} % For vertically-aligned side-by-side minipages
\usepackage{array, amsmath,  mhchem}
\usepackage[hidelinks]{hyperref}
\usepackage{courier, subcaption}
\usepackage{multirow, enumerate}
\usepackage[autolinebreaks,framed,numbered]{mcode}
\usepackage{float}
\restylefloat{table}

\pagenumbering{gobble}
\setlength\parindent{0 cm}
\renewcommand{\arraystretch}{1.2}
\begin{document}
\large

MCB 135 Problem Set 8 \hfill Due Monday, April 13, 2015 at 2:30 PM

\section*{Problem 1: Fluorescence Recovery After Photobleaching (40 points)}

A protein's localization can be used to regulate its activity. Fluorescence Recovery After Photobleaching (FRAP) is one method to investigate whether a protein is diffusing freely or physically confined. The coding sequence of a fluorescent protein is appended to the open reading frame of the protein of interest. A small region of a cell expressing this construct is then photobleached so that all proteins in that region permanently lose fluorescence. Diffusion of nearby fluorescent proteins into the region gradually restores fluorescence. This problem will guide you through a calculation of the expected spatiotemporal profile of fluorescence recovery for diffusion in one dimension, which can be compared to experimental data to estimate the protein's diffusion coefficient.
\begin{enumerate}[a)]
\item Consider the initial concentration profile:
\[ c(x,t=0) = \left\{
     \begin{array}{lr}
       0 & : x < 0\\
       a & : x \geq 0
     \end{array}
   \right. \]
Using the fact that the ``impulse response function" for 1-D diffusion from a point source is $h(x,t)=e^{-x^2/4Dt}/\sqrt{4\pi D t}$, show via convolution that:
\[ c(x,t) = \frac{a}{2} \left[ 1 + \textrm{erf} \left( \frac{x}{\sqrt{4Dt}} \right)\right], \hspace{3 cm} \textrm{ where }\textrm{erf} \left( z \right) \triangleq \frac{2}{\sqrt{\pi}} \int_0^z e^{-u^2} \, du \]
\item A region along the axis of a rod-shaped cell is photobleached so that the initial concentration profile is:
\[ c(x,t=0) = \left\{
     \begin{array}{lr}
       0 & : -L < x < L\\
       a & : \textrm{otherwise}
     \end{array}
   \right. \]
Find an expression for $c(x,t)$ in terms of the error function erf(). (Hint:  this can be done without taking any more integrals.)
\item Plot $c(x,t)$ from part (b) for $x\in[-20,20]$ at $t=0.01, 1,$ and $100$. Use the parameter values $D=1$, $a=1$, and $L=5$.
\item Outline how you would estimate $D$ if given a single fluorescence profile collected $\tau$ seconds after photobleaching. You may assume that photobleaching is perfectly efficient, and that $L$ and $x$ are known.
\end{enumerate}

\section*{Problem 2: Epidemic (60 points)}
A disease spreads through a population of $N$ persons: $x$ of them are infected, and the remainder, $s=N-x$, are susceptible. When the infection subsides, a person becomes susceptible again (no immunity is conferred). Infection and recovery are modeled by two events:
\[ \ce{X + S ->[k_1] X + X} \hspace{3 cm} \ce{X ->[k_2] S}  \]

\begin{enumerate}[a)]
\item What is the analog of the system size $\Omega$ in this model?
\item What is the stoichiometry matrix for these events?
\item What are the two event propensities $\Omega r_i(x, \Omega)$?
\item Using your answers to (a)-(c), find expressions for the first and second jump moments, $\mu(x,t)$ and $\sigma^2(x,t)$.
\item Write down an expression for $dx$ in Langevin notation.
\item Simulate the system using the Euler-Maruyama method with parameters $N=1000$, $k_1 = 0.2$, and $k_2 = 0.1$ and with step size $\Delta t = 0.1$ and $t \in [0,1000]$. Include a plot with three sample trajectories with initial values $x(0)=100,500,$ and $900$.
\item Use Wright's formula to find an expression proportional to the stationary probability distribution of states, $P(x)$. Do not calculate the normalization constant. Hint: to save headaches later, don't omit the absolute value notation when taking integrals of the form  $\int \frac{dx}{x} = \ln |x|+C$.
\item In the real world, what would happen if $x$ chances to reach zero? How does this reflect what will happen if you attempt to normalize your expression for $P(x)$ over $x \in [0, N] \cap \mathbb{Z}$?
\end{enumerate}
As you saw in part f, this system has a different, ``pseudo-stable" behavior that is apparent on intermediate timescales. We can investigate it by normalizing $P(x)$ over all $x \neq 0$.
\begin{enumerate}[a)]
\setcounter{enumi}{8}
\item Numerically calculate $P^*(x)$, the ``pseudo-stationary probability distribution," by normalizing $P(x)$ with the parameter values given above for $x \in [1, N] \cap \mathbb{Z}$.  Hint: to minimize rounding errors, calculate $\ln P(x)$ for each value of $x$, subtract the minimum value in this array from all values in the array, then exponentiate and normalize.
\item Calculate the mean $m$ and standard deviation $s$ of $P^*(x)$.
\item Add lines to your plot from part (f) to mark $x=m-2s$ and $x=m+2s$. Do your simulated trajectories tend to remain within these bounds after reaching the pseudo-stationary distribution?

\end{enumerate}

\end{document}

problem sets/ps8/mcb 135 problem set 8.tex

problem set keys/ps8/mcb 135 problem set 8.tex