\documentclass{article}

\usepackage[letterpaper, portrait, margin=1in]{geometry}
\usepackage{siunitx}
\usepackage{url}
\usepackage{tikz}
\usepackage{mathtools}
\usetikzlibrary{shapes,backgrounds}
\usepackage{graphicx}
\usepackage{amsmath}

\setlength{\parindent}{0pt}

\begin{document}

\title{Dyanmics Equations for Smartmouse 2018}
\author{Peter Mitrano}

\maketitle

\section{Forward Kinematics}
Deriving the kinematic equations of a differential drive robot.

\hfill

\begin{figure}[h]
  \begin{tikzpicture} [scale=2]
    % coordinate frame and grid%
    \definecolor{lg}{rgb}{0.9,0.9,0.9}
    \draw[step=1,lg,very thin] (-1,-3) grid (6,1);
    \draw [very thick,->] (-1,1) -- (-1,0);
    \draw [very thick,->] (-1,1) -- (0,1);
    \draw (-1.2, 0.1) node {$row$};
    \draw (0.1, 1.1) node {$col$};

    % robot and stuff %
    \draw [line width=1mm, draw=gray,rotate around={-15:(0,0)}]{(3.5,0)--(4.5, 0)};
    \draw [rotate around={-15:(0,0)}] {(3.2,-0.2) rectangle (3.5, 0.2)};
    \draw [rotate around={-15:(0,0)}] {(4.5,-0.2) rectangle (4.75, 0.2)};
    \draw [rotate around={-15:(0,0)}] {(0,0) -- (4, 0)};
    \draw [dashed,rotate around={-30:(0,0)}] {(0,0) -- (4, 0)};
    \draw [dashed,rotate around={-15:(0,0)}] (4,0) arc (0:-15:4);
    \draw [rotate around={-15:(0,0)}] (2,0) arc (0:-15:2);
    \draw [thick,->,rotate around={-15:(0,0)}] (3.375,0) -- (3.375,-0.5);
    \draw [thick,->,rotate around={-15:(0,0)}] (4.625,0) -- (4.625,-0.5);
    \draw [thick,|-|,rotate around={-15:(0,0)}] (3.375,0.5) -- (4.625,0.5);
    \filldraw [rotate around={-15:(0,0)}] {(0,0) circle (.05)};
    \filldraw [rotate around={-15:(0,0)}] {(4,0) circle (.05)};
    \filldraw [rotate around={-30:(0,0)}]{(4,0) circle (.02)};
    \draw [rotate around={-15:(0,0)}] (1.75, -0.25) node {$\Delta\theta$};
    \draw [rotate around={-15:(0,0)}] (3.625, -0.5) node {$v_r$};
    \draw [rotate around={-15:(0,0)}] (4.875, -0.5) node {$v_l$};
    \draw [rotate around={-15:(0,0)}] (2, 0.25) node {$R$};
    \draw [rotate around={-15:(0,0)}] (4, 0.7) node {$W$};
    \draw [rotate around={-15:(0,0)}] (4, .2) node {$(c,r,\theta)$};
    \draw [rotate around={-15:(0,0)}] (0, 0.4) node {$ICC$};
    \draw [rotate around={-15:(0,0)}] (0, .2) node {$(c_{ICC},r_{ICC},\theta_{ICC})$};
  \end{tikzpicture}
  \centering
\end{figure}

It's worth noting up front that we do not consider an X/Y plane. It is not a useful coordinate system for smartmouse. We think instead of row/column, where rows increase going down and columns increase going left to right. The top left cell is 0,0. Normally, we think of these as integer values, but we can also think of them as floating point values if we want to talk about the exact position in a cell. If you really want to, you can think of column as $x$ and row as $y$, with $z$ pointing down into the maze and positive angles going clockwise. With that out of the way, let's do the derivation.

At an instant in time we say that the robot is turning around some point $ICC$, the instanteous center of curvature. The radius $R$ about that point is what we want to solve for. We start with the knowedge that since the robot doesn't tear itself apart while driving, the rate $\omega$ at which both wheels (and the robot) move around $ICC$ is the same.
\begin{equation} \label{eq:1}
  \omega_l = \omega_r = \omega
\end{equation}
Let $R_l$ and $R_l$ be the radius to the right and left wheels.
\begin{equation} \label{eq:2}
  \omega = \frac{v_l}{R_l} = \frac{v_r}{R_r}
\end{equation}
We can then combine \ref{eq:1} and \ref{eq:2}
\begin{equation}
  \frac{v_l}{R_l} = \frac{v_r}{R_r}
\end{equation}
We can then substitute $R_l = R + \frac{W}{2}$ and $R_r = R - \frac{W}{2}$
\begin{equation}
  \frac{v_l}{R+\frac{W}{2}} = \frac{v_r}{R-\frac{W}{2}}
\end{equation}

Now do some algebra...
\begin{align*}
  \frac{v_l}{R+\frac{W}{2}} &= \frac{v_r}{R-\frac{W}{2}} \\[1em]
  \frac{R+\frac{W}{2}}{v_l} &= \frac{R-\frac{W}{2}}{v_r} \\[1em]
  \frac{R}{v_l}+\frac{W}{2v_l} &= \frac{R}{v_r}-\frac{W}{2v_r} \\[1em]
  \frac{W}{2v_l} + \frac{W}{2v_r} &= \frac{R}{v_r} - \frac{R}{v_l} \\[1em]
  \frac{W(v_r + v_l)}{2v_rv_l} &= \frac{R(v_l - v_r)}{v_rv_l} \\[1em]
  \frac{W(v_r + v_l)}{2(v_l - v_r)} &= R
\end{align*}

We can use this result to get a cleaner equation for $\omega$, which right now requires diving by $R$. This is problematic because $R$ can be $0$.

\begin{align*}
  \omega &= \frac{v_l}{R+\frac{W}{2}}\\[1em]
         &= \frac{v_l}{\frac{W(v_r+v_l)}{2(v_l - v_r)}+\frac{W}{2}}\\[1em]
         &= \frac{v_l}{\frac{W(v_r+v_l)}{2(v_l - v_r)}+\frac{W(v_l - v_r)}{2(v_l - v_r)}}\\[1em]
         &= \frac{v_l}{\frac{W(v_r+v_l)+W(v_l - v_r)}{2(v_l - v_r)}}\\[1em]
         &= \frac{2v_l(v_l - v_r)}{W(v_r+v_l)+W(v_l - v_r)}\\[1em]
         &= \frac{2v_l(v_l - v_r)}{Wv_r+Wv_l+Wv_l-Wv_r}\\[1em]
         &= \frac{2v_l(v_l - v_r)}{2Wv_l}\\[1em]
         &= \frac{v_l - v_r}{W} [1em]
\end{align*}

\textbf{Next we need to figure out how to update our $c$, $r$, and $\theta$ given $R$.} \\

Before we can solve any of these, we need to figure out what $\Delta\theta$ is equal to. We will assume we are following this arc of constant radius for a given time step $\Delta t$. This is a good assumption if our time step is equal to our controller time step, during which presumably the speeds of the motors aren't changing, and so neither will our turning radius. If so, then $\Delta\theta = \omega\Delta t$, and we know

$$\omega=\frac{v_l - v_r}{W}$$

Lets just pick $v_l$, and put them together to get $\Delta\theta$.

$$\Delta\theta = \frac{v_l - v_r}{W}\Delta t$$

So what are our update equations? \\

Theta is obvious: $\theta \leftarrow \theta+\Delta\theta$. \\

To discover the rest, we will consider how to c and r change when we rotate around the $ICC$. \\

The coordinates of the $ICC$ are:

$$(c_{ICC}, r_{ICC}) = (c-R\sin{\theta}, r+R\cos{\theta})$$

You can see this if you think that the vector to $ICC$ is 90 degrees offset from $\theta$ and do the trig. Let's assume in the situation diagramed above, $\theta=\ang{105}$, $R=4$, and $c=4.8, r=2$, so $ICC = (4.8-4\sin{(105)}, 2+4\cos{(105)}) \approx (1, 1)$. For another example, pretend the robot is right below the origin facing east at $(0,1,0)$ and $R=-1$. $ICC$ should be $(0,0)$ so let's check. $ICC = (0-{-1}\sin{(0)}, 1+{-1}\cos{(0)}) = (0, 0).$ Great, the math seems to check out. Now we just rotate the robot coordinates around the point $ICC$ by $\Delta\theta$, which we can do easily with a rotation matrix. Of course, we're not rotating around the origin, we're roating around $ICC$, so we first subtract out the coordinates of $ICC$ to get $(c_o, r_o) = (c-c_{ICC}, r-r_{ICC})$. Recall that to rotate around the origin by $\Delta\theta$, we multiply our point $(c_o, r_o)$ as follows.
\begin{equation}
  \begin{bmatrix}
    \cos{\Delta\theta} & -\sin{\Delta\theta} \\
    \sin{\Delta\theta} & \cos{\Delta\theta} \\
  \end{bmatrix}
  \begin{bmatrix}
    c_o \\
    r_o \\
  \end{bmatrix}
  =
  \begin{bmatrix}
    c_{new} \\
    r_{new} \\
  \end{bmatrix}
\end{equation}
We then just add back the coordinates of $ICC$. Great! Now we know how to update all our coordinates. Let's summarize:

\begin{align}
 \theta &\leftarrow \theta + \Delta\theta \\
  c &\leftarrow \cos{(\Delta\theta)}(c-c_{ICC})-\sin{(\Delta\theta)}(r-r_{ICC}) + c_{ICC} \\
  r &\leftarrow \sin{(\Delta\theta)}(c-c_{ICC})+\cos{(\Delta\theta)}(r-r_{ICC}) + r_{ICC} \\
\shortintertext{where}
  c_{ICC} &= c-R\sin{\theta} \\
  r_{ICC} &= r+R\cos{\theta} \\
  \Delta\theta &= \frac{v_l-v_r}{W}\Delta t \\
  R &= \frac{W(v_r+v_l)}{2(v_l-v_r)}
\end{align}

We can expand and simplify the update equations for $c$.

\begin{align}
  c &\leftarrow \cos{(\frac{v_l-v_r}{W}\Delta t)}(c-(c-R\sin{\theta}))-\sin{(\frac{v_l-v_r}{W}\Delta t)}(r-(r+R\cos{\theta})) + c-R\sin{\theta} \\
  c &\leftarrow \cos{(\frac{v_l-v_r}{W}\Delta t)}(c-c+R\sin{\theta})-\sin{(\frac{v_l-v_r}{W}\Delta t)}(r-r-R\cos{\theta}) + c-R\sin{\theta} \\
  c &\leftarrow \cos{(\frac{v_l-v_r}{W}\Delta t)}(R\sin{\theta})-\sin{(\frac{v_l-v_r}{W}\Delta t)}(-R\cos{\theta}) + c-R\sin{\theta} \\
  c &\leftarrow R\cos{(\frac{v_l-v_r}{W}\Delta t)}\sin{\theta}+R\sin{(\frac{v_l-v_r}{W}\Delta t)}\cos{\theta} + c-R\sin{\theta} \\
  c &\leftarrow c+R\cos{(\frac{v_l-v_r}{W}\Delta t)}\sin{\theta}+R\sin{(\frac{v_l-v_r}{W}\Delta t)}\cos{\theta}-R\sin{\theta} \\
  c &\leftarrow c+R\Big(\cos{(\frac{v_l-v_r}{W}\Delta t)}\sin{\theta}+\sin{(\frac{v_l-v_r}{W}\Delta t)}\cos{\theta}\Big)-R\sin{\theta} \\
  \shortintertext{let $\frac{v_l-v_r}{W}=a$, and $\theta=b$, we can use $\cos{a}\sin{b}+\sin{a}\cos{b}=\sin{(a+b)}$}
  c &\leftarrow c+R\Bigg(\sin{\Big(\frac{v_l-v_r}{W}\Delta t+\theta}\Big)\Bigg)-R\sin{\theta} \\
  c &\leftarrow c+R\Bigg(\sin{\Big(\frac{v_l-v_r}{W}\Delta t+\theta}\Big)-\sin{\theta}\Bigg)
\end{align}

We can apply the same process for $r$.

\begin{align}
  r &\leftarrow \sin{(\frac{v_l-v_r}{W}\Delta t)}(c-(c-R\sin{\theta}))+\cos{(\frac{v_l-v_r}{W}\Delta t)}(r-(r+R\cos{\theta})) + r+R\cos{\theta} \\
  r &\leftarrow \sin{(\frac{v_l-v_r}{W}\Delta t)}(c-c+R\sin{\theta})+\cos{(\frac{v_l-v_r}{W}\Delta t)}(r-r-R\cos{\theta}) + r+R\cos{\theta} \\
  r &\leftarrow \sin{(\frac{v_l-v_r}{W}\Delta t)}(R\sin{\theta})+\cos{(\frac{v_l-v_r}{W}\Delta t)}(-R\cos{\theta}) + r+R\cos{\theta} \\
  r &\leftarrow R\sin{(\frac{v_l-v_r}{W}\Delta t)}(\sin{\theta})-R\cos{(\frac{v_l-v_r}{W}\Delta t)}(\cos{\theta}) + r+R\cos{\theta} \\
  r &\leftarrow r + R\sin{(\frac{v_l-v_r}{W}\Delta t)}(\sin{\theta})-R\cos{(\frac{v_l-v_r}{W}\Delta t)}(\cos{\theta}) + R\cos{\theta} \\
  r &\leftarrow r + R\Big(\sin{(\frac{v_l-v_r}{W}\Delta t)}(\sin{\theta})-\cos{(\frac{v_l-v_r}{W}\Delta t)}(\cos{\theta}\Big) + R\cos{\theta} \\
  \shortintertext{let $\frac{v_l-v_r}{W}=a$, and $\theta=b$, we can use $\sin{a}\sin{b}-\cos{a}\cos{b}=-\cos{(a+b)}$}
  r &\leftarrow r - R\Bigg(\cos{\Big(\frac{v_l-v_r}{W}\Delta t + \theta\Big)}\Bigg) + R\cos{\theta} \\
  r &\leftarrow r - R\Bigg(\cos{\Big(\frac{v_l-v_r}{W}\Delta t + \theta\Big)} - \cos{\theta}\Bigg)
\end{align}

\textbf{Final Solution to the forward Kinematics:}
\begin{align}
 \theta &\leftarrow \theta + \frac{v_l-v_r}{W}\Delta t \\
  c &\leftarrow c + R\Bigg(\sin{\Big(\frac{v_l-v_r}{W}\Delta t+\theta\Big)}-\sin{\theta}\Bigg) \\
  r &\leftarrow r + -R\Bigg(\cos{\Big(\frac{v_l-v_r}{W}\Delta t+\theta\Big)}-\cos{\theta}\Bigg)
\end{align}

However, there is also the case where the robot is going perfectly straight. This has to be handled seperately, because otherwise the equations above involve $R$, but $R=\infty$ if we're going straight. Luckily, the equations for moving straight are trivial:
\begin{align}
 \theta &\leftarrow \theta \\
  c &\leftarrow c + v\Delta t\cos(theta) \\
  r &\leftarrow r - v\Delta t\sin(theta)
\end{align}

Here, $v$ can be $v_l$, or $v_r$ since they should be the same. In code, a simple average is used to correct for any slight numerical inconsistencies. \\

\section{DC Motor Modeling}
We must also consider how to model the DC Motors. \\

\includegraphics[scale=0.5]{./dc_motor_model.png}

The motor torque, $T$, is related to the armature current, $i$, by a constant factor $K$. $C$ is the damping factor ($b$ in the picture), $J$ is the inertia of the motor shaft and wheel. The back emf, $e$, is related to the rotational velocity by the following equations:
$$T=Ki$$
$$e=K\dot{\theta}$$

From the figure above we can write the following equations based on Newton's law combined with Kirchhoff's law:
$$J\frac{d}{dt}\dot{\theta} + C\dot{\theta} = Ki$$
$$L\frac{d}{dt}i+Ri=V-K\dot{\theta}$$

In state-space form, the equations above can be expressed by choosing the rotating speed and electric current as the state variables and the voltage as an input. The output is chosen to be the rotating speed. The general linear state-space form is $\dot{X} = AX + BW$. We can get the two equations above in this form with some algebra.
\begin{align}
  J\frac{d}{dt}\dot{\theta} + C\dot{\theta} &= Ki \\
  \frac{d}{dt}\dot{\theta} + \frac{C\dot{\theta}}{J} &= \frac{Ki}{J} \\
  \frac{d}{dt}\dot{\theta} &= \frac{Ki}{J} - \frac{C\dot{\theta}}{J}
\end{align}

\begin{align}
  L\frac{d}{dt}i + Ri &= V - K\dot{\theta} \\
  \frac{d}{dt}i + \frac{Ri}{L} &= \frac{V}{L} - \frac{K\dot{\theta}}{L} \\
  \frac{d}{dt}i &= \frac{V}{L} - \frac{K\dot{\theta}}{L} - \frac{Ri}{L}
\end{align}

Next we combine these in a matrix.

\begin{align}
  \frac{d}{dt}\begin{bmatrix}\dot{\theta}\\i\\\end{bmatrix} &=
    \begin{bmatrix}
      \frac{-C}{J} & \frac{K}{J} \\
      \frac{-K}{L} & \frac{-R}{L} \\
    \end{bmatrix}
    \begin{bmatrix}
      \dot{\theta} \\
      i
    \end{bmatrix}
    +
    \begin{bmatrix}
      0 \\
      \frac{1}{L}
    \end{bmatrix}
    V
\end{align}

What this gives us is a nice matrix-y formula for the change in the current and angle of our motor over time. We can use this equation to simulate the behavior of the motor. If we assume the motor start at some initial $\dot{\theta}$, $i_0$ and $\dot{i}$, and we know all our motor constants ($K$, $R$, $L$, $C$, $J$) we can figure out the right hand side of the equation, and the result will be how much $i$ and $\dot{\theta}$ changes over some discrete time step. That is what we do in the smartmouse simulator server code.

\section{sources}
\url{http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed&section=SystemModeling}

\end{document}


%!TEX root = morusAC.tex

\section{Linear Trail for \MiniMORUS}
\label{sec/minitrails}

In this section, we describe how we build a trail for \MiniMORUS, then compute its correlation and validate the correlation experimentally.

\subsection{Overview of the Trail}

To build a linear trail for \MiniMORUS, we combine the following five trail fragments $\alpha^t_i$, $\beta^t_i$, $\gamma^t_i$, $\delta^t_i$, $\varepsilon^t_i$, where the subscript $i$ denotes a bit position, and the superscript $t$ denotes a step number:
\begin{itemize}
    \item $\alpha^t_i$ approximates (one bit of) state word $S_0$ using the ciphertext;
    \item $\beta^t_i$ approximates $S_1$ using $S_0$ and the ciphertext;
    \item $\gamma^t_i$ approximates $S_4$ using two approximations of $S_1$ in consecutive steps;
    \item $\delta^t_i$ approximates $S_2$ using two approximations of $S_4$ in consecutive steps;
    \item $\varepsilon^t_i$ approximates $S_0$ using two approximations of $S_2$ in consecutive steps.
\end{itemize}

The trail fragments are depicted on \Cref{fig:minimorusfragments}. In all cases except $\alpha^t_i$, the trail fragment approximates a single AND gate by zero, which holds with probability 3/4, and hence the trail fragment has weight 1. In the case of $\alpha^t_i$, two AND gates are involved; however the two gates share an entry in common, and in both cases the other entry also has a linear contribution to the trail, which results in an overall contribution of the form (see \cite[Sec.~3.3]{DBLP:conf/indocrypt/AshurR16})
\[
x \cdot y \oplus x \cdot z \oplus y \oplus z= (x \oplus 1) \cdot (y \oplus z).
\]
As a result, the trail fragment $\alpha^t_i$ also has a weight of 1. Another way of looking at this phenomenon is that the trail holds for two different approximations of the AND gates: the alternative approximation is depicted by a dashed line on \Cref{fig:minimorusfragments}.

\begin{figure}
  \substatesfalse
  % \substatesfalse to label state words and/or masks
  \centering
  \begin{subfigure}{.32\textwidth}
  \centering
  \tikzsetnextfilename{minimorus_part_alpha}
  \begin{tikzpicture}[xscale=0.65,yscale=1.5]%{{{
    \printstate
    \draw[trail, alpha]
      (C) -- node[right] {$i$} (lll-1)
      (lll-1) -- (tlll-1) (lll-1) -- (xor-1) (xor-1) -- (xnd-1)
      (xnd-1) -- (and-1) (xor-1) -- (txor-1) (txor-1) -- (tanB0) (tanB0) -- (tanB0-|and0.east)
      (and0) -- (xnd0) (xnd0) -- (tlll-1) (xnd0) -- (xor0)
      (and-1.east|-tanA-1) -- (tanA-1) (tanA-1) -- (txor0) (txor0) -- (xor0)
      (xor0) -- (lll0) (lll0) -- (W40) node[below] {$i+b_0$}
      ;
    \draw[trail, alpha, dashed]
      (and-1.east|-tanB-1) -- (tanB-1) (tanB-1) -- (tanA0) (tanA0) -- (tanA0-|and0.east)
      ;
  \end{tikzpicture}%}}}
  \caption*{$\alpha^t_i$: weight 1 (not 2)} %$C^j_i, S^{j-1,0}_{i+5}$ ($w\!=\!1$)}
  \end{subfigure}
  \hfill
  \begin{subfigure}{.32\textwidth}
  \centering
  \tikzsetnextfilename{minimorus_part_beta}
  \begin{tikzpicture}[xscale=0.65,yscale=1.5]%{{{
    \printstate
    \draw[trail, beta]
      (C) -- node[right] {$i$} (lll-1)
      (lll-1) -- (tlll-1) (lll-1) -- (xor-1) (xor-1) -- (xnd-1)
      (tlll-1) -- (W-20) node[above] {$i$}
      (xor-1) -- (txor-1) (txor-1) -- (W-21) node[above] {$i$}
      (xnd-1) -- (and-1)
      (W40) node[below] {\phantom{$i$}}
      ;
  \end{tikzpicture}%}}}
  \caption*{$\beta^t_i$: weight 1} %$C^j_i, S^{j,0}_i, S^{j,1}_i$ ($w\!=\!0$)}
  \end{subfigure}
  \hfill
  \begin{subfigure}{.32\textwidth}
  \tikzsetnextfilename{minimorus_part_gamma}
  \begin{tikzpicture}[xscale=0.65,yscale=1.5]%{{{
    \printstate
    \draw[trail, gamma]
      (W-21) node[above] {$i$} -- (xnd1) (xnd1) -- (xor1) (xor1) -- (lll1)
      (xnd1) -- (and1)
      (xor1) -- (txor1)
      (txor1) -- (W-24) node[above] {$i$}
      (lll1) -- (W41) node[below] {$i+b_1$}
      ;
  \end{tikzpicture}%}}}
  \caption*{$\gamma^t_i$: weight 1} %$S^{j,1}_i, S^{j,4}_i, S^{j+1,1}_{i-1}$ ($w\!=\!1$)}
  \end{subfigure}
  \bigskip

  \begin{subfigure}{.32\textwidth}
  \centering
  \tikzsetnextfilename{minimorus_part_delta}
  \begin{tikzpicture}[xscale=0.65,yscale=1.5]%{{{
    \printstate
    \draw[trail, delta]
      (W-24) node[above] {$i$} -- (xnd4) (xnd4) -- (xor4) (xnd4) -- (and4)
      (xor4) -- (lll4) (xor4) -- (txor4) (txor4) -- (W42) node[below] {$i$}
      (lll4) -- (W44) node[below] {$i+b_4$}
      ;
  \end{tikzpicture}%}}}
  \caption*{$\delta^t_i$: weight 1} %$S^{j,4_i}, S^{j+1,2}_i, S^{j+1,4}_{i+13}$ ($w\!=\!1$)}
  \end{subfigure}
  \hfill
  \begin{subfigure}{.32\textwidth}
  \centering
  \tikzsetnextfilename{minimorus_part_epsil}
  \begin{tikzpicture}[xscale=0.65,yscale=1.5]%{{{
    \printstate
    \draw[trail, epsil]
      (W-22) node[above] {$i$} -- (xnd2) (xnd2) -- (xor2) (xnd2) -- (and2)
      (xor2) -- (lll2) (xor2) -- (txor2) (txor2) -- (W40) node[below] {$i$}
      (lll2) -- (W42) node[below] {$i+b_2$}
      ;
  \end{tikzpicture}%}}}
  \caption*{$\varepsilon^t_i$: weight 1} %$S^{j,2}_i, S^{j+1,0}_i, S^{j+1,2}_{i+7}$ ($w\!=\!1$)}
  \end{subfigure}
  \hfill
  \begin{subfigure}{.32\textwidth}
    \small
    \begin{align*}
      \intertext{\MiniMORUS[640]:}
\alpha^t_i:&& C^t_i &\to S^{t+1}_{0,i+5} \\
\beta^t_i:&& C^t_i, S^t_{0,i} &\to S^t_{1,i} \\
\gamma^t_i:&& S^t_{1,i}, S^{t+1}_{1,i+31} &\to S^t_{4,i} \\
\delta^t_i:&& S^t_{4,i}, S^{t+1}_{4,i+13} &\to S^{t+1}_{2,i} \\
\varepsilon^t_i:&& S^t_{2,i}, S^{t+1}_{2,i+7} &\to S^{t+1}_{0,i}.
      \intertext{\MiniMORUS[1280]:}
\alpha^t_i:&& C^t_i &\to S^{t+1}_{0,i+13} \\
\beta^t_i:&& C^t_i, S^t_{0,i} &\to S^t_{1,i} \\
\gamma^t_i:&& S^t_{1,i}, S^{t+1}_{1,i+46} &\to S^t_{4,i} \\
\delta^t_i:&& S^t_{4,i}, S^{t+1}_{4,i+4} &\to S^{t+1}_{2,i} \\
\varepsilon^t_i:&& S^t_{2,i}, S^{t+1}_{2,i+38} &\to S^{t+1}_{0,i}.
    \end{align*}
    \caption*{\MiniMORUS instances}
  \end{subfigure}
  \caption{\MiniMORUS linear trail fragments.}
  \label{fig:minimorusfragments}
\end{figure}

The way we are going to use each trail fragment may be summarized as follows, where in each case, elements to the left of the arrow $\to$ are used to approximate the element on the right of the arrow:
\begin{alignat*}{2}
\alpha^t_i:\quad&& C^t_i &\to S^{t+1}_{0,i+b_0} \\
\beta^t_i:\quad&& C^t_i, S^t_{0,i} &\to S^t_{1,i} \\
\gamma^t_i:\quad&& S^t_{1,i}, S^{t+1}_{1,i+b_1} &\to S^t_{4,i} \\
\delta^t_i:\quad&& S^t_{4,i}, S^{t+1}_{4,i+b_4} &\to S^{t+1}_{2,i} \\
\varepsilon^t_i:\quad&& S^t_{2,i}, S^{t+1}_{2,i+b_2} &\to S^{t+1}_{0,i}.
\end{alignat*}

In more detail, the idea is that by using $\alpha^t_i$, we are able to approximate a bit of $S_0$ using only a ciphertext bit. By combining $\alpha^t_i$ with $\beta^{t+1}_{i+b_0}$, we are then able to approximate a bit of $S_1$ (at step $t+1$) using only ciphertext bits from two consecutive steps. Likewise, $\gamma^t_i$ allows us to ``jump'' from $S_1$ to $S_4$, i.e. by combining $\alpha^t_i$ with $\beta^t_i$ and $\gamma^t_i$ with appropriate choices of parameters $t$ and $i$ for each, we are able to approximate one bit of $S_4$ using only ciphertext bits. Notice however that $\gamma^t_i$ requires approximating $S_1$ in two consecutive steps; and so the previous combination requires using $\alpha^t_i$ and $\beta^t_i$ \emph{twice} at different steps. In the same way, $\delta^t_i$ allows us to jump from $S_4$ to $S_2$; and $\varepsilon^t_i$ allows jumping from $S_2$ back to $S_0$. Eventually, we are able to approximate a bit of $S_0$ using only ciphertext bits via the combination of all trail fragments $\alpha^t_i$, $\beta^t_i$, $\gamma^t_i$, $\delta^t_i$, and $\varepsilon^t_i$.

However, the same bit of $S_0$ can also be approximated directly by using $\alpha^t_i$ at the corresponding step. Thus that bit can be linearly approximated from two different sides: the first approximation uses a combination of all trail fragments, and involves successive approximations of all state registers (except $S_3$) spanning several encryption steps, as explained in the previous paragraph. The second approximation only involves using $\alpha^t_i$ at the final step reached by the previous trail. By XORing up these two approximations, we are left with only ciphertext bits, spanning five consecutive encryption steps.

Of course, the overall trail resulting from all of the previous combinations is quite complex, especially since $\gamma^t_i$, $\delta^t_i$, and $\varepsilon^t_i$ each require two copies of the preceding trail fragment in consecutive steps: that is, $\varepsilon^t_i$ requires two approximations of $S_2$, which requires using $\delta^t_i$ twice; and $\delta^t_i$ in turn requires using $\gamma^t_i$ twice, which itself requires using $\alpha^t_i$ and $\beta^t_i$ twice. Then $\alpha^t_i$ is used one final time to close the trail.
The full construction with the exact bit indices for \MiniMORUS[640] and
\MiniMORUS[1280] is illustrated in \Cref{fig:twoapproximations}, where the left
and right half each show half of the full trail.
One may naturally wonder if some components of this trail are in conflict. In particular, products of bits from registers $S_2$ and $S_3$ are approximated multiple times, by $\alpha^t_i$, $\beta^t_i$ and $\gamma^t_i$. To address this concern, and ensure that all approximations along the trail are in fact compatible, we now compute the full trail equation explicitly.

\begin{figure}
  \newcommand{\M}[2]{1.65,-1.5*#1-.25-.25*#2}
  \newcommand{\C}[1]{-.1,-.25-1.5*#1}
  \renewcommand{\S}[2]{.25+.25*#2,-1.5*#1}
  \centering
  \resizebox{!}{0.95\textheight}{
  \begin{tikzpicture}[xscale=3, yscale=1.5, every node/.style={font=\scriptsize,inner sep=2pt}]
    \begin{scope}
      \foreach \r in {0,...,3} { \draw[gray, rounded corners=2pt] (0,-\r*1.5) rectangle ++(1.5,-1.5); }
      \foreach \r in {0,...,4} { \draw (\S{0}{\r}) node[above] {$S_{\r}$}; }
      \draw (\C{0}|-\S{0}{0}) node[above] {$C$};

      \draw[alpha] (\C{0}) node[left] {27} -| (\S{1}{0}) node[above right] {0}
                   (\M{0}{0}) node[right] {$\alpha_{27}$};

      \draw[beta]  (\C{1}) node[above left] {0} -| (\S{1}{0}) node[below right] {0}
                   (\C{1}-|\S{1}{0}) -| ([xshift=-1pt]\S{1}{1}) node[above] {0\,}
                   (\M{1}{0}) node[right] {$\beta_0$};
      \draw[alpha] ([yshift=-1.5pt]\C{1}) node[left] {8} -| (\S{2}{0}) node[above right] {\!\!13}
                   (\M{1}{1}) node[right] {$\alpha_{8,26}$};
      \draw[alpha] ([yshift=-3.0pt]\C{1}) node[below left] {26} -| ([xshift=-1pt]\S{2}{0}) node[above left] {31\!};
      \draw[gamma] (\S{1}{1}) node[above] {\,0} -- (\S{2}{1}) node[above left] {31\!\!}
                   (\S{1}{1}) ++(0,-.75) -| ([xshift=-1pt]\S{1}{4}) node[above] {0\,}
                   (\M{1}{2}) node[right] {$\gamma_0$};
      \draw[delta] (\S{1}{4}) node[above] {\,0} -- (\S{2}{4}) node[above right] {13}
                   (\S{1}{4}) ++(0,-1.25) -| ([xshift=2pt]\S{2}{2}) node[below] {0} node[black] {$\times$}
                   (\M{1}{3}) node[right] {$\delta_0$};

      \draw[beta]  (\C{2}) node[above left] {31} -| ([xshift=-1pt]\S{2}{0}) node[below left] {31\!}
                   ([xshift=-1pt]\C{2}-|\S{2}{0}) -| (\S{2}{1}) node[below left] {31\!\!}
                   (\M{2}{0}) node[right] {$\beta_{13,31}$};
      \draw[beta]  ([yshift=-1.5pt]\C{2}) node[left] {13} -| (\S{2}{0}) node[below right] {\!\!13}
                   ([yshift=-1.5pt]\C{2}-|\S{2}{0}) -| ([xshift=1pt]\S{2}{1}) node[above] {\,\,\,13};
      \draw[alpha] ([yshift=-3.0pt]\C{2}) node[below left] {7} -| (\S{3}{0}) node[above right] {12}
                   (\M{2}{1}) node[right] {$\alpha_7$};
      \draw[gamma] ([xshift=2pt]\S{2}{1}) node[below right] {13} -- ([xshift=2pt]\S{3}{1}) node[above right] {12}
                   ([xshift=2pt]\S{2}{1}) ++(0,-.75) -| (\S{2}{4}) node[below right] {13}
                   (\M{2}{2}) node[right] {$\gamma_{13}$};

      \draw[beta]  (\C{3}) node[left] {12} -| (\S{3}{0}) node[below right] {12}
                   (\C{3}-|\S{3}{0}) -| ([xshift=2pt]\S{3}{1}) node[below right] {12}
                   (\M{3}{0}) node[right] {$\beta_{12}$};

      \draw (\S{4}{2}) node[above] {\normalsize $\chi_1$: weight 7 (not 11)};
    \end{scope}

    \begin{scope}[xshift=2.5cm]
      \foreach \r in {1,...,4} { \draw[gray, rounded corners=2pt] (0,-\r*1.5) rectangle ++(1.5,-1.5); }
      \foreach \r in {0,...,4} { \draw (\S{1}{\r}) node[above] {$S_{\r}$}; }
      \draw (\C{0}|-\S{1}{0}) node[above] {$C$};

      \draw[alpha] (\C{1}) node[left] {2} -| (\S{2}{0}) node[above right] {7}
                   (\M{1}{0}) node[right] {$\alpha_{2}$};

      \draw[beta]  (\C{2}) node[above left] {7} -| (\S{2}{0}) node[below right] {7}
                   (\C{2}-|\S{2}{0}) -| ([xshift=-1pt]\S{2}{1}) node[above] {7\,}
                   (\M{2}{0}) node[right] {$\beta_7$};
      \draw[alpha] ([yshift=-1.5pt]\C{2}) node[left] {15} -| (\S{3}{0}) node[above right] {\!20}
                   (\M{2}{1}) node[right] {$\alpha_{15,1,27}$};
      \draw[alpha] ([yshift=-3.0pt]\C{2}) node[below left] {1} -| ([xshift=-1pt]\S{3}{0}) node[above left] {6\!};
      \draw[alpha] ([yshift=-4.5pt]\C{2}) node[below] {\,\,\,\,27} -| ([xshift=-3pt]\S{3}{0}) node[below] {0\,\,};
      \draw[gamma] (\S{2}{1}) node[above] {\,7} -- (\S{3}{1}) node[above left] {6\!}
                   (\S{2}{1}) ++(0,-.75) -| ([xshift=-1pt]\S{2}{4}) node[above] {7\,}
                   (\M{2}{2}) node[right] {$\gamma_7$};
      \draw[delta] (\S{2}{4}) node[above] {\,7} -- (\S{3}{4}) node[above right] {20}
                   (\S{2}{4}) ++(0,-1.25) -| ([xshift=1pt]\S{3}{2}) node[below] {\,7}
                   (\M{2}{4}) node[right] {$\delta_7$};
      \draw[epsil] (\S{2}{2}) node[above] {0} node[black] {$\times$} -- (\S{3}{2}) node[below] {7\,}
                   (\S{2}{2}) ++(0,-1.00) -| ([xshift=-4pt]\S{3}{0}) node[above left] {0}
                   (\M{2}{3}) node[right] {$\varepsilon_0$};

      \draw[beta]  (\C{3}) node[above left] {6} -| ([xshift=-1pt]\S{3}{0}) node[below left] {6\!}
                   ([xshift=-1pt]\C{3}-|\S{3}{0}) -| (\S{3}{1}) node[below left] {6\!}
                   (\M{3}{0}) node[right] {$\beta_{20,6}$};
      \draw[beta]  ([yshift=-1.5pt]\C{3}) node[left] {20} -| (\S{3}{0}) node[below right] {\!20}
                   ([yshift=-1.5pt]\C{3}-|\S{3}{0}) -| ([xshift=1pt]\S{3}{1}) node[above] {\,\,\,\,20};
      \draw[alpha] ([yshift=-3.0pt]\C{3}) node[below left] {14} -| (\S{4}{0}) node[above right] {19}
                   (\M{3}{1}) node[right] {$\alpha_{14}$};
      \draw[gamma] ([xshift=2pt]\S{3}{1}) node[below right] {20} -- ([xshift=2pt]\S{4}{1}) node[above right] {19}
                   ([xshift=2pt]\S{3}{1}) ++(0,-.75) -| (\S{3}{4}) node[below right] {20}
                   (\M{3}{2}) node[right] {$\gamma_{20}$};

      \draw[beta]  (\C{4}) node[left] {19} -| (\S{4}{0}) node[below right] {19}
                   (\C{4}-|\S{4}{0}) -| ([xshift=2pt]\S{4}{1}) node[below right] {19}
                   (\M{4}{0}) node[right] {$\beta_{19}$};

      \draw (\S{5}{2}) node[above] {\normalsize $\chi_2$: weight 9 (not 13)};
      \draw (\S{0}{2}) node[below] {\normalsize \MiniMORUS[640]};
    \end{scope}

    \draw[dashed] (\S{4.25}{-1}) -- (\S{4.25}{7}) -- ++(\S{1}{-1}) -- ++(\S{0}{7});

    \begin{scope}[yshift=-7.0cm]
      \foreach \r in {0,...,3} { \draw[gray, rounded corners=2pt] (0,-\r*1.5) rectangle ++(1.5,-1.5); }
      \foreach \r in {0,...,4} { \draw (\S{0}{\r}) node[above] {$S_{\r}$}; }
      \draw (\C{0}|-\S{0}{0}) node[above] {$C$};

      \draw[alpha] (\C{0}) node[left] {51} -| (\S{1}{0}) node[above right] {0}
                   (\M{0}{0}) node[right] {$\alpha_{51}$};

      \draw[beta]  (\C{1}) node[above left] {0} -| (\S{1}{0}) node[below right] {0}
                   (\C{1}-|\S{1}{0}) -| ([xshift=-1pt]\S{1}{1}) node[above] {0\,}
                   (\M{1}{0}) node[right] {$\beta_0$};
      \draw[alpha] ([yshift=-1.5pt]\C{1}) node[left] {55} -| (\S{2}{0}) node[above right] {\!4}
                   (\M{1}{1}) node[right] {$\alpha_{55,33}$};
      \draw[alpha] ([yshift=-3.0pt]\C{1}) node[below left] {33} -| ([xshift=-1pt]\S{2}{0}) node[above left] {46\!};
      \draw[gamma] (\S{1}{1}) node[above] {\,0} -- (\S{2}{1}) node[above left] {46\!}
                   (\S{1}{1}) ++(0,-.75) -| ([xshift=-1pt]\S{1}{4}) node[above] {0\,}
                   (\M{1}{2}) node[right] {$\gamma_0$};
      \draw[delta] (\S{1}{4}) node[above] {\,0} -- (\S{2}{4}) node[above right] {4}
                   (\S{1}{4}) ++(0,-1.25) -| ([xshift=2pt]\S{2}{2}) node[below] {0} node[black] {$\times$}
                   (\M{1}{3}) node[right] {$\delta_0$};

      \draw[beta]  (\C{2}) node[above left] {46} -| ([xshift=-1pt]\S{2}{0}) node[below left] {46\!}
                   ([xshift=-1pt]\C{2}-|\S{2}{0}) -| (\S{2}{1}) node[below left] {46\!}
                   (\M{2}{0}) node[right] {$\beta_{4,46}$};
      \draw[beta]  ([yshift=-1.5pt]\C{2}) node[left] {4} -| (\S{2}{0}) node[below right] {\!4}
                   ([yshift=-1.5pt]\C{2}-|\S{2}{0}) -| ([xshift=1pt]\S{2}{1}) node[above] {\,\,\,4};
      \draw[alpha] ([yshift=-3.0pt]\C{2}) node[below left] {37} -| (\S{3}{0}) node[above right] {50}
                   (\M{2}{1}) node[right] {$\alpha_{37}$};
      \draw[gamma] ([xshift=2pt]\S{2}{1}) node[below right] {4} -- ([xshift=2pt]\S{3}{1}) node[above right] {50}
                   ([xshift=2pt]\S{2}{1}) ++(0,-.75) -| (\S{2}{4}) node[below right] {4}
                   (\M{2}{2}) node[right] {$\gamma_{4}$};

      \draw[beta]  (\C{3}) node[left] {50} -| (\S{3}{0}) node[below right] {50}
                   (\C{3}-|\S{3}{0}) -| ([xshift=2pt]\S{3}{1}) node[below right] {50}
                   (\M{3}{0}) node[right] {$\beta_{50}$};

      \draw (\S{4}{2}) node[above] {\normalsize $\chi_1$: weight 7 (not 11)};
      \draw (\S{5}{2}) node[above] {\normalsize \MiniMORUS[1280]};
    \end{scope}

    \begin{scope}[xshift=2.5cm,yshift=-7.0cm]
      \foreach \r in {1,...,4} { \draw[gray, rounded corners=2pt] (0,-\r*1.5) rectangle ++(1.5,-1.5); }
      \foreach \r in {0,...,4} { \draw (\S{1}{\r}) node[above] {$S_{\r}$}; }
      \draw (\C{0}|-\S{1}{0}) node[above] {$C$};

      \draw[alpha] (\C{1}) node[left] {25} -| (\S{2}{0}) node[above right] {38}
                   (\M{1}{0}) node[right] {$\alpha_{25}$};

      \draw[beta]  (\C{2}) node[above left] {38} -| (\S{2}{0}) node[below right] {38}
                   (\C{2}-|\S{2}{0}) -| ([xshift=-1pt]\S{2}{1}) node[above] {38\,}
                   (\M{2}{0}) node[right] {$\beta_{38}$};
      \draw[alpha] ([yshift=-1.5pt]\C{2}) node[left] {7} -| (\S{3}{0}) node[above right] {\!20}
                   (\M{2}{1}) node[right] {$\alpha_{7,1,51}$};
      \draw[alpha] ([yshift=-3.0pt]\C{2}) node[below left] {29} -| ([xshift=-1pt]\S{3}{0}) node[above left] {42\!};
      \draw[alpha] ([yshift=-4.5pt]\C{2}) node[below] {\,\,\,\,51} -| ([xshift=-4pt]\S{3}{0}) node[below] {0\,\,\,};
      \draw[gamma] (\S{2}{1}) node[above right] {38} -- (\S{3}{1}) node[above left] {20\!}
                   (\S{2}{1}) ++(0,-.75) -| ([xshift=-1pt]\S{2}{4}) node[above left] {38}
                   (\M{2}{2}) node[right] {$\gamma_{38}$};
      \draw[delta] (\S{2}{4}) node[above] {\,38} -- (\S{3}{4}) node[above right] {42}
                   (\S{2}{4}) ++(0,-1.25) -| ([xshift=1pt]\S{3}{2}) node[below right] {38}
                   (\M{2}{4}) node[right] {$\delta_{38}$};
      \draw[epsil] (\S{2}{2}) node[above] {0} node[black] {$\times$} -- (\S{3}{2}) node[below] {38}
                   (\S{2}{2}) ++(0,-1.00) -| ([xshift=-5pt]\S{3}{0}) node[above left] {0}
                   (\M{2}{3}) node[right] {$\varepsilon_0$};

      \draw[beta]  (\C{3}) node[above left] {42} -| ([xshift=-1pt]\S{3}{0}) node[below left] {42\!}
                   ([xshift=-1pt]\C{3}-|\S{3}{0}) -| (\S{3}{1}) node[below left] {42\!}
                   (\M{3}{0}) node[right] {$\beta_{20,42}$};
      \draw[beta]  ([yshift=-1.5pt]\C{3}) node[left] {20} -| (\S{3}{0}) node[below right] {\!20}
                   ([yshift=-1.5pt]\C{3}-|\S{3}{0}) -| ([xshift=1pt]\S{3}{1}) node[above] {\,\,\,\,20};
      \draw[alpha] ([yshift=-3.0pt]\C{3}) node[below left] {11} -| (\S{4}{0}) node[above right] {24}
                   (\M{3}{1}) node[right] {$\alpha_{11}$};
      \draw[gamma] ([xshift=2pt]\S{3}{1}) node[below right] {42} -- ([xshift=2pt]\S{4}{1}) node[above right] {24}
                   ([xshift=2pt]\S{3}{1}) ++(0,-.75) -| (\S{3}{4}) node[below right] {42}
                   (\M{3}{2}) node[right] {$\gamma_{42}$};

      \draw[beta]  (\C{4}) node[left] {24} -| (\S{4}{0}) node[below right] {24}
                   (\C{4}-|\S{4}{0}) -| ([xshift=2pt]\S{4}{1}) node[below right] {24}
                   (\M{4}{0}) node[right] {$\beta_{24}$};

      \draw (\S{5}{2}) node[above] {\normalsize $\chi_2$: weight 9 (not 13)};
    \end{scope}
  \end{tikzpicture}}

  \caption{\MiniMORUS: two approximations for $S_{2,0}^2$.}
  \label{fig:twoapproximations}
\end{figure}

\subsection{Trail Equation}
\label{sec:minitraileq}

The equation corresponding to each of the five trail fragments $\alpha^t_i$, $\beta^t_i$, $\gamma^t_i$, $\delta^t_i$, $\varepsilon^t_i$ may be written explicitly as $A^t_i$, $B^t_i$, $C^t_i$, $D^t_i$, $E^t_i$ as follows. For each equation, we write on the left-hand side of the equality the biased linear combination used in the trail; and on the right-hand side, the remainder of the equation, which must have non-zero correlation (in all cases the correlation is $2^{-1}$).
\begin{alignat*}{2}
A^t_i:\quad&& C^t_i \oplus S^{t+1}_{0,i+b_0} &= S^t_{1,i} \oplus S^t_{3,i} \oplus S^t_{1,i} \cdot S^t_{2,i} \oplus S^t_{2,i} \cdot S^t_{3,i}\\
B^t_i:\quad&& C^t_i \oplus S^t_{0,i} \oplus S^t_{1,i} &= S^t_{2,i} \cdot S^t_{3,i} \\
C^t_i:\quad&& S^t_{1,i} \oplus S^{t+1}_{1,i+b_1} \oplus S^t_{4,i} &= S^t_{2,i} \cdot S^t_{3,i}\\
D^t_i:\quad&& S^t_{4,i} \oplus S^{t+1}_{4,i+b_4} \oplus S^{t+1}_{2,i} &= S^{t+1}_{0,i} \cdot S^{t+1}_{1,i}\\
E^t_i:\quad&& S^t_{2,i} \oplus S^{t+1}_{2,i+b_2} \oplus S^{t+1}_{0,i} &= S^t_{3,i} \cdot S^t_{4,i}
\end{alignat*}

From an algebraic point of view, building the full trail amounts to adding up copies of the previous equations for various choices of $t$ and $i$, so that eventually all $S^x_{y,z}$ terms on the left-hand side cancel out. Then we are left with only ciphertext terms on the left-hand side, while the right-hand side consists of a sum of biased expressions. By measuring the correlation of the right-hand side expression, we are then able to determine the correlation of the linear combination of ciphertext bits on the left-hand side. We now set out to do so.

In order to build the equation for the full trail, we start with $E^2_0$:
\[
S^2_{2,0} \oplus S^{3}_{2,b_2} \oplus S^{3}_{0,0} = S^2_{3,0} \cdot S^2_{4,0}.
\]
In order to cancel the $S^{3}_{0,0}$ term on the left-hand side, we add to the equation $A^2_{-b_0}$ (where the sum of two equations of the form $a = b$ and $c = d$ is defined to be $a+c = b+d$). This yields:
\begin{align*}
&S^2_{2,0} \oplus S^3_{2,b_2} \oplus C^2_{-b_0}\\
=\; &S^2_{3,0} \cdot S^2_{4,0} \oplus S^2_{1,-b_0} \oplus S^2_{3,-b_0} \oplus S^2_{1,-b_0} \cdot S^2_{2,-b_0} \oplus S^2_{2,-b_0} \cdot S^2_{3,-b_0}.
\end{align*}
We then need to cancel two terms of the form $S^t_{2,i}$. To do this, we add to the equations $D^t_i$ for appropriate choices of $t$ and $i$. This replaces the two $S^t_{2,i}$ terms by four $S^t_{4,i}$ terms. By using equation $B^t_i$ four times, we can then replace these four $S^t_{4,i}$ terms by eight $S^t_{1,i}$ terms. By applying equation $B^t_i$ eight times, these eight $S^t_{1,i}$ terms can in turn be replaced by eight $S^t_{0,i}$ terms (and some ciphertext terms). Finally, applying $A^t_i$ eight times allows to replace these eight $S^t_{0,i}$ terms by only ciphertext bits. Ultimately, for \MiniMORUS[1280], this yields the equation:
\begin{flalign*}
&&&C^0_{51} \oplus C^1_{0} \oplus C^1_{25} \oplus C^1_{33} \oplus C^1_{55} \oplus C^2_{4} \oplus C^2_{7} \oplus C^2_{29} \oplus C^2_{37}&&\\
&&\oplus\; &C^2_{38} \oplus C^2_{46} \oplus C^2_{51} \oplus C^3_{11} \oplus C^3_{20} \oplus C^3_{42} \oplus C^3_{50} \oplus C^4_{24}&&\\
&&=\; &S^0_{1,51} \cdot S^0_{2,51} \oplus S^0_{2,51} \cdot S^0_{3,51} \oplus S^0_{1,51} \oplus S^0_{3,51}&&\text{weight 1}\\
&&\oplus\; & S^1_{1,25} \cdot S^1_{2,25} \oplus S^1_{2,25} \cdot S^1_{3,25} \oplus S^1_{1,25} \oplus S^1_{3,25}&&\text{weight 1}\\
&&\oplus\; & S^1_{1,33} \cdot S^1_{2,33} \oplus S^1_{2,33} \cdot S^1_{3,33} \oplus S^1_{1,33} \oplus S^1_{3,33}&&\text{weight 1}\\
&&\oplus\; & S^1_{1,55} \cdot S^1_{2,55} \oplus S^1_{2,55} \cdot S^1_{3,55} \oplus S^1_{1,55} \oplus S^1_{3,55}&&\text{weight 1}\\
&&\oplus\; & S^2_{1,7} \cdot S^2_{2,7} \oplus S^2_{2,7} \cdot S^2_{3,7} \oplus S^2_{1,7} \oplus S^2_{3,7}&&\text{weight 1}\\
&&\oplus\; & S^2_{1,29} \cdot S^2_{2,29} \oplus S^2_{2,29} \cdot S^2_{3,29} \oplus S^2_{1,29} \oplus S^2_{3,29}&&\text{weight 1}\\
&&\oplus\; & S^2_{1,37} \cdot S^2_{2,37} \oplus S^2_{2,37} \cdot S^2_{3,37} \oplus S^2_{1,37} \oplus S^2_{3,37}&&\text{weight 1}\\
&&\oplus\; & S^2_{1,51} \cdot S^2_{2,51} \oplus S^2_{2,51} \cdot S^2_{3,51} \oplus S^2_{1,51} \oplus S^2_{3,51}&&\text{weight 1}\\
&&\oplus\; & S^3_{1,11} \cdot S^3_{2,11} \oplus S^3_{2,11} \cdot S^3_{3,11} \oplus S^3_{1,11} \oplus S^3_{3,11}&&\text{weight 1}\\
&&\oplus\; & S^2_{0,0} \cdot S^2_{1,0}&&\text{weight 1}\\
&&\oplus\; & S^2_{2,46} \cdot S^2_{3,46}&&\text{weight 1}\\
&&\oplus\; & S^2_{3,0} \cdot S^2_{4,0}&&\text{weight 1}\\
&&\oplus\; & S^3_{0,38} \cdot S^3_{1,38}&&\text{weight 1}\\
&&\oplus\; & S^3_{2,20} \cdot S^3_{3,20}&&\text{weight 1}\\
&&\oplus\; & S^3_{2,50} \cdot S^3_{3,50}&&\text{weight 1}\\
&&\oplus\; & S^4_{2,24} \cdot S^4_{3,24}&&\text{weight 1}
\end{flalign*}

The equation for \MiniMORUS[640] is very similar, and is given in \Cref{sec:traileq}.

\subsection{Correlation of the Trail}
\label{sec:minibias}

In the equation for \MiniMORUS[1280] from the previous section, each line on the right-hand side of the equality involves distinct $S^t_{i,j}$ terms (in the sense that no two lines share a common term), and each line has a weight of 1. By the Piling-Up Lemma, it follows that if we assume distinct $S^t_{i,j}$ terms to be uniform and independent, then the expression on the right-hand side has a weight of 16. Hence the linear combination of ciphertext bits on the left-hand side has a correlation of $2^{-16}$. The same holds for \MiniMORUS[640] (cf. \Cref{sec:traileq}).

That the correlation is so high may be surprising: indeed, the full trail uses trail fragment $\varepsilon^t_i$ 1 time, $\delta^t_i$ 2 times, $\gamma^t_i$ 4 times, $\beta^t_i$ 8 times, and $\alpha^t_i$ 9 times. Since each trail fragment has a weight of 1, this would suggest that the total weight should be $1+2+4+8+9 = 24$ rather than 16. However, when combining trail fragments $\beta_i$ and $\gamma_i$, notice that the same AND is computed at the same step between registers $S_2$ and $S_3$ (equivalently, notice that the right-hand side of equations $B^t_i$ and $C^t_i$ is equal). In both cases it is approximated by zero. When XORing the corresponding equations, these two ANDs cancel each other, which saves two AND gates. Since $\gamma^t_i$ is used four times in the course of the full trail, this results in saving 8 AND gates overall, which explains why the final correlation is $2^{-16}$ rather than $2^{-24}$.

\subsection{Experimental Verification}

To confirm that our analysis is correct, we ran experiments on an implementation of \MiniMORUS[1280] and \MiniMORUS[640]. In both cases, we measured the correlation of two halves $\chi_1$ and $\chi_2$ of the full trail, as well as the correlation of the full trail itself (denoted by $\chi$). Results are displayed on \Cref{tab:miniapproximations}.
While our analysis from the previous section predicts a correlation of $2^{-16}$, experiments indicate a slightly better empirical correlation of $2^{-15.5}$ for \MORUS[640]. The discrepancy of $2^{-0.5}$ probably arises from the fact that register bits across different steps are not completely independent.

\ifanonymous
The programs used to verify the bias experimentally have been
submitted as supporting material.
\else
The programs we used to verify the bias experimentally are available at:\\
\centerline{
\url{https://github.com/ildyria/MorusBias}
}
\fi

%\noindent
%2 approximations for $S^{2,2}_{0}$ of \MiniMORUS[640]:
%\begin{align*}
%  S^{2,2}_0 &= C^0_{27} \oplus C^1_{0, 8, 26} \oplus C^2_{7,13,31} \oplus C^3_{12} \tag{corr. $2^{-7}$} \\
%  S^{2,2}_0 &= C^1_{2} \oplus C^2_{1,7,15,27} \oplus C^3_{6,14,20} \oplus C^4_{19} \tag{corr. $2^{-9}$} \\
%\intertext{Combined ciphertext-only approximation:}
%  0 &= C^0_{27} \oplus C^1_{0, 2, 26, 8} \oplus C^2_{1,13,15,27,31} \oplus
%  C^3_{6,12,14,20} \oplus C^4_{19} \tag{corr. $\approx 2^{-15.5}$}
%\end{align*}
%\bigskip
%
%\noindent
%2 approximations for $S^{2,2}_{0}$ of \MiniMORUS[1280]:
%\begin{align*}
%  S^{2,2}_0 &= C^0_{51} \oplus C^1_{0, 33, 55} \oplus C^2_{4,37,46} \oplus C^3_{50} \tag{corr. $2^{-7}$} \\
%  S^{2,2}_0 &= C^1_{25} \oplus C^2_{7,29,38,51} \oplus C^3_{11,20,42} \oplus C^4_{24} \tag{corr. $2^{-9}$} \\
%\intertext{Combined ciphertext-only approximation:}
%  0 &= C^0_{51} \oplus C^1_{0, 25, 33, 55} \oplus C^2_{4,7,29,37,38,46,51} \oplus C^3_{11,20,42,50} \oplus C^4_{24} \tag{corr. $\approx 2^{-??}$}
%\end{align*}

\begin{table}[h!]
  \caption{Experimental verification of trail correlations.}
  \label{tab:miniapproximations}
  \centerline{
  \begin{tabular}{@{}llSSS@{}}
    \toprule
    & & \multicolumn{3}{@{}c@{}}{Weight} \\
    \cmidrule{3-5}
    \multicolumn{2}{@{}l}{Approximations for \MiniMORUS[640]}
             & {Exp.} & {Bool.} & {Meas.} \\
    \midrule
    $\chi_1$ & $S^{2,2}_0 = C^0_{27} \oplus C^1_{0, 8, 26} \oplus C^2_{7,13,31} \oplus C^3_{12}$
             & 7    & 7     & 7 \\
    $\chi_2$ & $S^{2,2}_0 = C^1_{2} \oplus C^2_{1,7,15,27} \oplus C^3_{6,14,20} \oplus C^4_{19}$
             & 9    & 9     & 9 \\
    $\chi$   & $0 = C^0_{27} \oplus C^1_{0, 2, 26, 8} \oplus C^2_{1,13,15,27,31} \oplus C^3_{6,12,14,20} \oplus C^4_{19}$
             & 16   & 16    & 15.5 \\
    \midrule
    \multicolumn{2}{@{}l}{Approximations for \MiniMORUS[1280]} \\
    \midrule
    $\chi_1$ & $S^{2,2}_0 = C^0_{51} \oplus C^1_{0, 33, 55} \oplus C^2_{4,37,46} \oplus C^3_{50}$
             & 7    & 7     & 7 \\
    $\chi_2$ & $S^{2,2}_0 = C^1_{25} \oplus C^2_{7,29,38,51} \oplus C^3_{11,20,42} \oplus C^4_{24}$
             & 9    & 9     & 9 \\
    $\chi$   & $0 = C^0_{51} \oplus C^1_{0, 25, 33, 55} \oplus C^2_{4,7,29,37,38,46,51} \oplus C^3_{11,20,42,50} \oplus C^4_{24}$
             & 16   & 16    & 15.9 \\
    \bottomrule
  \end{tabular}
  }
\end{table}

%%% Local Variables:
%%% TeX-master: "morusAC"
%%% End:


% Copyright 2020 Markus J. Pflaum, licensed under CC BY-NC-ND 4.0
% main author:
%   Markus J. Pflaum
%
\section{The monoidal structure of the category of Hilbert spaces}
\label{sec:monoidal-structure-category-hilbert-spaces}
%
\para
Let $\fldK$ be the field of real or complex numbers.
Hilbert spaces over $\fldK$ together with bounded $\fldK$-linear maps
between them form a category denoted by $\fldK\text{-}\category{Hilb}$
or just $\category{Hilb}$ if no confusion can arise. This can be seen
immediately by observing that the identity map $\idn_\hilbertH$ on a Hilbert space
is a bounded linear operator  and that the composition $B \circ A : \hilbertH_1 \to\hilbertH_3$
of two bounded linear operators between Hilbert spaces
$A:\hilbertH_1 \to \hilbertH_2 $ and $B :\hilbertH_2 \to \hilbertH_3$ is again a
bounded linear operator.
We want to endow the category $\category{Hilb}$ with a bifunctor
$ \cplttensor : \category{Hilb} \times \category{Hilb} \to \category{Hilb}$
so that it becomes a monoidal category. The (bi)functor $\cplttensor$ will be
called the \emph{Hilbert tensor product}.

Unless mentioned differently, Hilbert spaces, vector spaces and the algebraic tensor product $\otimes$
in this section are assumed to be taken over the ground field $\fldK$.

\begin{proposition}
\label{thm:construction-tensor-inner-product}
 Let $\hilbertH_1$ and $\hilbertH_2$ be two Hilbert spaces.
 Then there exists a unique inner product
 $\inprod{\cdot,\cdot}: (\hilbertH_1 \otimes \hilbertH_2) \times (\hilbertH_1 \otimes \hilbertH_2)
  \to \fldK $ on the algebraic tensor product $\hilbertH_1\otimes \hilbertH_2$ such that
  \begin{equation}
    \label{eq:defining-relation-inner-product-tensor-product}
    \inprod{v_1 \otimes v_2 , w_1 \otimes w_2} =  \inprod{v_1,w_1} \cdot \inprod{v_2,w_2}
    \quad\text{for all } v_1,w_1 \in \hilbertH_1, \: v_2,w_2 \in \hilbertH_2 \ .
  \end{equation}
\end{proposition}

\begin{proof}
  Let us first provide some preliminary constructions.
  Recall that  for every pair of vector spaces $\vectorspV_1$ and $\vectorspV_2$
  the bilinear map
  \begin{equation*}
    \begin{split}
    \tau: \Hom (\vectorspV_1 ,\fldK) \times \Hom (\vectorspV_2,\fldK) & \to
    \Hom (\vectorspV_1 \otimes \vectorspV_2,\fldK), \\
    (\lambda_1,\lambda_2) & \mapsto \big( \vectorspV_1 \otimes \vectorspV_2 \to \fldK, \:
    v_1 \otimes v_2 \mapsto \lambda_1 (v_1) \cdot\lambda_2 (v_2) \big)
    \end{split}
  \end{equation*}
  induces a linear map
  \[
    \widehat{\tau}: \Hom (\vectorspV_1 ,\fldK) \otimes \Hom (\vectorspV_2,\fldK) \to
    \Hom (\vectorspV_1 \otimes \vectorspV_2,\fldK)
  \]
  by the universal property of the tensor product.
  This map is an isomorphism. To see this choose a basis $(v_{1i})_{i\in I} $ of $V_1$ and
  a basis $(v_{2j})_{j\in J} $ of $V_2$. Let  $(v^\prime_{1i})_{i\in I} $ and $(v^\prime_{2j})_{j\in J} $
  denote the respective dual bases of $V_1^\prime$ and  $V_2^\prime$. Then
  $\left( v^\prime_{1i} \otimes v^\prime_{2j}\right)_{(i,j)\in I \times J}$ is a basis of
  $\Hom (\vectorspV_1 ,\fldK) \otimes \Hom (\vectorspV_2,\fldK)$ which under $\widehat{\tau}$
  is  mapped bijectively to the basis $\left( (v_{1i} \otimes v_{2j})^\prime \right)_{(i,j)\in I \times J}$
  of $\Hom (\vectorspV_1 \otimes \vectorspV_2,\fldK)$ dual to the basis
  $\left( v_{1i} \otimes v_{2j}\right)_{(i,j)\in I \times J}$ of $\vectorspV_1 \otimes \vectorspV_2$.
  Hence $\widehat{\tau}$ is a linear isomorphism as claimed, and we can identify
  the tensor product $\lambda_1\otimes \lambda_2$ of two linear functionals
  $\lambda_i: \vectorspV_i\to\fldK$, $i=1,2$
  with its image in $\Hom (\vectorspV_1 \otimes \vectorspV_2,\fldK)$.

  Now observe that for two conjugate-linear maps $\mu_1 :\vectorspV_1 \to \fldK$
  and $\mu_2 :\vectorspV_2 \to \fldK$ the map
  $ \tau^* (\mu_1,\mu_2)  = \overline{\overline{\mu_1}\otimes \overline{\mu_2}} :
     \vectorspV_1 \otimes \vectorspV_2 \to \fldK$
  is conjugate-linear and satisfies
  \begin{equation}
  \label{eq:defining-relation-tensor-product-conjugate-linear-maps}
     \tau^* (\mu_1,\mu_2) \, (v_1\otimes v_2) = \mu_1(v_1) \cdot \mu_2(v_2) \quad
     \text{for all } v_1\in\vectorspV_1 ,\: v_2 \in\vectorspV_2 \ .
  \end{equation}
  %If $\varrho : \vectorspV_1 \otimes \vectorspV_2 \to \fldK$ is another conjugate-linear map
  %with the property that $\varrho (v_1\otimes v_2) = \mu_1(v_1) \cdot \mu_2(v_2)$ for all
  %$v_i\in\vectorspV_i$, $i=1,2$, then
  %$\overline{\varrho} = \overline{\mu_1}\otimes \overline{\mu_2}$, hence $\varrho =  \tau^* (\mu_1,\mu_2) $.
  One obtains a map
  \[
    \tau^*: \Hom^* (\vectorspV_1,\fldK) \times \Hom^* (\vectorspV_2,\fldK)
    \to \Hom^* (\vectorspV_1 \otimes \vectorspV_2 ,\fldK) \ ,
  \]
  where here the symbol $\Hom^* (\vectorspV,\fldK)$ denotes the space  of all conjugate linear
  functionals on a vector space $\vectorspV$. Since $\tau^*$ is biadditive and
  since $\tau^* (z\mu_1,\mu_2) = \tau^* (\mu_1,z\mu_2)$ for all $\mu_1\in \Hom^*(\vectorspV_1 ,\fldK)$,
  $\mu_2\in \Hom^*(\vectorspV_2 ,\fldK)$, and $z\in \fldK$, the map $\tau^*$ factors through a linear map
   \[
    \widehat{\tau^*} :\Hom^* (\vectorspV_1 ,\fldK) \otimes \Hom^* (\vectorspV_2,\fldK) \to
    \Hom^* (\vectorspV_1 \otimes \vectorspV_2,\fldK)  \ .
  \]
  Using the above bases $(v_{1i})_{i\in I} $ and $(v_{2j})_{j\in J} $ of $V_1$ and $V_2$ respectively,
  one observes that $\widehat{\tau^*}$ is an isomorphism since it maps the basis
  $\left( \overline{v^\prime_{1i}} \otimes \overline{v^\prime_{2j}}\right)_{(i,j)\in I \times J}$ of
  $\Hom^* (\vectorspV_1 ,\fldK) \otimes \Hom^* (\vectorspV_2,\fldK)$
  bijectively to the basis $\left( \overline{(v_{1i} \otimes v_{2j})^\prime} \right)_{(i,j)\in I \times J}$
  of the space $\Hom^* (\vectorspV_1 \otimes \vectorspV_2,\fldK)$.  So $\widehat{\tau^*}$ is also
  a linear isomorphism, which allows us to identify the tensor product $\mu_1 \otimes \mu_2$
  of two conjugate linear functionals  $\mu_i: \vectorspV_i\to\fldK$, $i=1,2$ with its image in
  $\Hom^* (\vectorspV_1 \otimes \vectorspV_2,\fldK)$.

  After these preliminary considerations we consider the map
  \[
    \hilbertH_1\times \hilbertH_2 \to \Hom^* (\hilbertH_1\otimes \hilbertH_2,\fldK) ,
    \: (v_1,v_2) \mapsto \overline{v_1^\flat} \otimes  \overline{v_2^\flat} =
    \tau^* \left( \overline{v_1^\flat} , \overline{v_2^\flat}  \right)=
    \widehat{\tau^*}  \left( \overline{v_1^\flat} \otimes \overline{v_2^\flat}  \right)\ ,
  \]
  which is well-defined and bilinear since the musical isomorphisms
  ${}^\flat: \hilbertH_l \to \hilbertH_l'$, $v \mapsto  \inprod{ - ,v} $, $l=1,2$,
  are conjugate-linear and  since $\tau^*$ is bilinear. Hence it factors through a linear map
  \[
    \beta: \hilbertH_1\otimes \hilbertH_2 \to \Hom^* (\hilbertH_1\otimes \hilbertH_2,\fldK)
  \]
  such that
  \begin{equation}
  \label{eq:defining-relation-map-beta}
    \beta (v_1\otimes v_2) (w_1\otimes w_2) =  \inprod{v_1,w_1} \cdot \inprod{v_2,w_2}
    \quad \text{for all } v_1,w_1\in \hilbertH_1 , \: v_2,w_2\in \hilbertH_2 \ .
  \end{equation}
  Now put
  \[
   \inprod{\cdot,\cdot} :
   (\hilbertH_1 \otimes \hilbertH_2) \times (\hilbertH_1 \otimes \hilbertH_2)
   \to \fldK, \: (v,w) \mapsto \beta (v) (w) \ .
  \]
  Then $\inprod{\cdot,\cdot}$ is sesquilinear by construction, and
  \eqref{eq:defining-relation-inner-product-tensor-product} holds true by
  \eqref{eq:defining-relation-map-beta}.

  Let us show that $\inprod{\cdot,\cdot}$ is positive definite. Let
  $v = \sum_{k=1}^n v_{1k} \otimes v_{2k} \in \hilbertH_1 \otimes \hilbertH_2$.
  Choose an orthonormal basis $e_1, \ldots , e_m$ of the linear subspace
  spanned by $v_{21}, \ldots , v_{2n}$. Expand
  $ v_{2k} = \sum_{i=1}^m c_{ki} e_i$ with $c_{k1}, \ldots , c_{km} \in \fldK$.
  Then
  \begin{equation}
    \label{eq:expansion-tensor-product-vector-orthonormal-basis-second-component}
    v = \sum_{k=1}^n v_{1k} \otimes v_{2k} =  \sum_{k=1}^n \sum_{i=1}^m   v_{1k} \otimes  (c_{ki} e_i) =
    \sum_{i=1}^m \left( \sum_{k=1}^n   c_{ki} v_{1k} \right) \otimes  e_i =
    \sum_{i=1}^m  w_{1i}  \otimes  e_i \ ,
  \end{equation}
  where $ w_{1i} = \sum_{k=1}^n   c_{ki} v_{1k} $. Hence
  \begin{equation}
    \label{eq:positivity-tensor-inner-product}
    \inprod{v,v} =  \inprod{\sum_{i=1}^m  w_{1i}  \otimes  e_i,\sum_{j=1}^m  w_{1j}  \otimes  e_j }
    = \sum_{i=1}^m \sum_{j=1}^m  \inprod{w_{1i},  w_{1j}} \, \inprod{ e_i,e_j } =
     \sum_{i=1}^m \| w_{1i} \|^2 \geq 0 \ .
  \end{equation}
  Moreover, if $\inprod{v,v} = 0$, then $w_{1i}=0$ for $i=1,\ldots , m$, which implies
  $v=  \sum_{i=1}^m  w_{1i}  \otimes  e_i =0$.
  So $ \inprod{\cdot,\cdot}$ is an inner product on $\hilbertH_1\otimes \hilbertH_2$ satisfying
  \eqref{eq:defining-relation-inner-product-tensor-product}. It is uniquely determined by this
  condition since the vectors $v_1\otimes v_2$ with $v_1\in \hilbertH_1$ and $v_2\in \hilbertH_2$  span
  $\hilbertH_1\otimes \hilbertH_2$.
\end{proof}

\begin{definition}
  Let $\hilbertH_1$ and $\hilbertH_2$ be Hilbert spaces.
  The Hilbert completion of the algebraic tensor product $\hilbertH_1 \otimes \hilbertH_2$
  equipped with the unique inner product $\inprod{\cdot,\cdot}$  fulfilling
  \eqref{eq:defining-relation-inner-product-tensor-product}
  will be denoted $\hilbertH_1 \cplttensor \hilbertH_2$, its inner product again by $\inprod{\cdot,\cdot}$. One calls the Hilbert space
  $\big(\hilbertH_1 \cplttensor \hilbertH_2 ,\inprod{\cdot,\cdot}\big)$
  the \emph{Hilbert tensor product} of $\hilbertH_1$ and $\hilbertH_2$ or just the
  \emph{tensor product} of $\hilbertH_1$ and $\hilbertH_2$ if no confusion can arise.
\end{definition}

\begin{proposition}\label{thm:totality-tensor-product-total-sets}
  Let $\hilbertH_1$ and $\hilbertH_2$ be Hilbert spaces.
  \begin{romanlist}
  \item\label{ite:totality-simple-tensor-products-total-sets}
    If $A_i \subset \hilbertH_i$ for $i=1,2$ are total in the ambient  Hilbert space,
    then the set of simple vectors $a_1\otimes a_2$ with $a_1 \hilbertH_1$ and
    $a_2 \hilbertH_2$ is total in the Hilbert
    tensor product  $\hilbertH_1 \cplttensor \hilbertH_2$.
  \item
    If $(e_i)_{i\in I}$ and $(f_j)_{j\in J}$ are orthonormal bases of  $\hilbertH_1$ and $\hilbertH_2$,
    respectively, then $(e_i\otimes f_j)_{(i,j)\in I \times J}$ is an orthonormal basis of the Hilbert
    tensor product $\hilbertH_1 \cplttensor \hilbertH_2$.
  \end{romanlist}
\end{proposition}

\begin{proof}
  \begin{adromanlist}
  \item
    Recall that a subset $A \subset \hilbertH$ or a family $A = (a_j)_{j\in J}$ of elements of
    a Hilbert space $\hilbertH$ is called \emph{total} in $\hilbertH$ if the linear span
    of $A$ is dense in  $\hilbertH$. By density of the algebraic tensor product
    $\hilbertH_1\otimes \hilbertH_2$ in the Hilbert tensor product
    $\hilbertH_1\cplttensor \hilbertH_2$, the set of simple tensors $v_1\otimes v_2$
    with $v_i \in \hilbertH_i$ for $i= 1,2$  is total in $\hilbertH_1\cplttensor \hilbertH_2$.
    Hence it suffices to find for such $v_i$ and all $\varepsilon >0$
    vectors $w_i \in \Span A_i$ for $i= 1,2$ such that
    \[
                \| v_1\otimes v_2 - w_1\otimes w_2 \| < \frac{\varepsilon}{2} \ .
    \]
    By totality of $A_i$ in $\hilbertH_i$ there exist $w_i \in \Span A_i$  such that
    \[
      \| v_1 - w_1 \| < \min \left\{ 1, \frac{\varepsilon}{2(\| v_2 \| +1 ) } \right\}
      \quad \text{and}\quad
      \| v_2 - w_2 \| < \frac{\varepsilon}{2(\| v_1 \| +1 ) } \ .
    \]
    Then
    \[
      \| v_1\otimes v_2 - w_1\otimes w_2 \| \leq
      \| v_1 - w_1 \| \, \| v_2 \| +  \|  v_2 - w_2 \| \| w_1 \|  < \varepsilon \ .
    \]

  \item
  The family $(e_i\otimes f_j)_{(i,j)\in I \times J}$ is orthonormal by definition of the inner product on
  $\hilbertH_1 \cplttensor \hilbertH_2$. It is total by
  \ref{ite:totality-simple-tensor-products-total-sets} and therefore a Hilbert basis.
  \end{adromanlist}
\end{proof}

\begin{proposition}
\label{thm:tensor-product-functor-category-hilbert-spaces-bounded-linear-operators}
  Assigning to each pair of Hilbert spaces $\hilbertH_1$ and $\hilbertH_2$ the Hilbert tensor product
  $\hilbertH_1 \cplttensor  \hilbertH_2$
  and to each pair of bounded linear operators $A_1:\hilbertH_1 \to \hilbertH_3$ and  $A_2:\hilbertH_2 \to \hilbertH_4$
  between Hilbert spaces the unique bounded extension
  $A_1 \cplttensor A_2 : \hilbertH_1 \cplttensor \hilbertH_2 \to   \hilbertH_3 \cplttensor  \hilbertH_4$ of the operator
  $A_1 \otimes A_2 : \hilbertH_1 \otimes \hilbertH_2 \to   \hilbertH_3 \cplttensor  \hilbertH_4$,
  $v_1 \otimes v_2 \mapsto A_1(v_1) \otimes  A_2(v_2)$
  comprises a (covariant) bifunctor
  \[ \cplttensor : \category{Hilb} \times \category{Hilb} \to \category{Hilb} \ . \]
  Moreover, $\cplttensor$ is isometric in the sense that
  \begin{align}
    \label{eq:completed-tensor-product-isometry-equation-vectors}
    \| v_1 \otimes v_2\| & = \|v_1\| \, \|v_2\| \quad \text{for all } v_1\in \hilbertH_1, \: v_2 \in \hilbertH_1 \text{ and }\\
    \label{eq:completed-tensor-product-isometry-equation-bounded-linear-maps}
    \| A_1 \cplttensor     A_2\| & = \| A_1\| \, \|A_2\| \quad \text{for all }
       A_1\in \blinOps ( \hilbertH_1, \hilbertH_3 ), \: A_2\in \blinOps ( \hilbertH_2, \hilbertH_4 ) \ .
  \end{align}
\end{proposition}

\begin{proof}
  We first show that $A_1 \otimes A_2 $ is a bounded operator. To this end observe that
  $A_1 \otimes A_2 $ can be written as the composition of the two operators $A_1\otimes \idn_{\hilbertH_2}$
  and $ \idn_{\hilbertH_3} \otimes A_2$. Hence it suffices to show that each of these linear maps is bounded.
  Let $v = \sum_{k=1}^n v_{1k} \otimes v_{2k} \in \hilbertH_1 \otimes \hilbertH_2$ be of norm $1$.
  As in the proof of \Cref{thm:construction-tensor-inner-product}  expand
  $ v_{2k} = \sum_{i=1}^m c_{ki} e_i$, $k=1,\ldots ,n$, where $e_1, \ldots , e_m$ is an orthonormal basis of
  $\Span \{ v_{21}, \ldots , v_{2n}\}$  and $c_{k1}, \ldots , c_{km} \in \fldK$.
  Equations \eqref{eq:expansion-tensor-product-vector-orthonormal-basis-second-component}
  and \eqref{eq:positivity-tensor-inner-product} then entail that
  \begin{displaymath}
    v = \sum_{i=1}^m  w_{1i}  \otimes  e_i \quad\text{and}\quad
    1  = \inprod{v,v}  = \sum_{i=1}^m \| w_{1i} \|^2
  \end{displaymath}
  for $ w_{1i} = \sum_{k=1}^n   c_{ki} v_{1k} $, $i=1,\ldots , m$.
  Hence
  \[
    \|( A_1 \otimes \idn_{\hilbertH_2})v \|^2 =  \left\| \sum_{i=1}^m A_1 (w_{1i}) \otimes e_i\right\|^2
    = \sum_{i=1}^m \| A_1 (w_{1i}) \|^2 \leq \|A_1\|^2 \sum_{i=1}^m \| w_{1i} \|^2  = \|A_1\|^2  \ ,
  \]
  so $A_1\otimes \idn_{\hilbertH_2}$ is bounded with norm $\leq \|A_1\|$.
  By symmetry,  $ \idn_{\hilbertH_3} \otimes A_2$ is  bounded with norm $\leq \|A_2\|$. Hence
  $A_1 \otimes A_2 = (\idn_{\hilbertH_3} \otimes A_2 )\circ (A_1\otimes \idn_{\hilbertH_2}) $
  is bounded and
  \[
    \| A_1 \otimes A_2 \| \leq \|A_1\| \, \|A_2\| \ .
  \]
  Let us show the converse inequality. For given $\varepsilon >0$ there exist
  unit vectors $v_i \in \hilbertH_i$, $i=1,2$ such that
  $\|A_iv_i \|\geq \| A_i \| - \frac{\varepsilon}{2(\| A_1\| +\|A_2\| +1)}$. Then
  \[
    \| (A_1 \cplttensor A_2) (v_1\otimes v_2) \| =   \| A_1v_1\| \,  \| A_2v_2\|
    \geq \| A_1 \| \, \| A_2\| -  \varepsilon \ .
    % + \frac{\varepsilon^2}{4(\| A_1\| +\|A_2\| +1)^2}
  \]
  This implies
  \[
    \| A_1 \otimes A_2 \| \geq \|A_1\| \, \|A_2\|
  \]
  and \eqref{eq:completed-tensor-product-isometry-equation-bounded-linear-maps} follows.
  Equality \eqref{eq:completed-tensor-product-isometry-equation-vectors} is clear by
  construction of the Hilbert tensor product.

  Next observe that
  $\idn_{ \hilbertH_1} \cplttensor \idn_{\hilbertH_2} = \idn_{\hilbertH_1 \cplttensor \hilbertH_2}$
  by definition.  Given Hilbert spaces $\hilbertH_1,\ldots,\hilbertH_6$
  and bounded linear operators $A_i: \hilbertH_{i}\to \hilbertH_{i+2}$ and
  $B_i : \hilbertH_{i+2}\to \hilbertH_{i+4}$ for $i=1,2$, the composition
  $(B_1 \otimes B_2 ) \circ (A_1 \otimes A_2)$ coincides with
  $ (B_1\circ A_1) \otimes (B_2\circ A_2) $ by functoriality of the algebraic tensor product.
  By continuity of the operators $A_1 \cplttensor A_2$ and $B_1 \cplttensor B_2$ and
  by density of $\hilbertH_1\otimes \hilbertH_2$ in $\hilbertH_1\cplttensor \hilbertH_2$
  the equality
  \[
    (B_1 \cplttensor B_2 ) \circ (A_1 \cplttensor A_2) =
    (B_1\circ A_1) \cplttensor (B_2\circ A_2)
  \]
  follows. Hence $\cplttensor$ is a bifunctor as claimed.
\end{proof}

\begin{proposition}
 For every Hilbert space $\hilbertH$ one has two natural isomorphisms
  \[
   \widehat{u}_\hilbertH : \fldK \cplttensor \hilbertH \to \hilbertH ,\: z\otimes v \to z v \quad \text{and} \quad
   {}_\hilbertH \widehat{u} : \hilbertH \cplttensor \fldK \to \hilbertH ,\: v \otimes z \to z v
  \]
  called the \emph{left} and the \emph{right  unit}, respectively. Furthermore, for every triple of Hilbert spaces
  $\hilbertH_1,\hilbertH_2,\hilbertH_3$ there is a natural isomorphism, called \emph{associator}
  \[
   \widehat{a}_{\hilbertH_1,\hilbertH_2,\hilbertH_3} : (\hilbertH_1 \cplttensor \hilbertH_2) \cplttensor \hilbertH_3 \to
   \hilbertH_1 \cplttensor ( \hilbertH_2  \cplttensor \hilbertH_3 ),\:
   (v_1\otimes v_2)\otimes v_3 \mapsto v_1\otimes (v_2 \otimes v_3 )\ .
  \]
  These data fulfill the so-called \emph{coherence conditions} that is the \emph{pentagon diagram}
  \begin{displaymath}
    \begin{tikzpicture}
\node (P0) at (90:2.8cm) {$((\hilbertH_1 \cplttensor \hilbertH_2) \cplttensor \hilbertH_3) \cplttensor \hilbertH_4$};
\node (P1) at (90+72:2.5cm) {$(\hilbertH_1\cplttensor (\hilbertH_2\cplttensor \hilbertH_3))\cplttensor \hilbertH_4$} ;
\node (P2) at (90+2*72:2.5cm) {$\mathllap{\hilbertH_1\cplttensor ((\hilbertH_2\cplttensor \hilbertH_3)}\cplttensor \hilbertH_4)$};
\node (P3) at (90+3*72:2.5cm) {$\hilbertH_1\cplttensor (\hilbertH_2\mathrlap{\cplttensor (\hilbertH_3\cplttensor \hilbertH_4))}$};
\node (P4) at (90+4*72:2.5cm) {$(\hilbertH_1\cplttensor \hilbertH_2)\cplttensor (\hilbertH_3\cplttensor \hilbertH_4)$};
\draw
(P0) edge[->,>=angle 90] node[left] {$\widehat{a}_{\hilbertH_1,\hilbertH_2,\hilbertH_3} \cplttensor \, \idn_{\hilbertH_4}\hspace{2mm}$} (P1)
(P1) edge[->,>=angle 90] node[left] {$\widehat{a}_{\hilbertH_1,\hilbertH_2\cplttensor \hilbertH_3 , \hilbertH_4}$} (P2)
(P2) edge[->,>=angle 90] node[below] {$\hspace{5mm}\idn_{\hilbertH_1}\cplttensor \, \widehat{a}_{\hilbertH_2,\hilbertH_3,\hilbertH_4}$} (P3)
(P4) edge[->,>=angle 90] node[right] {$ \widehat{a}_{\hilbertH_1 , \hilbertH_2,\hilbertH_3 \cplttensor  \hilbertH_4}$} (P3)
(P0) edge[->,>=angle 90] node[right] {$ \widehat{a}_{\hilbertH_1\cplttensor \hilbertH_2, \hilbertH_3 , \hilbertH_4}$} (P4);
  \end{tikzpicture}
  \end{displaymath}
  and the \emph{triangle diagram}
  \begin{displaymath}
  \begin{tikzcd}
      ( \hilbertH_1 \cplttensor \fldK) \cplttensor \hilbertH_2
      \ar[rrrr,"\widehat{a}_{\hilbertH_1,\fldK,\hilbertH_3}"]
      \ar[drr,"{}_{\hilbertH_1}\!\widehat{u} \, \cplttensor \,\idn_{\hilbertH_2}",swap]& & &&
      \hilbertH_1 \cplttensor (\fldK \cplttensor \hilbertH_2 )
      \ar[dll,"\idn_{\hilbertH_1} \cplttensor \, \widehat{u}_{\hilbertH_2}"]  \\
      & & \hilbertH_1 \cplttensor \hilbertH_2 &  &
  \end{tikzcd}
  \end{displaymath}
  commute for all Hilbert spaces $\hilbertH_1,\hilbertH_2,\hilbertH_3,\hilbertH_4$.  In other words,
  the category $\category{Hilb}$ endowed with the Hilbert tensor product $\cplttensor$ is a monoidal  category.
\end{proposition}

\begin{proof}
  The category of $\fldK$-vector spaces with the usual tensor product as tensor functor is monoidal.
  Denote the corresponding unit isomorphisms and associator by
  $_{-}u$, $u_{-}$, and $a_{-,-,-}$, respectively. Then observe that by construction
  $\fldK \cplttensor \hilbertH = \fldK \otimes \hilbertH$ and $\hilbertH \cplttensor \fldK = \hilbertH \otimes \fldK$
  for every Hilbert space $\hilbertH$. In particular this means that putting
  $\widehat{u}_\hilbertH = u_\hilbertH$ and ${}_{\hilbertH}\widehat{u} = {}_{\hilbertH}u$ gives the desired units.
  Next recall that  $\hilbertH_1 \otimes \hilbertH_2$ is dense in $\hilbertH_1 \cplttensor \hilbertH_2$
  which by \Cref{thm:totality-tensor-product-total-sets} implies density of $(\hilbertH_1 \otimes \hilbertH_2) \otimes \hilbertH_3$
  and $\hilbertH_1 \otimes (\hilbertH_2 \otimes \hilbertH_3)$ in $(\hilbertH_1 \cplttensor \hilbertH_2) \cplttensor \hilbertH_3$
  and $\hilbertH_1 \cplttensor (\hilbertH_2 \cplttensor \hilbertH_3)$, respectively.
  Similarly one argues that $\hilbertH_1 \otimes (\hilbertH_2 \otimes (\hilbertH_3\otimes \hilbertH_4))$
  is dense in  $\hilbertH_1 \cplttensor (\hilbertH_2 \cplttensor (\hilbertH_3\cplttensor \hilbertH_4))$,
  % that $(\hilbertH_1 \otimes \hilbertH_2) \otimes (\hilbertH_3\otimes \hilbertH_4)$
  % is dense in  $(\hilbertH_1 \cplttensor \hilbertH_2) \cplttensor (\hilbertH_3\cplttensor \hilbertH_4)$
  and so on. Since the associator map
  $a_{\hilbertH_1,\hilbertH_2,\hilbertH_3} : (\hilbertH_1 \otimes \hilbertH_2) \otimes \hilbertH_3 \to
  \hilbertH_1 \otimes ( \hilbertH_2  \otimes \hilbertH_3 )$ is bounded, it extends in a unique way to a linear
  bounded map $\widehat{a}_{\hilbertH_1,\hilbertH_2,\hilbertH_3} : (\hilbertH_1 \cplttensor \hilbertH_2) \cplttensor \hilbertH_3 \to
  \hilbertH_1 \cplttensor ( \hilbertH_2  \cplttensor \hilbertH_3 )$. Using density, continuity, and commutativity
  of the pentagon and triangle diagrams for the tensor product functor one concludes that the coherence conditions for
  $\cplttensor$ with the unit and associator maps $_{-}\widehat{u}$, $\widehat{u}_{-}$, and $\widehat{a}_{-,-,-}$ are satisfied.
\end{proof}


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage{aeguill}
\usepackage{setspace}

\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{trees}

\allowdisplaybreaks

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

\begin{document}
\title{Notes}
\date{4 fevrier, 2015}
\maketitle
\section*{3.1 eulerian paths}
if $G$ is a non-trivial graph containing a path that visits every edge then we call the path Eulerian. If the trail is closed, (a cycle) then we call the graph Eulerian.

can you draw it without picking up pencil?
\subsection*{example}
eulerian path:
\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]
  \node[main_node] (1) at (-1,-1) {};
  \node[main_node] (2) at (1,-1) {};
  \node[main_node] (3) at (-1,0) {};
  \node[main_node] (4) at (1,0) {};
  \node[main_node] (5) at (0,1) {};
  \draw (1) -- (2) -- (4) -- (3)--(5)--(4)--(2);
  \draw (1)--(4);
  \draw (1)--(3);
  \draw (2)--(3);
\end{tikzpicture}
eulerian graph
\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]
  \node[main_node] (1) at (-1,-1) {};
  \node[main_node] (2) at (-1,1) {};
  \node[main_node] (3) at (1,-1) {};
  \node[main_node] (4) at (1,1) {};
  \node[main_node] (5) at (0,0) {};
  \node[main_node] (6) at (2,0) {};
  \draw (1) -- (2) -- (4) -- (3)--(5)--(4)--(6)--(3)--(1);
\end{tikzpicture}
\section*{theorem}
let $G$ be a connected (not necessarily simple graph). $G$ is Eulerian if and only if $d(v)$ degree of $v$ is even $\forall v\in V(G)$

\subsubsection*{proof}
forward direction:

let $C$ be an eulerian cycle. $C$ visits every edge which means each time it enters a vertex, it also exits. except first and last? the degree increases by $2$ for each visit. increase of one when we start, increase of 1 when finishing for the starting/endpoint. so the source vertex has even degree also.

reverse direction:

we are given that every vertex is even degree. let $P$ be a $u-v$ path for some $u,v\in V(G)$.
However, since $\deg(v)=2k$ we have an exit available. choose an available neighbor $v'$ and extend $P$ to include $v'$. Now $P$ is a $u-v'$ path. but $\deg(v')=2k'$ and so we have an exit. repeat and eventually we will hit $u$ again ($|V(G)|<\infty$) creating a cycle. Call this cycle $C$ and assume it is not eulerian, else done. let $H=G-C$. remove edges in $C$ and the hanging vertices. let $x\in V(C)$ that is adjacent to and edge not in $C$. then this point is in $H$ and exists because $C$ is not eulerian. let $H'$ be a component of $H$ such that $x\in V(H')$. the degrees of all vertices in $H'$ are necessarily even because $C$ removed an even number of edges from each vertex. Repeating, we can create an $x-x$ path in $H'$. If the $x-x$ cycle is not eulerian in $H'$, recurse (graph is finite).  the cycle is: start on $C$ when we get to another cycle, traverse it, and then continue on with $C$.

\subsection*{
bridges of königsburg:
}
old
\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]
  \node[main_node] (1) at (-1,-1) {a};
  \node[main_node] (2) at (1,-1) {b};
  \node[main_node] (3) at (1,1) {c};
  \node[main_node] (4) at (-1,1) {d};
  \draw (2) -- (1) -- (3) -- (4)--(2) to[out=135,in=45] (1) to[out=45,in=-45] (3);
\end{tikzpicture}
new
\begin{tikzpicture}[main_node/.style={circle,draw,text=black,inner sep=1pt,outer sep=0pt]}]
  \node[main_node] (1) at (-1,-1) {a};
  \node[main_node] (2) at (1,-1) {b};
  \node[main_node] (3) at (1,1) {c};
  \node[main_node] (4) at (-1,1) {d};
  \draw (2) -- (1) -- (3) -- (4)--(2);
  \draw (2) -- (3);
  \draw (2) to[out=45,in=45] (3);
  \draw (3) to[out=45,in=45] (4);
\end{tikzpicture}

\section*{corollary}
let $G$ be a connected graph, $G$ has an eulerian trail if and only if $G$ has two or fewer odd vertices.
\subsubsection*{proof}
$\Leftarrow$
if $0$ odd vertices we are done. if $G$ has two odd vertices, add an edge between them, create the E.C. and delete the edge.

$\Rightarrow$
``go in, go out'' argument.

\section*{homework}
3,4,6,7
\end{document}


\documentclass[twoside]{MATH77}
\usepackage{multicol}
\usepackage[fleqn,reqno,centertags]{amsmath}
\begin{document}
\begmath 7.2 Roots of a Quadratic Polynomial

\silentfootnote{$^\copyright$1997 Calif. Inst. of Technology, \thisyear \ Math \`a la Carte, Inc.}

\subsection{Purpose}

Compute the two roots of a quadratic polynomial having real coefficients.

\subsection{Usage}

\subsubsection{Program Prototype, Single Precision}

\begin{description}
\item[\bf REAL]  \ {\bf A}$(\geq 3)$

\item[\bf COMPLEX]  \ {\bf Z}$(\geq 2)$
\end{description}

Assign values to A().
$$
\fbox{{\bf CALL SPOLZ2(A, Z)}}
$$
The roots are returned in Z($).$

\subsubsection{Argument Definitions}

\begin{description}
\item[A()]  [in] Contains the coefficients of the polynomial%
\begin{equation*}
a_1x^2+a_2x+a_3
\end{equation*}
Require A($1)\neq 0$. The contents of the array A() are not modified by the
subroutine.

\item[Z()]  [out] Array in which the two roots are returned. The roots will
be stored as complex numbers even in cases in which they are real.
\end{description}

\subsubsection{Modifications for Double Precision}

For double precision usage change the subroutine name to {\bf DPOLZ2} and
change the type statements to:

{\bf DOUBLE PRECISION} \ {\bf A}($\geq 3)$

{\bf DOUBLE PRECISION} \ {\bf Z}($2$, $\geq 2)$, or

{~~~~\bf COMPLEX*16} \ {\bf Z}($\geq 2)$)

On return the real and imaginary parts of the $j^{th}$ root will be stored
in Z($1,j)$ and Z($2,j)$ respectively.

\subsection{Examples and Remarks}

The program, DRSPOLZ2, uses SPOLZ2 to compute the roots of the polynomials, $%
x^2+x-1$, $2x^2-12x+26$, and $x^2-4x+4$. The output is shown in ODSPOLZ2.

See the remark in Chapter~15.1, Section~C, concerning the use of COMPLEX*16.

\subsection{Functional Description}

\subparagraph{Method}

We are given the real coefficients of a quadratic polynomial:%
\begin{equation*}
a_1x^2+a_2x+a_3
\end{equation*}
The case of $a_1=0$ is regarded as an error. The subroutine issues an error
message and returns, setting both roots to zero.

Compute $p = a_2/a_1$ and $q = a_3/a_1$. The cases of $p = 0$ or $q = 0$ are
given special treatment. Otherwise we compute the roots of $x^2 + px + q$,
knowing that $p$ and $q$ are both nonzero.

Compute $u=-p/2$. Direct use of the quadratic formula would give the roots
as $r_1=u+z$ and $r_2=u-z$, where $z= \sqrt{u^2-q}$. To extend the range of
data for which results can be obtained without overflow or underflow, the
expression for $z$ is evaluated differently depending on the magnitude of $u$%
. We use thresholds, $c_1$ and $c_2$, such that $c_1^2/16$ is the underflow
limit and $16c_2^2$ is the overflow limit. The values of $c_1$ and $c_2$ are
set on the first call to this subroutine by use of the subprograms R1MACH or
D1MACH from Chapter~19.1.

Rather than computing $z$, we compute $f=|z|$ and a quantity, $d$, having
the same sign as $u^2-q:$
\begin{tabbing}
\hspace{.2in}\=If $|u| > c_2$\\
\>\ \ \ \ \=$d=1-(q/u)/u$\\
\>\>$f = |u| \sqrt{|d|}$\\
\>Elseif $|u| < c_1$\\
\>\>$d=u(u/|q|)- \sign q$\\
\>\>$f = \sqrt{|q|} \ \sqrt{|d|}$\\
\>Else\\
\>\>$d=u^2-q$\\
\>\>$f = \sqrt{|d|}$\\
\>Endif
\end{tabbing}
If $d=0$, the polynomial has the real root, $u$, with multiplicity two. If $%
d<0$, the roots are the complex numbers, $(u,f)$ and $(u,-f).$

If $d>0$, the roots are the two real numbers, $u+f$ and $u-f$, however use
of these expressions would cause unnecessary loss of accuracy in the root of
smaller magnitude when the magnitudes of $u$ and $f$ are nearly the same.
Instead we use the expressions, $r_1=u+f \sign u$, and $r_2=q/r_1.$

\subparagraph{Accuracy tests}

A test program ran cases exercising all of the branches of the subroutine.
Accuracy was consistent with the computer being used.

\subsection{Error Procedures and Restrictions}

If the high-order coefficient, A(1), is zero, the subroutine issues an error
message via ERMSG of Chapter~19.2, with an error level of 0,
and returns with both roots set to zero.

\subsection{Supporting Information}

The Source Language is ANSI Fortran~77.

Designed by C. L. Lawson, JPL, May~1986.

Programmed by C. L. Lawson and S. Y. Chiu, JPL, May~1986, Feb.~1987.

\begin{tabular}{@{\bf}l@{\hspace{5pt}}l}
\bf Entry & \hspace{.35in} {\bf Required Files}\vspace{2pt}\\
DPOLZ2 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
 AMACH, DPOLZ2, ERFIN, ERMSG\rule[-5pt]{0pt}{8pt}}\\
SPOLZ2 & \parbox[t]{2.7in}{\hyphenpenalty10000 \raggedright
 AMACH, ERFIN, ERMSG, SPOLZ2}\\
\end{tabular}

\begcode

\medskip\
\lstset{language=[77]Fortran,showstringspaces=false}
\lstset{xleftmargin=.8in}

\centerline{\bf \large DRSPOLZ2}\vspace{10pt}
\lstinputlisting{\codeloc{spolz2}}
\newpage
\vspace{30pt}\centerline{\bf \large ODSPOLZ2}\vspace{10pt}
\lstset{language={}}
\lstinputlisting{\outputloc{spolz2}}
\end{document}


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

\section{The Boltzmann equation}

\marginpar{Wednesday\\ 2020-11-18, \\ compiled \\ \today}

The phase space distribution function is denoted as \(f(x^{\mu }, p^{\mu })\); the Boltzmann equation reads
%
\begin{align}
\hat{L}[f] = \hat{C}[f]
\,.
\end{align}

If \(\hat{C} = 0\), then Liouville's theorem tells us that \(\dv*{f}{t} = 0\).
The nonrelativistic expression for \(\hat{L}[p]\) is
%
\begin{align}
\hat{L}[f] = \qty[ \pdv{\vec{x}}{t} \cdot \nabla_{\vec{x}} + \pdv{\vec{v}}{t} \cdot \nabla_{\vec{v}} + \pdv{}{t}]f
\,,
\end{align}
%
while the general relativistic expression is
%
\begin{align}
\hat{L}[f] = \qty[p^{\mu } \pdv{}{x^{\mu }} - \Gamma^{\alpha }_{\beta \gamma } p^{\beta } p^{\gamma } \pdv{}{p^{\alpha }}]f
\,,
\end{align}
%
since by the geodesic equation
%
\begin{align}
\dv[2]{x^{\mu }}{\lambda}
= - \Gamma^{\mu}_{\alpha \beta } \dv{x^{\alpha }}{\lambda } \dv{x^{\beta }}{\lambda }
= - \Gamma^{\mu }_{\alpha \beta } p^{\alpha } p^{\beta }
\,.
\end{align}

In the homogeneous and isotropic case we will have \(f = f (\abs{p}, t)\), since the dependences on \(\abs{p}\) and \(E\) are related.
The only nonzero Christoffel symbols for a flat FLRW metric are
%
\begin{align}
\Gamma^{0}_{ij} = \delta_{ij} a \dot{a} && \Gamma^{i}_{0j} = \Gamma^{j}_{i0}
= \delta^{i}_{j} \frac{\dot{a}}{a}
\,.
\end{align}

Therefore, the Liouville operator in our case can be written in terms of \(p^2 = g_{ij} p^{i}p^{j} = a^2 \delta_{ij} p^{i} p^{j}\), the square of the \emph{three}-momentum, which scales like \(1/a\):
%
\begin{align}
\hat{L}[f(E, t)] &= E \pdv{f}{t} - \frac{\dot{a}}{a} p^2 \pdv{f}{E}
\,.
\end{align}

The number density reads
%
\begin{align}
n = \frac{g}{(2 \pi )^3} \int \dd[3]{p} f
\,,
\end{align}
%
so the Boltzmann equation can be manipulated by rewriting the Liouville operator as
%
\begin{align}
\underbrace{\pdv{}{t} \qty( \frac{g}{(2 \pi )^3} \int \dd[3]{p} f)}_{\dot{n}(t)} - \frac{\dot{a}}{a} \frac{g}{(2 \pi )^3}\int \dd[3]{p} \frac{p^2}{E} \pdv{f}{E} &=
\frac{g}{(2 \pi )^3} \int \dd[3]{p} \frac{C[f]}{E}
\,.
\end{align}
%

Manipulating the second term in the equation we find
%
\begin{align}
\frac{g}{(2 \pi )^3} \int \dd[3]{p} p^2 \pdv{f}{E}
= \frac{4 \pi g}{(2 \pi )^3} \int \dd{p} \frac{p^{4}}{E} \pdv{f}{E}
\,,
\end{align}
%
and since \(E^2 = p^2 + m^2 \implies E \dd{E} =p \dd{p}\) we get
%
\begin{align}
\frac{4 \pi g}{(2 \pi )^3} \int \dd{p} p^3 \pdv{f}{p}
= -\frac{4 \pi g}{(2 \pi)^3} \int \dd{p} (3 p^2) f(p)
= -3 n(t)
\marginnote{Integrated by parts}
\,.
\end{align}

Then our equation reads
%
\begin{align}
\dot{n}(t) + 3 H n(t) = \frac{g}{(2 \pi )^3} \int \dd[3]{p} \frac{\hat{C}[f]}{E}
\,.
\end{align}

This, as expected, gives \(n \propto a^{-3}\) if there are no collisions.

Let us apply this to a process \(1 + 2 \leftrightarrow 3 + 4\), of which we are interested in the density \(n_1 (t)\): the collision terms reads
%
\begin{align}
\begin{split}
\frac{g_1 }{(2 \pi )^3} \int \frac{\hat{C}[f_1 ]}{E_1 } \dd[3]{p_1 } &=
\int \dd{\Pi_1 }\dd{\Pi_2 }\dd{\Pi_3 }\dd{\Pi_4 }
(2 \pi )^{4} \delta^{(4)}(p_1 + p_2 - p_3 - p_4 ) \times \\
&\phantom{=}\
\qty[
    \abs{\mathcal{M}}^2_{3 + 4 \to 1 + 2} f_3 f_4 (1 \pm f_1 ) (1 \pm f_2 )
    -
    \abs{\mathcal{M}}^2_{1 + 2 \to 3 + 4} f_1 f_2 (1 \pm f_3 ) (1 \pm f_4 )
    ]
\end{split}
\marginnote{The minus in the second term is because in that case we are annihilating particle 1.}
\,,
\end{align}
%
where
%
\begin{align}
\dd{\Pi _i} = \frac{g_i \dd[3]{p_i}}{(2 \pi )^3 2 E_i}
\,,
\end{align}
%
while \(\mathcal{M}\) is the Feynman amplitude.
The terms \(1 \pm f_i\) are given by the Pauli blocking (\(-\)) or Bose enhancement (\(+\)) coming from the statistics of the chosen particle.

This equation must be written for all the particle species, in general yielding a complicated integrodifferential equation system.
Because of time reversal symmetry (our first assumption) we will have \(\abs{\mathcal{M}}^2_{1 + 2 \to 3 + 4} = \abs{\mathcal{M}}^2_{3 + 4 \to 1 +2} \equiv \abs{\mathcal{M}}^2\).

We can further postulate that all the particle species are in kinetic equilibrium (our second assumption): then, we say that they are distributed according to the Bose-Einstein or Fermi-Dirac distribution,
%
\begin{align}
f^{i}_{BE - FD} = \qty[\exp(\frac{E - \mu}{T}) \mp 1]^{-1}
\,.
\end{align}

In this case we write \(\mp\) since the \(-\) corresponds to Bosons, while the \(+\) is for Fermions.

This works well as long as the scatterings are fast enough.
This parametrization is quite useful, since it makes our integrodifferential equations into simple(r) ODEs.

Kinetic equilibrium is not just local thermodynamic equilibrium: it also requires local \emph{chemical} equilibrium, which implies the following for the chemical potentials:
%
\begin{align}
\mu _1 + \mu _2 = \mu _3 + \mu _4
\,.
\end{align}

Since we can find such linear relations for any possible reaction, the true number of independent chemical potentials will dramatically shrink.
We expect these to be related to conserved quantities.
Since these are mostly small, we can approximate \(\mu _i = 0 \forall i\).
For the CMB photons, this is confirmed with \(\mu _\gamma / T \lesssim \num{e-4}\).

Further, we make the semiclassical approximation (our third assumption): \(1 \pm f_i \approx 1\), so that the distribution just becomes \(f = \exp((\mu - E) /T)\).
With all these considerations, we find
%
\begin{align}
\dot{n}_1 (t) + 3 H n_1 (t)
&= \int \dd{\Pi_1 }\dd{\Pi_2 }\dd{\Pi_3 }\dd{\Pi_4 } (2 \pi )^{4}\delta^{(4)} (p_1 +p_2 - p_3 - p_4 )
\abs{\mathcal{M}}^2 \qty(f_3 f_4 - f_1 f_2 )\\
\begin{split}
&= \int \dd{\Pi_1 }\dd{\Pi_2 }\dd{\Pi_3 }\dd{\Pi_4 }
(2 \pi )^{4}\delta^{(4)} (p_1 +p_2 - p_3 - p_4 ) \\
&\phantom{=}\
\abs{\mathcal{M}}^2 \exp(- \frac{E_1 + E_1 }{T})
\qty(\exp(\frac{\mu_3 + \mu _4 }{T}) - \exp( \frac{\mu _1 + \mu _2 }{T}))
\end{split}
\marginnote{Used \(E_1 + E_2 = E_3 + E_4 \).}
\,.
\end{align}

This yields
%
\begin{align}
n_i (t) &= \frac{g_i}{(2 \pi )^3} \int \dd[3]{p_i} f_i  \\
&= g_i \exp( \frac{\mu_i}{T}) \int \frac{ \dd[3]{p_i}}{(2 \pi )^3}
\exp(- \frac{E_i}{T})
\,.
\end{align}

At equilibrium, and using the approximation that \(\mu _i = 0\), this yields
%
\begin{align} \label{eq:equilibrium-number-density}
n^{\text{eq}}_i =
g_i \int \frac{ \dd[3]{p_i}}{(2 \pi )^3}
\exp(- \frac{E_i}{T}) \approx \begin{cases}
    g_i \qty(\frac{m_i T}{2 \pi })^{3/2} \exp(- \frac{m_i}{T}) & \text{nonrelativistic}  \\
    \frac{g_i}{\pi^2} T^3 & \text{relativistic}
\end{cases}
\,.
\end{align}

Also,
%
\begin{align}
f_3 f_4 - f_1 f_2 = \exp(- \frac{E_1 + E_2 }{T})
\qty[ e^{ \frac{\mu_3}{T}} e^{ \frac{\mu_4}{T}} - e^{ \frac{\mu_1}{T}} e^{ \frac{\mu_2}{T}} ]
= \exp(- \frac{E_1 + E_2 }{T}) \qty[
    \frac{n_3 n_4 }{n_3^{\text{eq}} n_4^{\text{eq}}} -
    \frac{n_1 n_2 }{n_1^{\text{eq}} n_2^{\text{eq}}}
]
\,.
\end{align}

The thermally averaged cross-section is
%
\begin{align}
\expval{\sigma \abs{v}} =
\frac{1}{n_1^{\text{eq}} n_2^{\text{eq}}}
\int \dd{\Pi_1 }\dd{\Pi_2}\dd{\Pi_3 }\dd{\Pi_4 }
(2 \pi )^{4} \delta^{(4)} (p_1 + p_2 - p_3 - p_4 )
\abs{\mathcal{M}}^2 \exp(- \frac{E_1 + E_2 }{T})
\,.
\end{align}

Then,
%
\begin{align}
\dot{n}_1(t) + 3 H n_1 (t) = n_1^{\text{eq}} n_2^{\text{eq}}
\expval{\sigma \abs{v}}
\qty[
    \frac{n_3 n_4 }{n_3^{\text{eq}} n_4^{\text{eq}}} -
    \frac{n_1 n_2 }{n_1^{\text{eq}} n_2^{\text{eq}}}
]
\,.
\end{align}

For a standard DM particle --- a process in the form \(\psi \overline{\psi} \leftrightarrow X \overline{X}\), with \(\psi \) and \(\overline{\psi }\) in local thermal equilibrium, and \(n_\psi = n_{\overline{\psi}}\) as well as \(n_X = n_{\overline{X}}\)---, we get
%
\begin{align}
\dot{n}_1 (t) + 3 H n_1 (t) = \expval{\sigma \abs{v}} \qty[ (n_1^{\text{eq}})^2 - n_1^2]
\,.
\end{align}

The left-hand side is roughly \(n_1 / \tau \sim n_1 H\); while the right-hand side is roughly \(n_1^2 \expval{\sigma v}\): then, we are comparing \(H\) and \(\Gamma = n_1 \expval{\sigma v}\).
If \(\Gamma \gg H\), then \(n_1 \) must tend towards its equilibrium value in the limit.

\end{document}


\chapter{Chapter ~\ref{ch:modeling-evaluation} Aditional Plots}
\label{ap:aditional-plots}

In this appendix, we include some plots generated by the study presented in chapter~\ref{ch:modeling-evaluation}, which have been cut off and not included in the final text version. They are:

\begin{itemize}

	\item CDF's distributions;

	\item QQPlots;

	\item Cost history ($J_\nabla$) and data linearization from linear regression;

	\item Other plots for $AIC$, $BIC$ and $J_M$.

\end{itemize}

\clearpage

\begin{figure}[ht!]
	\centering
	\label{fig:aproximation-original-cdf-bigFlows}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/cdf/bigFlows_Log_-_Cauchy_aproximation_vs_Original_set}
	}
	\subfloat[Exponential(LR)]{
		\includegraphics[width=62mm]{figures/apC/cdf/bigFlows_Log_-_Exponential_aproximation_(linear_regression)_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Exponential(Me)]{
		\includegraphics[width=62mm]{figures/apC/cdf/bigFlows_Log_-_Exponential_aproximation_(mean)_vs_Original_set}
	}
	\subfloat[Normal]{
		\includegraphics[width=62mm]{figures/apC/cdf/bigFlows_Log_-_Normal_aproximation_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Pareto(LR)]{
		\includegraphics[width=62mm]{figures/apC/cdf/bigFlows_Log_-_Pareto_aproximation_(linear_regression)_vs_Original_set}
	}
	\subfloat[Pareto(MLH)]{
		\includegraphics[width=62mm]{figures/apC/cdf/bigFlows_Log_-_Pareto_aproximation_(maximum_likehood)_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/cdf/bigFlows_Log_-_Weibull_aproximation_vs_Original_set}
	}
	\caption{CDF functions for the approximations of \textit{lan-gateway-pcap} inter  packet times, of many stochastic functions.}
\end{figure}

\clearpage

\begin{figure}[ht!]
	\centering
	\label{fig:aproximation-original-cdf-wan}
	\subfloat[Chauchy]{
		\includegraphics[width=62mm]{figures/apC/cdf/Wan_Log_-_Cauchy_aproximation_vs_Original_set}
	}
	\subfloat[Exponential(LR)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Wan_Log_-_Exponential_aproximation_(linear_regression)_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Exponential(Me)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Wan_Log_-_Exponential_aproximation_(mean)_vs_Original_set}
	}
	\subfloat[Normal]{
		\includegraphics[width=62mm]{figures/apC/cdf/Wan_Log_-_Normal_aproximation_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Pareto(LR)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Wan_Log_-_Pareto_aproximation_(linear_regression)_vs_Original_set}
	}
	\subfloat[Pareto(MLH)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Wan_Log_-_Pareto_aproximation_(maximum_likehood)_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/cdf/Wan_Log_-_Weibull_aproximation_vs_Original_set}
	}
	\caption{CDF functions for the approximations of \textit{wan-pcap} inter  packet times, of many stochastic functions.}
\end{figure}

\clearpage

\begin{figure}[ht!]
	\centering
	\label{fig:aproximation-original-cdf-lan}
	\subfloat[Chauchy]{
		\includegraphics[width=62mm]{figures/apC/cdf/Lan_Log_-_Cauchy_aproximation_vs_Original_set}
	}
	\subfloat[Exponential(LR)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Lan_Log_-_Exponential_aproximation_(linear_regression)_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Exponential(Me)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Lan_Log_-_Exponential_aproximation_(mean)_vs_Original_set}
	}
	\subfloat[Normal]{
		\includegraphics[width=62mm]{figures/apC/cdf/Lan_Log_-_Normal_aproximation_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Pareto(LR)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Lan_Log_-_Pareto_aproximation_(linear_regression)_vs_Original_set}
	}
	\subfloat[Pareto(MLH)]{
		\includegraphics[width=62mm]{figures/apC/cdf/Lan_Log_-_Pareto_aproximation_(maximum_likehood)_vs_Original_set}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/cdf/Lan_Log_-_Weibull_aproximation_vs_Original_set}
	}
	\caption{CDF functions for the approximations of \textit{lan-diurnal-firewall-pcap} inter  packet times, of many stochastic functions.}
\end{figure}

%\begin{figure}[ht!]
%	\centering
%	\label{fig:aproximation-original-cdf-skype}
%	\subfloat[Chauchy]{
%		\includegraphics[width=62mm]{figures/apC/qq/skype_QQplot_-_Cauchy}
%	}
%	\subfloat[Exponential(LR)]{
%		\includegraphics[width=62mm]{figures/apC/qq/skype_QQplot_-_Exponential(LR)}
%	}
%	\hspace{0mm}
%	\subfloat[Exponential(Me)]{
%		\includegraphics[width=62mm]{figures/apC/qq/skype_QQplot_-_Exponential(Me)}
%	}
%	\subfloat[Normal]{
%		\includegraphics[width=62mm]{figures/apC/qq/skype_QQplot_-_Normal}
%	}
%	\hspace{0mm}
%	\subfloat[Pareto(LR)]{
%		\includegraphics[width=62mm]{figures/apC/qq/skype_QQplot_-_Pareto(LR)}
%	}
%	\subfloat[Pareto(MLH)]{
%		\includegraphics[width=62mm]{figures/apC/qq/skype_QQplot_-_Pareto(MLH)}
%	}
%	\hspace{0mm}
%	\subfloat[Weibull]{
%		\includegraphics[width=62mm]{figures/apC/qq/skype_QQplot_-_Weibull}
%	}
%	\caption{CDF functions for the approximations of \textit{skype-pcap} inter  packet times, of many stochastic functions.}
%\end{figure}

\clearpage

\begin{figure}[ht!]
	\centering
	\label{fig:qq-bigFlows}
	\subfloat[Chauchy]{
		\includegraphics[width=62mm]{figures/apC/qq/bigFlows_QQplot_-_Cauchy}
	}
	\subfloat[Exponential(LR)]{
		\includegraphics[width=62mm]{figures/apC/qq/bigFlows_QQplot_-_Exponential(LR)}
	}
	\hspace{0mm}
	\subfloat[Exponential(Me)]{
		\includegraphics[width=62mm]{figures/apC/qq/bigFlows_QQplot_-_Exponential(Me)}
	}
	\subfloat[Normal]{
		\includegraphics[width=62mm]{figures/apC/qq/bigFlows_QQplot_-_Normal}
	}
	\hspace{0mm}
	\subfloat[Pareto(LR)]{
		\includegraphics[width=62mm]{figures/apC/qq/bigFlows_QQplot_-_Pareto(LR)}
	}
	\subfloat[Pareto(MLH)]{
		\includegraphics[width=62mm]{figures/apC/qq/bigFlows_QQplot_-_Pareto(MLH)}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/qq/bigFlows_QQplot_-_Weibull}
	}
	\caption{CDF functions for the approximations of \textit{lan-gateway-pcap} inter  packet times, of many stochastic functions.}
\end{figure}

\clearpage

\begin{figure}[ht!]
	\centering
	\label{fig:qq-lan}
	\subfloat[Chauchy]{
		\includegraphics[width=62mm]{figures/apC/qq/Lan_QQplot_-_Cauchy}
	}
	\subfloat[Exponential(LR)]{
		\includegraphics[width=62mm]{figures/apC/qq/Lan_QQplot_-_Exponential(LR)}
	}
	\hspace{0mm}
	\subfloat[Exponential(Me)]{
		\includegraphics[width=62mm]{figures/apC/qq/Lan_QQplot_-_Exponential(Me)}
	}
	\subfloat[Normal]{
		\includegraphics[width=62mm]{figures/apC/qq/Lan_QQplot_-_Normal}
	}
	\hspace{0mm}
	\subfloat[Pareto(LR)]{
		\includegraphics[width=62mm]{figures/apC/qq/Lan_QQplot_-_Pareto(LR)}
	}
	\subfloat[Pareto(MLH)]{
		\includegraphics[width=62mm]{figures/apC/qq/Lan_QQplot_-_Pareto(MLH)}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/qq/Lan_QQplot_-_Weibull}
	}
	\caption{CDF functions for the approximations of \textit{lan-diurnal-firewall-pcap} inter  packet times, of many stochastic functions.}
\end{figure}

\clearpage

\begin{figure}[ht!]
	\centering
	\label{fig:qq-wan}
	\subfloat[Chauchy]{
		\includegraphics[width=62mm]{figures/apC/qq/Wan_QQplot_-_Cauchy}
	}
	\subfloat[Exponential(LR)]{
		\includegraphics[width=62mm]{figures/apC/qq/Wan_QQplot_-_Exponential(LR)}
	}
	\hspace{0mm}
	\subfloat[Exponential(Me)]{
		\includegraphics[width=62mm]{figures/apC/qq/Wan_QQplot_-_Exponential(Me)}
	}
	\subfloat[Normal]{
		\includegraphics[width=62mm]{figures/apC/qq/Wan_QQplot_-_Normal}
	}
	\hspace{0mm}
	\subfloat[Pareto(LR)]{
		\includegraphics[width=62mm]{figures/apC/qq/Wan_QQplot_-_Pareto(LR)}
	}
	\subfloat[Pareto(MLH)]{
		\includegraphics[width=62mm]{figures/apC/qq/Wan_QQplot_-_Pareto(MLH)}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/qq/Wan_QQplot_-_Weibull}
	}
	\caption{CDF functions for the approximations of \textit{wan-pcap} inter  packet times, of many stochastic functions.}
\end{figure}

\clearpage

%% Skype
\begin{figure}[ht!]
	\centering
	\label{fig:lr-skype}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Cauchy_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Cauchy_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Exponential_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Exponential_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Pareto_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Pareto_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Weibull_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/Skype_Weibull_-_Linearized_data_and_linear_fitting.png}
	}
	\caption{Data linearization, and linear regression cost history, from gradient descendent for \textit{skype-pcap}.}
\end{figure}

\clearpage

%% bigFlows
\begin{figure}[ht!]
	\centering
	\label{fig:lr-bigFlows}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Cauchy_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Cauchy_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Exponential_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Exponential_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Pareto_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Pareto_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Weibull_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/bigFlows_Weibull_-_Linearized_data_and_linear_fitting.png}
	}
	\caption{Data linearization, and linear regression cost history, from gradient descendent for \textit{lan-gateway-pcap}.}
\end{figure}

\clearpage

%% Wan
\begin{figure}[ht!]
	\centering
	\label{fig:lr-wan}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Cauchy_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Cauchy_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Exponential_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Exponential_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Pareto_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Pareto_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Weibull_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/Wan_Weibull_-_Linearized_data_and_linear_fitting.png}
	}
	\caption{Data linearization, and linear regression cost history, from gradient descendent for \textit{wan-pcap}.}
\end{figure}

\clearpage

%% lanDiurnal
\begin{figure}[ht!]
	\centering
	\label{fig:lr-lanDiurnal}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Cauchy_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Cauchy]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Cauchy_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Exponential_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Exponential]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Exponential_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Pareto_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Pareto]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Pareto_-_Linearized_data_and_linear_fitting.png}
	}
	\hspace{0mm}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Weibull_-_Cost_J(iterations)_convergence.pdf}
	}
	\subfloat[Weibull]{
		\includegraphics[width=62mm]{figures/apC/lr/Lan_Weibull_-_Linearized_data_and_linear_fitting.png}
	}
	\caption{Data linearization, and linear regression cost history, from gradient descendent for \textit{lan-firewall-pcap}.}
\end{figure}

\clearpage

\begin{figure}[ht!]
%%%%%%%%%%%%%%%%%%%%%%%
% AIC / BIC logscale
%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[H]
\centering
\includegraphics[scale=0.5]{figures/apC/rm/aic-bic-logscale-sumary.eps}
\caption{$AIC$ and $BIC$ summary for all the traces, presented in log scale.}
\label{fig:aic-bic-summary-logscale}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%
% AIC / BIC order
%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[H]
\centering
\includegraphics[scale=0.5]{figures/apC/rm/aic-bic-order.eps}
\caption{$AIC$ and $BIC$ summary for all the traces, presenting the order.}
\label{fig:aic-bic-order-old}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%
% Cost function summary
%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[H]
\centering
\includegraphics[scale=0.5]{figures/apC/rm/cost-function-summary.eps}
\caption{Cost function $J_M$ summary.}
\label{fig:cost-function-summary}
\end{figure}
\end{figure}

\clearpage


\documentclass[letterpaper]{article}

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

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

\begin{document}
\title{Notes}
\date{October 29, 2014}
\maketitle
\section*{3.8 \#10}
$N\le G$ and $m=[G:N]=|G/N|$

if $x\in G/N$ then $\text{order}(x)|m$. then $\forall a\in G, aN\in G/N$. let $x\in aN$ and then $\text{order}(aN)|m$ and $(aN)^m=N$.

$a^mN=N\leftrightarrow a^m\in N$

\section*{simple group}
$G$ is simple iff `normal' subgroups.

\section*{3.8 \#6}
two subgroups intersecting is a subgroup.  $x\in H\cap N$ means $x\in H\cap N$ so for all $a\in H$we have $axa^{-1}\in N$ and $axa^{-1}\in H$ (from closure of $H$).

\section*{chapter 4}
\subsection*{polynomials with coefficients in fields}
\subsubsection*{field definition}
a set with two operations on it. $(K,+,\cdot)$ is a field if $+,\cdot$ are binary operations on $K$ such that $(K,+)$ is an abelian group and $K^*=K\setminus\{0\}$ and $(K*,\cdot)$ is an abelian group and $(a+b)\cdot c=ac+bc$ and $a(b+c)=ab+ac$.

\subsubsection*{examples}
$(\mathbb{R},+,\cdot)$ is a field. $(\mathbb{Q},+,\cdot)$ is a field, and so is $\mathbb{C}$.  $(\mathbb{Z},+,\cdot)$ is not a field because $(\mathbb{Z}^*,\cdot)$ is not a group. $\{a+b\sqrt{2}:a,b\in\mathbb{Q}\}$ is a field with respect to usual mult and addition.

\subsubsection*{polynomial definition}
let $K$ be a field, $f(x)=a_mx^m+a_{m-1}x^{m-1}+\dots+a_1x+a_0$ where $x$ is indeterminate and $a_i\in K$. we say that $f(x)$ is a polynomial with coefficients in $K$. if $a_m\ne 0$ then we define deg $f=m$. conventional problem with degree of zero. defined to be $-\infty$.

$K[x]=$ the set of all polynomials with coefficients in $K$. on $K[x]$ we define two operations. if $f(x)$ is deg $m$ and $g(x)$ is degree $n$ then $f(x)+g(x)=$ as usual and $f(x)g(x)=$ as usual.

\subsubsection*{obeservation}
given a polynomial $f(x)\in K[x]$, the polynomial function associated with $f(x)$ is the function defined from $K\to K$ that takes $c\to f(c)$.

there is a difference between a polynomial and a polynomial function. they are different objects. lets take $K=\mathbb{Z}_p$. where $p$ is prime. This is a field.

let $f(x)=x^{p}-x\in K[x]$. $\text{def} f=p$. polynomial function assosiated with $f(x)$ is $[a]\to[a]^p-[a]=[a^p-a]$ but for $a\in \mathbb{Z}$ we have $a^p\equiv a\mod p$ and so the function is zero.

finite fields make confusing the polynomial and the function dangerous.

\subsubsection*{observation}
$f(x),g(x)\in K[x]$, if $f(x)\ne 0$ and $g(x)\ne 0$ then the product is not zero and the degree of the product is the sum of the degrees of $f(x)$ and $g(x)$

claim $a,b\ne0$ then $ab\ne 0$. assume $ab=0$ then $a^{-1}ab=a^{-1}0$ because $a\ne 0$ and so $b=0$ because $a^{-1}0=a^{-1}(0+0)$ minus $a^{-1}0$ from both sides.
\end{document}