\documentclass[11pt, oneside]{article}

\usepackage{../../shared/preamble}
\addbibresource{../../shared/references.bib}

\usepackage{sets}

\title{Sets}
\author{Arthur Ryman, {\tt arthur.ryman@gmail.com}}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This article contains Z Notation type declarations for concepts related to sets.
It has been type checked by \fuzz.
\end{abstract}

\section{Introduction}

Typed set theory forms the mathematical foundation of Z Notation
and many concepts relating to set theory are defined by its built-in mathematical tool-kit.
This articles augments the tool-kit with some additional concepts.

\section{Arbitrary Sets}

\subsection{\zcmd{setT}, \zcmd{setU}, \dots, \zcmd{setZ}}

Let $\setT$, $\setU$, and $\setZ$ denote arbitrary sets.
These will be used throughout in the statement of theorems, remarks, and examples that are parameterized
by arbitrary sets.

\begin{zed}
	[\setT, \setU, \setV, \setW, \setX, \setY, \setZ]
\end{zed}

\section{Formal Arguments to Generic Constructions}

The following typographically distinctive symbols will be used as formal arguments to generic constructions:
$\genT, \genU, \genV, \genW, \genX, \genY, \genZ$.
They denote arbitrary sets.

\section{Families}

\subsection{\zcmd{family}}

Let $\genT$ be a set.
A {\it family} of subsets of $\genT$ is a set of subsets of $\genT$.
Let $\family \genT$ denote the set of all families of subsets of $X$.

\begin{zed}
	\family \genT == \power(\power \genT)
\end{zed}

\section{Functions}

\subsection{\zcmd{const}}

Let $\genT$ and $\genU$ be sets and let $c \in \genU$ be some given point.
The mapping that sends every point of $\genT$ to $c$ is called the {\it constant mapping} defined by $c$.
Let $\const(c)$ denote the constant mapping.

\begin{gendef}[\genT, \genU]
	\const: \genU \fun (\genT \fun \genU)
\where
	\forall c: \genU @ \\
	\t1	\const(c) = (\lambda x: \genT @ c)
\end{gendef}

\subsection{\zcmd{restrictU}}

Let $\genT$ and $\genU$ be sets, let $f: \genT \fun \genU$, and let $T \subseteq \genT$.
Let $f \restrictU T$ denote the restriction of $f$ to $T$.

\begin{gendef}[\genT, \genU]
	\_ \restrictU \_: (\genT \fun \genU) \cross \power \genT \fun (\genT \pfun \genU)
\where
	\forall f: \genT \fun \genU; T: \power \genT @ \\
	\t1	f \restrictU T = T \dres f
\end{gendef}

\subsection{$bit$}

Let $bit$ denote the set of \textit{binary digits}, namely the set $\{ 0, 1\} \subseteq \num$.

\begin{zed}
	bit == \{ 0, 1 \}
\end{zed}

\subsection{\zcmd{B}}

We introduce the notation $\B = bit$.

\begin{zed}
	\B == bit
\end{zed}

\subsection{$indicator\_function$}

Let $\genT$ be a set,
let $X$ be a subset of $\genT$, and
let $a \in \genT$ be some element.
The \textit{indicator function} or \textit{characteristic function} of $X$ maps $a$ to 1 if $a \in X$ and 0 otherwise.
Let $indicator\_function(X) \in \genT \fun \B$ denote this function.

\begin{gendef}[\genT]
	indicator\_function : \power \genT \fun \genT \fun \B
\where
	\forall X : \power \genT @ \\
		\t1 indicator\_function(X) = \\
			\t2 (\lambda a : \genT @ \IF a \in X \THEN 1 \ELSE 0)
\end{gendef}

\subsection{\zcmd{indF}}

We introduce the notation $\indF[\genT](X) = indicator\_function[\genT](X)$.

\begin{zed}
	\indF[\genT] == indicator\_function[\genT]
\end{zed}

\printbibliography

\end{document}


\documentclass[11pt,a4paper]{article}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}

\newcommand{\dpar}[1]{\left(#1\right)}

\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}

\theoremstyle{definition}
\newtheorem{ex}{Exercise}

\title{Physics 3: Class 6}
\author{Max Jauregui}

\begin{document}
\maketitle

\section{Electric potential}

Let us consider a system of charges and let us suppose that we want to
bring a particle with charge $q$ from an infinite distance to a
position $\mathbf{r}$ following a trajectory $C$. The necessary energy
to perform this task, denoted by $U(q,\mathbf{r})$, is proportional to
$q$. Then, we can define an energy per unit of charge, which is called
the \emph{electric potential} of the system, by
$$V(\mathbf{r})=\frac{U(q,\mathbf{r})}{q}\,.$$
The unit of electric potential in the SI is the volt (V).

In terms of the electric force, the energy $U(q,\mathbf{r})$ can be
written as
$$U(q,\mathbf{r})=-\int_C\mathbf{F}_e\cdot d\mathbf{r}\,.$$
Since $\mathbf{F}_e=q\mathbf{E}$, where $\mathbf{E}$ is the electric
field generated by the system, we have
$$U(q,\mathbf{r})=-q\int_C \mathbf{E}\cdot d\mathbf{r}\,.$$
This implies that the electric potential of the system of charges is
given by
\begin{equation}
  \label{eq:1}
  V(\mathbf{r})=-\int_C\mathbf{E}\cdot d\mathbf{r}\,.
\end{equation}

The electric potential of a particle with charge $Q$, localized at the
origin of our coordinate system, at a point $\mathbf{r}$ is
\begin{eqnarray*}
  V(\mathbf{r})&=&-\int_C\frac{Q}{4\pi \epsilon_0}\frac{\mathbf{r'}}{(r')^3}\,\cdot d\mathbf{r}'\\
               &=&-\int_{t_1}^{t_2}\frac{Q}{4\pi \epsilon_0[r'(t)]^3}\mathbf{r'(t)}\cdot\frac{d\mathbf{r}'}{dt}\,dt\\
               &=&-\int_{t_1}^{t_2}\frac{Q}{4\pi \epsilon_0[r'(t)]^3}r'(t)\frac{dr'}{dt}\,dt\\
               &=&-\int_{\infty}^{r}\frac{Q}{4\pi \epsilon_0(r')^2}\,dr'\,.
\end{eqnarray*}
Therefore,
$$V(\mathbf{r})=\frac{Q}{4\pi\epsilon_0}\frac{1}{r}\,.$$

If the particle of charge $Q$ is at a position $\mathbf{r'}$, the
electric potential at a point $\mathbf{r}$ will be given by
$$V(\mathbf{r})=\frac{Q}{4\pi\epsilon_0}\frac{1}{|\mathbf{r}-\mathbf{r}'|}\,.$$

If we have a system of $n$ charges $q_1,\ldots,q_n$, the electric
potential at a point $\mathbf{r}$ will be given by
$$V(\mathbf{r})=\sum_{i=1}^n\frac{q_i}{4\pi\epsilon_0}\frac{1}{|\mathbf{r}-\mathbf{r}_i|}\,.$$
In the case of a continuous distribution of charges with charge
density $\rho(\mathbf{r})$, the electric potential at a point
$\mathbf{r}$ will be
$$V(\mathbf{r})=\int_{\R^3}\frac{\rho(\mathbf{r}')}{4\pi\epsilon_0|\mathbf{r}-\mathbf{r}'|}\,dV'\,.$$

Let us consider a charged particle that is initially at a position
$\mathbf{r}_1$ and moves slowly to a position $\mathbf{r}_2$
describing a trajectory $C$ under the action of an external electric
field $\mathbf{E}$. Then, it follows from Eq.~(\ref{eq:1}) that
$$\int_C\mathbf{E}\cdot d\mathbf{r}=V(\mathbf{r}_1)-V(\mathbf{r}_2)\,.$$
In particular, if $\mathbf{r}_1=\mathbf{r}_2$, we have
$$\oint_C\mathbf{E}\cdot d\mathbf{r}=0\,.$$

\end{document}


\documentclass[11pt,twoside]{article}

\usepackage[headings]{fullpage}
\usepackage[utopia]{mathdesign}

\pagestyle{myheadings}
\markboth{Spring fever}{Spring fever}

\input{../../fncextra}

\begin{document}

\begin{center}
  \bf Spring fever
\end{center}

 The second-order ODE
\[
  y'' + \gamma y' + 2y = \sin(t)
\]
describes the simple harmonic oscillation of (for example) a mass
suspended by a spring and subjected to a periodic force. The constant
$\gamma$ models damping due to friction. Neglecting the friction, the
natural frequency of oscillation is $\omega_0=\sqrt{2}$, and the total
motion combines the natural oscillation with that of the driving
external force. If $\gamma>0$, however, the unforced solution dies
off, and the oscillation is driven entirely by the external force.

One complication in assessing variable-step automatic integrators, such as the RK23 method described in the text, is that we mathematically describe convergence as being at the rate $O(h^p)$ for a fixed step size $h$. If we look instead at the total number $n$ of steps taken by the method over time interval $[a,b]$, then the ``average step size'' is $(b-a)/n$ and we can hope for convergence of $O(n^{-p})$.

\subsection*{Goals}

You will use the driven spring problem to assess the convergence of the \texttt{rk23} function given in the text.

\subsection*{Preparation}

Read section 6.5. Write the ODE as the first-order system $\bfu' = \bff(t,\bfu)$. (That is, write out exactly what the function $\bff$ is.)

\subsection*{Procedure}

Download the script template and complete it to perform the following steps. Throughout this lab, use $0\le t \le 20$ and $y(0)=0$, $y'(0)=0$.

\begin{enumerate}
\item Consider the ODE as a first-order system, $\bfu'=\bff(t,\bfu)$. In a separate file, write a function
\begin{verbatim}
function f = myspring(t,u,gamma)
\end{verbatim} that defines the ODE by returning the value of $\bff$ for any given $t$ and $\bfu$.

\item Define \texttt{u0} as the initial condition of the first-order system and let $\gamma=10$. Create a reference solution using the syntax
\begin{verbatim}
dudt = @(t,u) myspring(t,u,10);
opt = odeset('reltol',1e-13,'abstol',1e-13);
[t,u_ref] = ode15s(dudt,[0 20],u0,opt);
\end{verbatim}
  where \texttt{u0} is defined appropriately. Plot the solution $y(t)$ as a function of $t$, using a title and labeled axes. In the title or as text on the plot, include the number of time steps that were taken by the solver.

\item Use the adaptive \texttt{rk23} solver from the text to solve the
  problem with the \texttt{tol} argument set to $10^{-4}$. Make a
  phase plot of the solution (i.e., with $y$ on the horizontal axis
  and $y'$ on the vertical axis). Don't forget labels and a title.

\item Use \texttt{rk23} to solve the problem with each of the error
  tolerances $10^{-2}$, $10^{-3}$, \ldots, $10^{-12}$ in turn. After each
  solution, record in two vectors the number of time steps
  taken, $n$, and the global error, $E_n=\| \bfu_{\text{ref}}(20) - \bfu(20)\|$. (\emph{Important}: This is at the final time $t=40$, \emph{not} the solution in the 30th row of the output from \texttt{rk23}.) Output a table with each row giving the tolerance, $n$, and $E_n$.

\item On a new graph, make a log-log plot of $E_n$ versus $n$. The points
    should mostly lie close to a straight line. Add to the plot two
    straight lines indicating perfect second- and third-order convergence,
    $E_n=n^{-2}$ and $E_n=n^{-3}$.

\item Now let $\gamma=5000$. Repeat steps 2--3.

\item Repeat steps 4--5 (still with $\gamma=5000$). The results will be very different.
\end{enumerate}

\subsection*{Discussion}

The time stepping in \texttt{rk23} is supposed to be third-order
accurate. But that is a statement about the mathematical limit
$h\to 0$, or $n\to \infty$. For particular finite values of $n$, we
might observe something close to the ideal $E_n=Cn^{-3}$, but just
about anything is possible.

In fact, for this spring problem with $\gamma=5000$, the time step
size adaptation is being constrained by something other than
third-order accuracy. The mathematics behind this observation is
considered in Chapter 10.

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\section*{Exercises}

\begin{ex}
  Draw the complex numbers $z = 2+i$ and $w = -2+3i$ as points in the
  plane. Then use the geometric interpretation to find $z+w$,
  $z-w$, $zw$, $z^{-1}$, $\conjugate{z}$, and $\abs{z}$.
\end{ex}

\begin{ex}
  Use the geometric interpretation to find a complex number $z$ such
  that $z^2 = i$. Can you find two such numbers?
  \begin{sol}
    Since $i$ has magnitude $1$ and argument $\pi/2$ (or
    $90^{\circ})$, the number $z$ must have magnitude $1$ and argument
    $\pi/4$. It therefore lies at $45^{\circ}$ on the unit circle. The
    solution is $z=\frac{1+i}{\sqrt{2}}$. A second solution is
    $-z=-\frac{1+i}{\sqrt{2}}$, whose argument is $-3\pi/4$ or
    $-135^{\circ}$. Note that if we double this angle, we get
    $-270^{\circ}$, which is the same as $+90^{\circ}$.
    \begin{equation*}
      \begin{tikzpicture}[scale=1.7]
        \draw[black!30] (0,0) circle (1);
        \draw[->](-1.5,0) -- (1.5,0);
        \draw[->](0,-1.25) -- (0,1.25);
        \draw(0,-1) -- +(-0.2,0) node[left,yshift=-3pt] {$-i$};
        \draw(0,1) -- +(-0.2,0) node[left,yshift=3pt,red] {$i$};
        \draw(-1,0) -- +(0,-0.2) node[below,xshift=-3pt] {$-1$};
        \draw(1,0) -- +(0,-0.2) node[below,xshift=3pt] {$1$};
        \draw[ultra thick, red] (0,0) -- (90:1);
        \draw[ultra thick, blue] (0,0) -- (45:1);
        \draw[ultra thick, purple!70!blue] (0,0) -- (225:1);
        \draw[fill, black] (45:1) circle [radius=1.06pt] node [right=2mm, blue] {$z = \frac{1+i}{\sqrt{2}}$};
        \draw[fill, black] (225:1) circle [radius=1.06pt] node [left=2mm, purple!70!blue] {$-z = -\frac{1+i}{\sqrt{2}}$};
        \draw[fill, black] (90:1) circle [radius=1.06pt];
      \end{tikzpicture}
    \end{equation*}
  \end{sol}
\end{ex}

\begin{ex}
  Use the geometric interpretation to find 3 different complex numbers
  $z$ such that $z^3 = -1$. Hint: these numbers will lie on the unit
  circle.
  \begin{sol}
    The three solutions can be found on the unit circle at
    $60^{\circ}$, $180^{\circ}$, and $300^{\circ}$. If we triple any
    of these angles, we get $180^{\circ}$ (up to multiples of $360^{\circ}$).
    Thus, the three cube roots of $-1$ are $z=-1$ and $z=0.5\pm\sqrt{0.75}\,i$.
    \begin{equation*}
      \begin{tikzpicture}[scale=1.7]
        \draw[black!30] (0,0) circle (1);
        \draw[->](-1.15,0) -- (1.5,0);
        \draw[->](0,-1.25) -- (0,1.25);
        \draw[ultra thick, blue] (0,0) -- (60:1);
        \draw[ultra thick, red] (0,0) -- (180:1);
        \draw[ultra thick, purple!70!blue] (0,0) -- (300:1);
        \draw[fill, black] (60:1) circle [radius=1.06pt] node [right=2mm,blue] {$0.5+\sqrt{0.75}\,i$};
        \draw[fill, black] (180:1) circle [radius=1.06pt] node [left=2mm,red] {$-1$};
        \draw[fill, black] (300:1) circle [radius=1.06pt] node [right=2mm,purple!70!blue] {$0.5-\sqrt{0.75}\,i$};
      \end{tikzpicture}
    \end{equation*}
  \end{sol}
\end{ex}


\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\title{Soil Carbon Models}
\date{12/9/2016}
\begin{document}
\maketitle
\section*{Century Model}
The century model is proposed by Parton et al. (1988). We only focus on the three soil pools in this model which are listed below along with their decomposition rates:

\begin{itemize}
\item[pool 1:] \makebox[2.5cm]{Active Soil C,\hfill}  $\kappa_1 \approx 1/1.5$,
\item[pool 2:] \makebox[2.5cm]{Slow Soil C,\hfill} $\kappa_2 \approx 1/25$,
\item[pool 3:] \makebox[2.5cm]{Passive Soil C,\hfill}  $\kappa_3 \approx 1/1000$,
\end{itemize}
where $\kappa$ denotes the decay rate which is defined as 1 over the turnover.

We denote the transfer rate from pool $j$ to pool $i$ by $r_{ij}$. The transfer rates are parameterized as a ratio of the decay rate: $r_{ij} = \alpha_{ij} \kappa_j$. For the Century model, we have:
\begin{align*}
\alpha_{21} & = 1 - F(\text{T}) - 0.004, \\
\alpha_{31} & = 0.004, \\
\alpha_{12} & = 0.42, \\
\alpha_{32} & = 0.03, \\
\alpha_{13} & = 0.45, \\
\alpha_{23} & = 0,
\end{align*}
where `T' is the soil silt + clay content, and $F(\text{T}) = 0.85 - 0.68 \times \text{T}$. These values are expert-tuned; however, in our Bayesian framework, we estimate them from the data. For each pool, we can write the following differential equation:
\begin{equation*}
\frac{d C_i(t)}{dt} = -\kappa_i C_i(t) + \sum_{j\neq i} \alpha_{ij} \kappa_j.
\end{equation*}
Combining all these differential equations into a single formula, we get:
\begin{equation*}
\frac{dC(t)}{dt} =
   \left( {\begin{array}{ccc}
   -\kappa_1 & \alpha_{12} \kappa_2 & \alpha_{13}\kappa_3 \\
    \alpha_{21}\kappa_1 & -\kappa_2& 0  \\
    \alpha_{31} \kappa_1 & \alpha_{32} \kappa_2 & -\kappa_3
   \end{array} } \right) C(t).
\end{equation*}

The total amount of Carbon in the beginning is $C_{tot}$ which is divided among the three pools: $C(0) = (\gamma_1, \gamma_2, \gamma_3) \cdot C_{tot}$.

\section{Outline of Simulations}

\subsection{Data generation and fitting models}
We generate simulated data from the century model above, and fit the following six models to the simulated data:

\begin{enumerate}
\item Independent Model:
\begin{equation*}
\frac{dC(t)}{dt} =
   \left( {\begin{array}{ccc}
   -\kappa_1 & 0 & 0 \\
    0 & -\kappa_2& 0  \\
    0 & 0 & -\kappa_3
   \end{array} } \right) C(t).
\end{equation*}
\item Cascade Model:
\begin{equation*}
\frac{dC(t)}{dt} =
   \left( {\begin{array}{ccc}
   -\kappa_1 & 0 & 0 \\
    \alpha_{21}\kappa_1 & -\kappa_2& 0  \\
    \alpha_{31} \kappa_1 & \alpha_{32} \kappa_2 & -\kappa_3
   \end{array} } \right) C(t).
\end{equation*}
\item Feedback Model:
\begin{equation*}
\frac{dC(t)}{dt} =
   \left( {\begin{array}{ccc}
   -\kappa_1 & \alpha_{12} \kappa_2 & \alpha_{13}\kappa_3 \\
    \alpha_{21}\kappa_1 & -\kappa_2& \alpha_{23} \kappa_3 \\
    \alpha_{31} \kappa_1 & \alpha_{32} \kappa_2 & -\kappa_3
   \end{array} } \right) C(t).
\end{equation*}
\item Century Model:
\begin{equation*}
\frac{dC(t)}{dt} =
   \left( {\begin{array}{ccc}
   -\kappa_1 & \alpha_{12} \kappa_2 & \alpha_{13}\kappa_3 \\
    \alpha_{21}\kappa_1 & -\kappa_2& 0  \\
    \alpha_{31} \kappa_1 & \alpha_{32} \kappa_2 & -\kappa_3
   \end{array} } \right) C(t).
\end{equation*}
\item Two-pool Model:
\begin{equation*}
\frac{dC(t)}{dt} =
   \left( {\begin{array}{cc}
   -\kappa_1 & \alpha_{12} \kappa_2  \\
    \alpha_{21}\kappa_1 & -\kappa_2  \\
   \end{array} } \right) C(t).
\end{equation*}
\item One-pool Model:
\begin{equation*}
\frac{dC(t)}{dt} = -\kappa_1 C(t).
\end{equation*}
\end{enumerate}

For generating the simulated data, we use the expert-tuned values for decomposition and transfer parameters and also assume $\gamma_1=\gamma_2=0.1$ and $\gamma_3=0.8$.
\subsection{CO$_2$ flux}
We assume that our observations are in terms of CO$_2$ fluxes. Theoretically, the CO$_2$ flux at time $t$ is defined as $\sum_{i=1}^3 |{dC_i(t)}/{dt}|$. In experiments, this is calculated by measuring the CO$_2$ emitted between a cap time, $t_{cap}$ and $t$: ${\Delta CO_2}/(t - t_{cap})$.

\subsection{Sampling times}
Generally, the sampling times are not uniform. The CO$_2$ flux is sampled more frequently in the beginning and then less frequently towards the end. A common practice is to sample once per day for the first week, then once per week for the first month, and then once per month. Given that the scale of the turnover rates are in years, this amounts to the following sampling times:
\begin{equation*}
t_s = (\frac{1}{360}, \frac{2}{360}, \frac{3}{360}, \frac{4}{360}, \frac{5}{360}, \frac{6}{360}, \frac{7}{360}, \frac{14}{360}, \frac{21}{360}, \frac{28}{360}, \frac{60}{360}, \frac{90}{360}, \frac{120}{360}, \ldots)
\end{equation*}

\subsection{Observation error}
From empirical studies we know that the noise standard deviation is approximately half the value of the flux.  We simulate this by averaging the values of simulated CO$_2$ flux and dividing by two to set the value for noise standard deviation.

\subsection{Replications}
Generally, we have several replications for each experiment (i.e., several CO$_2$ fluxes). We can fit these replicates in three ways:
\begin{enumerate}
\item No pooling: fitting models separately to each model, i.e., estimating the model parameters independently for each replication;
\item Complete pooling: fitting a single model to all the replications, i.e., estimating only a single set of parameters for all models;
\item Partial pooling: fitting a hierarchical Bayesian model which estimates parameters jointly for all replications and allows for variation between replicates.
\end{enumerate}
\section{Statistical models}
As mentioned in the previous section, we fit the data in three ways: no pooling, complete pooling, and partial pooling using a hierarchical model.

\subsection{No pooling and complete pooling}
In terms of model specification, no pooling and complete pooling are similar; the only difference is the data provided for likelihood computations. For complete pooling, all the data is used for parameter estimation and for no pooling, each replication is used separately.

\begin{itemize}
\item {\bf Turnover rates: } we assume a prior which is centered around the values chosen by experts. We believe that the estimated values should be around these values; so, we set the standard deviations to be $1/10$'th of the mean times a Cauchy random variable.  Therefore, we enforce the standard deviation to be small, but let the data specifies the exact value. We can check the sensitivity of the results to these assumptions later.
\begin{align*}
\tau_1  \sim  \mathcal{N}(1.5, 0.15 \sigma_1) \qquad
\tau_2  &\sim \mathcal{N}(25, 2.5 \sigma_2) \qquad
\tau_3 \sim \mathcal{N}(1000,100 \sigma_3) \\ \sigma_1 \sim \text{Cauchy}(0,1) \qquad  \sigma_2 &\sim \text{Cauchy}(0,1) \qquad \sigma_3 \sim \text{Cauchy}(0,1)
\end{align*}
The decomposition rates are then $\kappa_1=1/\tau_1, \kappa_2=1/\tau_2, \kappa_3=1/\tau_3$.
\item {\bf Initial allocations: } the vector $(\gamma_1, \gamma_2, \gamma_3)$ governs how the Carbon is initially divided between the three pools. We know that $\gamma_1+\gamma_2+\gamma_3=1$; so, the vector is simplex. We assign a uniform prior to this vector:
\begin{align*}
(\gamma_1, \gamma_2, \gamma_3) \sim \text{Dirichlet}(1,1,1)
\end{align*}
\item {\bf Transfer rates: } the transfer rates are between 0 and 1 and are given a uniform prior with the following constraints for each $j$:
\begin{equation*}
\sum_{i \ \text{s.t.} \ i\neq j}{a_{ij}} < 1, \qquad j=1, 2, 3
\end{equation*}
We can model this inequality constraint as an equality in the form of a simplex vector. For example, we can write:
\begin{align*}
a_{11} + a_{21} + a_{31} = 1,
\end{align*}
where $a_{11}$ is a nuisance parameter which is not used in the model but enforces the inequality constraint. Thus, we can write:
\begin{align*}
(a_{11}, a_{21}, a_{31}) & \sim \text{Dirichlet}(1,1,1) \\
(a_{12}, a_{22}, a_{32}) & \sim \text{Dirichlet}(1,1,1) \\
(a_{13}, a_{23}, a_{33}) & \sim \text{Dirichlet}(1,1,1)
\end{align*}
\end{itemize}

\subsection{Partial pooling (hierarchical model)}
We assume that we have $K$ replications. For each parameter, we have a global value, denoted by the superscript $0$, and local values for each replication, denoted by a superscript $k$ where $k=1,\ldots, K$.
The global parameters have priors identical to the ones in the no pooling model. The local parameter are equal to these global parameters plus some variability.

\begin{itemize}
\item {\bf Turnover rates: }
\begin{align*}
\tau_1^0  \sim  \mathcal{N}(1.5, 0.15 \sigma_1) \qquad
\tau_2^0  &\sim \mathcal{N}(25, 2.5 \sigma_2) \qquad
\tau_3^0 \sim \mathcal{N}(1000,100 \sigma_3) \\ \sigma_1 \sim \text{Cauchy}(0,1) \qquad  \sigma_2 &\sim \text{Cauchy}(0,1) \qquad \sigma_3 \sim \text{Cauchy}(0,1) \\
\tau_1^k \sim \mathcal{N}(\tau_1^0, 0.15 \sigma_4) \qquad
\tau_2^k &\sim \mathcal{N}(\tau_2^0, 2.5 \sigma_5) \qquad
\tau_3^k \sim \mathcal{N}(\tau_3^0, 100 \sigma_6) \\ \sigma_4 \sim \text{Cauchy}(0,1) \qquad  \sigma_5 &\sim \text{Cauchy}(0,1) \qquad \sigma_6 \sim \text{Cauchy}(0,1)
\end{align*}
\item {\bf Initial allocations: }
\begin{align*}
(\gamma_1^0, \gamma_2^0, \gamma_3^0) &\sim \text{Dirichlet}(1,1,1) \\
(\gamma_1^k, \gamma_2^k, \gamma_3^k) &\sim \text{Dirichlet}(\gamma_1^0, \gamma_2^0, \gamma_3^0)
\end{align*}
Another possibility is:
\begin{align*}
(\gamma_1^0, \gamma_2^0, \gamma_3^0) &\sim \text{Dirichlet}(1,1,1) \\
(\lambda_1^k, \lambda_2^k, \lambda_3^k) &\sim \mathcal{N}((\gamma_1^0, \gamma_2^0, \gamma_3^0), \Sigma) \\
(\gamma_1^k, \gamma_2^k, \gamma_3^k) & = \frac{(\lambda_1^k, \lambda_2^k, \lambda_3^k)}{\lambda_1^k+ \lambda_2^k+ \lambda_3^k}
\end{align*}
\item {\bf Transfer rates: } As described in the previous section, by introducing a nuisance parameter, we can model the transfer rates as simplex vectors. A hierarchical structure can then be imposed in exact same way as explained in the previous paragraph for initial allocations.
\end{itemize}

\end{document}


\section{$\S$ Complex Numbers}
\subsection{Definition and Forms}

\textbf{Definition of $i$}: $i = \sqrt{-1}$, $i^2 = -1$, $i^3 = -i$, $i^4 = 1$ \\
\textbf{Rectangular form}: $a+bi$. \\
\textbf{Exponential form}: $re^{i\theta}$ where $r$ is the magnitude and $\theta$ is the angle around the polar plane.


\section{Groups}

\subsection{Groups and Symmetry}

\subsubsection{Exercise 2}
Map each element $x \in \mathbb{Z}_6$ to the pair $(p_2(x), p_3(x))$.
This is an isomorphism, since the projections $\mathbb{Z}_6 \to \mathbb{Z}_3$
and $\mathbb{Z}_6 \to \mathbb{Z}_3$ are both group morphisms, and the mapping
itself is a bijection.

\subsubsection{Exercise 3}
To see that there is no isomorphism $f: \mathbb{Z}_4 \to \mathbb{Z}_2 \times \mathbb{Z}_2$,
consider $f(1)$ and $f(3)$. We have that $f(0) = f(1 + 3) = f(1) + f(3)$ which is not
possible since $f(0) = (0, 0)$ (has to be the case since $f(x) = f(0) + f(x)$ ).

Rotations do not preserve symmetry for rectangles, since distances between adjacent
vertices change. The only transformations that preserve symmetry are reflections
across the vertical and horizontal axes, giving 4 possible transformations. We can
then map $(0, 0)$ to the identity, $(0, 1)$ to a vertical reflection, $(1, 0)$ to
a horizontal reflection, and $(1, 1)$ to a vertical + horizontal reflection.

\subsubsection{Exercise 4}

\subsubsection{Exercise 5}

\subsubsection{Exercise 6}

\subsubsection{Exercise 10}
The set of these permutations has identity  $(1, 0)$, and any permutation $(a, b)$ has
inverse $(\frac{1}{a}, -\frac{b}{a})$. Furthermore, $(a_2, b_2) \circ (a_1, b_1) = (a_1 a_2, a_2 b_1 + b_2)$,
which is associative since multiplication and addition are both associative.

\subsubsection{Exercise 11}
(a) To show that the given function is a permutation on $\mathbb{R}\cup{\infty}$, we need to show that it is a
bijection from $\mathbb{R}\cup{\infty} \to \mathbb{R}\cup{\infty}$.
Suppose $f(x_1) = f(x_2)$. Then
\begin{align*}
        \frac{ax_1 + b}{cx_1 + d} &= \frac{ax_2 + b}{cx_2 + d} \\
        (ad - bc)x_1 &= (ad - bc)x_2 \implies x_1 = x_2
\end{align*}
So $f$ is an injection from $\mathbb{R}\cup{\infty} \to \mathbb{R}\cup{\infty}$. Furthermore, if
we set $f(x) = y$, we can solve for $x$, which gives us that $f$ is also a surjection.

(b) I'm sure an inverse can be found, but it's tedious... Associativity then follows again from associativity
of multiplication and addition.

\subsubsection{Exercise 12}

\subsubsection{Exercise 13}
(a) Any automorphism of $\mathbb{Z}_3$ has to fix 0. Thus, the only two automorphisms are the identity
and the automorphism that swaps 1 and 2.

(b) Fixing $(0, 0)$, we see that we can permute the remaining three elements as we want, giving
the isomorphism to $S_3$.

(c)

\subsection{Rules of Calculation}

\subsubsection{Exercise 1}
(a) Multiply by inverse and use associativity.

(b) Associativity.

(c) Associativity and then inverse of product.

\subsubsection{Exercise 2}
Multiply by $a^{-1}$.

\subsubsection{Exercise 3}
Since the unit is its own inverse, we're left with $2n - 1$ elements that need to be paired with one another.
Since $2n - 1$ is odd, we have that one of the elements must be its own inverse.

\subsubsection{Exercise 4}
Any group with 3 elements must be of the form $1, a, a^{-1}$. Thus, each of these groups is clearly
isomorphic to the others.

\subsubsection{Exercise 5}
I struggled to untie the ideas of cancellation and inverse, so I ended up looking up a hint for this one. To
see that an infinite set with cancellation does not need to be a group, consider $(\mathbb{N}, +)$.
This is a monoid that was proven to have cancellation in chapter 1, but does not contain inverses.

For the case of a finite set $G$, we can use the fact that $f(x) = ax$ is an injection for any $a \in G$,
since $ax = ay \implies x = y$ by cancellation. Since $G$ is finite, $f$ is also a surjection. Therefore,
$\exists a \: | \: ax = 1$ which gives us that there is a left inverse. Applying the same logic using
$f(x) = xa$ gives a right inverse, which completes the proof since these inverses must be equal.

\subsubsection{Exercise 6}
Left cancellation is possible due to left inverse and left unit.
Furthermore, $uu = u \implies (a' a) u = a' a \implies a u = a$ by left cancellation, indicating that
$u$ is also a right unit. Then we have that $u a' = a' u \implies a' a a' = a' u \implies a a' = u$,
and $a'$ is also a right inverse. This proves that $X$ is a group.

\subsubsection{Exercise 7}
We proceed as directed in the hint. Since the equation $ua = a$ has solution $u$, and any $b$
can be written as $b = ay$, we have $u b = u (ay) = ay = b$. Thus, $u$ is a left unit. Since
the equation $a'a = u$ also has a solution $a'$, we are done by Exercise 6.

\subsubsection{Exercise 10}
Since each element of $G$ has a unique inverse, $f(a) = a^{-1}$ is a bijection. Additionally,
$f(ab) = (ab)^{-1} = b^{-1} a^{-1} = f(b) f(a) = f(a) \square^{\text{op}} f(b)$.

\subsubsection{Exercise 11}
Associativity of $\square$ immediately follows from the associativity of $G$ 's binary operation and
the fact that $p$ is a morphism. Additionally, since $p$ is an epimorphism, $\forall x, \: \exists g
\: | \: x = p(g)$. Since $u g = g u$, $p(u)$ is then the unit for $X$. Similarly, $p(g')$ is the
inverse of $x$, thus making $X$ a group.

\subsubsection{Exercise 12}
$b b_R = u \implies b_L b b_R = b_L \implies b_R b = b_L b = u$.

\subsection{Cyclic Groups}
We first show that $\mathbb{Z}_n$ is generated only by those $c$ that are coprime to $n$. If
$c$ is coprime to $n$, then $ac = 0$ only when $a = n$ since $c$ and  $n$ share no prime factors.
Thus, the subgroup generated by $c$ has order $n$ and is therefore all of $\mathbb{Z}_n$. Similarly,
if $c$ is a generator of $\mathbb{Z}_n$, then $c$ has order $n$ and must therefore be coprime to $n$.

\subsubsection{Exercise 1}
The only possible generators are 1 and 5, since those are the only elements of $\mathbb{Z}_6$
that are coprime to 6.

\subsubsection{Exercise 2}
The endomorphisms of $\mathbb{Z}_n$ are completely determined by the mapping of 1, so there are
only $n$ such endomorphisms.

\subsubsection{Exercise 3}
5 is prime, so all elements of $\mathbb{Z}_5$ other than 0 are coprime to it.

\subsubsection{Exercise 4}
14 has 6 positive integers less than it that are coprime to it (3, 5, 7, 9, 11, 13).

\subsubsection{Exercise 5}
The two generators of $\mathbb{Z}$ are $1$ and $-1$, as elements of $\mathbb{Z}$ can be written as $-m$ or $m$.

\subsubsection{Exercise 7}
If $G$ is abelian, then $(g_1 g_2)^m$ can be rearranged to $g_1^m g_2^m$. If $(g_1 g_2)^m = g_1^m g_2^m$.
The reverse direction follows from the $m = 2$ case, $g_1 g_2 g_1 g_2 = g_1^2 g_2^2$.

\subsubsection{Exercise 8}
$(g_1 g_2) (g_1 g_2) = 1 \implies g_1 g_2 = g_2 g_1$.

\subsubsection{Exercise 9}
The automorphisms are all determined by the mappings of the generators; the isomorphisms follow from the
number of generators of each group.

\subsubsection{Exercise 10}

\subsection{Subgroups}

\subsubsection{Exercise 1}
The subgroup mapping a given diagonal to itself consists of $\{1, R^3, D, D'\}$, where
$R^3$ is 3 clockwise rotations, $D$ is reflection across the given diagonal, and $D'$ is
reflection across the diagonal perpendicular to the given. Mapping those elements to
$\{(0, 0), (1, 1), (0, 1), (1, 0)\}$ (in order) is an isomorphism.

\subsubsection{Exercise 4}
If $S$ is closed under product and inverse, then it contains the identity and is thus a subgroup.

\subsubsection{Exercise 5}
We have that $(s, t) (t, s) = st^{-1} ts^{-1} $, so $S$ contains the identity. Then $(1, s) = s^{-1}$ and
$(s, t^{-1}) = st$, so $S$ is closed under products and inverses as well, thus making it a subgroup.

\subsubsection{Exercise 6}
(a) The identity has order 1. Additionally, if $a$ has finite order, so does $a^{-1}$. Finally,
$a^n = 1, \: b^k = 1 \implies (ab)^{nk} = a^{nk} b^{nk} = 1$.

(b) If non-abelian, we do not necessarily have $(ab)^{nk} = a^{nk} b^{nk}$.

\subsubsection{Exercise 7}
If $G$ has no proper subgroups, then it is generated by all of its non-identity elements.
This is only possible if $G$ has order 1 (vacuously true), or if $G$ is a cyclic group of
prime order (as was shown in the beginning of the previous section).

\subsubsection{Exercise 8}
(a) If $a$ has order $n$, so does $a^{-1}$. Additionally, $(ab)^n = a^n b^n = 1$, making all elements that
satisfy $a^n = 1$ a subgroup of $A$. To see that this is not true for non-abelian groups, consider $S_3$.
The elements $(1 2)$ and $(2 3)$ are both of order 2, but $(1 2) (2 3) = (1 2 3)$ is of order 3.

(b) That the $n^{\text{th}}$ powers form a subgroup follows from $a^n a^{-n} = 1$ and $a^n b^n = (ab)^{n}$.

\subsubsection{Exercise 9}
If $T$ is a submonoid of $S$, then $i: T \to S$ is a morphism of monoids, so $T$ must necessarily be
closed under products and identity. For the reverse direction, if $T$ is closed under products and
identity, then the insertion $i$ is a morphism of monoids and $T$ is a submonoid of $S$.

\subsection{Defining Relations}

\subsubsection{Exercise 3}
The subgroup of rotations is isomorphic to $\mathbb{Z}_5$, so each element other than the identity has order 5.
The element $D$ has order 2. Furthermore, we have from the generator relations that
\begin{align*}
        DR = R^{n-1}D \implies DR^i = R^{n-1} DR^{i-1} = DR^i = R^{i(n - 1)}D = R^{n - i}D
\end{align*}
So all elements of the form $DR^i$ also have order 2.

\subsubsection{Exercise 4}
I believe the inclusion diagram looks like a tree with $\Delta_5$ as the root, and the subgroups generated by
$R$ and each of the  $DR^i$ as leaves (they don't contain one another).

\subsubsection{Exercise 5}
After reflecting, it takes $2(i - 1)$ rotations to get vertex $i$ back to its original place. Thus,
reflection through vertex $i$ can be expressed as $DR^{2(i-1)}$.

\subsubsection{Exercise 6}
The two groups are the same order, so
we just need to identify two elements of $S_3 \times S_2$ with $R$ and $D$ and show that these two elements
satisfy the generator relations. Let $x = ((1 2 3), (1 2))$ and $y = ((1 3), 1)$. Then $x^6 = (1, 1)$ since
$(1 2 3)$ has order 3 and $(1 2)$ has order 2. Similarly, $y^2 = (1, 1)$ and $yx = x^{n - 1}y$, so we have
an isomorphism.

\subsubsection{Exercise 8}
(a) From $a^4 = 1$ we get that $a$ is an element of order  4. From $b^2 = a^2$, we get that only $b$, $b^3$,
$ab$, and $ab^3$, are distinct from the $a^i$. Hence, there are 8 distinct elements.

(b) There is no isomorphism to $\Delta_8$, since the only element of order 2 is $b^2 = a^2$.

\subsubsection{Exercise 10}
We let $\psi((b, c)) = bc$. This is a morphism, since $\psi((b, c)(b', c')) = uu'vv' = uvu'v'$. Additionally,
$\psi$ sends $(b, 1)$ to $u$ and $(1, c)$ to $v$. To see that $\psi$ is unique, we note that
\begin{align*}
        \psi'((b, 1)) = u, \: \psi'((1, c)) = v \implies \psi'((b, c)) = uv
\end{align*}
if $\psi'$ is a morphism.

\subsection{Symmetric and Alternating Groups}

\subsubsection{Exercise 3}
Since $(1 2 3) (1 2) = (1 3)$ and $(1 2) (1 2 3) = (2 3)$ we have that $S_3$ is not abelian, and therefore
$S_n$ with $n \geq 3$ is non-abelian ($S_3 \subset S_{n \geq 3}$). $S_1$ and $S_2$ are cylic and thus abelian.
As for the alternating groups, it is again straightforward to see that $A_2$ is abelian (it only consists of
the identity). $A_3$ is also abelian, since the only even permutations are $1, (1 2 3), (1 3 2)$, all of which
commute. For $n \geq 4$ though, we have that $(1 2 3) (2 3 4) \neq (2 3 4) (1 2 3)$, so $A_{n \geq 4}$ is
non-abelian.

\subsubsection{Exercise 4}
(a) The 4-element subgroup consisting of $1, (1 2), (3 4), (1 2) (3 4)$.

(b) The 6-element subgroup consisting of all of the elements in (a), plus \\ $(1 3) (2 4), (1 4) (2 3)$.

\subsubsection{Exercise 5}
There are $\binom{4}{3} = 4$ ways of choosing 3 elements in $S_4$. The subgroup generated by the
transpositions of the 3 selected elements is isomorphic to $S_3$.
There are $\binom{4}{2} = 6$ ways of choosing 2 elements in $S_4$. The subgroup generated by the transposition
of these two elements is ismorphic to $S_2$. Additionally, any such transposition can be paired with the
transposition of the remaining two elements (e.g. $(1 2) (3 4)$ ) to produce another subgroup isomorphic to
$S_2$, giving 9 such subgroups.

\subsubsection{Exercise 6}
The idea is the same as the second part of Exercise 5. We have $\binom{6}{3} = 20$ ways to pick 3 elements in
$S_6$, and the transpositions of these elements can then be paired with the transpositions of the remaining 3
elements to produce at least another 10 subgroups isomorphic to $S_3$ (the pairing order can be changed to
produce more).

\subsubsection{Exercise 7}
The fact that $\sigma$ and $\tau \sigma \tau^{-1}$ have the same parity follows immediately from Proposition
15 ($(x_1 \: ...\:  x_k) \to (\tau(x_1) \: ... \: \tau(x_k))$). That the two need not have the same number of inversions
can be seen from looking at $(1 2 3) (1 2) (1 3 2) = (1 3)$. The permutation $(1 2)$ only inverts $(1, 2)$,
whereas $(1 3)$ inverts $(1, 2), (1, 3), (2, 3)$.

\subsubsection{Exercise 8}
Any cycle of length $2m$ has parity $2m - 1$ (Theorem 17, Corollary 2), and is thus odd. Therefore the product
of not necessarily disjoint cycles being even implies that the product contains an even number of even length
cycles. Noting that odd cycles have even parity gives the reverse direction.

\subsubsection{Exercise 9}
A permutation of order 14 must consist of either a single cycle of order 14, two cycles of orders 2 and 7, or
a combination of both (since the order is the LCM of the disjoint cycle decomposition lengths). However, since
we are considering permutations on 10 letters, only the case of 2 and 7 is possible, which means any such
permutation must be odd.

\subsubsection{Exercise 10}
We first show that any odd length cycle can be written as a product of length 3 cycles. Let $\sigma =
(x_1 ... x_{2n + 1})$. Then $\sigma$ can be decomposed as $(x_1 x_{2n} x_{2n+1}) \: ... \: (x_1 x_2 x_3)$, or,
in other words, the product of 3-cycles consisting of its first element $x_1$ paired with consecutive pairs
$x_{2k}, x_{2k+1}$. Next, we show that a product of two disjoint even length cycles $\sigma_1 = (x_1 \: ... \: x_{2n})$
and $\sigma_2 = (y_1 \: ... \: y_{2m})$ can be rewritten as the product of two odd length cycles. To do so,
we modify $\sigma_1$ to be $\sigma_1' = (x_1 \: ... \: x_{2n} y_1)$ and modify $\sigma_2$ to be
$\sigma_2' = (y_1 \: ... \: y_{2m} x_{2n})$. We can then verify that $\sigma_1' \circ \sigma_2' = \sigma_1 \circ \sigma_2$. Thus, since any even permutation must have a disjoint cycle decomposition consisting of an even
number of even length cycles (since they have odd parity), an even permutation can be written as the product
of 3-cycles.

\subsubsection{Exercise 11}

\subsubsection{Exercise 12}

\subsubsection{Exercise 13}
That $(1 2), (2 3), \: ...\:  (n - 1 n)$ are generators for $S_n$ follows immediately from Exercise 11 and the fact
that $(1 2 \: ... \: n - 1) = (n - 2 n - 1) ... (1 2)$.

\subsection{Transformation Groups}

\subsubsection{Exercise 2}
The left regular representation of $S_3$ is the function that assigns each element $\sigma \in S_3$ to
$f_{\sigma} (x) = \sigma \circ x$ where $f_{\sigma}:  S_3 \to S_3$.

\subsubsection{Exercise 4}
The isotropy subgroup of a single vertex is just the group of permutations that leave the given vertex fixed
and permute the other seven vertices (isomorphic to $S_7$).

\subsubsection{Exercise 5}
The isotropy subgroups are all isomorphic to $S_{n - 1}$, as they consist of all permutations that leave a
single element fixed. To see that these subgroups are conjugate to one another, let $G_i$ be the isotropy
subgroup of $i$. Then we have that for  $g \in G_i$, $(i j) g (i j) \in G_j$, since $(i j)$ maps $j$ to $i$
and then back to $j$ again.

\subsubsection{Exercise 6}
From Proposition 15, we have that cyles of the same length are conjugate to one another. Furthermore,
we know that every element of $S_n$ has a unique disjoint cycle decomposition. The different possible length
cycle decompositions form unique conjugacy classes (from Proposition 15), so the number of conjugacy classes
for $S_n$ is just the number of partitions of $n$. For $S_3$ this is 3 and for $S_4$ this is 5.

\subsubsection{Exercise 7}
The left regular representation of the additive group  $\mathbb{R}$ assigns to each element $z \in \mathbb{R}$
the function $f_z(x) = x + z$, which is exactly a translation by $z$ of the real line. Similarly,
the left regular representation of the additive group $\mathbb{R} \times \mathbb{R}$ corresponds to a
translation of $(z_1, z_2)$ in the cartesian plane.

\subsubsection{Exercise 8}
Since $G$ acts transitively on $x$, there exists $g$ such that $gx = y$. Let $z$ be an element that fixes
$x$. Then we have that $gzg^{-1} y = gzx = gx = y$, so $gzg^{-1}$ fixes $y$ as desired.

\subsubsection{Exercise 9}
For any subgroup $S$ of $\Delta_4$, we can consider any action of $\Delta_4$ on the square that has each
element of an equivalence class of $\Delta_4 / S$ act the same way on an element of the square (not exactly
sure how an ``element'' of the square should be defined, I suppose a point). Such an action necessarily
fixes the subgroup $S$.

I was a bit confused by this question and found some more discussion \href{https://math.stackexchange.com/questions/76255/show-every-subgroup-of-d4-can-be-regarded-as-an-isotropy-group-for-a-suitable-ac}{here}.

\subsubsection{Exercise 10}
Let $I$ be an invariant subset containing $x$. Then $gx \in I$ for all $g \in G$, implying that
$\text{Orb}(x) \subset I$. Since by definition  $\text{Orb}(x)$ is invariant, it must be the smallest such
set. By the previous logic, we further have that $I = \cup_{x \in G} \text{Orb}(x)$, which can be reduced
to a union of disjoint orbits (since one element appearing in another's orbit means their orbits are the same).

\subsection{Cosets}

\subsubsection{Exercise 1}
The image of a right coset $aS = \{ as \: | \: s \in S \}$ under the bijection $a \mapsto a^{-1}$ is the set
$\{ s^{-1} a^{-1} \: | \: s \in S\}$, which is the left coset $Sa^{-1}$.

\subsubsection{Exercise 2}
The indicated subgroup $S$ is just ${D, 1}$. Thus, the left cosets consist of reflections followed by rotations
while the right cosets consist of rotations followed by reflections.

\subsubsection{Exercise 5}
Consider $x \in S / S \cap T$ and $y \in T$. By the definition of join, the product $xy$ must be in $S \vee T$.
Since $S / S \cap T$ and $T$ are disjoint, this means that $[S : S \cap T] [T : 1] \leq [S \vee T : 1]$ (since
$S \vee T$ contains every such product $xy$). Using the fact that  $[S : S \cap T] = \frac{[S : 1]}{[S \cap T : 1]}$, we then have the desired inequality.

\subsubsection{Exercise 6}
We use the result of Exercise 8 to get that a group with 6 elements is either isomorphic to $\mathbb{Z}_6$ or
to a group with 3 elements of order 2 and 2 elements of order 3. Since $S_3$ has 3 elements of order 2 and
2 elements of order 3, there is an isomorphism between the latter category of order 6 groups and $S_3$.

\subsubsection{Exercise 7}
Again we rely on Exercise 8. Since $\Delta_5$ contains 5 elements of order 2 and 4 elements of order 5,
any group of order 10 without an order 10 element is isomorphic to $\Delta_5$ by exercise 8.

\subsubsection{Exercise 8}
If a group of order $2p$ contains an element of order $2p$, then it is cyclic and thus isomorphic to
$\mathbb{Z}_{2p}$. If a group of order $2p$ does not contain an element of order $2p$, then we will show
the following:
\begin{itemize}
  \item It can have at most one subgroup of order $p$.
  \item It must have at least one subgroup or order $p$.
\end{itemize}
To see the first, we appeal to the inequality from Exercise 5. If there were two distinct subgroups of order
$p$, then their join would consist of at least $p^2 > 2p$ elements (for $p > 2$). To see the second, we
consider the case where all  $2p - 1$ non-identity elements have order 2. Such a group must be abelian,
since we have $abab = 1 \implies ab = b^{-1} a^{-1} = ba$. Taking the join of the groups generated by $a$
and $b$ would then give us a subgroup of order 4, which is not possible since 4 does not divide $2p$. Thus,
there must be an element (and hence a generated subgroup) of order $p$. Combining these two results gives
that a group of order $2p$ that does not contain an element of order $2p$ must have $p-1$ elements of order
$p$ and $p$ elements of order 2.

\subsubsection{Exercise 9}
(a) Suppose $s a t = s' b t'$. Then we would have  $a = s^{-1} s' b t' t^{-1}$, so $a \in SbT$ and the
double cosets $SaT$ and $SbT$ are equal. The alternative is that $s a t \neq s' b t'$ for all $s, s', t, t'$,
which would imply that the double cosets are disjoint. Thus, the double cosets of $G$ form a partition of
$G$, so their union is $G$.

(b)

\subsection{Kernel and Image}

\subsubsection{Exercise 2}
If $N \triangleleft S_3$, then all elements in $N$ must have the same sign
(since $\text{sgn}(ana^{-1}) = \text{sgn}(n)$). As there are no subgroups consisting of only odd
permutations, we need only consider subgroups consisting of even permutations. The only such proper
subgroup of $S_3$ is $A_3$.

\subsubsection{Exercise 3}
Since $DR^i = R^{n - i}D \implies DR^i D^{-1} = R^{n - i}$, we have that $\{R^i\} \triangleleft \Delta_p$.
The only other proper subgroups of $\Delta_p$ are the order 2 groups generated by $DR^i$. However,
none of these subgroups are normal since $D DR^i D = DR^{n - i}$, which is clearly not
$DR^i$ or 1 for all $0 < i < n$. Thus, the subgroup of rotations is the only normal subgroup of $\Delta_p$.

\subsubsection{Exercise 4}
We first note that $R^j DR^i R^{-j} = DR^{i - 2j}$, and $DR^{i - 2j} = DR^i$ only when $j = 0$ or
$j = \frac{n}{2}$. Thus, none of the subgroups generated by elements of the form $DR^i$ are normal,
and we only need to consider subgroups of the rotation subgroup. Any such subgroup
is normal, since $i$ divides $n - i$, so $\{R^i\}, \{R^{2i}\} \triangleleft \Delta_4$ and
$\{R^i\}, \{R^{2i}\}, \{R^{3i}\} \triangleleft \Delta_6$.

\subsubsection{Exercise 5}
(a) $ax = xa \implies x^{-1} a x = a$, so $Z(G)$ is normal.

(b) From Exercises 3 and 4, we can see that $DR^i \notin Z(\Delta_n)$. Furthermore, $R^i \in Z(\Delta_n)$
only if $R^i = R^{n - i}$, which is only possible if $n$ is even. Thus, $Z(\Delta_n)$ is either 1 or the
subgroup generated by $R^{\frac{n}{2}}$, with the latter being isomorphic to $\mathbb{Z}_2$.

(c) From Proposition 15, we have that $\tau \sigma \tau^{-1} = \sigma$ only if $\tau$ and $\sigma$ commute or
if $\tau = 1$. For $n > 2$, $S_n$ is not commutative, so $Z(S_n) = 1$.

\subsubsection{Exercise 6}
Let $A$ and $B$ be two normal subgroups of $G$. Then for $a \in A$, $b \in B$, and $g \in G$, we have
$g a g^{-1} g b g^{-1} = g a b g^{-1} = a' b'$ for some $a' \in A$ and $b' \in B$, so $A \vee B$ is
normal in G. Additionally, if $a \in A \cap B$, then we have that $g a g^{-1} \in A$ and
$g a g^{-1} \in B$ by normality of $A$ and $B$, so $A \cap B \triangleleft G$.

\subsubsection{Exercise 7}
(a) Let $f_{g}(x) = gxg^{-1}$. Then $f_{g'} \circ f_{g} (x) = g' g x g^{-1} g'^{-1} = f_{g' g} (x)$ so
$\text{In} (G)$ is a group under composition.

(b) Let $h \in \text{Aut}(G)$. Then $h \circ f_g \circ h^{-1} (x) = h(gh^{-1}(x)g^{-1}) = h(g) x h(g)^{-1}$,
so $\text{In} (G) \triangleleft \text{Aut} (G)$.

\subsubsection{Exercise 12}
Since $g \to ag$ is a permutation on $G$, $gT \to agT$ is a permutation on $G / T$. We also have that
$h_a \circ h_b (gT) = a (bg T) = (ab)g T = h_{ab} (gT)$ so $h: G \to S(G / T)$ is a morphism.

\subsection{Quotient Groups}

\subsubsection{Exercise 1}
Let $\phi$ be a morphism with $\phi(R) = 0$ and $\phi(D) = 1$. Then $\phi$ is an epimorphism with kernel
$S$, so $\Delta_n / S \cong \mathbb{Z}_2$.

\subsubsection{Exercise 2}
The quotient groups of $\Delta_4$ correspond to its normal subgroups, which are:
\begin{itemize}
        \item $\{1\}, \{R\}, \{R^2\}$
        \item  $\{R^2, D\}, \{R^2, RD\}$
\end{itemize}

\subsubsection{Exercise 3}
(a) Let $\phi: 4\mathbb{Z} \to \mathbb{Z}_5$ be defined as $\phi(x) = x \mod 5$. Then $\phi$ is an epimorphism
with kernel $20\mathbb{Z}$, so $4\mathbb{Z} / 20\mathbb{Z} \cong \mathbb{Z}_5$. Similarly, we can also
define $\phi: \mathbb{Z}_6 \to \mathbb{Z}_3$ as $\phi(x) = x \mod 3$. This is another epimorphism with
kernel $3\mathbb{Z}_6$, so $\mathbb{Z}_6 / 3\mathbb{Z}_6 \cong \mathbb{Z}_3$.

(b) More generally, we can define $\phi: k \mathbb{Z} \to \mathbb{Z}_m$ as $\phi(x) = \frac{x}{k} \mod m$,
which is an epimorphism with kernel $m k  \mathbb{Z}$. Thus, $k\mathbb{Z} / m k \mathbb{Z} \cong \mathbb{Z}_m$.
From this result, we get that
$(\mathbb{Z} /m k \mathbb{Z}) / (k\mathbb{Z} / m k \mathbb{Z}) \cong \mathbb{Z}_{m k} / \mathbb{Z}_m$, which
is in turn isomorphic to $\mathbb{Z}_k$.

\subsubsection{Exercise 4}
I'm not really sure what counts as a ``familiar group here'', but we can consider $x \to \abs{x}$ again to
see that $Q^* / \{\pm 1 \}$ is isomorphic to the multplicative group of positive rationals.

\subsubsection{Exercise 6}
Consider $\phi: G \to \text{In} G$ where $\phi(g) = \gamma_g$ with $\gamma_g(x) = gxg^{-1}$. By construction,
$\phi$ is an epimorphism, and $\gamma_g(x) = x$ iff $g \in Z$. Thus, $G / Z \cong \text{In} G$.

\subsubsection{Exercise 7}
(a) Since $[xgx^{-1}, xhx^{-1}] = x g x^{-1} x h x^{-1} x g^{-1} x^{-1} x h^{-1} x^{-1} = x[g, h]x^{-1}$, we
have that $[G, G] \triangleleft G$.

(b) Since $[G, G] [x, y] = [G, G] \implies [G, G] xy = [G, G] yx$, $G / [G, G]$ is abelian. Any morphism
$\phi: G \to A$ carries all of the elements of the coset $[G, G]x$ to the single element $\phi(x)$. Thus,
we can factor $\phi$ as $\phi' \circ p$, where $\phi': G / [G, G] \to A$ with $\phi'([G, G]x) = \phi(x)$.

\subsubsection{Exercise 8}
Since $G/N \cong \mathbb{Z}_5$, $G$ must be a group of order 10. This implies that  $G$ is either  $\Delta_5$
or $\mathbb{Z}_10$ (see exercise 7 in section 8). However, $\Delta_5$ does not have a normal subgroup
of order 2, so $G \cong Z_{10}$.

\subsubsection{Exercise 9}
Since $N \subset M$, we can define an epimorphism $\phi: G / N \to G / M$ that maps the coset $Ng$ to the
coset  $Mg$. The kernel of this epimorphism is $Nm$ for all $m \in M$, which is exactly $M / N$. Thus,
we get that  $(G / N) / (M / N) \cong G / M$.


\section{Background}\label{sec:background}
%===========================================================

Cellular complexes are largely used in Computer Graphics and in Geometric and Solid Modeling~\cite{Elter:10.1007/978-3-642-78114-8_12}. In particular, they provide the geometric-topological discretization for computer modeling and simulation of physical properties of both man-made and natural objects~\cite{DiCarlo:2009:DPU:1629255.1629273,ieee-tase}.

\subsection{Cell complexes vs Chain complexes}
\label{cell-complexes-vs-chain-complexes}
%--------------------------------------------

A \(p\)-chain can be seen as a subset of \(p\)-cells from a cellular
complex. The space of \(p\)-chains is closed
w.r.t.~addition and product times a scalar from a field. In particular, it is a linear (vector) space.

\paragraph{Cells and Chains}\label{sec:chain}
%------------------------------------------------------------------------------
%--
A $p$-\emph{manifold} is a topological space where each point has a neighborhood
that is homeomorphic to $\E^p$. A \emph{$p$-cell} $\sigma$ ($0\leq p\leq d$) of cellular complexes is piecewise-linear, connected, possibly non convex, $p$-manifold, and not necessarily contractible\footnote{The cells of CW-complexes are contractible to a point. With our LAR representation they may contain internal holes.}. An
$r$-face $\tau$ of a $p$-cell $\sigma$ ($0\leq r\leq p$) is an $r$-cell contained
in the frontier of $\sigma$.

A \emph{$p$-chain} can be seen, with some abuse of language, as a collection of $p$-cells.
The set $C=\oplus\ C_p$ of chains can be given the structure of a graded vector space  by
defining sums of chains with the same dimension, and products times scalars in a
field, with the usual properties.

A \emph{basis} $U_p$  is the set of \emph{independent} (or \emph{elementary}) chains $u_p \in C_p$, given
by singletons of $\Lambda_p$ elements. Every chain $c\in C_p$ is uniquely generated by
a linear combination of the basis with field coefficients. Once  the  basis is fixed, the coordinate
representation of each $\{\sigma_k\} = u_k \in C_p$ is unique. This is an ordered
sequence of coefficients, either from $\{0,1\}$ (unsigned representation) or from
$\{-1,0,+1\}$ (signed representation). With abuse of language, we
often call $p$-cells the independent generators of $C_p$, {i.e.}~the elements of
$U_p$.

\paragraph{Chain and cochain complexes}\label{graded-complexes}
%-------------------------------------------------------------------------------
%
A \emph{graded vector space} is a vector space $V$ expressed as a direct sum  of
spaces $V_k$ indexed by integers in $[0,d]$:
\[ V = \oplus_{k = 0}^d V_k, \qquad [0,d] := \{k\in\N \ |\ 0\leq k\leq d\}.
\]

A linear map $f:V\to W$ between graded vector spaces is called a \emph{graded
map} of degree $p\ $ if $f(V_k) \subset W_{k+p}$.

A \emph{chain complex} is a graded vector  space $V$ furnished with a graded
linear map $\partial : V \to V$ of degree $-1$ which satisfies $\partial^2 = 0$, called
\emph{boundary operator}. In other words, a chain complex
is a sequence of vector spaces $C_k$ and linear maps $\partial_k : C_k \to C_{k-1}$,
such that $\partial_{k-1} \circ\ \partial_{k} = 0$.

A \emph{cochain complex} is a graded vector space $V$ provided with a graded
linear map $\delta : V \to V$ of degree $+1$ which satisfies $\delta^2 = 0$,
called \emph{coboundary operator}. That is to say, a cochain complex is a
sequence of vector spaces $C^k$ and linear maps $\delta^k : C^k \to C^{k+1}$,
such that $\delta^{k+1} \circ\ \delta^{k} = 0$.
%This duality implies that ... (Antonio !)

Since any linear map $L: V\to W$ between linear spaces induces a dual map $L':
W' \to V'$ between their duals, any chain complex is associated with a dual
cochain complex, and viceversa:
\[
(\delta^k \omega) g = \omega (\partial_{k+1} g), \qquad \omega \in C^k, g \in C_{k+1}.
\]
 In a Euclidean space, chain and cochain spaces can be trivially identified~\cite{ieee-tase}, so that we use the $C_p$ notation for both spaces, with $\partial_p: C_p\to C_{p-1}$, and $\delta_p = \partial_{p-1}^\top: C_{p-1}\to C_p$.


\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\author{Daniel Frederico Lins Leite}
\title{Gaussian Maximum Likelihood}
\newcommand{\distas}[1]{\mathbin{\overset{#1}{\kern\z@\sim}}}%
\newsavebox{\mybox}\newsavebox{\mysim}
\newcommand{\distras}[1]{%
	\savebox{\mybox}{\hbox{\kern3pt$\scriptstyle#1$\kern3pt}}%
	\savebox{\mysim}{\hbox{$\sim$}}%
	\mathbin{\overset{#1}{\kern\z@\resizebox{\wd\mybox}{\ht\mysim}{$\sim$}}}%
}
\begin{document}
	\maketitle

	\section{Gaussian Maximum Likelihood}
	\begin{align*}
		X \overset{iid}{\sim} N(\mu,\sigma^2)\\
		L(theta|X) &= p(X|theta)\\
		&= p(X|\mu,\sigma^2)\\
		&= \prod{p(x_i|\mu,\sigma^2)}\\
		\\
		\max_{\mu,sd}{L(theta|X)} &= \max_{\mu,\sigma^2}{\prod{p(x_i|\mu,\sigma^2)}}\\
		&= \max_{\mu,\sigma^2}{ln(\prod{p(x_i|\mu,\sigma^2)))}}\\
		&= \max_{\mu,\sigma^2}{\sum{ln(p(x_i|\mu,\sigma^2))}}\\
		\\
		p(x|\mu,\sigma^2) = \frac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}
		\\
		&= \max_{\mu,\sigma^2}{\sum{ln(\frac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{(x_i-\mu)^2}{2\sigma^2}})}}\\
		&= \max_{\mu,\sigma^2}{\sum{\big[ln(\frac{1}{\sqrt{2\pi\sigma^2}})+ln( e^{-\frac{(x_i-\mu)^2}{2\sigma^2}})\big]}}\\
		&= \max_{\mu,\sigma^2}{\sum{\big[ln(\frac{1}{\sqrt{2\pi\sigma^2}})+-\frac{(x_i-\mu)^2}{2\sigma^2}\big]}}\\
		&= \max_{\mu,\sigma^2}{\sum{\big[ln(\frac{1}{\sqrt{2\pi\sigma^2}})\big]-\sum{\big[\frac{(x_i-\mu)^2}{2\sigma^2}\big]}}}\\
		&= \max_{\mu,\sigma^2}{\sum{\big[ln((2\pi\sigma^2)^{\frac{1}{2}})\big]-\sum{\big[\frac{(x_i-\mu)^2}{2\sigma^2}\big]}}}\\
		&= \max_{\mu,\sigma^2}{\big[ln((2\pi\sigma^2)^{\frac{1}{2}})\big]\sum{1}-\sum{\big[\frac{(x_i-\mu)^2}{2\sigma^2}\big]}}\\
		&= \max_{\mu,\sigma^2}{\big[\frac{1}{2}ln(2\pi\sigma^2)\big]\sum{1}-\sum{\big[\frac{(x_i-\mu)^2}{2\sigma^2}\big]}}\\
		&= \max_{\mu,\sigma^2}{\big[\frac{1}{2}ln(2\pi\sigma^2)\big]N-\sum{\big[\frac{(x_i-\mu)^2}{2\sigma^2}\big]}}\\
	\end{align*}

	TODO

	\begin{align*}
		\overset{*}{\mu} &= \frac{1}{N}\sum{x_i}\\
		\overset{*}{\sigma^2}&=\frac{1}{N}\sum{(x_n-\overset{*}{\mu})^2}
	\end{align*}
\end{document}


\chapter{Divide \& Conquer}

\section{Principles}
\runinhead{Divide.}\runinhead{Reduce \# sub-problems.} After dividing, we have $a$ subproblems. Now need to identify the redundancy in the $a$ sub-problems. Find the common shared calculations among sub-problems and thus try to reduce $a$ to $a-1$. Identify the \textbf{commonality}.
\runinhead{Sub-problem dimension.} Reduce the dimensionality of the original problem; thus consider the simpler version of the problem.
\runinhead{Input dimension.}  Increase the representation dimensionality of the input. For example, in FFT (Fast Fourier Transform) augment the input with complex space.
\begin{align*}
w_{j, k} = e^{j2\pi i/k}
\end{align*}


\chapter{RTS Smoothing} \label{ch:RTS}

While the Kalman filter is an optimal solution to computing state estimates from all previous data, better estimates could be obtained if all future data were also incorporated.

The RTS Smoothing algorithm is an approach to determine estimates of states and uncertainties by considering the state transistion between two kalman filtered estimates, smoothing the transition between prior and 'future' data.

\section{Example}

Consider the system of a single particle moving in one dimension. At time t=0, the particle's position is measured to be x=0. The system then evolves with a random walk, with no more measurements until the time t=100.

At t=99, the particles position has a large uncertainty - it has likely moved from its original position, however, with no more data available, its mean expected value remains as x=0.

At t=100, the particles position is again measured, this time as x=10. If this system were monitored using a Kalman filter, the expected position of the particle would be a constant x=0 for the first 99 seconds, before an abrupt change in location at t=100. During the 100 seconds, the variance would increase steadily, before abruptly returning to a low value when the second measurement is taken.

If the kalman filter measurements were taken in reverse order, with the first measurement at t=100, the variance of the particle would steadily increase going backward in time until t=0, before the second measurement again reduced the variance, this time at t=0.

Using an RTS Smoother effectively combines both forward and backward filtering. At t=1, the variance is low due to the measurement at t=0. Likewise, at t=99, the variance is low due to the measurement at t=100. In this example, in addition to the measurements at t=0 and t=100, the expected mean value at t=50 can be expected to be the midpoint between the two measurements - a result that can not be obtained using Kalman filtering alone.

In order to accurately calculate the expected position and variance at t=50 however, knowledge of the measurement at t=100 was required (50 seconds later). RTS smoothed estimates necessarily lag behind the primary Kalman filter to allow some time for future data to be obtained. The length of this lag determines the effectiveness of the smoothing.

\section{Usage}

\begin{lstlisting}[language=yaml,caption=RTS Configuration]
user_filter_parameters:

    max_filter_iterations:      5
    max_prefit_removals:        3

    rts_lag:                    -1      #-ve for full reverse, +ve for limited epochs
    rts_directory:              ./
    rts_filename:               PPP-<CONFIG>-<STATION>.rts

    inverter:                   LLT         #LLT LDLT INV

\end{lstlisting}

All kalman filters in the toolkit are capable of having RTS Smoothing applied. If configured appropriately with an RTS\_lag and output files, intermediate filter results will be stored to file for reverse smoothing.

For real-time processing, a small lag may be applied to improve short-term accuracy. After each filtering stage, the new result is propagated backward through time to correct the previous N epochs. Each epoch worth of lag however requires a comparable processing time to an Kalman filter processing stage - a lag of N epochs may slow processing by up to a multiple of N.

For post-processing, the optimal lag is to use all future and past data. This is achieved by first computing the forward solution, before propagating the final results backward through to the first epoch. The processing time required for a complete backward smoothed filter may be less than 2x a non-smoothed filte - considerably faster than a finite lag in real-time.

\subsection{rts\_lag:}
Number of future epochs to use in RTS smoothing. A larger lag will give more optimal smoothing results, at the expense of a longer lag before they are calculated, and requiring more processing time per epoch.

A negative value indicates that the entire solution should be smoothed at the conclusion of processing.
This will obtain optimal results, with lowest processing time, but is not suitable for real-time applications.

\subsection{rts\_directory:}
Directory to output RTS files.

\subsection{rts\_filename:}
Filename for RTS files. Multiple intermediate files are generated by RTS smoothing, as well as an additional output files for kalman filter states and clocks.