% !TeX root = ../main.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
\section{Preliminary}
\subsection{Tensor}
\begin{equation}\label{Tensor:Sum}
\tensor{\left(A+B\right)}{
^{i_1}^{\dots}^{i_n}
_{j_1}_{\dots}_{j_m}
}
=
\tensor{A}{
^{i_1}^{\dots}^{i_n}
_{j_1}_{\dots}_{j_m}
}
+
\tensor{B}{
^{i_1}^{\dots}^{i_n}
_{j_1}_{\dots}_{j_m}
}
\end{equation}
\begin{equation}\label{Tensor:Product:Scalar}
\tensor{\left(\alpha A\right)}{
^{i_1}^{\dots}^{i_n}
_{j_1}_{\dots}_{j_m}
}
=
\alpha
\tensor{A}{
^{i_1}^{\dots}^{i_n}
_{j_1}_{\dots}_{j_m}
}
\end{equation}
\begin{equation}\label{Tensor:Product:Tensor}
\tensor{\left(A\otimes B\right)}{
^{i_1}^{\dots}^{i_l}^{i_{l+1}}^{\dots}^{i_{l+n}}
_{j_1}_{\dots}_{j_k}_{j_{k+1}}_{\dots}_{j_{k+m}}
}
=
\tensor{A}{
^{i_1}^{\dots}^{i_l}
_{j_1}_{\dots}_{j_k}
}
\tensor{B}{
^{i_{l+1}}^{\dots}^{i_{l+n}}
_{j_{k+1}}_{\dots}_{j_{k+m}}
}
\end{equation}
\begin{equation}\label{Tensor:Contraction}
\tensor{\left(\contr{\tensor{T}{}}\right)}{
^{i_1}^{\dots}^{i_n}
_{j_1}_{\dots}_{j_m}
}
=
\sum_a{\tensor{T}{
^{i_1}^{\dots}^{i_n}^a
_a_{j_1}_{\dots}_{j_m}
}}
\end{equation}
\begin{equation}\label{Matrix:Product}
\tensor{\left(AB\right)}{^i_j}
=\contr{\left(A\otimes B\right)}
=\sum_k\tensor{A}{^i_k}\tensor{B}{^k_j}
\end{equation}
\begin{equation}\label{Matrix:Product:Block}
\left(\begin{bmatrix}
A_{11}&A_{12} \\
A_{21}&A_{22} \\
\end{bmatrix}
\begin{bmatrix}
B_{11}&B_{12} \\
B_{21}&B_{22} \\
\end{bmatrix}\right)_{ij}
=
\sum_k A_{ik} B_{kj}
\end{equation}
\begin{equation}\label{Matrix:Identity}
IA = A = AI
\end{equation}
\begin{equation}\label{Matrix:Identity:Value}
I_n=\diag{\left(1,1,\dots,1\right)}
\end{equation}
\begin{equation}\label{Matrix:Identity:Block}
I_{a+b}=
\begin{bmatrix}
I_a&0_{a\times b} \\
0_{b\times a}&I_b           \\
\end{bmatrix}
\end{equation}
\begin{equation}\label{Matrix:Permutation:Square}
T_{a,b} T_{a,b}= I
\end{equation}
\subsection{Differential}
\begin{equation}
J_xF = \left(\left.\frac{\partial F_i}{\partial x_j}\right|_x\right)_{i,j}
\end{equation}
\begin{equation}
\left.Df\right|_x
: T_x\R^k\to T_{f(x)}\R^n
= \left(x,v\right) \mapsto \left(f(x),J_xf(v)\right)
\end{equation}
\subsection{Group}
\begin{definition}[Lie group {\autocite[][Chapter~7]{lee_2013}}]\label{Group:Lie}
A \textit{Lie group} is a smooth manifold \(G\) (without boundary)
that is also a group in the algebraic sense,
with the property that
the multiplication map \(m\colon G\times G\to G\)
and the inversion map \(i\colon G\to G\), given by
\[
m\left(g,h\right)=gh\text{,}
\quad\quad
i\left(g\right)=g^{-1}
\]
are both smooth.
\end{definition}
\begin{proposition}[Lie group {\autocite[][Chapter~7]{lee_2013}}]\label{Group:Lie:Assertion}
If \(G\) is a smooth manifold with a group structure such that the map \(G\times G\to G\) given by \(\left(g,h\right)\mapsto gh^{-1}\) is smooth, then \(G\) is a Lie group.
\end{proposition}
\begin{definition}[Semidirect product]\label{Group:SemidirectProduct}
Suppose \(H\) and \(N\) are groups,
and \(\theta\colon H\times N\to N\) is a smooth left action of \(H\) on \(N\).
It is said to be an \textit{action by automorphisms}
if for each \(h\in H\), the map \(\theta_h\colon N\to N\) is a group automorphism of \(N\) (i.e., an isomorphism from \(N\) to itself).
Given such action, we define a new group \(N\rtimes_\theta H\),
called a \textit{semidirect product} of \(H\) and \(N\), as follows.
\(N\rtimes_\theta H\) is just the Cartesian product \(N\times H\);
but the group multiplication is defined by
\[\left(n,h\right)\left(n^\prime,h^\prime\right)=\left(n\theta_h\left(n^\prime\right),hh^\prime\right)\text{.}\]
\end{definition}
\begin{definition}\label{OrthogonalGroup}
An orthogonal group \(O\left(n\right)\) is a group of orthogonal matrix \(M\) where \(M^{-1}=M^T\) with matrix multiplication.
\end{definition}
\begin{definition}\label{SpecialOrthogonalGroup}
An special orthogonal group \(SO\left(n\right)\) is a subgroup of the orthogonal group \(O\left(n\right)\) whose element \(M\) have the property that \(\det{M}=1\).
\end{definition}
\begin{definition}\label{IndefiniteOrthogonalGroup}
An indefinite orthogonal group \(O\left(m,n\right)\) is a group of indefinite orthogonal matrix \(M\) where \(M^{-1}=gM^Tg\) for \(g=\diag{\left(-1,\dots,-1,1,\dots,1\right)}\) with matrix multiplication.
\end{definition}
\begin{definition}\label{OrthochronusIndefiniteOrthogonalGroup}
An orthochronus indefinite orthogonal group \(O^{+}\left(m,n\right)\) is a subgroup of the indefinite orthogonal group \(O\left(m,n\right)\) whose element \(M\) have the property that \(\tensor{M}{^1_1}>0\).
\end{definition}
\begin{definition}\label{SpecialOrthochronusIndefiniteOrthogonalGroup}
An special orthochronus indefinite orthogonal group \(SO^{+}\left(m,n\right)\) is a subgroup of the orthochronus indefinite orthogonal group \(O^{+}\left(m,n\right)\) whose element \(M\) have the property that \(\det{M}=1\).
\end{definition}
\begin{definition}\label{TranslationGroup}
An translation group \(T\left(n\right)\) is a group of vectors in \(\R^n\) with vector addition.
\end{definition}
\begin{definition}\label{EuclideanGroup}
An euclidean group \(E\left(n\right)\) is a semidirect product of orthogonal group \(O\left(n\right)\) extended by translation group \(T\left(n\right)\).
\end{definition}
\subsection{Manifold}
\begin{definition}[Abstract differentiable manifold {\autocite[][Chapter~5A]{kuhnelwolfgang_2006}}]\label{Manifold}
A \textit{\(k\)-dimensional differentiable manifold} (briefly: a \(k\)-manifold)
is a set \(M\) together with a family \(\left(M_i\right)_{i\in I}\) of subsets such that
\begin{APAenumerate}
\item \(M=\bigcup_{i\in I} M_i\) (union),
\item for every \(i\in I\) there is an injective map \(\varphi_i\colon M_i\to\R^k\) so that \(\phi_i\left(M_i\right)\) is open in \(\R^k\), and
\item for \(M_i\cap M_j\ne\emptyset\), \(\varphi_i\left(M_i\cap M_j\right)\) is open in \(\R^k\).
\end{APAenumerate}
\end{definition}
\begin{definition}[Structures on a manifold {\autocite[][Chapter~5A]{kuhnelwolfgang_2006}}]\label{Manifold:Extended}
Given a \(k\)-dimensional differentiable manifold,
one gets additional structure
by replacing aditional requirements on the transformation functions \(\varphi_j\circ\varphi_i^{-1}\),
which belong to the atlas of the manifold;
if all \(\varphi_j\circ\varphi_i^{-1}\) are (left-hand side),
then one speaks of (right-hand side) as follows:
\begin{center}
\begin{tabular}{ r c l }
continuous&\(\iff\)&topological manifold                                 \\
differentiable&\(\iff\)&differentiable manifold                              \\
\(C^1\)-differentiable&\(\iff\)&\(C^1\)-manifold                                       \\
\(C^r\)-differentiable&\(\iff\)&\(C^r\)-manifold                                       \\
\(C^\infty\)-differentiable&\(\iff\)&\(C^\infty\)-manifold                                  \\
real analytic&\(\iff\)&real analytic manifold                               \\
complex analytic&\(\iff\)&complex analytic manifold of dimension \(\frac{k}{2}\) \\
affine&\(\iff\)&affine manifold                                      \\
projective&\(\iff\)&projective manifold                                  \\
conformal&\(\iff\)&manifold with a conformal structure                  \\
orienatation-preserving&\(\iff\)&orientable manifold                                  \\
\end{tabular}
\end{center}
\end{definition}
\begin{definition}[Tangent vector {\autocite[][Chapter~5B]{kuhnelwolfgang_2006}}]\label{Manifold:TangentVector}
A \textit{tangent vector} \(X\) at \(p\)
is a derivation (derivative operator) defined on the set of \textit{germs of functions}
\[\mathcal{F}_p\left(M\right)\coloneqq\Set{f\colon M\to\R|f\text{ differentiable}}/\sim\text{,}\]
where the equivalence relation \(\sim\) is defined by
declaring \(f\sim f^\ast\) if and only if
\(f\) and \(f^\ast\) coincide in a neighborhood of \(p\).
The value \(X\left(f\right)\) is also referred to as the \textit{directional derivative} of \(f\) in the direction \(X\).
This definition means more precisely the following.
\(X\) is a map \(X\colon\mathcal{F}_p\left(M\right)\to\R\)
with the two following properties:
\begin{APAenumerate}
\item \(X\left(\alpha f+\beta g\right)=\alpha X\left(f\right)+\beta\left(g\right)\), \(f,g\in\mathcal{F}_p\left(M\right)\) (\textit{\(\R\)-linearity});
\item \(X\left(f\cdot g\right)=X\left(f\right)\cdot g\left(p\right)+f\left(p\right)\cdot X\left(g\right)\) for \(f,g\in\mathcal{F}_p\left(M\right)\) (\textit{product rule}).
\end{APAenumerate}
(For this to make sense, both \(f\) and \(g\) have to be defined in a neighborhood of \(p\).)
Briefly: \textit{tangent vectors are derivations acting on scalar functions.}
\end{definition}
\begin{corollary}[Tangent space {\autocite[][Chapter~5B]{kuhnelwolfgang_2006}}]\label{Manifold:TangentSpace}
The \textit{tangent space} \(T_pM\) of \(M\) at \(p\)
is defined in all cases as
the set of all tangent vectors at the point \(p\).
By definition \(T_pM\) and \(T_qM\) are disjoint if \(p\ne q\).
\end{corollary}
\begin{definition}[Riemannian metric {\autocite[][Chapter~5C]{kuhnelwolfgang_2006}}]\label{Manifold:RiemannianMetric}
A \textit{Riemannian metric} \(g\) on \(M\)
is an association \(p\mapsto g_p\in L^2\left(T_pM;\R\right)\)
such that the following conditins are satisfied:
\begin{APAenumerate}
\item \(g_p\left(X,Y\right)=g_p\left(Y,X\right)\) for all \(X\), \(Y\), \hfill (\textit{symmetry})
\item \(g_p\left(X,X\right)>0\) for all \(X\ne0\), \hfill (\textit{positive definiteness})
\item The coefficient \(\tensor{g}{_i_j}\) in every local representation (i.e., in every chart) \[g_p=\sum_{i,j}\tensor{g}{_i_j}\left(p\right)\cdot \left.d\tensor{x}{^i}\right|_p \otimes\left.d\tensor{x}{^j}\right|_p\] are differentiable functions. \hfill (\textit{differentiability})
\end{APAenumerate}
\end{definition}
\begin{remark}\label{Manifold:Riemannian}
The pair \(\left(M,g\right)\) is then called \textit{Riemannian manifold}.
One also refers to the Riemannian metric as the \textit{metric tensor}.
In local coordinates the metric tensor is given by the matrix (\(\tensor{g}{_i_j}\)) of functions.
In Ricci calculus this is simply written as \(\tensor{g}{_i_j}\).
{\autocite[][Chapter~5C]{kuhnelwolfgang_2006}}
\end{remark}
\begin{remark}\label{Manifold:InnerProduct}
A Riemannian metric \(g\) defines at every point \(p\)
an \textit{inner product} \(g_p\) on the tangent space \(T_pM\),
and therefore the notation \(\inner{X}{Y}\) instead of \(g_p\left(X,Y\right)\) is also used.
The notions of angles and lengths are determined by this inner product,
just as these notions are determined by the first fundamental form on surface elements.
The length or norm of vector \(X\) is given by \(\norm{X}\coloneqq\sqrt{g\left(X,X\right)}\),
and the angle \(\beta\) between two tangent vectors \(X\) and \(Y\)
can be defined by the validity of the equation \(\cos\beta\cdot\norm{X}\cdot\norm{Y}=g\left(X,Y\right)\).
{\autocite[][Chapter~5C]{kuhnelwolfgang_2006}}
\end{remark}
\subsection{Curvature}
\begin{definition}[The Lie bracket {\autocite[][Chapter~5D]{kuhnelwolfgang_2006}}]\label{Manifold:LieBracket}
Let \(X\), \(Y\) be (differentiable) vector fields on \(M\),
and let \(f\colon M\to\R\) be a differentiable function.
Through the relation
\[
\left[X,Y\right]\left(f\right)
\coloneqq
X\left(Y\left(f\right)\right)
- Y\left(X\left(f\right)\right)
\]
we define a vector field \(\left[X,Y\right]\),
which is referred to as the \textit{Lie bracket} of \(X\), \(Y\)
(also called the \textit{Lie derivative} \(\mathcal{L}_XY\) of \(Y\) in the direction \(X\)).
At a point \(p\in M\) we have \(\left[X,Y\right]_p\left(f\right)=X_p\left(Yf\right)-Y_p\left(Xf\right)\).
\end{definition}
\begin{lemma}[Properties of the Lie bracket {\autocite[][Chapter~5D]{kuhnelwolfgang_2006}}]\label{Manifold:LieBracket:Property}
Let \(X\), \(Y\), \(Z\) be vector fields,
let \(\alpha\), \(\beta\) be real constants,
and let \(f, h\colon M\to\R\) be differentiable functions.
Then the Lie bracket has the following properties:
\begin{APAenumerate}
\item \(\left[\alpha X+\beta Y, Z\right]=\alpha\left[X,Z\right]+\beta\left[Y,Z\right]\);
\item \(\left[X,Y\right]=-\left[Y,X\right]\);
\item \(\left[fX,hY\right]=f\cdot h\cdot\left[X,Y\right]+f\cdot\left(Xh\right)\cdot Y-h\cdot\left(Yf\right)\cdot X\);
\item \(\left[X,\left[Y,Z\right]\right]+\left[Y,\left[Z,X\right]\right]+\left[Z,\left[X,Y\right]\right] = 0\); (\textit{Jacobi identity})
\item \(\left[\frac{\partial}{\partial\tensor{x}{^i}}, \frac{\partial}{\partial\tensor{x}{^j}}\right]=0\) for every chart with coordinates (\(\tensor{x}{^1},\dots,\tensor{x}{^n}\));
\item \(\left[\sum_i\tensor{\xi}{^i}\frac{\partial}{\partial\tensor{x}{^i}},\sum_j\tensor{\eta}{^j}\frac{\partial}{\partial\tensor{x}{^j}}\right]=\sum_{i,j}\left(\tensor{\xi}{^i}\frac{\partial\tensor{\eta}{^j}}{\partial\tensor{x}{^i}}-\tensor{\eta}{^i}\frac{\partial\tensor{\xi}{^j}}{\partial\tensor{x}{^i}}\right)\frac{\partial}{\partial\tensor{x}{^j}}\) (\textit{representation in local coordinates}).
\end{APAenumerate}
\end{lemma}
\begin{definition}[Riemannian connection {\autocite[][Chapter~5D]{kuhnelwolfgang_2006}}]\label{Manifold:Connection}
A \textit{Riemannian connection} \(\nabla\) (pronounced "nabla")
on a Riemannian manifold \(\left(M,g\right)\) is a map
\[\left(X,Y\right)\mapsto\nabla_XY\text{,}\]
which associates to two given differentiable vector fields \(X\), \(Y\)
a third differentiable vector field \(\nabla_XY\),
such that the following conditions are satisfied: (\(f\colon M\to\R\) denotes a differentiable function):
\begin{APAenumerate}
\item \(\nabla_{X_1+X_2}Y=\nabla_{X_1}Y+\nabla_{X_2}Y\); (\textit{additivity in the subscript})
\item \(\nabla_{fX}Y=f\cdot\nabla_{X}Y\); (\textit{linearity in the subscript})
\item \(\nabla_X\left(Y_1+Y_2\right)=\nabla_XY_1+\nabla_XY_2\); (\textit{additivity in the argument})
\item \(\nabla_X\left(fY\right)=f\cdot\nabla_XY+\left(X\left(f\right)\right)\cdot Y\); (\textit{product rule in the argument})
\item \(X\left(g\left(Y,Z\right)\right)=g\left(\nabla_XY,Z\right)+g\left(Y,\nabla_XZ\right)\); (\textit{compatibility with the metric})
\item \(\nabla_XY-\nabla_YX-\left[X,Y\right]=0\). (\textit{symmetry or torsion-freeness})
\end{APAenumerate}
\end{definition}
\begin{remark}
We get the following expression for \(\nabla_XY\), in local coordinates, provided \(X=\sum_i\tensor{\xi}{^i}\frac{\partial}{\partial\tensor{x}{^i}}\) and \(Y=\sum_j\tensor{\eta}{^j}\frac{\partial}{\partial\tensor{x}{^j}}\):
\[
\nabla_XY=\sum_k\left(\sum_i\tensor{\xi}{^i}\frac{\partial\tensor{\eta}{^k}}{\partial\tensor{x}{^i}}+\sum_{i,j}\tensor{\Gamma}{^k_i_j}\tensor{\xi}{^i}\tensor{\eta}{^j}\right)\frac{\partial}{\partial\tensor{x}{^k}}\text{.}
\]
Especially for \(X=\frac{\partial}{\partial\tensor{x}{^i}}\) we obtain
\[
\nabla_XY=\sum_k\left(\frac{\partial\tensor{\eta}{^k}}{\partial\tensor{x}{^i}}+\sum_j\tensor{\Gamma}{^k_i_j}\tensor{\eta}{^j}\right)\frac{\partial}{\partial\tensor{x}{^k}}\text{.}
\]
Consequently, in Ricci calculus the notation for this formular is
\[
\nabla_i\tensor{\eta}{^k}=\frac{\partial\tensor{\eta}{^k}}{\partial\tensor{x}{^i}}+\tensor{\Gamma}{^k_i_j}\tensor{\eta}{^j}\text{.}
\]
\end{remark}
\begin{definition}[Christoffel symbols {\autocite[][Chapter~4A]{kuhnelwolfgang_2006}}]\label{Manifold:ChristoffelSymbol}
\;\newline
\begin{APAenumerate}
\item The quantities \(\partial_k\tensor{\Gamma}{_i_j}\) defined by the expressions
\[
\partial_k\tensor{\Gamma}{_i_j}
\coloneqq
\inner{\nabla_{\frac{\partial f}{\partial\tensor{u}{^i}}}\frac{\partial f}{\partial\tensor{u}{^j}}}{\frac{\partial f}{\partial\tensor{u}{^k}}}
\]
are called the \textit{Christoffel symbols of the first kind}.
\item The quantities \(\tensor{\Gamma}{^k_i_j}\) defined by the expressions
\[
\nabla_{\frac{\partial f}{\partial\tensor{u}{^i}}}\frac{\partial f}{\partial\tensor{u}{^j}}
=
\sum_k{\tensor{\Gamma}{^k_i_j}\frac{\partial f}{\partial\tensor{u}{^k}}}
\]
are called the \textit{Christoffel symbols of the second kind}.
\item By definition one has \(\partial_k\tensor{\Gamma}{_i_j}=\partial_k\tensor{\Gamma}{_j_i}\), \(\tensor{\Gamma}{^k_i_j}=\tensor{\Gamma}{^k_j_i}\)
as well as \(\partial_k\tensor{\Gamma}{_i_j}=\sum_{m}\tensor{\Gamma}{^m_i_j}\tensor{g}{_m_k}\).
\end{APAenumerate}
\end{definition}
\begin{definition}[Curvature tensor {\autocite[][Chapter~4C]{kuhnelwolfgang_2006}}]\label{Manifold:CurvatureTensor}
\[
R\left(X,Y\right)Z
\coloneqq
\nabla_X\nabla_YZ - \nabla_Y\nabla_XZ - \nabla_{\lie{X}{Y}}Z
\]
is a tensor field, which is called the \textit{curvature tensor} of the surface.
\end{definition}
\begin{remark}[Curvature tensor {\autocite[][Chapter~4C]{kuhnelwolfgang_2006}}]\label{Manifold:CurvatureTensor:ChristoffelSymbol}
The left-hand side of the Gauss equation is called the \textit{curvature tensor}
and is in general expressed in the form
\[
\tensor{R}{^s_i_k_j}
\coloneqq
\frac{\partial}{\partial\tensor{u}{^k}}\tensor{\Gamma}{^s_i_j}
- \frac{\partial}{\partial\tensor{u}{^j}}\tensor{\Gamma}{^s_i_k}
+ \sum_{r}\left(\tensor{\Gamma}{^r_i_j}\tensor{\Gamma}{^s_r_k}-\tensor{\Gamma}{^r_i_k}\tensor{\Gamma}{^s_r_j}\right) \text{.}
\]
\end{remark}
\begin{definition}[ {\autocite[][Chapter~6B]{kuhnelwolfgang_2006}}]
With respect to a given Riemannian metric \(\inner{}{}\),
the \textit{standard curvature tensor} \(\tensor{{R_1}}{}\) is defined by the relation
\(R_1\left(X,Y\right)Z\coloneqq\inner{Y}{Z}X-\inner{X}{Z}Y\).
We then set
\begin{align*}
\kappa_1\left(X,Y\right)
\coloneqq\inner{R_1\left(X,Y\right)Y}{X}
=\inner{X}{X}\inner{Y}{Y}-\inner{X}{Y}^2\text{,}\\
\kappa\left(X,Y\right)
\coloneqq\inner{R\left(X,Y\right)Y}{X}\text{.}
\end{align*}
Let \(\sigma\subset T_pM\) be a two-dimensional subspace, spanned by \(X\), \(Y\).
Then the quantity
\[
K_\sigma
\coloneqq
\frac{\kappa\left(X,Y\right)}{\kappa_1\left(X,Y\right)}
\]
is called the \textit{sectional curvature} of the Riemannian manifold with respect to the plane \(\sigma\).
\end{definition}
\begin{definition}[Space of constant curvature {\autocite[][Chapter~6B]{kuhnelwolfgang_2006}}]\label{Manifold:Spaceform}
If on a Riemannian manifold \(K_\sigma\) is constant
or, equalently,
if \(R=K\cdot R_1\) with \(K\in\R\),
the manifold is called a \textit{space of constant curvature}.
\end{definition}
\begin{remark}
By \textit{scaling} one means the process of
replacing a metric \(g\) by \(\tilde{g}]\coloneqq\lambda^2g\), where \(\lambda\ne0\) is a constant.
In this case one has \(\tilde{R_1}\left(X,Y\right)Z=\lambda^2R_1\left(X,Y\right)Z\).
On the other hand we have
\(\tilde{\tensor{\Gamma}{^k_i_j}}=\tensor{\Gamma}{^k_i_j}\),
\(\tilde{\nabla}_XY=\nabla_XY\) and, consequently,
\(\tilde{R}\left(X,Y\right)Z=R\left(X,Y\right)Z\)
as well as \(\tilde{K}=K\lambda^{-2}\).
Hence in \cref{Manifold:Spaceform} there are (up to scaling) only three possible curvature tensor with constant curvature:
\begin{align*}
R=R_1&\text{(with \(K=1\)),}\\
R=0&\text{(with \(K=0\)),}\\
R=R_{-1}\coloneqq-R_1&\text{(with \(K=-1\)).}
\end{align*}
Model spaces for these are the sphere \(S^n\), the euclidean space \(E^n\) and the hyperbolic space \(H^n\)
\end{remark}
\subsection{Space of Constant Curvature}
\begin{definition}(Pseudo-Euclidean space \(\R^n_k\) {\autocite[][Chapter~7A]{kuhnelwolfgang_2006}})
The so-called \textit{pseudo-Euclidean} metric (or pseudo-Euclidean inner product)
\[
g\left(X,X\right)
=\inner{X}{X}_k
=-\sum_{i=1}^{k}x_i^2+\sum_{i=k+1}^{n}x_i^2
\]
for a vector \(X\) with components \(s_1,\dots,x_n\),
where \(0\le k\le n\) is a fixed number which is called the \textit{index} or the \textit{signature} of the inner produce.
The pair \(\left(\R^n,g\right)\) is then called a \textit{pesudo-Euclidean space}
and is denoted by \(\R^n_k\) or \(E^n_k\).
In particular, \(E^n=R^n_0\) is the usual Euclidean space.
\end{definition}
\begin{definition}(The sphere \(S^n\) {\autocite[][Chapter~7A]{kuhnelwolfgang_2006}})
The sphere with its spherical metric is most easily defined as a hypersurface in Euclidean space with the associated first fundamental form, that is,
\[
S^n\coloneqq\Set{X\in\R^{n+1}|\inner{X}{X}=\sum_ix_i^2=1}\text{.}
\]
The Gauss equation then implies the sectional curvature to be \(K_\sigma=+1\) at every point \(p\) and every plane \(\sigma\subseteq T_pS^n\).
\end{definition}
\begin{definition}(Hyperbolic space \(H^n\) {\autocite[][Chapter~7A]{kuhnelwolfgang_2006}})
We defined the \(n\)-dimensional \textit{hyperbolic space} \(H^n\)
as the component of \(\Set{X\in\R^{n+1}_1|\inner{X}{X}_1=-1}\)
which contains the point \(\left(+1,0,\dots,0\right)\),
that is, the upper component of the two-sheeted hyperboloid.
The sectional curvature of hyperbolic space defined in this manner is constant: \(K=-1\).
\end{definition}
\begin{definition}(Symmetries of the space \(E^n\) {\autocite[][Chapter~7A]{kuhnelwolfgang_2006}})\label{Group:Euclidean}
The group \(E\left(n\right)\) of Euclidean motions
(the so-called \textit{Euclidean group})
acts on \(E^n\).
This group contains in particular all transpations
(these form a subgroup which is isomorphic to \(\R^n\), in fact a normal subgroup of \(E\left(n\right)\))
as well as the rotation group \(O\left(n\right)\),
consisting of symmetries which leave a point invariant.
In fact, \(E\left(n\right)\) is a semi-direct product of these two subgroups.
\end{definition}
\begin{definition}(Symmetries of the space \(S^n\) {\autocite[][Chapter~7A]{kuhnelwolfgang_2006}})\label{Group:Sphere}
The \textit{orthogonal group}
\[
O\left(n+1\right)
=
\Set{A\colon\R^{n+1}\to\R^{n+1}|\text{\(A\) preserves the Euclidean inner product}}
\]
acts on the sphere \(S^n\).
Here, \(A\) denotes a linear map.
As is well-known, \(A\in O\left(n+1\right)\) holds if and only if \(A^T=A^{-1}\).
As a matter of fact, the orthogonal group acts on the entire space \(\R^{n+1}\),
but we can consider its action when restricted to the sphere and denote the group in the same way.
\end{definition}
\begin{definition}(Symmetries of the space \(H^n\) {\autocite[][Chapter~7A]{kuhnelwolfgang_2006}})\label{Group:Hyperbolic}
The \textit{Lorentz group}
\[
O\left(n,1\right)
=
\Set{A\colon\R^{n+1}_1\to\R^{n+1}_1|\text{\(A\) preserves the pseudo-Euclidean inner product}}
\]
acts on \textit{Lorentz space} or on \textit{Minkowski space} \(\R^{n+1}_1\)
and preserves the set \(\tilde{H}=\Set{X|\inner{X}{X}_1=-1}\).
The "positive" part of this set,
\[
O_{+}\left(n,1\right)
=
\Set{A\colon O\left(n,1\right)|\text{\(A\) preserves \(\tilde{H}\cap\Set{x_0>0}\)}}
\]
then acts on hyperbolic space \(H^n\) and preserves its metric.
\end{definition}
\end{document}


\subsubsection{Adiabatic Processes}
Adiabatic processes are compression/expansion processes in which the gas has no heat flow ($Q=0$). These processes tend to be either fast, or occur under insulated conditions; for example, consider the same gas cylinder with the piston we discussed in the isothermal section. If instead of pushing in the piston very slowly, we push down forcefully, the compression will occur so quickly that there wouldn't be time for heat to flow out of the gas. This would be an adiabatic compression. As another example, if we had a cylinder of gas surrounded with thermal insulation, then even if we were to compress the piston or let the gas expand, there would be no heat flow and again we would have an adiabatic process.Let's consider some mathematical consequences of adiabatic processes. As a consequence of zero heat flow, by the first law of thermodynamics we have that:
\begin{equation}
    \Delta E = W
\end{equation}
So then for an adiabatic process, we can get that:
\begin{equation}
    W = \frac{\chi}{2}N{k_b}\Delta T
\end{equation}
I'm also going to show the derivation for the other relation relevant to adiabatic processes. The derivation is beyond the scope of this course, so if you don't want to read it just skip to the final equations we obtain at the end end\footnote{My disappointment will be immeasurable and my day ruined if you do}. This derivation first takes the relation in (20) for an infinitesimal step, then runs some rearrangement before integrating:
\begin{align*}
    dE &= \delta W \\
    \frac{\chi}{2}N{k_b}dT &= -PdV
\end{align*}
Like in the isothermal case, we make a substitution with ideal gas law, namely
\begin{equation*}
    N{k_b}dT = d(PV)
\end{equation*}
I also use the approximation $d(PV) = VdP + PdV$\footnote{As for why, play around with $d(PV) = (P+dP)(V+dV) - PV$... or just consider the product rule.}. Making all of these substitutions gives
\begin{equation*}
    \frac{\chi}{2}(VdP + PdV) = -PdV
\end{equation*}
At this point you have all the parts necessary to rearrange this equation into
\begin{equation*}
    \frac{\chi}{2}\frac{dP}{P} = -\Big(\frac{\chi}{2} + 1\Big)\frac{dV}{V}
\end{equation*}
If you guessed that we integrate both sides of this equation, then you're right! This may seem a bit strange, since we're integrating the two sides of the equation against two different variables, but it is in fact perfectly legal. By integrating, we're taking a sum on both sides of all the infinitesimal steps from the initial to final state. Since both sides are using the same initial and final state, it makes sense that taking small steps between them should always yield the same result. Anyways, integrating this equation gives:
\begin{equation*}
    \int_{P_1}^{P_2} \frac{\chi}{2}\frac{dP}{P} = \int_{V_1}^{V_2} -\Big(\frac{\chi}{2} + 1\Big)\frac{dV}{V}
\end{equation*}
Again, we can factor out the constant terms to get:
\begin{equation*}
    \frac{\chi}{2}\int_{P_1}^{P_2} \frac{dP}{P} = -\Big(\frac{\chi}{2} + 1\Big)\int_{V_1}^{V_2} \frac{dV}{V}
\end{equation*}
At this point the integral on each side evaluates in the exact same way as when we integrated to get isothermal work done:
\begin{equation*}
    \frac{\chi}{2}\ln{\Big(\frac{P_2}{P_1}\Big)} = -\Big(\frac{\chi}{2} + 1\Big)\ln{\Big(\frac{V_2}{V_1}\Big)}
\end{equation*}
Multiplying both sides of this equation by $\frac{2}{\chi}$ yields:
\begin{equation*}
    \ln{\Big(\frac{P_2}{P_1}\Big)} = -\Big(\frac{\chi+2}{\chi}\Big)\ln{\Big(\frac{V_2}{V_1}\Big)}
\end{equation*}
We then take the natural exponent of both sides of the equation to get:
\begin{align*}
    e^{\ln{\big(\frac{P_2}{P_1}\big)}} &= e^{-\big(\frac{\chi+2}{\chi}\big)\ln{\big(\frac{V_2}{V_1}\big)}} \\
    \frac{P_2}{P_1} &= e^{\ln{\Big(\big(\frac{V_2}{V_1}\big)^{-\big(\frac{\chi+2}{\chi}\big)}\Big)}} \\
    \frac{P_2}{P_1} &= \Big(\frac{V_2}{V_1}\Big)^{-\big(\frac{\chi+2}{\chi}\big)}
\end{align*}
Raise both sides to the exponent -1, rearrange a bit, and you get:
\begin{equation}
    {P_1}{V_1}^{\frac{\chi+2}{\chi}} = {P_2}{V_2}^{\frac{\chi+2}{\chi}}
\end{equation}
Sometimes the quantity $\frac{\chi+2}{\chi}$ is called $\gamma$ as well. Note that this identity we have discovered can take some alternative forms (which can be useful for exams); for example, making the subtitution $P = \frac{nRT}{V}$, we get:
\[ \frac{nRT_1}{V_1}V_1^\gamma = \frac{nRT_2}{V_2}V_2^\gamma \]
And cancelling out $nR$ on both sides and grouping like terms, we obtain the formula:
\begin{equation}
    T_1V_1^{\gamma-1} = T_2V_2^{\gamma-1}
\end{equation}
Finally, we again consider what an adiabatic process looks like on a PV diagram; the visual answer is that it looks quite a bit like the isothermal curve, but is steeper/lies above it. You can see both curves pictured below for comparison. The adiabatic compression is pictured in black, and the isothermal curve is dashed and red:
\begin{center}
    \begin{tikzpicture}
    \begin{axis}[
        axis x line=bottom,
        axis y line=left,
        xmin=0, xmax=10,
        ymin=0, ymax=10,
%        % (made labels more common)
%        % (because of the "sketch" type of the plot these should not be needed)
%        xlabel={Volume $(\mathrm{m}^3)$},
%        ylabel={Pressure (Pa)},
        % (changed ticks + labels to normal ticks instead of extra ticks)
        xtick={3.75,6},
        xticklabels={$V_1$,$V_2$},
        ytick={1.5,6},
        yticklabels={$P_2$,$P_1$},  % <-- (changed order of entries)
    ]
        % fill the area below the curve
        % (draw it first, so it is below everything else)

        % draw the dashed lines
        % (using two different approaches)
        \addplot [dashed,domain=0:3.75,samples=2] {6};
        \addplot [dashed,domain=0:6,samples=2] {1.5};

        \draw [dashed,thin] (axis cs:6,1.5) -- (axis cs:6,0);
        \draw [dashed,thin] (axis cs:3.75,6)   -- (axis cs:3.75,0);

        % now draw the curve
        \draw [
            dotted,red             % <-- added
        ] (axis cs:3,6) to [bend right=30]
            % store start and end coordinates
            coordinate [pos=1] (start)
            coordinate [pos=0] (end)
        (axis cs:6,1.5);

        \draw [
            fleche={0.6:black}            % <-- added
        ] (axis cs:3.75,6) to [bend right=30]
            % store start and end coordinates
            coordinate [pos=1] (start)
            coordinate [pos=0] (end)
        (axis cs:6,1.5);

        % draw start and end point
        \fill [radius=2pt]
            (start) circle[]
            (end)   circle[];
        \node[right] at (axis cs:6,1.5) {$T_2$};
        \node[right] at (axis cs:3.75,6) {$T_1$};
    \end{axis}
        \node[below] at (6.5,0) {$V$};
        \node[left] at (0,5.5) {$P$};

\end{tikzpicture}
\end{center}


% !TEX root =  manual.tex

\section{Covariance Functions Recognized by the Emulator}
\label{sec:CovarianceFunctions}

$u$ and $v$ are zero-indexed vectors that represent a point in parameter space.  $P$ is the number of parameters. $\Theta=(\theta_0, \theta_1,\theta_2,\ldots)$ is a list of $P+2$ or $P+3$ hyperparameters. $\theta_0$ is called \emph{amplitude}; $\theta_1$ is called the \emph{nugget}.  $\Vert\,\cdotp\Vert{}_\Theta$ is a distance function parametrized by $\Theta$.  $\epsilon$ is $10^{-5}$. $c_\Theta{}(u, v)$ is the covariance between $u$ and $v$, as parametrized by $\Theta$.

\begin{figure}[b]
\includegraphics[width=4in]{figs/kernel_functions.pdf}
\parbox[b]{2.5in}
{\caption{\label{fig:kernelfunctions}
$C_\Theta{}(0, x)$ for a one-dimensional parameter space with each covariance function type. The amplitude is 1, the nugget is 0, and the length scale is 1.
\vspace*{30pt}
}}
\end{figure}

%% FIGURE SOURCE CODE:
%%
%% #!/usr/bin/env python
%% import matplotlib.pyplot
%% import numpy
%% x = numpy.arange(-4,4,0.01)
%% SE = numpy.exp(-0.5 * (x ** 2))
%% alpha = 1.75
%% PE = numpy.exp(-0.5 * (numpy.power(numpy.abs(x),alpha)))
%% M52 = (1 + numpy.sqrt(5) * numpy.abs(x) + 5/3.0 * (
%%     (numpy.abs(x))**2) ) * numpy.exp(- numpy.sqrt(5) *
%%     numpy.abs(x))
%% M32 = (1 + numpy.sqrt(3) * numpy.abs(x) ) * numpy.exp(
%%     - numpy.sqrt(3) * numpy.abs(x))
%% matplotlib.pyplot.plot(x, SE,  '-',  label=u'Squared\nExponential')
%% matplotlib.pyplot.plot(x, M32, '--', label=u'Mat\u00e9rn 3/2')
%% matplotlib.pyplot.plot(x, M52, '-.', label=u'Mat\u00e9rn 5/2')
%% matplotlib.pyplot.plot(x, PE, ':',
%%     label=u'Power\nExponential\n(\u03b1=%g)'%alpha)
%% matplotlib.pyplot.legend()
%% matplotlib.pyplot.axes().set_aspect(3)
%% matplotlib.pyplot.savefig('kernel_functions.pdf',
%%     bbox_inches='tight')

\begin{itemize}
\item Squared-Exponential [\variable{SQUARE\_EXPONENTIAL\_FUNCTION}]
\[ \Vert{}u-v\Vert{}_\Theta{} = \sqrt{\sum_{i=0}^{P-1} \frac{(u_i - v_i)^2}{(\theta{}_{2+i})^2}} \qquad
 \delta{}_{uv} = 1 \text{ if } (\Vert{}u-v\Vert{}_\Theta{} < \epsilon{}) \textrm{ else } \delta{}_{uv} = 0 \]
\[ c_\Theta{}(u, v) = \theta{}_0 \exp\left({-\tfrac{1}{2} \Vert{}u-v\Vert{}_\Theta{}^2}\right) + \theta{}_1\delta{}_{uv} \]

\item {Power-Exponential}
[\variable{POWER\_EXPONENTIAL\_FUNCTION}]
\[ \Vert{}u-v\Vert{}_\Theta{} = \sqrt{\sum_{i=0}^{P-1} \frac{(u_i - v_i)^2}{(\theta{}_{3+i})^2}} \qquad
 \delta{}_{uv} = 1 \text{ if } (\Vert{}u-v\Vert{}_\Theta{} < \epsilon{}) \textrm{ else } \delta{}_{uv} = 0 \]
\[ c_\Theta{}(u, v) = \theta{}_0 \exp\left({-\tfrac{1}{2} \Vert{}u-v\Vert{}_\Theta{}^{\theta{}_2}}\right) + \theta{}_1\delta{}_{uv} \]

\item {Mat\'{e}rn 3/2}
[\variable{MATERN\_32\_FUNCTION}]
\[ \Vert{}u-v\Vert{}_\Theta{} = \sqrt{\sum_{i=0}^{P-1} \frac{(u_i - v_i)^2}{(\theta{}_{2+i})^2}} \qquad
 \delta{}_{uv} = 1 \text{ if } (\Vert{}u-v\Vert{}_\Theta{} < \epsilon{}) \textrm{ else } \delta{}_{uv} = 0 \]
\[ c_\Theta{}(u, v) = {\theta{}_0} \left({ 1 + \sqrt{3} \Vert{}u-v\Vert{}_\Theta{} }\right)
\exp \left({ - \sqrt{3} \Vert{}u-v\Vert{}_\Theta{} }\right) + \theta{}_1\delta{}_{uv} \]

\item {Mat\'{e}rn 5/2}
[\variable{MATERN\_52\_FUNCTION}]
\[ \Vert{}u-v\Vert{}_\Theta{} = \sqrt{\sum_{i=0}^{P-1} \frac{(u_i - v_i)^2}{(\theta{}_{2+i})^2}} \qquad
 \delta{}_{uv} = 1 \text{ if } (\Vert{}u-v\Vert{}_\Theta{} < \epsilon{}) \textrm{ else } \delta{}_{uv} = 0 \]
\[ c_\Theta{}(u, v) = {\theta{}_0} \left({ 1 + \sqrt{5} \Vert{}u-v\Vert{}_\Theta{}
 + \tfrac{5}{3} \left({\Vert{}u-v\Vert{}_\Theta{}}\right)^2  }\right) + \theta{}_1\delta{}_{uv} \]
\end{itemize}

%%  LocalWords:  hyperparameters


\chapter{Foundation}

If you are already familiar with the things here,
please at least skim this chapter to verify that
we are speaking the same language.

\section{Type}

\index{type}%
\index{inhabitant}%
\(x : T\) means that the \emph{type} of \(x\) is \(T\).
We also say that \(x\) \emph{inhabits} \(T\) and that \(x\) is an \emph{inhabitant} of \(T\).
\index{function type}%
\index{type!function}%
A \emph{function type} looks like \(a \to b\).

Function application:
Iff \(x:A\) and \(f:A\to B\), then \(f(x):B\).

The arrow in a function type associates to the right.
The type \(a \to b \to c\) means \(a \to (b \to c)\).

Types and sets are different:
\(x \in A\) and \(x : A\) are different.

\section{Logic}

\index{iff}%
\index{if and only if}%
``Iff'' is ``if and only if''.
It is bi-implication.

\index{connectives}%
\index{logical connectives}%
Logical connectives:
\index{conjunction}%
\index{and}%
\emph{Conjunction} is \(a \wedge b\) (\(a\) and \(b\)).
\index{disjunction}%
\index{or}%
\emph{Disjunction} is \(a \vee b\) (\(a\) or \(b\)).
\index{implication}%
\emph{Implication} is \(a \implies b\) (if \(a\) then \(b\)).
\index{bi-implication}%
\emph{Bi-implication} is \(a \iff b\) (iff \(a\) then \(b\)).
\index{negation}%
\index{not}%
\emph{Negation} is \(\neg a\) (not \(a\)).

\section{Set}

\index{set}%
Practically, a \emph{set} is an unordered collection of unique things.%
\index{Russell's paradox}%
\footnote{Theoretically, a set cannot be defined this way due to Russell's paradox.}
If \(a \neq b\), then the notations \(\{a,b\}\), \(\{b,a\}\), and \(\{a,a,b\}\)
all describe the same set of \emph{two} elements.
The \emph{cardinality} of a set \(A\), written \(|A|\),
is the number of elements of \(A\).

\index{set builder notation}%
\index{notation!set builder}%
\paragraph{Set builder notation}
\( \{ M ~|~ F \} \)
describes the set of every \(M\) where \(F\) is true
where \(M\) is an expression and \(F\) is a logic formula.
For example, \(\{ x^2 ~|~ x \in \Nat \}\) is \(\{ 0^2, 1^2, 2^2, \ldots \}\).
The ellipsis (\ldots) is not an element of the set;
there are just too many things to write.

\paragraph{Set relationships}
\index{subset}%
\(A \subseteq B\)
(\(A\) is a \emph{subset} of \(B\))
iff \(\forall x (x \in A \implies x \in B)\).
\index{disjoint sets}%
\index{sets!disjoint}%
Two sets \(a\) and \(b\) are \emph{disjoint} iff \(a \cap b = \emptyset\).

\paragraph{Set operations}
\index{intersection}%
\index{intersection  (set theory)}%
The \emph{intersection of \(A\) and \(B\)} is
\(A \cap B = \{ x ~|~ x \in A \wedge x \in B \}\).
\index{union}%
\index{union (set theory)}%
The \emph{union of \(A\) and \(B\)} is
\(A \cup B = \{ x ~|~ x \in A \vee x \in B \}\).
\index{subtraction (set theory)}%
\index{sets!subtraction}%
The \emph{subtraction of \(A\) and \(B\)} is
\(A - B = \{ x ~|~ x \in A \wedge x \not\in B \}\).
\index{Cartesian product}%
The \emph{Cartesian product of \(A\) and \(B\)} is \(A \times B = \{ (a,b) ~|~ a \in A, b \in B \}\).
The \emph{Cartesian product of \(A_1,\ldots,A_n\)} is
\(\prod_{k=1}^n A_k = A_1 \times \ldots \times A_n = \{ (a_1,\ldots,a_n) ~|~ a_1 \in A_1, ~\ldots, ~a_n \in A_n \}\).
\index{power set}%
\index{set!power}%
The \emph{power set} of \(A\) is \(2^A = \{ X ~|~ X \subseteq A \}\),
the set of all subsets of \(A\).

\paragraph{Closed under binary operation}
\index{closed under binary operation}%
Let \(S\) be a set and \(f\) be a \emph{binary operation} (a two-argument function).
\emph{\(S\) is closed under \(f\)} iff
\(\forall a, b \in S : f(a,b) \in S\).

\paragraph{Partitioning}
\(A_1,\ldots,A_n\) is a \emph{partitioning of \(A\)} if and only if
\(\bigcup_{k=1}^n A_k = A\) and
\(\forall i \neq j (A_i \cap A_j = \emptyset)\).

\section{Relation}

\index{relation}%
A \emph{relation} is a subset of a Cartesian product.
\index{binary relation}%
\index{relation!binary}%
\(R\) is a \emph{binary relation} between \(A\) and \(B\) iff \(R \subseteq A \times B\).
Iff \(A = B\), then \(R\) is an \emph{endorelation}.

\paragraph{Notation}
We write \(a R b\) or \(R(a,b)\) to mean \((a,b) \in R\).
We write \(\neg (a R b)\) or \(\neg R(a,b)\) to mean \((a,b) \not\in R\).

Properties of an endorelation:
\index{reflexive relation}%
\index{relation!reflexive}%
An endorelation \(R \subseteq A \times A\) is \emph{reflexive} iff
\(\forall x \in A : (x,x) \in R\),
\index{symmetric relation}%
\index{relation!symmetric}%
is \emph{symmetric} iff
\(\forall x,y: (x,y) \in R \iff (y,x) \in R\),
\index{antisymmetric relation}%
\index{relation!antisymmetric}%
is \emph{antisymmetric} iff
\(\forall x,y: (x,y) \in R \wedge (y,x) \in R \implies x = y\),
\index{transitive relation}%
\index{relation!transitive}%
is \emph{transitive} iff
\(\forall x,y,z: (x,y) \in R \wedge (y,z) \in R \implies (x,z) \in R\),
\index{total relation}%
\index{relation!total}%
is \emph{total} iff
\(\forall x \in A , y \in A : (x,y) \in R \vee (y,x) \in R\).

\index{equivalence relation}%
\index{relation!equivalence}%
An \emph{equivalence relation} is a symmetric transitive reflexive relation.
\index{partial order}%
\index{total order}%
\index{order!partial}%
\index{order!total}%
A \emph{partial order} is a antisymmetric transitive reflexive relation.
A \emph{total order} is an antisymmetric transitive total relation.

The
\index{composition}%
\index{composition!of two relations}%
\index{relation!composition}%
\emph{composition} of \(f\) and \(g\) is
\(f \circ g = \{ (a,c) ~|~ (a,b) \in g \wedge (b,c) \in f \}\).
Repeated composition: \(f^{n+1} = f \circ f^n\).

\(R\) is \emph{transitive} iff \(\forall a,b,c : a R b \wedge b R c \implies a R c\).

The \emph{inverse} of \(R\) is \(R^{-1} = \{ (b,a) ~|~ a R b \}\).

The
\index{symmetric closure}%
\emph{symmetric closure} of \(R\)
is the smallest symmetric relation that is also a superset of \(R\).
The symmetric closure of \(R\) is \(R \cup R^{-1}\).
The
\index{transitive closure}%
\emph{transitive closure} of \(R\)
is the smallest transitive relation that is also a superset of \(R\).

\section{Function}

\index{function}%
A \emph{function} \(f\) is a relation such that
\(\forall a, b, c : (a,b) \in f \wedge (a,c) \in f \implies b = c\).
The type of a function is \(a \to b\).
If \(f\) is a function, then \(f(a) = b\) iff \((a,b) \in f\).
The type of a relation between \(a\) and \(b\) is \(a \to 2^b\).
If $(a,b) \in f$ and $(a,c) \in f$, then $b = c$.

\index{endofunction}%
The type of an \emph{endofunction} is \(a \to a\).
An endofunction is a function whose input type is equal to its output type.

\index{Iverson bracket}%
\paragraph{Iverson bracket}
\([E]\) is \(1\) iff \(E\) is true
and \(0\) iff \(E\) is false.

\index{indicator function}%
\paragraph{Indicator function}
\(1_A(x) = [x \in A]\).

\index{unnamed function}%
\paragraph{Unnamed function}
\(f(x) = x + 1\) and \(f = x \to x+1\) describe the same function.
When an expression is expected, the notation \(X \to Y\)
means a function that evaluates to \(Y\) if given \(X\).
When a type is expected, the notation \(X \to Y\) describes a function type.
Expressions like \(x \to x + 1\) are called \emph{unnamed functions}.

The
\index{image!of relation}%
\emph{\(R\)-image} of \(A\) is \(\{ y ~|~ (x,y) \in R, ~ x \in A \}\).

The
\index{preimage!of relation}%
\emph{\(R\)-preimage} of \(A\) is \(\{ x ~|~ (x,y) \in R, ~ y \in A \}\).

The
\index{image!of function}%
\emph{\(f\)-image} of \(A\) is \(\{ f(x) ~|~ x \in A \}\).

The
\index{preimage!of function}%
\emph{\(f\)-preimage} of \(A\) is \(\{ x ~|~ f(x) \in A \}\).

For all function \(f\):
if \(A \subset B\) then \(F(A) \subseteq F(B)\)
where \(F(A) = \{ f(x) ~|~ x \in A \}\).

For all function \(f\):
if \(A \subset B\) then \(G(A) \subseteq G(B)\)
where \(G(A) = \{ x ~|~ f(x) \in A \}\).

The function type operator associates to the right: \(a \to b \to c = a \to (b \to c)\).

\paragraph{Currying}
\index{curry}%
\index{currying}%
\emph{Currying} turns every function that takes \(n\) arguments
to an equivalent function that takes one argument.
Currying \(f : (a_1,\ldots,a_n) \to b\) turns it into \(f' : a_1 \to \ldots \to a_n \to b\)
such that \(f(x_1,\ldots,x_n)
= f'~x_1~\ldots~x_n
= (((f'~x_1)~x_2)\ldots)~x_n\).

If it is clear from context that \(f\) can take 3 arguments (and not one 3-tuple argument),
then we abuse the notation \(f(a,b,c)\) to mean \(((f~a)~b)~c\).

\section{Polynomial}

A \emph{polynomial of \(x\)} is an expression of the form \(\sum_{k=0}^n a_k x^k\)
where \(n\) is the \emph{degree} of the polynomial.

A
\index{polynomial}%
\emph{polynomial function of degree \(n\)} is a function of the form
\(f(x) = \sum_{k=0}^n a_k x^k\) where each \(a_k\) is constant.

A \emph{polynomial function of degree \(n\)} is a function of the form
\(f(x) = \prod_{k=1}^n (x - r_k)\) where each \(r_k\) is constant.
Each \(r_k\) is a \emph{root} of the polynomial.

\section{Limit}

Informally, \(\lim_{x \to a} f(x) = b\)
iff \(f(x)\) approaches \(b\) as \(x\) approaches \(a\).

\section{Sequence}

\index{sequence}%
A \emph{sequence} \(x\) is a list of things \(x_0, x_1, x_2\), and so on.

An
\index{arithmetic sequence}%
\index{sequence!arithmetic}%
\emph{arithmetic sequence} is a sequence of the form \(x_k = x_0 + a k\).

A
\index{geometric sequence}%
\index{sequence!geometric}%
\emph{geometric sequence} is a sequence of the form \(x_k = r^k x_0\).

\section{Series}

\index{series}%
If \(x\) is a sequence, then \(\sum_k x_k\) is a \emph{series}.
The series \emph{converges} iff it is a number.

The
\index{sequence of partial sums}%
\index{partial sum}%
\emph{sequence of partial sums} of the sequence \(x\) is
the sequence \(y\)
where \(y_n = \sum_{k=0}^n x_k\).
The series is \(\lim_{n \to \infty} y_n\).

The
\index{geometric series}%
\index{series!geometric}%
\emph{geometric series} with ratio \(r\) is \(g(r) = \sum_{k=0}^\infty r^k\).
If \(0 < \abs{r} < 1\) then \(g(r) = \frac{1}{1-r}\).


 \section{$k$-Means Clustering Problem}
	$k$-Means clustering problem is an unsupervised problem that can be described as follow.

\begin{definition}[$k$-Means Clustering Problem\footnote{High frequency definition.}]
    \label{alo: def1}
 Given an observation set
        \begin{equation}
        X=\{x_{1}, x_{2}, \dots, x_{N} | x_{i} \in\mathbb{R}^n\}
        \end{equation}

	The goal is to arrange the $N$ observation instances into $k$ sets, $\mathcal{S} = \{S^{1}, S^{2}, \dots, S^{k}\}$, and choose one cluster, $\mathcal{C} = \{c^{1}, c^{2}, \dots, c^{k}\}$. So as to minimize the \textbf{Objective Function}:

        \begin{equation}
        \phi_{X}(\mathcal{C}) = \sum_{i = 1}^{N} d^{2}(x_{i}, \mathcal{C})
        \end{equation}

        where

         \begin{equation}
        d^{2}(x_{i}, \mathcal{C}) = \min_{l = 1, \dots, k} ||x_{i} - c^{l}||_{2}^{2}
        \end{equation}

        Noting that $\phi_{X}$ has the additivity about $X$, i.e., if $X = X_{1}\cup X_{2}$, then $\phi_{X} = \phi_{X_{1}} + \phi_{X_{2}}$.  There is also one equivalent optimization version of $k$-Means problem.
\end{definition}
    \begin{definition}[$k$-Means Clustering Problem\footnote{Optimization form.}]
    \label{alo: def2}
	Minimizing the \textbf{Objective Function}:

	\begin{equation}{\label{eq:1}}
	\phi(W, c) = {\sum_{l=1}^{k}\sum_{i=1}^{N}} w_{li} \cdot ||x_{i} - c^{l}||^{2}_{2}
	\end{equation}

	where
	\begin{equation}{\label{eq:2}}
	c = (c^{1}, c^{2}, \dots, c^{k}), c^{l} \in\mathbb{R}
	\end{equation}
	\begin{equation}
        W =(w_{li}) \in M_{k\times N}(\mathbb{R})
	\end{equation}
	\begin{equation}
	w_{li} = \begin{cases} 1,&\text{$x_{i} \to S^{l}$},\\
	0,&\text{otherwise}.
	\end{cases}
	\end{equation}
	s. t.

	\begin{equation}
	\sum_{l=1}^{k} w_{li} = 1, i = 1, 2, \dots, N; \sum_{i=1}^{N}w_{li}\geq 1, l = 1, 2, \dots, k.
	\end{equation}

	\begin{equation}{\label{eq:3}}
	w_{li} \in \{0, 1\}, i = 1, 2, \ldots, N, l = 1, 2, \dots, k.
	\end{equation}
    \end{definition}

        For convenience, we named $W$ as \textbf{assignment matrix}. By the format of Definition \ref{alo: def1}, we have transformed $k$-means Problem into one \textbf{Optimization Problem} consists of \textbf{Objective Function} (\ref{eq:1}) and \textbf{Constraints} (\ref{eq:2}-\ref{eq:3}).

       \begin{theorem}[Definition \ref{alo: def1} is equivalent to \ref{alo: def2}]
        \begin{proof}
        Firstly, the formula (\ref{eq:1}) can be rewritten as $\phi(W, c) = {\sum_{i=1}^{N}\sum_{l=1}^{k}} w_{li} \cdot ||x_{i} - c^{l}||^{2}_{2}$. It's trivial that given $x_{i}$,
        $$\min_{l = 1, \dots, k} ||x_{i} - c^{l}||_{2}^{2} \leq \sum_{l=1}^{k} w_{li} \cdot ||x_{i} - c^{l}||^{2}_{2}$$
         where $\sum_{l=1}^{k} w_{li} = 1$.

         Besides, the best optimizer of definition \ref{alo: def1} has the corresponding assignment matrix, $\hat{W}$ of definition \ref{alo: def2}, here it goes,
         $$\sum_{i = 1}^{N}\min{||x_{i} - c^{l}||} = {\sum_{i=1}^{N}\sum_{l=1}^{k}} \hat{w}_{li} \cdot ||x_{i} - c^{l}||^{2}_{2}\geq \min{\sum_{l=1}^{k}\sum_{i=1}^{N}} w_{li} \cdot ||x_{i} - c^{l}||^{2}_{2}$$
        \end{proof}
        \end{theorem}
        \begin{remark}
        $k$-means problem is one optimization problem with nonlinear, non-convex objective function and discrete constraints. More directly, it can be written as follow,

        \begin{equation}
        \min \phi(W, c) \quad s.t. (\ref{eq:2})-(\ref{eq:3}).
        \end{equation}
        \end{remark}

      	Then, we give one theorem from Shokri and M. A. in 1984\cite{ref01}.

	\begin{theorem}{\label{alo:convergence}}
	$k$-means Problem has local minimum points.
	\end{theorem}

	For completeness, We rewrite the proof here by giving some definitions and lemmas and add some details based on the previous proof.

	\begin{definition}
	Consider the set $\Omega$ given by
	\begin{equation}
	\Omega = \{W \in M_{k\times N}(\mathbb{R}) : \sum_{l=1}^{k} w_{li} = 1, i = 1, 2, \dots, N; \sum_{i=1}^{N}w_{li}\geq 1; w_{li} \geq 0 \}.
	\end{equation}
	\end{definition}

	\begin{lemma} \label{alo:lem1}
	The set $\Omega$ is convex, and the extreme points of $\Omega$ satisfy constraints

	$$w_{li} \in \{0, 1\}, i = 1, 2, \dots, N, l = 1, 2, \dots, k.$$
	\end{lemma}

	\begin{proof}
	$\forall W^{1}, W^{2}$, and $0 \leq \lambda \leq 1$,
	\begin{equation}
	\sum_{l=1}^{k} [\lambda w_{li}^{1}+(1-\lambda)w_{li}^{2}] = \lambda\sum_{l=1}^{k} w_{li}^{1}+(1-\lambda)\sum_{l=1}^{k}w_{li}^{2} = 1.
	\end{equation}

	\begin{equation}
	\sum_{i=1}^{N} [\lambda w_{li}^{1}+(1-\lambda)w_{li}^{2}] = \lambda\sum_{i=1}^{N} w_{li}^{1}+(1-\lambda)\sum_{i=1}^{N}w_{li}^{2} \geq 1.
	\end{equation}

	On the one hand, $\forall W$ satisfies constraint $w_{ki} = 0$ or $1$, if $\exists W^{l_{1}}, W^{l_{2}} \in \Omega$, s.t.

	\[W = \lambda_{0}W^{l_{1}}+(1-\lambda_{0})W^{l_{2}}, 0 < \lambda_{0} <1\]
	or
	\[w_{li}=\lambda_{0} w_{li}^{l_{1}}+(1-\lambda_{0})w_{li}^{l_{2}}\]

	\begin{itemize}
	\item If $w_{li} = 0$, then
	\[w_{li}^{l_{1}}=w_{li}^{l_{2}}=0\]
	\item if $w_{li} = 1$, then
	\[w_{li}^{l_{1}}=w_{li}^{l_{2}}=1.\]
	\end{itemize}
	That is to say, $W^{l_{1}}= W^{l_{2}}$. The points satisfy $w_{li} \in \{0, 1\}$ must be extreme points of  $\Omega$.

	 On the other hand, each extreme point of $\Omega$ is associated with a basis of the constraints in $\Omega$. Hence, each basic variable will have value $1$ and nonbasic variables will be zeros. Then we have completed the proof.
	\end{proof}

        \begin{remark}
	With the principle of combination, there are at most $M$ extreme points of $\Omega$,
	\[M := k^{N} - \sum_{i=1}^{k-1} \binom{k}{i} \cdot (k-i)^{N} \]

        and denote the extreme points of $\Omega$ as $\{W^{1}, W^{2}, \dots, W^{M}\}$.
        \end{remark}

	\begin{definition}[Reduced Problem of $k$-means Problem]\label{alo: reduce}
	The reduced problem of $k$-means problem is given by minimizing $\Phi(W)$,
	\begin{equation}
	\Phi (W) = \min_{c \in \mathbb{R}^{nk}} \phi(W, c),  \quad s.t. W \in \Omega
	\end{equation}
	\end{definition}

	\begin{lemma}
	The function $\Phi(W)$ is a concave function, which subjects to $W\in\Omega$. Reduced problem gets local minimum value at the extreme point of $\Omega$.
	\end{lemma}

	\begin{proof}
	First, we prove that $\Phi$ is concave. $\forall W^{{l}_{1}}, W^{{l}_{2}}\in \Omega$ and $0 \leq \gamma \leq 1$,
	\begin{equation}
	\begin{aligned}
	\Phi(\gamma W^{{l}_{1}}+(1-\gamma)W^{{l}_{2}}) & =\min_{c \in\mathbb{R}^{nk}} \phi(\gamma W^{{l}_{1}}+(1-\gamma) W^{{l}_{2}}, c)\\
	&= \min_{c \in \mathbb{R}^{nk}} [\gamma\phi(W^{{l}_{1}}, c)+(1-\gamma)\phi (W^{{l}_{2}}, c)]\\
	&\geq \gamma \min_{c \in \mathbb{R}^{nk}} \phi(W^{{l}_{1}}, c)+\min_{c \in \mathbb{R}^{nk}}(1-\gamma) \phi(W^{{l}_{2}}, c)\\
	&=\gamma \Phi(W^{{l}_{1}})+(1-\gamma)\Phi(W^{{l}_{2}}).
	\end{aligned}
	\end{equation}

	Second, We illustrate $\Phi(W)$ has smaller value at extreme points.
	Fix one $\hat W \in \Omega$, which is not one extreme point but near one extreme point. We denote all extreme points of $\Omega$ as above. So here exists one constant vector $\alpha=(\alpha_{1}, \alpha_{2}, \dots, \alpha_{M})$, s.t.
	\begin{equation}
	{\hat W}= \sum_{j=1}^{M} \alpha_{j} W^{j}, \quad where \sum_{j=1}^{M}\alpha_{j}=1; 0 \leq \alpha <1
	\end{equation}

	\begin{equation}
	\begin{aligned}
	\Phi({\hat W}) &= \Phi(\sum_{l=1}^{m} \alpha_{l} W^{l}) \geq \sum_{l=1}^{m} \alpha_{l}\Phi(W^{l})
	\end{aligned}
	\end{equation}
	Then the local minimum of $\Phi(W)$ must be obtained at the extreme point of $\Omega$.
	\end{proof}

	\begin{lemma}
	The reduced problem of $k$-means problem and $k$-means problem are equivalent.
	\end{lemma}

	\begin{proof}
	It equals to prove that
	\begin{equation}\label{eq: 4}
	{\arg\min} \phi(W, c) \iff \arg\min_{W \in \Omega} \Phi(W)
	\end{equation}
	Suppose  $(W^{*}, c^{*}) = {\arg\min} \phi(W, c)$ and $W_{*} = \arg\min_{W \in \Omega} \Phi(W)$.

	At first, given $\tilde W \in \Omega$, we denote or find the $c_{*}= (c_{*}^{1}, \dots, c_{*}^{k})$ in reduced problem.

	\begin{equation}
	\min_{c \in \mathbb{R}^{nk}} \phi(\tilde W, c) = \min_{c \in \mathbb{R}^{nk}} {\sum_{l=1}^{k}\sum_{i=1}^{N}} \tilde{w_{li}} \cdot ||x_{i} - c^{l}||^{2}_{2}
	\end{equation}
	It's obvious that
	\begin{equation}
	c_{*}^{l} = \frac{\sum_{i=1}^{N} \tilde{w_{li}}\cdot x_{i}}{\sum_{i=1}^{N} \tilde{w_{li}}}
        \end{equation}
	Denote that
	\[\Phi(W_{*}, c_{*}) = \Phi(W_{*})\]
	Then, we prove that $\phi (W^{*}, c^{*}) = \Phi(W_{*}, c_{*})$.

	``$\phi (W^{*}, c^{*}) \leq \Phi(W_{*}, c_{*})$'' can be gotten by the definition and Lemma of concave function $\Phi(W)$ easily.

	``$\phi (W^{*}, c^{*}) \geq \Phi(W_{*}, c_{*})$'':

	$\forall c \in \mathbb{R}^{nk}$, $\phi(W^{*}, c^{*}) \leq \phi(W^{*}, c)$, and fix $W^{*}$,
	\[\phi(W^{*}, c_{*}) \leq \phi(W^{*}, c)\]

	Or directly, $\phi(W^{*}, c_{*}) = \phi(W^{*}, c^{*})$. But $\phi(W^{*}, c_{*}) \geq \phi(W_{*}, c_{*})$, so we conclude that
	\[\phi(W^{*}, c^{*}) \geq \phi(W_{*}, c_{*})\]

	Further, we can prove there exists $(W^{*}, c^{*}) = (W_{*}, c_{*})$.

	\end{proof}

	Now we complete the proof of the \textbf{Theorem \ref{alo:convergence}}.

	$k$-means problem is one mixed integer programming with nonlinear objective, which is NP-hard. Here is difficulty consist of two part. First, the constraints are discrete. Secondly, the objective function is nonlinear and non-convex. However, next part we will list heuristic algorithms of $k$-means problem and analyze the pros and cons for each.

	\section{Heuristic Algorithm of $k$-Means Problem}\label{alo:Heuristic}
	Though the $k$-Means problem is NP-hard, there are many efficient heuristic algorithm to solve it. The most common one is the standard $k$-Means algorithm. To estimate different algorithms, we import some definition of validation entry of $k$-Means.
	\begin{definition}[$\alpha-approximation$]
	Let $\phi^{*}$ be the objective of optimal $k$-Means clustering, a set of centers, $\mathcal{C}$ is $\alpha-approximation$, if
	\begin{equation}
	\phi_{X}(\mathcal{C}) \leq \alpha \phi^{*}
	\end{equation}
	\end{definition}

	\subsection{Basic Knowledge}
	\begin{lemma}
	\label{sum}
	Let $S$ be a set of points with center of $x^{*}$, and let $z$ be an arbitrary point. Then,
	\begin{equation}
	\sum_{x \in S}||x - z||^{2} = \sum_{x \in S} ||x - x^{*}||^{2} + |S|\cdot ||z - x^{*}||^{2}
	\end{equation}
	\end{lemma}

	\begin{lemma}[Power-mean Inequality]
	Let $a_{1}, \dots, a_{m}\in\mathbb{R}$, then
	\begin{equation}
	\sum_{i = 1}^{m} a_{i}^{2} \geq \frac{1}{m} \left(\sum_{i = 1}^{m}a_{i}\right)^{2}
	\end{equation}
	\label{powermean}

	\end{lemma}

	\begin{lemma}
	\label{optle}
	Let $S$ be an arbitrary clustering set in optimal clustering, and $\mathcal{C}$ be the clustering with just one center, which is chosen uniformly at random from $S$, then
	\begin{equation}
	E[\phi_{S}(\mathcal{C})] = 2 \phi^{opt}_{S}
	\end{equation}
	\label{powermean}

	\end{lemma}

	\subsection{The Standard $k$-Means Algorithm/Lloyd's Algorithm}
	The Standard $k$-Means algorithm can be written in Algorithm \ref{alo:kmeans}. Lloyd's Algorithm is not a good clustering algorithm in terms of efficiency or quality, whose running time can be exponential in the worst case and solution is locally optimal. Nevertheless, the unbeatable speed and simplicity of $k$-Means make its good reputation in industry.

%%%%%%%
	\begin{algorithm}
		\caption{The Standard $k$-Means/Lloyd's Algorithm}
		\label{alo:kmeans}
		\textbf{Input:}  $X=\lbrace x_{1},...,x_{N}| x_{i}\in\mathbb{R}^n\rbrace$ and $k$\\
		\textbf{Output:} The cluster centers $\mathbf c_1,...,\mathbf c^{k}\in\mathbb{R}^n$\\
		\begin{algorithmic}[1]
			\State Arbitrarily choose the initial centers, $c^{1},c^{2},...,c^{k}$.
			\State \textbf{Repeat} for $1\leq l \leq k$,
				$$
				S^{l} = \{x: ||x-c^{l}||^{2} \leq ||x-c^{j}||^{2}, \forall 1\leq j \leq k\}
				$$
				Update
				$$
				c^{l}=\cfrac{\sum_{x\in S^{l}}x}{|S^{l}|}.
				$$
			\textbf{Until} $S^{l}$ don't change, for $\forall l=1,2,\dots,k$.

		\end{algorithmic}
	\end{algorithm}

	From the figure \ref{alo:kmeans basic} below, we can clearly see the processes of the standard $k$-Means($k$ = 2) algorithm in $\mathbb{R}^{2}$. Figure $(a)$ scans the data set $X$. We initialize two cluster centers, which are marked by red and blue in figure $(b)$. Figure $(c), (d), (e)$ show the iteration of above algorithm. We stoped at the state of figure $(f)$.

	\begin{figure}[htbp]
	\centering{\includegraphics[width=10cm]{cluster4.png}}
	\caption{A concrete $k$-Means clustering process}
	\label{alo:kmeans basic}
\end{figure}

         Shokri, etc. put forward the partial convergence of  the standard $k$-Means algorithm. And they also described how to obtain a local minimum of the $k$-Means clustering problem under certain given conditions with Minkowsky metric. But how to find the global minimum is still a open problem.

         \begin{theorem}[Partial Convergence]
         The standard $k$-Means algorithm converges to a partial optimal solution of $k$-Means clustering problem in a finite number of iterations.
         \end{theorem}

         Here we give no specific proof but the definition of partial optimal solution of $k$-Means clustering problem.
         \begin{definition}
         A point $(W^{*}, c^{*})$ is partial optimal solution of $k$-Means clustering problem if it satisfies the following:
         \begin{equation}
         \phi(W^{*}, c^{*}) \leq \phi(W^{*}, c), \forall c \in \mathbb{R}^{nk};
         \end{equation}
         and
         \begin{equation}
         \phi(W^{*}, c^{*}) \leq \phi(W, c^{*}), \forall W \in M_{k \times N}(R).
         \end{equation}
         \end{definition}

         We give another form of the standard $k$-Means algorithm, which can give proof of theorem \textbf{Partial Convergence}.

	 \begin{algorithm}
		\caption{The Standard $k$-means(another form)}
	         \label{alo:kmeans2}
		\textbf{Input:}  Data set $X=\lbrace x_{1},...,x_{N}| x_{i}\in\mathbb{R}^n\rbrace$ and $k$(and Tol)

		\textbf{Output:} The cluster centers $c = ( c^{1},..., c^{k})$

		\begin{algorithmic}[1]
		\State Choose the \textbf{initial} centers arbitrarily, $c_{0}=(c_{0}^{1},c_{0}^{2},...,c_{0}^{k})$.
		\State \textbf{Repeat:} for $j \geq 0$
                                  $$
			w_{li}^{j+1} = I(l = \arg\min_{1 \leq l \leq k} ||x_{i}-c_{j}^{l}||_{2}^{2})
				$$
				Update
				$$
			c_{j+1}^{l} = \frac{\sum_{i=1}^{N} w_{li}^{j+1} \cdot x_{i}}{\sum_{i=1}^{N} w_{li}^{j+1} }
				$$
			\textbf{Stop} criterion $$ W^{j+1} = W^{j}$$ or ($||c_{j+1}-c_{j}|| \leq Tol$)
		\State \textbf{Output} $$c = c_{j}$$
	   \end{algorithmic}
	   \end{algorithm}

	\subsection{The $k$-Means++ Algorithm}
	The standard $k$-Means algorithm is highly sensitive to the initialization of cluster centers. It is easy to construct situations in which the standard $k$-Means algorithm converges to a local minimum that is arbitrarily bad compared to the optimal solution. Such an example is shown in figure \ref{alo:algorithm ratio} for $k=3$ and where $x<y<z$.

		 \begin{figure}[htbp]
		 	\centering{\includegraphics[width=10cm]{algo.png}}
		 	\caption{High approximation ratio}
		 	\label{alo:algorithm ratio}
		 \end{figure}

	       If we initialize cluster centers $(1, 2, 3)$, we can get the optimal centers shown at the middle with the standard $k$-Means algorithm.
	        \begin{equation}
	        \phi^{opt} = (\frac{x}{2})^{2}+(\frac{x}{2})^{2}=(\frac{x^{2}}{2})
	        \end{equation}

	        Unfortunately, if we initialize centers $(2, 3 ,4)$, it is easy to verify that the centers shown at the bottom is the solution, a bad solution.
	         \begin{equation}
	          \phi_{heu} = (\frac{y}{2})^{2}+(\frac{y}{2})^{2}=(\frac{y^{2}}{2})
	        \end{equation}
	        We can see the two different initialization such that the algorithm converges to very different solutions.

	 The following advanced algorithm provides a better initialization of the clustering and gives the $O(\log k)-approximation$ solution.
	 \begin{theorem}
	 \label{competitive}
	 If $\mathcal{C}$ is the cluster result of $k$-Means ++, then the corresponding potential function $\phi$ satisfies that
	 \begin{equation}
	 E[\phi] \leq 8(\ln k + 2)\phi^{*}
	 \end{equation}
	 \end{theorem}

	The k-means++ algorithm addresses the second of these obstacles above by specifying a procedure to initialize the cluster centers before proceeding with the standard k-means optimization iterations. With the k-means++ initialization, the algorithm is guaranteed to find a solution that is $ O(\log k) $ competitive to the optimal k-means solution. It improves the running time of the standard $k$-Means algorithm (i.e. Lloyd's algorithm), and the quality of the final solution.

	This algorithm is written in Algorithm \ref{alo:kmean++}.

	\begin{algorithm}[H]
		\begin{algorithmic}[1]
			\caption{$k$-Means++}
			\label{alo:kmean++}
			\State $\mathcal{C}\leftarrow$ Choose $c_1$ with a uniform distribution among the data points ($c_1$ is the first center).
			%均匀分布
			\State \textbf{For $l \leq k$},

		Sample $x$ from $X$ with probability $\frac{d^{2}(x, \mathcal{C})}{\phi_{X}(\mathcal{C})}$.

		    $\mathcal{C} \leftarrow \mathcal{C}\cup\{x\}$

		    \State Use the standard $k$-Means algorithm.
		\end{algorithmic}
	\end{algorithm}

         Here we import the definition of probability sampling. These days, we tend to use computers as the mechanism for generating random numbers as the basis for selection. One popular way to pick $x$ in the above algorithm is to:
         \begin{enumerate} [1.]
         \item Random one number $r \in [0, \phi_{X}(\mathcal{C})]$;
         \item Do subtraction $r = r - d^{2}(x, \mathcal{C})$ until $r \leq 0$;
         \item Choose the above $x$ as the next seed.
         \end{enumerate}

         Next we give the proof of theorem \ref{competitive} according to its creator's idea\cite{kmeansplus}.

         \begin{lemma}
         \label{corele}
         Let $\mathcal{C}$ be an arbitrary cluster, and $\mathcal{C}^{*}$ be one cluster of the optimal clustering. Choose $u$ centers from $\mathcal{C}^{*} \setminus \mathcal{C}$ and the union of clustering be $X^{u}$. Define $X^{c}$ as $X - X^{u}$. If adding $t \leq u$ randomly centers to $\mathcal{C}$ as the above algorithm \ref{alo:kmean++}'s step $\textbf{1}$ and $\textbf{2}$, let $\tilde{\mathcal{C}}$ denote the result set, and $\tilde{\phi}$ denote the corresponding potential function. Then,
         \begin{equation}
         E[\phi_{X}(\tilde{\mathcal{C}})] \leq \left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u}}\right)\cdot (1+H_{t}) + \frac{u-t}{u}\cdot \phi_{X^{u}}(\mathcal{C})
         \end{equation}
         where
         \begin{equation}
         H_{t} = \begin{cases}& 1 + \frac{1}{2} + \cdots + \frac{1}{t}, \ \text{$t > 0$}\\
         & 0,\  \text{ $t = 0$}
         \end{cases}
         \end{equation}
         %proof
         \begin{proof}

         For convenience, we define probability events as follows.
         \begin{equation}
         \begin{cases}
        & \mathscr{A} = \{\text{add the first center from $X$}\}\\
         & \mathscr{A}_{1} = \{\text{add the first center from $X^{u}$}\}\\
         &\mathscr{A}_{2}= \{\text{add the first center from $X^{c}$}\}\\
         &\mathscr{A}_{1} \cap \mathscr{A}_{2} = \empty, \mathscr{A}_{1} \cup  \mathscr{A }_{2} = \mathscr{A}
         \end{cases}
         \end{equation}

         One can split the whole expectation into two branches.
         \begin{equation}
         E[\phi_{X}(\tilde{\mathcal{C}})] = Prob_{\mathscr{A}_{1}} \cdot E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{1}] + Prob_{\mathscr{A}_{1}} \cdot E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{2}]
         \end{equation}

         Firstly, when $t = 0$ and $u > 0$, i.e. $\phi_{X}(\mathcal{C}^{'}) = \phi_{X}(\mathcal{C})$. it following $1 + H_{t} = 1$ naturally has
         \begin{equation}
         E[\phi_{X}(\tilde{\mathcal{C}})] \leq \phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u}} + \phi_{X^{u}}(\mathcal{C})
         \end{equation}

         If $t = u = 1$, there has
           \begin{equation}
           \label{eqlemma}
           \begin{aligned}
        E[\phi_{X^{u}}(\tilde{\mathcal{C}})|\mathscr{A}_{1}]   = &\sum_{x_{0} \in X^{u}} \frac{d^{2}(x_{0}, \mathcal{C})}{\sum_{x \in X^{u}} d^{2}(x, \mathcal{C})} \sum_{x \in X^{u}} \min \{d^{2}(x, \mathcal{C}), ||x - x_{0}||^{2}\} & \tilde{\mathcal{C}} = \mathcal{C} \cup \{x_{0}\} \\
          \leq &   \sum_{x_{0} \in X^{u}}\frac{ \left(\frac{2}{|X^{u}|} \sum_{x \in X^{u}}  d^{2}(x, \mathcal{C}) + \frac{2}{|X^{u}|} \sum_{x\in X^{u}} ||x - x_{0}||^{2} \right)}{\sum_{x \in X^{u}} d^{2}(x, \mathcal{C})} \cdot & Lemma\  \ref{powermean}\\
         &\sum_{x \in X^{u}} \min \{d^{2}(x, \mathcal{C}), ||x - x_{0}||^{2}\} \\
         \leq &  \frac{4}{|X^{u}|} \sum_{x_{0} \in X^{u}}  \sum_{x\in X^{u}} ||x-x_{0}||^{2} \\
          = & 4\cdot \frac{1}{|X^{u}|}  \sum_{x_{0} \in X^{u}} \left(\sum_{x\in X^{u}} ||x - c^{u}||^{2} + |X^{u}|\cdot ||x_{0} - c^{u}||^{2}\right)& Lemma \ \ref{sum}\\
          = & 8\phi^{opt}_{X^{u}} & Lemma \ref{optle}
         \end{aligned}
         \end{equation}
         where $c^{u}$ is the true center of $X^{u}$ in optimal cluster.
         Then

         \begin{equation}\begin{aligned}
          E[\phi_{X}(\tilde{\mathcal{C}})] = &\frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{1}] + \frac{\phi_{X^{c}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{2}]\\
          \leq &\frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \left(8\phi^{opt}_{X^{u}} +\phi_{X^{c}}(\mathcal{C}) \right) + \frac{\phi_{X^{c}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \phi_{X}(\mathcal{C})\\
          \leq &  2\phi_{X}(\mathcal{C}) + 8\phi^{opt}_{X^{u}}
          \end{aligned}
         \end{equation}

         %%%%induction
         By using induction method, it is sufficient to suppose that the result holds for the cases that $(t-1, u)$ and $(t-1, u-1)$. With similar analysis method as the case of $t = u =1$, if the event $\mathscr{A}_{2}$ happen with probability, $\frac{\phi_{X^{c}}(\mathcal{C})}{\phi_{X}(\mathcal{C})}$, then we still need choose $t-1$ centers with $u$ being unchanged, i.e.,
         \begin{equation}
         E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{2}] \leq \left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u}}\right)\cdot (1+H_{t-1}) + \frac{u-t + 1}{u}\cdot \phi_{X^{u}}(\mathcal{C})
         \end{equation}

         Supposed that $\mathscr{A}_{1}$ happened, more specifically, let the first center be chosen from one clustering set $S \subseteq X^{u}$ and $Prob_{x}$ denote the probability of choosing $x \in S$ as the first center. Besides, we define the event $\mathscr{A}_{1}^{s} = \{\text{add the first center from $S$}\}$ and we have its probability of $\frac{\phi_{S}(\mathcal{C})}{\phi_{X}(\mathcal{C})}$. We can conclude similar conclusion as the equation \ref{eqlemma}.
         $$ \sum_{x \in S} Prob_{x} \cdot \phi_{S}(\mathcal{C}) \leq 8\phi^{opt}_{S} $$

          \begin{equation}
          \begin{aligned}
         &E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{1}^{s}] \\
         = & \sum_{x \in S} Prob_{x} \cdot \left( \left(\phi_{X^{c}}(\mathcal{C}) + \phi_{S}(\mathcal{C})
         + 8\phi^{opt}_{X^{u} - S}\right)\cdot (1+H_{t-1}) + \frac{u-t}{u-1}\cdot \phi_{X^{u}-S}(\mathcal{C})\right)\\
           \leq & \left(\phi_{X^{c}}(\mathcal{C})
         + 8\phi^{opt}_{X^{u} }\right)\cdot (1+H_{t-1}) + \frac{u-t}{u-1}\cdot \phi_{X^{u}-S}(\mathcal{C})
           \end{aligned}
         \end{equation}

         \begin{equation}
         \begin{aligned}
         &\frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \cdot E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{1}] \\
        = & \sum_{S \subseteq X^{u}} \frac{\phi_{S}(\mathcal{C})}{\phi_{X}(\mathcal{C})} E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{1}^{s}]\\
         = & \frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \cdot \left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u} }\right)\cdot (1+H_{t-1}) + \frac{u-t}{u-1}\cdot \sum_{S \subseteq X^{u}} \frac{\phi_{S}(\mathcal{C})}{\phi_{X}(\mathcal{C})}\cdot \phi_{X^{u} - S}(\mathcal{C})\\
         \leq &  \frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \cdot \left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u} }\right)\cdot (1+H_{t-1})  \\
         & + \frac{u-t}{u-1}\cdot \frac{1}{\phi_{X}(\mathcal{C})} \left(\phi_{X^{u}}^{2}(\mathcal{C}) - \frac{1}{u} \cdot \phi_{X^{u}}^{2}(\mathcal{C}) \right) \\
         = & \frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \cdot \left(\left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u} }\right)\cdot (1+H_{t-1}) + \frac{u - t}{u} \cdot \phi_{X^{u}}(\mathcal{C}) \right) \\
         \end{aligned}
         \end{equation}

         Then
         \begin{equation}
         \begin{aligned}
         E[\phi_{X}(\tilde{\mathcal{C}})] = &\frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{1}] + \frac{\phi_{X^{c}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} E[\phi_{X}(\tilde{\mathcal{C}})|\mathscr{A}_{2}] \\
         \leq &   \left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u}}\right)\cdot (1+H_{t-1}) + \frac{u-t }{u}\cdot \phi_{X^{u}}(\mathcal{C}) + \frac{\phi_{X^{c}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \cdot \frac{\phi_{X^{u}}(\mathcal{C})}{\phi_{X}(\mathcal{C})} \\
         \leq &  \left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u}}\right)\cdot (1+H_{t-1} + \frac{1}{u}) + \frac{u-t }{u}\cdot \phi_{X^{u}}(\mathcal{C})\\
           \leq &  \left(\phi_{X^{c}}(\mathcal{C}) + 8\phi^{opt}_{X^{u}}\right)\cdot (1+H_{t}) + \frac{u-t }{u}\cdot \phi_{X^{u}}(\mathcal{C})\\
         \end{aligned}
         \end{equation}
         \end{proof}
         \end{lemma}
         Considering the cluster $\mathcal{C}$ that just cover the first clustering set $S$ in optimal clustering, after algorithm \ref{alo:kmean++}'s step $\textbf{1}$ and $\textbf{2}$, we get the initial seeding and clustering $\tilde{\mathcal{C}}$, which means applying lemma \ref{corele} with $t = u = k-1$, i.e., we choose $X^{c} = S$, then

	\begin{equation}
	\begin{aligned}
	E[\phi_{X}(\tilde{\mathcal{C}})]  \leq &\sum_{x \in S} Prob_{x} \cdot\left(\phi_{S}(\mathcal{C}) + 8\phi^{opt}_{X} - 8\phi_{S}^{opt}\right)\cdot (1+H_{k-1}) &\text{Lemma \ref{optle}} \\
	\leq &8\phi^{opt}_{X}\cdot (1+\ln k) & H_{k-1} \leq 1+\ln k\\
	\end{aligned}
	\end{equation}

         \subsection{Scalable $k$-Means++}
         \newcommand{\RNum}[1]{\uppercase\expandafter{\romannumeral #1}}
         $k$-Means$\RNum{2}$ uses an oversampling factor $l = \Omega(k)$, which is inspired by $k$-Means++. As we will see,
         	\begin{algorithm}[H]
		\begin{algorithmic}[1]
			\caption{$k$-Means$\RNum{2}$}
			\label{alo:kmean2}
			\State $\mathcal{C}\leftarrow$ Choose $c_1$ uniformly at random among the data points ($c_1$ is the first center).
			%均匀分布
			\State $\psi \leftarrow \phi_{X}(\mathcal{C})$
			 \State For $O(\log \psi)$ times do

		$\mathcal{C}^{'} \leftarrow $sample independently $x$ from $X$ with probability $\frac{l \cdot d^{2}(x, \mathcal{C})}{\phi_{X}(\mathcal{C})}$.

		    $\mathcal{C} \leftarrow \mathcal{C}\cup\{x\}$

		    end

		    \State For $x \in \mathcal{C}$, set $\omega_{x}$ to be the number of points in $X$ cluster to $x$ than any other point in $\mathcal{C}$
		    \State Recluster the weighted points in $\mathcal{C}$ into $k$ clusters.
		\end{algorithmic}
	\end{algorithm}

          \begin{theorem}
          \label{alo:the}
	 If an $\alpha-approximation$ algorithm is used in Step 5, the Algorithm $\ref{alo:kmean2}$ obtains a solution that is an $O(\alpha)-approximation$ to $k$-Means.
	 \end{theorem}

	 More mathematically, there has
	  \begin{theorem}
	 Let $\alpha = exp(-(1- e^{-l/(2k)})) \approx e^{-\frac{l}{2k}}$. In Algorithm $\ref{alo:kmeans2}$,
	 \begin{equation}
	 E[\phi_{X}(\mathcal{C}\cup \mathcal{C}^{'})] \leq 8 \phi^{*} + \frac{1+\alpha}{2} \phi_{X}(\mathcal{C})
	 \end{equation}
	 \end{theorem}

	 \begin{corollary}\label{alo:cor1}
	If $\phi^{(i)}$ is the objective of the clustering after the $i$-th round of Algorithm $\ref{alo:kmeans2}$, then
	\begin{equation}
	 E[\phi^{(i)}] \leq \frac{16}{1 - \alpha} \phi^{*} + \left(\frac{1+\alpha}{2}\right)^{i} \psi
	 \end{equation}
	 \end{corollary}
	 Corollary $\ref{alo:cor1}$ implies that after $O(\log \psi)$ rounds, the result can touch $O(\phi^{*})$. Then the Theorem is an immediate consequence.

\section{The Choice of $k$}
         In general, we don't know the optimal number of clusters, $k$ in the practical probems. Here we give one method named ``elbow''.
         Elbow method has two step can be written as following:
         \begin{enumerate}
         \item Compute the sum of squared error $(SSE)$ for some values of $l$ (for example $2, 4, 6, 8,$ etc.):
         \begin{equation}
         SSE={\sum_{l=1}^{k}\sum_{x \in S_{l}}} ||x-c_{l}||^{2}
         \end{equation}
         \item Plot $l$ against the SSE, and choose the $k$ at which the $SSE$ decreases abruptly.
\end{enumerate}

         For one example as the figure shown, we will understand how elbow method works.

          \begin{figure}[htbp]
		 	\centering{\includegraphics[width=10cm]{cluster_numbers.png}}
		 	\caption{Using the Elbow Method to Determine the Optimal Number of Clusters}
		 \end{figure}

         We note Dataset A on the left. At the top we see a number line plotting each point in the dataset, and below we see an elbow chart showing the SSE after running $k$-Means clustering for $k$ going from $1$ to $10$. We see a pretty clear elbow at $k = 3$, indicating that $3$ is the best number of clusters.

         However, the elbow method doesn't always work well; especially if the data is not very clustered. Notice how the elbow chart for Dataset B does not have a clear elbow. Instead, we see a fairly smooth curve, and it's unclear what is the best value of $k$ to choose.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Other Contents}
$k$-Means is one type of $k$-Partition clustering, which is about that given a set of $N$ points in Euclidean space and an integer $k$, find a partition of these points into $k$ subsets, each with a center. There are three common formulations of $k$-partition clustering depending on the particular objective used.
\begin{enumerate}[a.]
\item $k$-Center use the objective to minimize the maximum distance between a point and its nearest cluster center.
\item $k$-Median's objective is to minimize the sum of the distance of each point and its center.
\end{enumerate}
\subsection{Convolutional $k$-Means Clustering}
	Convolutional $k$-Means clustering is another type of algorithms for different problems, because CNN is in general a supervised learning algorithm. We mentioned it here just for complementary.

	Convolutional $k$-Means clustering proposed to train a deep convolutional network based on an enhanced version of the $k$-Means clustering algorithm, which reduces the number of correlated parameters in the form of similar filters, and thus increases test categorization accuracy.

	Generally speaking, this algorithm uses $k$-Means to cluster the parameters of CNN.


%---------------------------Distortion---------------------------
\section{Distortion}

Given a set of Gauss points $G=\{g_k\}$ for a hexahedron, let
\[
|J| = \min_{g_k}\left\{\det\left(J_{g_k}\right)\right\}
\]
be the minimum determinant of the Jacobian when evaluated at each Gauss point $g_k$.
Then the distortion is
\[
q = \frac{|J| V_m}{V}
\]
where $V_m = 8$ is the volume of a ``master'' hexahedron defined by the vertices
\[
\begin{array}{lcrcrcrl}
  \vec P_0 &= (&-1&,&-1&,& -1&)\\
  \vec P_1 &= (& 1&,&-1&,& -1&)\\
  \vec P_2 &= (& 1&,& 1&,& -1&)\\
  \vec P_3 &= (&-1&,& 1&,& -1&)
\end{array}\rule{5em}{0pt}
\begin{array}{lcrcrcrl}
  \vec P_4 &= (&-1&,&-1&,&  1&)\\
  \vec P_5 &= (& 1&,&-1&,&  1&)\\
  \vec P_6 &= (& 1&,& 1&,&  1&)\\
  \vec P_7 &= (&-1&,& 1&,&  1&)
\end{array}
\]
and $V$ is the volume of the hexahedron being evaluated.
See \S\ref{s:hex-volume} for details on computing the hex volume $V$.

\hexmetrictable{distortion}%
{$L^3$}%                                      Dimension
{$[0.5,1]$}%                                  Acceptable range
{$[0,1]$}%                                    Normal range
{$[-DBL\_MAX,DBL\_MAX]$}%                     Full range
{$1$}%                                        Cube
{Adapted from \cite{ideas:xx}}%               Citation
{v\_hex\_distortion}%                         Verdict function name


\label{seq_method_characteristics}
\section{Method of the characteristics}

\manuelComment{based on this video: https://www.youtube.com/watch?v=LpHqrlrU5pM}

The method of the characteristics is a powerful method to solve PDE. This method enable us to solve a wide range of problems including:
\begin{enumerate}
  \item Linear:
  \begin{equation}
  a(x, y) \frac{\partial u}{\partial x}
  + b(x, y) \frac{\partial u}{\partial y}
  + c(x, y) u
  = f(x, y)
  \end{equation}
  \item Semi-linear:
  \begin{equation}
  a(x, y) \frac{\partial u}{\partial x}
  + b(x, y) \frac{\partial u}{\partial y}
  + c(x, y) u
  = f(x, y, u)
  \end{equation}
  \item  Quasi-linear:
  \begin{equation}
  a(x, y) \frac{\partial u}{\partial x}
  + b(x, y) \frac{\partial u}{\partial y}
  = f(x, y, u)
  \end{equation}
\end{enumerate}

In this introduction  we will focus on semi-linear problems that also include
the linear ones. Let us consider a PDE of the form
\begin{equation}
  a(x, y) \frac{\partial u}{\partial x}
  + b(x, y) \frac{\partial u}{\partial y}
  = f(x, y, u),
  \label{eq_semi_linear}
\end{equation}
which is a semi-linear PDE. Semi-linear equations include equations of the form
\begin{equation}
  a(x, y) \frac{\partial u}{\partial x}
  + b(x, y) \frac{\partial u}{\partial y}
  + c(x, y) u
  = g(x, y),
\end{equation}
with $f(x, y, u) = g(x, y) - c(x, y) u$.

This PDE must have an initial condition associated with it. This initial
condition can be of the form
\begin{equation}
  u(x, 0) = u_0(x),
\end{equation}
or
\begin{equation}
  u(0, y) = u_1(x).
\end{equation}
The pair of a PDE like \eref[eq_semi_linear] and an initial condition is
sometimes called a semi-linear Cauchy problem.

Any solution to these Cauchy problems can be represented by a surface $u \equiv
u(x, y)$ in a 3D space as schematically shown in \fref[fig_integral_surface]
\begin{figure}[h!]
	\centering \includegraphics[scale=.75]{fig/fig1_method_characteristics.png}
	\caption{\captionStroke{Schematic integral surface.}}
	\label{fig_integral_surface}
\end{figure}

A surface $u = u(x, y)$ that solves a Cauchy problem is known as an integral
surface since integration is used to solve these problems. We can write down the
equation of this integral surface as
\begin{equation}
  F(x, y, u) \equiv u(x, y) - u = 0.
\end{equation}
Note that the first $u(x, y)$ is a function, while the second $u$ is a
variable. So for example if
\begin{equation}
  u(x, y) = x - y^2,
\end{equation}
then
\begin{equation}
  F(x, y, u) = x - y^2 - u.
\end{equation}

From vector calculus we know that any vector $\mathbf{n}$ normal to the surface $F = 0$ is given by the gradient
\begin{equation}
  \mathbf{n} = \nabla F =
  \frac{\partial u}{\partial x} \mathbf{i}
  + \frac{\partial u}{\partial y} \mathbf{j}
  - \mathbf{k}.
\end{equation}

\fref[fig_normal_vector] shows a schematic representation of this vector. The
vector is represented pointing downwards since $F = u(x, y) - u$.

\begin{figure}[h!]
	\centering \includegraphics[scale=.75]{fig/fig2_method_characteristics.png}
	\caption{\captionStroke{Schematic integral surface with normal vector.}}
	\label{fig_normal_vector}
\end{figure}

We can rewrite the PDE as a dot product of the form
\begin{equation}
  \left\langle a(x, y), b(x, y), f(x, y, u) \right\rangle \cdot \mathbf{n} = 0.
\end{equation}

This implies that since the dot product is zero, the vector $\left\langle a(x,
y), b(x, y), f(x, y, u) \right\rangle$ must be normal to $\mathbf{n}$. Since we
stated that the vector $\mathbf{n}$ is normal to the surface $F(x, y, u) = 0$,
any vector $\mathbf{v}$ normal to $\mathbf{n}$ must lie in the tangential plane
to $F = 0$ at every point as depicted in \fref[fig_tangential_vector]
\begin{figure}[h!]
	\centering \includegraphics[scale=.75]{fig/fig3_method_characteristics.png}
	\caption{\captionStroke{Schematic integral surface with normal vector
  $\mathbf{n}$ and tangential vector $\mathbf{v}$.}}
	\label{fig_tangential_vector}
\end{figure}

But what do all these details mean? This means that the PDE requires for any
integral surface that solves the equation to be tangential to the vector
\begin{equation}
  \mathbf{v} = a(x,y) \mathbf{i} +
  b(x, y) \mathbf{j} +
  f(x, y, u) \mathbf{k}.
\end{equation}
That is, if we start at some point set by the initial condition and we move in
the direction of the vector $\mathbf{v}$ (which we can determine just by looking
at the PDE) then we move along a curve that lies entirely within the surface
$F = 0$. This curve, depicted in \fref[fig_characteristic_curve] is called a
\textit{characteristic curve}. And by finding the collection of these
characteristic curves we can therefore reconstruct the entire integral surface,
solving therefore the PDE.
\begin{figure}[h!]
	\centering \includegraphics[scale=.75]{fig/fig4_method_characteristics.png}
	\caption{\captionStroke{Schematic of a characteristic curve on an integral
  surface.}}
	\label{fig_characteristic_curve}
\end{figure}

In other words, so far we have shown that given an initial condition
$u(x, 0) = u_0(x)$ as long as we move along the direction given by the vector
$\mathbf{v} = \left\langle a(x,y), b(x,y), f(x,y,u) \right\rangle$ we are
guaranteed to lay on the integral surface. So the process to reconstruct the
entire surface would be to choose a value for $x$, then start at $u_0(x)$ and
move along $\mathbf{v}$; then we would choose a new value of $x$ and repeat the
process. At the end, the union of all these paths along the integral surface
will determine entirely the solution of the PDE. The advantage of the method as
we will show is that walking along the characteristic curve is equivalent to
solving an ODE, which for many cases we know how to do.

We can describe all the points on a characteristic curve by parametrizing
the curve with a vector function
\begin{equation}
  \mathbf{p}(t) = x(t) \mathbf{i} + y(t) \mathbf{j} + u(t) \mathbf{k}.
\end{equation}
Furthermore, we can obtain a vector tangential to this curve $\mathbf{p}(t)$ by
differentiating with respect to the parametrization variable $t$, i.e.
\begin{equation}
  \mathbf{p}'(t) = x'(t) \mathbf{i}+ y'(t) \mathbf{j} + u'(t) \mathbf{k}.
\end{equation}

Since the curve $\mathbf{p}(t)$ lays on the integral surface $F = 0$, and
$\mathbf{p}'(t)$ is tangential to this curve, that means that $\mathbf{p}'(t)$
also lies on the surface.

We stated earlier that if we move along the direction of $\mathbf{v}$ we will
reconstruct the path of the characteristic curve which we now parametrized as
$\mathbf{p}(t)$. That implies that $\mathbf{v}$ and $\mathbf{p}'(t)$ must be
pointing in the same direction, i.e.
\begin{equation}
  \mathbf{p}'(t) = \lambda \mathbf{v},
\end{equation}
where $\lambda$ is a scalar. This can also be written as
\begin{equation}
  x'(t)\mathbf{i} + y'(t)\mathbf{j} + u'(t)\mathbf{k} =
  \lambda a(x,y) + \lambda b(x,y) + \lambda f(x,y,u).
\end{equation}
in other words
\begin{align}
  x'(t) = \lambda a(x,y),\\
  y'(t) = \lambda b(x,y), \\
  u'(t) = \lambda f(x,y,u).
\end{align}
We can now solve for $\lambda$ and equate all of the solutions, obtaining
\begin{equation}
  {{dx \over dt} \over a(x,y)} =
  {{dy \over dt} \over b(x,y)} =
  {{du \over dt} \over f(x,y,u)},
  \label{eq_char_eq}
\end{equation}
or simply in a compact differential form
\begin{equation}
  {dx \over a} = {dy \over b} = {du \over f}.
\end{equation}
These are the characteristic equations that are the key to the method. From
\eref[eq_char_eq] we can form two pairs of ODE as follows
\begin{equation}
  {dy \over dx} = {b(x,y) \over a(x,y)}; \;
  {du \over dx} = {f(x,y,u)\over a(x,y)},
\end{equation}
or
\begin{equation}
  {dx \over dy} = {a(x,y) \over b(x,y)}; \;
  {du \over dy} = {f(x,y,u)\over b(x,y)}.
\end{equation}
Solving this system of ODEs determines the characteristic of the PDE, giving
a clear path to the PDE solution.

\subsection{Example}

Solve for $x > 0$
\begin{equation}
  x {\partial u \over \partial x} + y {\partial u \over \partial y} = x e^{-u},
\end{equation}
with boundary condition
\begin{equation}
  u(x, x^2) = x.
  \label{eq_boundary_cond}
\end{equation}

First we set the system of ODEs for this semilinear problem. We have
\begin{equation}
  {dx \over a} = {dy \over b} = {du \over f}.
\end{equation}
substituting $f \equiv x e^{-u}$ we have
\begin{equation}
  {dx \over a} = {dy \over b} = {du \over x e^{-u}}.
\end{equation}

We now write the pair of ODEs
\begin{equation}
  {dy \over dx} = {y \over x},
  \label{eq_char_eq_one}
\end{equation}
and
\begin{equation}
  {dy \over dx} = e^{-u} {x \over x}.
  \label{eq_char_eq_two}
\end{equation}

\eref[eq_char_eq_one] can be solved using the integrating factor method. The
solution is given by
\begin{equation}
  y = C_1 \exp \left\{ \int {1 \over x} dx \right\} = C_1 e^{\ln x} = C_1 x,
\end{equation}
thus $C_1 = y / x$. \eref[eq_char_eq_two] can be simply solved by separation of
variables giving
\begin{equation}
  e^u = C_2 + x \rightarrow C_2 = e^u - x.
\end{equation}

We now need to find a functional relationship between these constants $C_1$ and
$C_2$. That is because usually after solving the \eref[eq_char_eq_one] we would
have to substitute the solution into \eref[eq_char_eq_two]. So let's combine
both constants via $C_2 = G(C_1)$, i.e.
\begin{equation}
  e^u - x = G\left( {y \over x} \right).
\end{equation}
Now to find $G$ we use the boundary condition on \eref[eq_boundary_cond]. This
gives
\begin{equation}
  e^x = x + G \left( {x^2 \over x} \right) = x = G(x).
\end{equation}
Therefore
\begin{equation}
  G(x) = e^x - x.
  \label{eq_sol_ODE}
\end{equation}

Hence we substitute \eref[eq_sol_ODE] into the solution, obtaining
\begin{equation}
  e^u = x + e^{y/x} - {y \over x}.
\end{equation}

The reason $C_1$ and $C_2$ have to be functionally related is because we are
solving the ODEs along the characteristic curves. Therefore to get to the value
of $u$ we need to solve along every characteristic curve, and each time we solve
it we obtain an undetermined constant $C_2$. This constant $C_2$ can vary
between characteristics, but it must be the same along a particular
characteristic. The particular characteristic curve that we are considering is
determined by the constant $C_1$. Hence, there must be a functional relation
between $C_1$ and $C_2$.


\section{Brief Derivation for equation (\ref{Equ_ori})}
\par\noindent

For convenience, here name $\angle CAB $ as $\alpha$ in figure \ref{vectorG}. Then it has
$$|AD| = |\vec{r^{'}}| \cos(\alpha - \theta)$$
$$|B^{'}D| = |\vec{r^{'}}| \sin(\alpha - \theta)$$

By applying angle sum identities,
$$|AD| = |\vec{r^{'}}| (\cos(\alpha)\cos(-\theta) - \sin(\alpha)\sin(-\theta))$$
$$|B^{'}D| = |\vec{r^{'}}| (\sin(\alpha)\cos(-\theta) + \sin(-\theta)\cos(\alpha))$$

Because $|r^{'}| = |r|$, $\sin(\theta) = - \sin(-\theta)$ for $\theta \in [0, \pi/2)$ and $\cos(\theta) = \cos(-\theta)$ for $\theta \in [0, \pi/2)$,
$$|AD| = |\vec{r}| (\cos(\alpha)\cos(\theta) + \sin(\alpha)\sin(\theta))$$
$$|B^{'}D| = |\vec{r}| (\sin(\alpha)\cos(\theta) - \sin(\theta)\cos(\alpha))$$

Then,
$$|AD| = (|\vec{r}|\cos(\alpha))\cos(\theta) + (|\vec{r}|\sin(\alpha))\sin(\theta)$$
$$|B^{'}D| = (|\vec{r}|\sin(\alpha))\cos(\theta) - (|\vec{r}|\cos(\alpha))\sin(\theta)$$

Hence,
$$|AD| = |AC|\cos(\theta) + |BC|\sin(\theta)$$
$$|B^{'}D| = |BC|\cos(\theta) - |AC|\sin(\theta)$$

Finally,
$$|x^{'}| = |x|\cos(\theta) + |y|\sin(\theta)$$
$$|y^{'}| = |x|(- \sin(\theta)) + |y|\cos(\theta)$$

For $\theta \in [0, \pi/2)$, the equations can be written simply as
$$ x^{'} = x\cos\theta + y\sin\theta$$
$$ y^{'} = x(- \sin\theta) + y\cos\theta$$

which can be easily extended to $\theta \in [ 0, 2\pi + 2k\pi)$ via discussion under different cases, given that $k \in Integer$.\\

The two equations can be written in matrix form :
\begin{equation*}
  \begin{bmatrix}
   x^{'} \\ y^{'}
   \end{bmatrix} =   \begin{bmatrix}
      \cos\theta & \sin\theta \\
      -\sin\theta & \cos\theta
    \end{bmatrix} \begin{bmatrix}
      x \\ y
     \end{bmatrix}
\end{equation*}
\section{Brief Derivation for equation (\ref{Equ_aff})}
\par\noindent
The equation \ref{Equ_anycen} can be transformed to:
\begin{equation*}
  \begin{split}
  \begin{bmatrix}
   x^{'} \\ y^{'}
   \end{bmatrix} &= \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} \left(\begin{bmatrix} x \\ y \end{bmatrix} - \begin{bmatrix} c_{x} \\ c_{y} \end{bmatrix}\right) + \begin{bmatrix} c_{x} \\ c_{y} \end{bmatrix} \\
                 &= \begin{bmatrix}
          \cos\theta & \sin\theta \\
          -\sin\theta & \cos\theta
        \end{bmatrix}
        \begin{bmatrix}
          x \\ y
         \end{bmatrix} - \begin{bmatrix}
            \cos\theta & \sin\theta \\
            -\sin\theta & \cos\theta
          \end{bmatrix}\begin{bmatrix}
            c_{x} \\ c_{y}
          \end{bmatrix} + \begin{bmatrix}
            c_{x} \\ c_{y}
          \end{bmatrix} \\
          &= \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
          - \begin{bmatrix} c_{x}\cos\theta + c_{y}\sin\theta \\ -c_{x}\sin\theta + c_{y}\cos\theta \end{bmatrix} +
           \begin{bmatrix} c_{x} \\ c_{y} \end{bmatrix} \\
          &= \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
          + \begin{bmatrix} c_{x}(1 - \cos\theta) - c_{y}\sin\theta \\ c_{y}(1 - \cos\theta) + c_{x}\sin\theta \end{bmatrix}
\end{split}
\end{equation*}

\section{List of Implemented Protocol}
\begin{itemize}
  \item Population Protocol
        \begin{itemize}
          \item Dancing Protocol
          \item Sum modulo 4
        \end{itemize}
  \item Network Constructor
        \begin{itemize}
          \item Cycle Cover
          \item Global Star
          \item Simple Global Line (5 states)
        \end{itemize}
  \item Terminating Grid Network Constructor
        \begin{itemize}
          \item Square Grid Network
        \end{itemize}
\end{itemize}
\section{Open source libraries used in the simulator}
Credits to:
\begin{itemize}
  \item Koma, A scientific computing library, under Apache 2.0, http://koma.kyonifer.com/
  \item TornadoFX, JavaFX Framework for Kotlin, under Apache 2.0, https://github.com/edvin/tornadofx
  \item GraphStream, A Dynamic Graph Library, under LGPLv3, http://graphstream-project.org/
  \item JUnit, A Unit test framework, under Eclipse Public License 1.0, https://junit.org/junit4/
\end{itemize}
Additionally, credit to NETCS, A Java implementation for non-grid dynamic network, under 3-Clause BSD, https://github.com/amaxilat/netcs,
this is not used in the simulator but give an some inspiration to author of the simulator.


% -*- root: Main.tex -*-
\section{Essentials}
\subsection*{Matrix/Vector}
\begin{compactdesc}
	\item $A\cdot B = C \Leftrightarrow c_{ik}=\sum_{j=1}^{m} a_{ij} \cdot b_{jk}, c=\sum_{i} a_i b_i^\top$
	\item $A^\top\cdot B = C \Leftrightarrow c_{ik}=a_i^\top \cdot b_k$
	\item $z=Ax\Leftrightarrow z_i=\sum_k a_{ik} x_k$
	\item $z^\top = y^\top A \Leftrightarrow z_i = \sum_k a_{ki} y_k$
	\item $A\cdot B=(A B^{(1)}\hspace{1pt} AB^{(2)}\hspace{1pt} \dots)=(A^{[1]}B\hspace{3pt}A^{[2]}B\hspace{3pt}\dots)^\top$
	\item $\mathbf{Ker}(A)=\{x|Ax=0\}$, $\mathbf{Im}(A)=\{y|\exists x.Ax=y\}$
	\item $\mathbf{Rank}(A) := dim(\mathbf{Im}(A))$
	\item $\mathbf{Rank}(A\cdot B) \leq min(\mathbf{Rank}(A), \mathbf{Rank}(B))$
	\item $dim(A)=\mathbf{Rank}(A) + dim(\mathbf{Ker}(A))$
	\item[Tr:] $\mathbf{Tr}(A) := \sum_i a_{ii}$, $\mathbf{Tr}(rA+sB)=r\mathbf{Tr}(A)+s\mathbf{Tr}(B)$, $\mathbf{Tr}(ABC)=\mathbf{Tr}(CAB)=\mathbf{Tr}(BCA)$
	\item[Vec(A):] Column by col. forming a new vector
	\item[det(A)=0:] $\exists$ linear dependent cols/rows
	\item[det(A)!=0:] $A$ regular, $Ax=b$ has 1 sol., $\exists A^{-1}$, $im(A)=\mathbb{M}^n, ker(A)=0$, 0 is not EW of $A$
	\item[Orthogonal:] cols. orthonormal, $\mathbf{A}^{-1} = \mathbf{A}^\top$, $\mathbf{A} \mathbf{A}^\top = \mathbf{A}^\top \mathbf{A} = \mathbf{I}$, $\operatorname{det}(\mathbf{A}) \in \{+1, -1\}$, $\operatorname{det}(\mathbf{A}^\top \mathbf{A}) = 1$, $(t\cdot A)^{-1}=1/t\cdot A^{-1}$, $A, B: orth \implies A\cdot B: orth$, Preserves norm ($||Ax||=x$), inner prod., dist., angle, EWs are on unit circle, EVs are unitary
	\item[Positive semi-definite:] $\forall x, x^\top A x \geq 0$, $Tr(A)\geq 0$, $A^{-1}$ psd., $\exists B . A=BB^\top$ with $\mathbf{Rank}(A)=\mathbf{Rank}(B)$, $x^\top A x = 0 \Rightarrow A x = 0$ $X\in \mathbb{R}^{n,r}, n\leq r, rank(X)=n \Rightarrow XX^\top$ psd.
	\item[Idempot.:] $A^2 = A$, $I-A$ idp. and $A(I-A)=0$, $rank(A)=tr(A)$, $CD$ idp. $\Rightarrow$ $CD=DC$, $f(sI+tA)=(I-A)f(s)+A f(s+t)$
	\item[Pseudo-Inverse:] $A\cdot A^+\cdot A = A$
	\item[Inner Product:] $\langle \mathbf{x}, \mathbf{y} \rangle = \mathbf{x}^\top \mathbf{y} = \sum_{i=1}^{N} \mathbf{x}_i \mathbf{y}_i$.
	\begin{inparaitem}
		\item $\langle \mathbf{x} \pm \mathbf{y}, \mathbf{x} \pm \mathbf{y} \rangle = \langle \mathbf{x}, \mathbf{x} \rangle \pm 2 \langle \mathbf{x}, \mathbf{y} \rangle + \langle \mathbf{y}, \mathbf{y} \rangle$
		\item $\langle \mathbf{x}, \mathbf{y} + \mathbf{z} \rangle = \langle \mathbf{x}, \mathbf{y} \rangle + \langle \mathbf{x}, \mathbf{z} \rangle$
		\item $\langle \mathbf{x} + \mathbf{y}, \mathbf{z} \rangle = \langle \mathbf{x}, \mathbf{z} \rangle + \langle \mathbf{y}, \mathbf{z} \rangle$
		\item $\langle \mathbf{x}, \mathbf{y} \rangle = \|\mathbf{x}\|_2 \cdot \|\mathbf{y}\|_2 \cdot \cos(\theta)$
		\item If $\mathbf{y}$ is a unit vector then $\langle \mathbf{x}, \mathbf{y} \rangle$ projects $\mathbf{x}$ onto $\mathbf{y}$
	\end{inparaitem}
	\item[Outer Product:] $\mathbf{u} \mathbf{v}^\top$, $(\mathbf{u} \mathbf{v}^\top)_{i, j} = \mathbf{u}_i \mathbf{v}_j$
	\item[Transp. + Inv.:] $(\mathbf{A}^\top)^{-1} = (\mathbf{A}^{-1})^\top$
	\item[Orth. proj.:] $P_y(x)=y y^\top x / ||y||^2_2 = <x,y>y$
	\item[Proj. to orth. compl.:] $v-<u,v>u$
	\item[Householder-Refl.:] $H_u=I-2uu^\top$ sym.+orth.
	\item[Jacobian:] $D f(x)=(\frac{\partial f_i(x)}{\partial x_j})_{i=1..m, j=1..n} \in \mathbb{R}^{m\cdot n}$
\end{compactdesc}

\subsection*{Norms}
$\|\mathbf{x}\|_0 = |\{i | x_i \neq 0\}|$ \qquad $\|\mathbf{x}\|_2 = \sqrt{\sum_{i=1}^{N} \mathbf{x}_i^2} = \sqrt{\langle \mathbf{x}, \mathbf{x} \rangle}$\\
$\|\mathbf{x}\|_p = \left( \sum_{i=1}^{N} |x_i|^p \right)^{\frac{1}{p}}$\\
$\|\mathbf{M}\|_F =\allowbreak \sqrt{\sum_{i=1}^{m} \sum_{j=1}^{n}\mathbf{m}_{i,j}^2} =\allowbreak \sqrt{\sum_{i=1}^{\min\{m, n\}} \sigma_i^2} = \sqrt{trace(A^\top A)}$\\
$\|\mathbf{M}\|_1 = \sum_{i,j} | m_{i,j}|$ \qquad $\|\mathbf{M}\|_2 = \sigma_{\text{max}}(\mathbf{M})$\\
$\|\mathbf{M}\|_p = \max_{\mathbf{v} \neq 0} \frac{\|\mathbf{M}\mathbf{v}\|_p}{\|\mathbf{v}\|_p}$ \qquad $\|\mathbf{M}\|_\star = \sum_{i=1}^{\min(m, n)} \sigma_i$ \qquad $\|\mathbf{M}\|_G = \sqrt{\sum_{i,j} \mathbf{g}_{ij} \mathbf{m}_{ij}^2}$

\subsection*{Sums}
$\sum_{n=a}^b f(n) = \sum_{n=0}^b f(n) - \sum_{n=0}^{n-1} f(n)$\\
$\sum_{n=s}^{t} f(n)=\sum_{n=s+p}^{t+p}f(n-p)$\\
$\sum_{n\in B} f(n) = \sum_{m\in A} f(\sigma (m))$ for $\sigma : A\rightarrow B$ bij.\\
$\sum_{k\leq j \leq i \leq n}a_{ij} = \sum_{i=k}^n \sum_{j=k}^i a_{ij} = \sum_{j=0}^{n-k}\sum_{i=k}^{n-j} a_{i+j, i}$\\
$\sum_{i=s}^m \sum_{j=t}^n a_i c_j = (\sum_{i=s}^m a_i)(\sum_{j=t}^n c_j)$\\
$\sum_{i=1}^n i = n(n+1)/2$ \qquad $\sum_{i=1}^n 2i-1 = n^2$\\
$\sum_{i=0}^n log(i) = log(n!)$\qquad $\sum_{i=0}^{n-1} a^i=\frac{1-a^n}{1-a}$

\subsection*{Derivatives}
$\frac{\partial}{\partial \mathbf{x}}(\mathbf{b}^\top \mathbf{x}) = \frac{\partial}{\partial \mathbf{x}}(\mathbf{x}^\top \mathbf{b}) = \mathbf{b}$ \quad
$\frac{\partial}{\partial \mathbf{x}}(\mathbf{x}^\top \mathbf{x}) = 2\mathbf{x}$\\
$\frac{\partial}{\partial \mathbf{x}}(f(\mathbf{x})^\top\cdot g(\mathbf{x})) = f(\mathbf{x})^\top \frac{\partial g(\mathbf{x})}{\partial \mathbf{x}} + g(\mathbf{x})^\top \frac{\partial f(\mathbf{x})}{\partial \mathbf{x}}$\\
$\frac{\partial}{\partial \mathbf{x}}(\mathbf{x}^\top \mathbf{A}\mathbf{x}) = (\mathbf{A}^\top + \mathbf{A})\mathbf{x}$ \quad
$\frac{\partial}{\partial \mathbf{x}}(\mathbf{b}^\top \mathbf{A}\mathbf{x}) = \mathbf{A}^\top \mathbf{b}$\\
$\frac{\partial}{\partial \mathbf{X}}(\mathbf{c}^\top \mathbf{X} \mathbf{b}) = \mathbf{c}\mathbf{b}^\top$ \quad
$\frac{\partial}{\partial \mathbf{X}}(\mathbf{c}^\top \mathbf{X}^\top \mathbf{b}) = \mathbf{b}\mathbf{c}^\top$\\
$\frac{\partial}{\partial \mathbf{x}}(\| \mathbf{x}-\mathbf{b} \|_2) = \frac{\mathbf{x}-\mathbf{b}}{\|\mathbf{x}-\mathbf{b}\|_2}$ \quad
$\frac{\partial}{\partial \mathbf{x}}(\|\mathbf{x}\|^2_2) = \frac{\partial}{\partial \mathbf{x}} (\mathbf{x}^\top \mathbf{x}) = 2\mathbf{x}$\\
$\frac{\partial}{\partial \mathbf{X}}(\|\mathbf{X}\|_F^2) = 2\mathbf{X}$\quad
$\frac{\partial}{\partial \mathbf{X}} \mathbf{Tr}(\mathbf{X})=\mathbf{I}$ \\
$\frac{\partial}{\partial \mathbf{x}}(\|\mathbf{Ax - b}\|_2^2) = \mathbf{2(A^\top Ax-A^\top b)}$

\subsection*{Eigenvalue / -vectors}
Eigenvalue Problem: $\mathbf{Ax} = \lambda \mathbf{x}$\\
1. solve $\operatorname{det}(\mathbf{A} - \lambda \mathbf{I}) \overset{!}{=} 0$ resulting in $diag(\lambda_i)$\\
2. $\forall \lambda_i$:
solve $(\mathbf{A} - \lambda_i \mathbf{I}) \mathbf{x}_i = \mathbf{0}$, for $\mathbf{x}_i$.

\subsection*{Eigendecomposition}
$\mathbf{A} \in \mathbb{R}^{N \times N}$ then $\mathbf{A} = \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q}^{-1}$ with $\mathbf{Q} \in \mathbb{R}^{N \times N}$.\\
if fullrank: $\mathbf{A}^{-1} = \mathbf{Q} \boldsymbol{\Lambda}^{-1} \mathbf{Q}^{-1}$ and $(\boldsymbol{\Lambda}^{-1})_{i,i} = \frac{1}{\lambda_i}$.\\
if $\mathbf{A}$ symmetric: $A = \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q^\top}$ ($\mathbf{Q}$ orthogonal).

\subsection*{Probability / Statistics}
\begin{inparaitem}
	\item $P(x) := Pr[X = x] := \sum_{y \in Y} P(x, y)$
	\item $P(x|y) := Pr[X = x | Y = y] := \frac{P(x,y)}{P(y)},\quad \text{if } P(y) > 0$
	\item $\forall y \in Y: \sum_{x \in X} P(x|y) = 1$ (for any fixed $y$)
	\item Bayes: $P(x|y) = \frac{P(y|x)P(x)}{P(y)}$
	\item ($x_i$ partition) $\Rightarrow P(y) = \sum_{i=1}^n P(y|x_i)\cdot P(x_i)$
	\item $P(x|y) = P(x) \Leftrightarrow P(y|x) = P(y)$ (iff $X$, $Y$ ind.)
	\item $P(x_1, \ldots, x_n) = \prod_{i=1}^n P(x_i)$ (iff IID)
	\item $P(x \cup y)=P(x)+P(y)-P(x,y)$ (mut. excl: rm last term)
	\item $P(x)=\sum_i P(x,y_i)$
\end{inparaitem}