\chapter{Geometry}
Geometry (from the Ancient Greek: geo- "earth", -metron "measurement") is a branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space.

\section{Plane Geometry}
\subsection{Point, Lines}
Distance between two points $P=(x_1,y_1)$ and $Q=(x_2,y_2)$ in $\mathbb{R}^2$ :
\[ \overline{PQ} = \sqrt{(x_1-x_2)^2+(y_1-y_2)^2} \]

Midpoint between P and Q:
\[ \left(\frac{x_1+x_2}{2},\frac{y_1+y_2}{2}\right) \]

Lines equation given one point P:
\[ y-y_1 = m(x-x_1) \]

Line equation given two points P and Q:
\[ y-y_1 = \frac{y_2-y_1}{x_2-x_1}(x-x_1) \]

Distance of one point P from the line r with equation $ax+by+c=0$ :
\[ d(U,r) = \frac{\left|ax_1+by_1+c\right|}{\sqrt{a^2+b^2}} \]

\section{Trigonometry}
\textbf{Definition:} Trigonometry (from Greek trigonon, "triangle" and metron, "measure") is a branch of mathematics that studies relationships involving lengths and angles of triangles.

\subsection{Goniometric functions}
\textbf{Definition:} In mathematics, the goniometric functions (also called circular functions, angle functions or trigonometric functions) are functions of an angle. They relate the angles of a triangle to the lengths of its sides.

For the goniometric ratios for a point $p$ on the unit circle holds:
\begin{table}[ht!]
\centering
\begin{tabular}{ c | c | c }
$ \displaystyle \sin(\phi)=y_p $   &
$ \displaystyle \cos(\phi)=x_p $   &
$ \displaystyle \tan(\phi)=\frac{\sin(\phi)}{\cos(\phi)} $
\end{tabular}
\end{table}

The reciprocal functions secant (sec), cosecant (csc), and cotangent (cot) are the reciprocals of the cosine, sine, and tangent:

\begin{table}[ht!]
	\centering
	\begin{tabular}{ c | c | c }
	$ \displaystyle \sec(\phi)=\frac{1}{\sin{\phi}} $  &
	$ \displaystyle \csc(\phi)=\frac{1}{\cos{\phi}} $  &
	$ \displaystyle \cot(\phi)=\frac{1}{\tan(\phi)}=\frac{\cos(\phi)}{\sin(\phi)} $
	\end{tabular}
\end{table}

\subsubsection{Inverse goniometric functions}
\begin{tabular}{  | c || c | c | c | c | c | c | }
	\hline
	Function   &  $\sin$  &  $\cos$  &  $\tan$  &  $\sec$ &  $\csc$ &  $\cot$ \\
	\hline
	Inverse   &  $\arcsin$  &  $\arccos$  &  $\arctan$  &  arcsec  &  arccsc  &  arccot \\
	\hline
\end{tabular}

\subsubsection{Pythagorean trigonometric identity}
\[
\sin^2(\phi)+\cos^2(\phi)=1
\]

\subsubsection{Identities in terms of their complements and supplements}
\[
\sin\left(\frac{\pi}{2}-\phi\right)=\cos(\phi) \ \ , \ \ \cos\left(\frac{\pi}{2}-\phi\right)=\sin(\phi)
\]
\[
\sin\left(\frac{\pi}{2}+\phi\right)=\cos(\phi) \ \ , \ \ \cos\left(\frac{\pi}{2}+\phi\right)=-\sin(\phi)
\]

\[
\sin(\pi-\phi)=\sin(\phi) \ \ , \ \ \cos(\pi-\phi)=-\cos(\phi)
\]
\[
\sin(\pi+\phi)=-\sin(\phi) \ \ , \ \ \cos(\pi+\phi)=-\cos(\phi)
\]

\[
\sin\left(\frac{3}{2}\pi-\phi\right)=-\cos(\phi) \ \ , \ \ \cos\left(\frac{3}{2}\pi-\phi\right)=-\sin(\phi)
\]
\[
\sin\left(\frac{3}{2}\pi+\phi\right)=-\cos(\phi) \ \ , \ \ \cos\left(\frac{3}{2}\pi+\phi\right)=\sin(\phi)
\]

\subsubsection{Identities for negative angles}
\[
\sin(-\phi) = -\sin(\phi) \ , \ \cos(-\phi) = \cos(\phi)
\]

\subsubsection{Periodicity of trig functions}
\[
\sin(\phi+2\pi)=\sin(\phi) \ , \ \cos(\phi+2\pi)=\cos(\phi) \ , \ \tan(\phi+\pi)=\tan(\phi)
\]

\subsubsection{Ptolemy's identities}
\[
\sin(a+b)=\sin(a)\cos(b)+\cos(a)\sin(b)
\]
\[
\cos(a+b)=\cos(a)\cos(b)-\sin(a)\sin(b)
\]
\[
\sin(a-b)=\sin(a)\cos(b)-\cos(a)\sin(b)
\]
\[
\cos(a-b)=\cos(a)\cos(b)+\sin(a)\sin(b)
\]

\[
\tan(\alpha+\beta)=\frac{\tan(\alpha) + \tan(\beta)}{1-\tan(\alpha)\tan(\beta)} \text{ where } \alpha, \beta, \alpha+\beta \ne \frac{\pi}{2} + k\pi, \ k \in \mathbb{Z}
\]
\[
\tan(\alpha-\beta)=\frac{\tan(\alpha) - \tan(\beta)}{1+\tan(\alpha)\tan(\beta)} \text{ where } \alpha, \beta, \alpha-\beta \ne \frac{\pi}{2} + k\pi, \ k \in \mathbb{Z}
\]

\subsubsection{Double angle formulas}
\begin{align*}
\sin(2\alpha) &= 2\sin(\alpha)\cos(\alpha) \\
\cos(2\alpha) &=\cos^2(\alpha)-\sin^2(\alpha) = 2\cos^2(\alpha)-1 = 1 - 2\sin^2(\alpha) \\
\tan(2\alpha) &= \frac{2\tan(\alpha)}{1-2\tan^2(\alpha)} \text{ where } \alpha \ne \frac{\pi}{4}+k\frac{\pi}{2} \ \wedge \ \alpha \ne \frac{\pi}{2}+k\pi, \ k \in \mathbb{Z}
\end{align*}

\subsubsection{Half angle formulas}
\begin{tabularx}{\textwidth}{ X X X }
$ \displaystyle \sin^2\left(\frac{\alpha}{2}\right) = \frac{1-\cos(\alpha)}{2} $ &
$ \displaystyle \cos^2\left(\frac{\alpha}{2}\right) = \frac{1+\cos(\alpha)}{2} $ &
$  \displaystyle \tan\left(\frac{\alpha}{2}\right) = \frac{\sin(\alpha)}{1+\cos(\alpha)} $
\end{tabularx}

\subsubsection{Product-to-sum identities}
\[
2\sin(\alpha)\sin(\beta) = \cos(\alpha-\beta) - \cos(\alpha+\beta)
\]
\[
2\cos(\alpha)\cos(\beta) = \cos(\alpha-\beta) + \cos(\alpha+\beta)
\]
\[
2\sin(\alpha)\cos(\beta) = \sin(\alpha-\beta) + \sin(\alpha+\beta)
\]

\subsubsection{Sum-to-product identities}
\[
\sin(\alpha)+\sin(\beta) = 2\sin\left(\frac{\alpha+\beta}{2}\right)\cos\left(\frac{\alpha-\beta}{2}\right)
\]
\[
\sin(\alpha)-\sin(\beta) = 2\cos\left(\frac{\alpha+\beta}{2}\right)\sin\left(\frac{\alpha-\beta}{2}\right)
\]
\[
\cos(\alpha)+\cos(\beta) = 2\cos\left(\frac{\alpha+\beta}{2}\right)\cos\left(\frac{\alpha-\beta}{2}\right)
\]
\[
\cos(\alpha)-\cos(\beta) = -2\sin\left(\frac{\alpha+\beta}{2}\right)\sin\left(\frac{\alpha-\beta}{2}\right)
\]

\subsubsection{Tangent half-angle substitution}
$ \displaystyle \sin(\alpha) = \frac{2t}{1+t^2} \text{ where } t=\tan\left(\frac{\alpha}{2}\right) \text{ and } \alpha \ne \pi + 2k\pi $

$ \displaystyle \cos(\alpha) = \frac{1-t^2}{1+t^2} \text{ where } t=\tan\left(\frac{\alpha}{2}\right) \text{ and } \alpha \ne \pi + 2k\pi $

$ \displaystyle \tan(\alpha) = \frac{2t}{1-t^2} \text{ where } t=\tan\left(\frac{\alpha}{2}\right) \text{ and } \alpha \ne \frac{\pi}{2} + k\pi \ \wedge \ \alpha \ne \pi + 2k\pi $

\subsection{Conversions of common angles}

\begin{tabular}{  | c | c || c | c | c | c | }
	\hline
	Degrees          & Radians              & Sin                               & Cos                                               & Tan                                    & Cot               \\
	\hline
    $0^{\circ}$      & 0                    & 0                                 &  1                                                & 0                                      & $\pm\infty$        \\
    \hline
    $15^{\circ}$     & $\frac{\pi}{12}$     & $\frac{\sqrt{6}-\sqrt{2}}{4}$       &  $\frac{\sqrt{6}+\sqrt{2}}{4}$                      & $2-\sqrt{3}$                            & $2+\sqrt{3}$       \\
    \hline
    $30^{\circ}$     & $\frac{\pi}{6}$     & $\frac{1}{2}$      &   $\frac{\sqrt{3}}{2} $     &  $\frac{\sqrt{3}}{3}$    &  $\sqrt{3}$  \\
    \hline
    $45^{\circ}$     & $\frac{\pi}{4}$     & $\frac{\sqrt{2}}{2}$   &   $\frac{\sqrt{2}}{2}$    &  1    &  1  \\
    \hline
    $60^{\circ}$     & $\frac{\pi}{3}$     & $\frac{\sqrt{3}}{2}$   &   $\frac{1}{2}$    &  $\sqrt{3}$    &  $\frac{\sqrt{3}}{3}$  \\
    \hline
    $75^{\circ}$     & $\frac{5}{12}\pi$     & $\frac{\sqrt{6}+\sqrt{2}}{4}$   &   $\frac{\sqrt{6}-\sqrt{2}}{4}$    &  $2+\sqrt{3}$    &  $2-\sqrt{3}$  \\
    \hline
    $90^{\circ}$     & $\frac{\pi}{2}$     & 1   &   0    &  $\pm\infty$   &  0  \\
    \hline
   	$105^{\circ}$     & $\frac{7}{12}\pi$     & $\frac{\sqrt{6}+\sqrt{2}}{4}$   &   $\frac{\sqrt{2}-\sqrt{6}}{4}$    &  $-2-\sqrt{3}$    &  $\sqrt{3}-2$  \\
    \hline
    $120^{\circ}$     & $\frac{2}{3}\pi$     & $\frac{\sqrt{3}}{2}$      &   $-\frac{1}{2} $     &  $-\sqrt{3}$    &  $-\frac{\sqrt{3}}{3}$  \\
    \hline
  	$135^{\circ}$     & $\frac{3}{4}\pi$     & $\frac{\sqrt{2}}{2}$   &   $-\frac{\sqrt{2}}{2}$    &  -1    &  -1  \\
  	\hline
  	$150^{\circ}$     & $\frac{5}{6}\pi$     & $\frac{1}{2}$      &   $-\frac{\sqrt{3}}{2}$     &  $-\frac{\sqrt{3}}{3}$    &  $-\sqrt{3}$  \\
  	\hline
    $165^{\circ}$     & $\frac{11}{12}\pi$   & $\frac{\sqrt{6}-\sqrt{2}}{4}$       &  -$\frac{\sqrt{6}+\sqrt{2}}{4}$     & $\sqrt{3}-2$   & $-\sqrt{3}-2$       \\
    \hline
    $180^{\circ}$     & $\pi$     & 0   &   -1   &  0    &  $\pm\infty$  \\
    \hline
	$195^{\circ}$     & $\frac{13}{12}\pi$   & $\frac{\sqrt{2}-\sqrt{6}}{4}$       &  -$\frac{\sqrt{6}+\sqrt{2}}{4}$     & $2-\sqrt{3}$   & $2+\sqrt{3}$       \\
	\hline
	$210^{\circ}$     & $\frac{7}{6}\pi$     & $-\frac{1}{2}$      &   $-\frac{\sqrt{3}}{2}$     &  $\frac{\sqrt{3}}{3}$    &  $\sqrt{3}$  \\
	\hline
  	$225^{\circ}$     & $\frac{5}{4}\pi$     & $-\frac{\sqrt{2}}{2}$      &   $-\frac{\sqrt{2}}{2}$     &  1    &  1  \\
  	\hline
  	$240^{\circ}$     & $\frac{4}{3}\pi$     & $-\frac{\sqrt{3}}{2}$      &   $-\frac{1}{2}$     &  $\sqrt{3}$    &  $\frac{\sqrt{3}}{3}$  \\
  	\hline
     $255^{\circ}$     & $\frac{17}{12}\pi$   & $-\frac{\sqrt{6}+\sqrt{2}}{4}$       &  $\frac{\sqrt{2}-\sqrt{6}}{4}$     & $2+\sqrt{3}$   & $2-\sqrt{3}$       \\
     \hline
     $270^{\circ}$     & $\frac{3}{2}\pi$     & -1      &   0    &  $\pm\infty$    &  0  \\
     \hline
    $285^{\circ}$     & $\frac{19}{12}\pi$   & $-\frac{\sqrt{6}+\sqrt{2}}{4}$       &  $\frac{\sqrt{6}-\sqrt{2}}{4}$     & $-2-\sqrt{3}$   & $\sqrt{3}-2$       \\
    \hline
    $300^{\circ}$     & $\frac{5}{3}\pi$     & $-\frac{\sqrt{3}}{2}$      &   $\frac{1}{2}$     &  $-\sqrt{3}$    &  $-\frac{\sqrt{3}}{3}$  \\
    \hline
    $315^{\circ}$     & $\frac{7}{4}\pi$     & $-\frac{\sqrt{2}}{2}$      &   $\frac{\sqrt{2}}{2}$     &  -1   &  -1  \\
    \hline
    $330^{\circ}$     & $\frac{11}{6}\pi$     & $-\frac{1}{2}$      &   $\frac{\sqrt{3}}{2}$     &  -$\frac{\sqrt{3}}{3}$   &  $-\sqrt{3}$  \\
    \hline
     $345^{\circ}$     & $\frac{23}{12}\pi$     & $\frac{\sqrt{2}-\sqrt{6}}{4}$       &  $\frac{\sqrt{2}+\sqrt{6}}{4}$    &  $\sqrt{3}-2$    &  $-2-\sqrt{3}$  \\
     \hline
     $360^{\circ}$     & $2\pi$   & 0       &  1     & 0   & $\pm\infty$       \\
     \hline
\end{tabular}

\section{Polar, Cylindrical and Spherical Coordinates}
\subsection{Polar Coordinates}
The polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a reference point and an angle from a reference direction.

The polar coordinates $r$ and $\varphi$ can be converted to the Cartesian coordinates $x$ and $y$ by:
\[
x=r\cos \varphi  ~~~, ~~~ y=r\sin \varphi
\]

The Cartesian coordinates $x$ and $y$ can be converted to polar coordinates $r$ and $\varphi$ with $r \ge 0$ and $\varphi$ in the interval $(-\pi, \pi]$ by:

$ \displaystyle r= \sqrt{ x^2 + y^2 } $

$ \displaystyle \varphi = atan2(y,x) =
\begin{cases}
\arctan(y/x) & \text{ if } x>0 \\
\arctan(y/x) + \pi & \text{ if } x<0 \text{ and } y\ge0\\
\arctan(y/x) - \pi & \text{ if } x<0 \text{ and } y<0\\
\pi/2 & \text{ if } x=0 \text{ and } y>0\\
-\pi/2 & \text{ if } x=0 \text{ and } y<0\\
\text{undefined} & \text{ if } x=0 \text{ and } y=0\\
\end{cases}
$

\subsection{Cylindrical Coordinates}
A cylindrical coordinate system is a three-dimensional coordinate system that specifies point positions by the distance from a chosen reference axis, the direction from the axis relative to a chosen reference direction, and the distance from a chosen reference plane perpendicular to the axis. The latter distance is given as a positive or negative number depending on which side of the reference plane faces the point.

\subsubsection{Convert From and To Cartesian coordinates}
For the conversion between cylindrical and Cartesian coordinates, it is convenient to assume that the reference plane of the former is the Cartesian $xy$-plane (with equation $z = 0$), and the cylindrical axis is the Cartesian $z$-axis. Then the $z$-coordinate is the same in both systems, and the correspondence between cylindrical (radius $\rho$, azimuth $\varphi$, elevation $z$) and Cartesian are the same as for polar coordinates, namely
\[
x=\rho \cos \varphi  ~~~, ~~~ y=\rho \sin \varphi ~~~, ~~~ z=z
\]

\subsection{Spherical Coordinates}
In mathematics, a spherical coordinate system is a coordinate system for three-dimensional space where the position of a point is specified by three numbers: the radial distance of that point from a fixed origin, its polar angle measured from a fixed zenith direction, and the azimuth angle of its orthogonal projection on a reference plane that passes through the origin and is orthogonal to the zenith, measured from a fixed reference direction on that plane.

\subsubsection{Convert From and To Cartesian coordinates}
The spherical coordinates of a point in the ISO convention (i.e. for physics: radius $r$, inclination $\theta$, azimuth $\varphi$) can be obtained from its Cartesian coordinates $(x, y, z)$ by the formulae:
\[
r=\sqrt{x^2+y^2+z^2} ~~,~~ \theta=\arccos\frac{z}{r} ~~,~~ \varphi = \arctan\frac{y}{x}
\]

Conversely, the Cartesian coordinates may be retrieved from the spherical coordinates (where $r \in [0, +\infty), \theta \in [0, \pi], \varphi \in [0, 2\pi)$), by:
\[
x=r\sin\theta\cos\varphi ~~,~~ y=r\sin\theta\sin\varphi ~~,~~ z=r\cos\theta
\]

\subsubsection{Convert From and To Cylindrical coordinates}
Cylindrical coordinates may be converted into spherical coordinates, by the formulas:

\[
r=\sqrt{\rho^2 + z^2} ~~,~~ \theta=\arctan\frac{\rho}{z}=\arccos\frac{z}{r}   ~~,~~ \varphi = \varphi
\]

Conversely, the spherical coordinates may be converted into cylindrical coordinates by the formulae:

\[
\rho = r\sin\theta   ~~,~~  \varphi=\varphi  ~~,~~ z = r\cos\theta
\]


\chapter{Quantum Mechanics: The Basics}

This chapter is a brief review of the fundamental quantum mechanics necessary for our treatment of quantum information theory. In here we discuss the basic mathematical objects and tools we shall deal with in the next chapter.

\section{Representing a Quantum Mechanical State}
\par The quantum mechanical state of a system is represented by a vector $\Ket{\psi}$ in the complex vector space known as the Hilbert space. In this section we see how such a state is constructed.
\par Let us consider a two-level quantum system such as a spin-half particle. Its state can be written in terms of two basis states which represent spin-up and spin-down. We can call these basis states $\Ket{0}$ and $\Ket{1}$ which are two orthogonal and normalized vectors in the Hilbert space.
\begin{align*}
\Ket{0} = \left(\! \begin{array}{c} 1 \\ 0 \end{array} \!\right) \\
\Ket{1} = \left(\! \begin{array}{c} 0 \\ 1 \end{array} \!\right)
\end{align*}
In such case the general state of the particle can be written as
\begin{align*}
\Ket{\psi} = \alpha \Ket{0} + \beta \Ket{1}
\end{align*}
\par When the particle's spin along an axis is measured, it collapses to one of these two states $\Ket{0}$ and $\Ket{1}$ with probabilities $|\alpha|^2$ and $|\beta|^2$ respectively with the condition that
\begin{align*}
|\alpha|^2 + |\beta|^2 = 1
\end{align*}
\par Instead of the basis states chosen above we could have chosen any other other as long as they are orthogonal and normalized so that they represent perfectly distinguishable outcomes in an experiment. One such example would be
\begin{center}
$ \frac{1}{\sqrt{2}} \left(\! \begin{array}{c} 1 \\ 1 \end{array} \!\right) $ and $ \frac{1}{\sqrt{2}} \left(\! \begin{array}{c} -1 \\ 1 \end{array} \!\right) $
\end{center}
The important point is that the chosen basis has to be consistent across our calculations. That is, when we bring physical quantities together in a calculation they have to be represented in the same basis. If they are not then they will need to be rotated into one standard basis. This operation of rotation is called a unitary transformation and represented by a matrix $U$ such that $U U^\dagger = U^\dagger U = I$. Unitary transformations have the property that they do not change the physically observable outcomes. Under a unitary transformation the predictions for all those observables will remain the same.
\par After establishing the general idea let us now look at an example state we may represent in this way.
\begin{align*}
  \Ket{\psi} &= \frac{2}{\sqrt{5}} \Ket{0} + \frac{1}{\sqrt{5}} \Ket{1} \\
  &= \frac{2}{\sqrt{5}} \left(\! \begin{array}{c} 1 \\ 0 \end{array} \!\right) + \frac{1}{\sqrt{5}} \left(\! \begin{array}{c} 0 \\ 1 \end{array} \!\right) \\
  &= \frac{1}{\sqrt{5}} \left(\! \begin{array}{c} 2 \\ 1 \end{array} \!\right)
\end{align*}
\par In this case we see that $\alpha = \frac{2}{\sqrt{5}}$ and $\beta = \frac{1}{\sqrt{5}}$.
\section{Pure States and Mixed States}
In terms of information that we have about the preparation of a quantum mechanical state, we identify it as either a pure state or as a mixed state.
\subsection{Pure State}
\par A pure state is a state for which we have complete knowledge about the preparation procedure. We already know in advance how the state was prepared, which, in principle is all that we can know about the system. The example of $\Ket{\psi}$ in the previous section is that of a pure state. We have a single state $\Ket{\psi}$ with 100\% certainty and the predictions we can make about it can be no more accurate than they are with our current knowledge of it.
\par At this point it will be appropriate to introduce a more general representation of a quantum mechanical state than a simple ket vector. This representation we are going to introduce is called the \textbf{density operator or density matrix}.
\subsection{The Density Operator}
\par The density operator for a state $\Ket{\psi}$ is simply a projection operator that projects all the vectors onto the state vector $\Ket{\psi}$.
\par If $\Ket{\psi}$ is represented by the column vector
\begin{align*}
\Ket{\psi} = \left(\! \begin{array}{c} a \\ b \end{array} \!\right)
\end{align*}
Then the density operator for the state would be
\begin{align*}
  \hat{\rho} = \Ket{\psi} \Bra{\psi} &= \begin{pmatrix} a \\ b \end{pmatrix} \begin{pmatrix} a^* & b^* \end{pmatrix} \\
  &= \begin{pmatrix} |a|^2 & a b^* \\ a^* b & |b|^2 \end{pmatrix}
\end{align*}
\par From this density operator we can determine outcomes of physical experiments. In quantum mechanics physical observable quantities are represented by Hermitian operators. Suppose we apply an observable $\hat{O}$ to the density matrix which is the mathematical equivalent of performing the observation in an experiment. The state will collapse and the outcome of the experiment will have the expectation value of
\begin{align*}
  \braket{\hat{O}} &= tr\{\hat{O} \Ket{\psi} \Bra{\psi}\} \\
  \braket{\hat{O}} &= tr\{\hat{O} \hat{\rho}\}
\end{align*}
Here $tr$ represents the trace operation, which is taking the sum of all entries on the main diagonal of the matrix.

\subsection{Mixed State}
\par In general when we deal with quantum systems in the real world, we will not have complete knowledge on how the state was prepared. This lack of knowledge can be due to several factors. It can be caused by errors in the apparatus that prepares the quantum state or it can be introduced later by environmental factors. In both cases we will not have a pure state with 100\% certainty.
\par Let us take a look at a real world example. Suppose we want to prepare a number of atoms in state $\ket{\psi_0}$. We have an apparatus to do that for us. However due to some random error in the machinery some of the atoms are prepared in state $\ket{\psi_1}$ instead. Let's suppose the state we want, $\ket{\psi_0}$, is prepared with a 95\% accuracy. Then the rest of the atoms we get from the machine - 5\% of them - will be in state $\ket{\psi_1}$. In this case we have a mixed state.
\par Notice that the probabilities involving the states are no longer limited to the quantum domain. There are now classical probabilities involved as well. 0.95 is the classical probability of $\ket{\psi_0}$ occurring in the mix and 0.05 is the classical probability of $\ket{\psi_1}$ occurring.
\par In general, we will have a mixture of more than one states each occurring with its respective classical probability. $\ket{\psi_0}$ with probability $p_0$, $\ket{\psi_1}$ with probability $p_1$, $\ket{\psi_2}$ with probability $p_2$, and so on.

\subsection{Density Operator for Mixed States}
\par For a mixture of a number of quantum states where each state $\ket{\psi_i}$ occurs with classical probability $p_i$, the density operator is written as
\begin{align*}
\hat{\rho} = \sum_i \ket{\psi_i} \bra{\psi_i}
\end{align*}
\par As we saw in the case of pure states, expectation values for experimental outcomes are calculated in a similar fashion. If $\hat{O}$ is the operator representing the observable quantity, then the expectation value for the operator will be given by
\begin{align*}
\braket{\hat{O}} = tr\{\hat{O}\hat{\rho}\}
\end{align*}
\par Similarly, we can calculate the probability of finding the system in a state $\ket{\sigma}$ by constructing the projection operator for that state $\ket{\sigma} \bra{\sigma}$ and applying it to the density operator $\hat{\rho}$ representing our system.
\begin{align*}
Prob_{\ket{\sigma}} = tr\{ \ket{\sigma} \bra{\sigma} \hat{\rho} \}
\end{align*}

\subsection{Basic properties of the density operator}
\par For a physically realizable state the density operator will always have the properties that
\begin{enumerate}
  \item It will be Hermitian
  \item It will have trace 1:
  $ tr\{\hat{\rho}\} = 1 $
\end{enumerate}
\par There is another additional property that will help us differentiate between density matrices for pure states and mixed states.
\begin{itemize}
  \item For a pure state, $ tr\{ \hat{\rho}^2 \} = 1 $
  \item For a mixed state, $ tr\{ \hat{\rho}^2 \} < 1 $
\end{itemize}

\section{Joint State of two Systems}
\par So far we have dealt with quantum mechanical states of isolated particles. What will happen if we consider the joint state of more than one such particles? Classical intuition says that the joint state consisting of two subsystems A and B at any time can be completely specified simply by specifying the states of A and B individually. It turns out that this idea does not always work in the domain of quantum mechanics. In quantum mechanics, the joint state of two or more subsystems is specified by their \textit{tensor product}. Let us take a look at a simple example to get some understanding of tensor products and joint states.
\par Suppose we have two atoms whose states are specified by $\ket{\psi_A}$ and $\ket{\psi_B}$.
\begin{align*}
  \ket{\psi_A} = \begin{pmatrix} a \\ b \end{pmatrix} \\
  \ket{\psi_B} = \begin{pmatrix} c \\ d \end{pmatrix}
\end{align*}
The joint state for $\ket{\psi_A}$ and $\ket{\psi_B}$ will be represented by the tensor product
\begin{align*}
  \ket{\psi_{AB}} &= \ket{\psi_A} \otimes \ket{\psi_B} \\
                &= \begin{pmatrix} a \\ b \end{pmatrix} \otimes \begin{pmatrix} c \\ d \end{pmatrix} \\
                &= \begin{pmatrix} ac \\ ad \\ bc \\ bd \end{pmatrix}
\end{align*}
Tensor products for higher dimensional vectors are obtained by component-wise multiplication in a similar fashion.
\par Let us now take a look at a simple example for joint state of two atoms where atom A is in the ground state $\ket{0}$ and atom B is in the excited sate $\ket{1}$. The joint state of both particles will be
\begin{align*}
  \ket{\psi_{AB}} &= \ket{0}_A \ket{1}_B \\
                  &= \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix}
\end{align*}
\par This suggests a more compact way of writing a joint state of two particles in our extended four-dimensional Hilbert space.
\begin{align*}
  \ket{\psi_{AB}} &= ac \ket{0}_A \ket{0}_B + ad \ket{0}_A \ket{1}_B + bc \ket{1}_A \ket{0}_B + bd \ket{1}_A \ket{1}_B
\end{align*}
where the four basis vectors represent possible combinations of ground and excited states of atoms A and B and the corresponding co-efficients squared are the probabilities of finding that particular combination. For example, $|ad|^2$ is the probability of the state collapsing to atom A in ground state and atom B in excited state.

\subsection{Operators for Joint States}
\par We have seen how joint states of two particles are given by tensor products which extend the systems to a higher dimensional Hilbert space. In our example two particles in their respective two-dimensional Hilbert spaces were extended to a four-dimensional Hilbert space. That means that the operators that work on those states will also be 4x4 matrices in the 4-D Hilbert space.
\par Suppose $\hat{O}_A$ and $\hat{O}_B$ are different observables acting respectively on the Hilbert space of particle A and particle B. The joint observable will be a tensor product of the two.
\begin{align*}
  \hat{O}_{AB} &= \hat{O}_A \otimes \hat{O}_B \\
               &= \begin{pmatrix} a_1 & b_1 \\ c_1 & d_1 \end{pmatrix} \otimes \begin{pmatrix} a_2 & b_2 \\ c_2 & d_2 \end{pmatrix} \\
               &= \begin{pmatrix}
                    a_1 a_2 & a_1 b_2 & b_1 a_2 & b_1 b_2 \\
                    a_1 c_2 & a_1 d_2 & b_1 c_2 & b_1 d_2 \\
                    c_1 a_2 & c_1 b_2 & d_1 a_2 & d_1 b_2 \\
                    c_1 c_2 & c_1 d_2 & d_1 c_2 & d_1 d_2
                  \end{pmatrix}
\end{align*}
\par As a simple exercise let us construct a projection operator for projecting atom A on its ground state and atom B on its excited state. The isolated projector for A in this case is $\ket{0} \bra{0}$ and for B it is $\ket{1} \bra{1}$. The joint projector will be a tensor product of the two.
\begin{align*}
  \ket{0} \bra{0} \otimes \ket{1} \bra{1} &= \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} \otimes \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} \\
  &= \begin{pmatrix} 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{pmatrix}
\end{align*}
\par We can apply this joint projection operator to a density operator for a joint state in a 4-D Hilbert space and take the trace to find out the probability for the outcome where A is in $\ket{0}$ and B is in $\ket{1}$.

\subsection{Partial Trace and the Reduced Density Operator}
\par Just like the example of joining two operators to form a combined operator in the enlarged Hilbert space, we can also take the tensor product of two density operators (or density matrices) to form the combined density operator for two particles A and B.
\begin{align*}
\hat{\rho}_{AB} = \hat{\rho}_A \otimes \hat{\rho}_B
\end{align*}
\par But what if we needed to do the inverse? Sometimes we will have a situation where we need to find the density matrix $\hat{\rho}_A$ from a combined density matrix $\hat{\rho}_{AB}$. The mathematical operation for that is called a partial trace over B and is denoted by
\begin{align*}
\hat{\rho}_A = tr_B\{ \hat{\rho}_{AB} \}
\end{align*}
We trace out system B and are left with only system A.
\par For a 4x4 density matrix, the partial trace over B to get the 2x2 density matrix for A looks like this.
\begin{align*}
\begin{pmatrix} a & b & c & d \\ e & f & g & h \\ i & j & k & l \\ m & n & o & p \end{pmatrix}
\rightarrow
\begin{pmatrix} a+f & c+h \\ i+n & k+p \end{pmatrix}
\end{align*}

\section{Entangled States}
\par In the previous section, we saw how we can write the product state of two particles as
\begin{align*}
\ket{\psi_{AB}} = ac \ket{0}_A \ket{0}_B + ad \ket{0}_A \ket{1}_B + bc \ket{1}_A \ket{0}_B + bd \ket{1}_A \ket{1}_B
\end{align*}
Now let us take a look at an interesting case.
\begin{align*}
  \ket{\psi_{AB}} = \frac{1}{\sqrt{2}} \ket{0}_A \ket{0}_B + \frac{1}{\sqrt{2}} \ket{1}_A \ket{1}_B
\end{align*}
What we have here is a state for which there is an equal probability of both particles being in their ground state or both being in their excited state. Now if we want to figure out the individual states of A and B separately, we hit a stop. We cannot determine the separate states of which this joint state is a product because we cannot determine a, b, c and d from these coefficients. Still this equation does represent a valid physical state because \textit{any} vector in the Hilbert space is a valid physical state.
\par Let us now look at the physical consequences of this situation. One is the obvious consequence that if the atom A is measured and turns out to be in state $\ket{0}$ then the atom B is also certainly in state $\ket{0}$, and vice versa.
\par But there is another more interesting consequence. The fact that we cannot factorize this state means that we cannot specify a pure state of its constituent components. We cannot \textit{in principle} know more than what we already have. Which means this certain state itself is a \textit{pure state}. We cannot have full knowledge of the states of atoms A and B separately.
\par This phenomenon of entangled states brings up a very interesting research topic. Being unable to distinguish the subsystems A and B as individual states means that the whole composite system AB acts as a single system. It does not matter if the particles are far away from each other. The composite system still behaves as a single system extended in space. There is no analogue to this phenomenon in classical physics.
\subsection{Bell States}
\par The particular state discussed earlier in this section is a \textit{maximally entangled} state of two subsystems - a state for which the amount of entanglement between the subsystems is maximum. This state is part of a set of four maximally entangled (or orthogonal entangled) states called Bell states. The four states are
\begin{align*}
\ket{\Phi^+} &= \frac{1}{\sqrt{2}} \left( \ket{0}_A \ket{0}_B + \ket{1}_A \ket{1}_B \right) \\
\ket{\Phi^-} &= \frac{1}{\sqrt{2}} \left( \ket{0}_A \ket{0}_B - \ket{1}_A \ket{1}_B \right) \\
\ket{\Psi^+} &= \frac{1}{\sqrt{2}} \left( \ket{0}_A \ket{1}_B + \ket{1}_A \ket{0}_B \right) \\
\ket{\Psi^-} &= \frac{1}{\sqrt{2}} \left( \ket{0}_A \ket{1}_B - \ket{1}_A \ket{0}_B \right)
\end{align*}
\par Before we study the phenomenon of entanglement in any further detail, we shall need to take a short detour to understand some basic concepts in quantum information theory. After that, we shall return to the topic of entanglement and how we quantify the amount of entanglement contained in a certain system (in other words, quantifying how entangled a particular system is).


\section{Introduction}

In this little write-up I want to calculate the cohomology ring of $G_2(\mathbb{C}^4$),
i.e. the Grassmannian manifold consisting of all 2-dimensional subspaces of $\mathbb{C}^4$.
To do this we use the Serre spectral sequence we get from the fibration
\begin{center}
\begin{tikzcd}
U(2) \arrow[r] & V_2(\mathbb{C}^4) \arrow[r] & G_2(\mathbb{C}^4)
\end{tikzcd}
\end{center}

where $V_2(\mathbb{C}^4)$ is the Stiefel manifold,
i.e. the collection of 2-frames in $\mathbb{C}^4$, and $U(2)$ is the unitary group.
I won't do the calculation of the cohomology rings of $V_2(\mathbb{C}^4)$ and $U(2)$,
but the latter we can easily get from the homeomorphism $U(n) \simeq U(1)\times SU(n-1)$,
giving in particular $U(2)\simeq S^1\times S^3$, and the former can be calculated by induction and the following fibration
\begin{center}
\begin{tikzcd}
S^{2(n-k)+1} \arrow[r] & V_k(\mathbb{C}^n) \arrow[r] & V_{k-1}(\mathbb{C}^n).
\end{tikzcd}
\end{center}

We then have
\begin{equation*}
    H^*(V_2(\mathbb{C}^4)) = \Lambda(a_5, a_7) \text{ and } H^*(U(2)) = \Lambda(a_1, a_3)
\end{equation*}
where $a_i$ lies in degree $i$.

From the fibration
\begin{center}
    \begin{tikzcd}
    U(2) \arrow[r] & V_2(\mathbb{C}^4) \arrow[r] & G_2(\mathbb{C}^4)
    \end{tikzcd}
\end{center}
we get a spectral sequence $E_r$ which uses the cohomology of $G_2(\mathbb{C}^4)$ with coefficients from the cohomology of $U(2)$ to calculate the cohomology of $V_2(\mathbb{C}^4)$.
Since we now already know the cohomology ring of $V_2(\mathbb{C}^4)$ we can guess what the cohomology of $G_2(\mathbb{C}^4)$ has to be in order for the spectral sequence to calculate the correct cohomology ring.
This is the approach of this write-up.


\subsection{Rules and Notation}

Domain is the input space and codomain is the output space.

\begin{itemize}
    \item $T(\tb{v}+\tb{w})=T(\tb{v})+T(\tb{w})$
    \item $T(c\tb{v})=cT(\tb{v})$
\end{itemize}

Thus,

\[\boxed{T(c\tb{v}+d\tb{w})=cT(\tb{v})+dT(\tb{w})}\]

where $c,d\in \R$ and $\tb{v},\tb{w}\in \R^n$.\newline

Notation given from $\R^m$ to $\R^n$:

\[T:\; \R^m\rightarrow \R^n.\]

\subsection{Nonlinear examples}

\begin{itemize}
    \item $S:\;R^2\rightarrow\R^2$ where $S\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}x^2\\y^2\end{bmatrix}$
    \item $f:\;\R\rightarrow\R$ where $f(x)=mx+b$
\end{itemize}

A transformation represented by the product of some matrix $A$ and the column vector input $\tb{x}$ is always a linear transformation.


%--------------------------------------------------------------------------
% @file linear_systems.tex
%
% @date 09/26/16 09:33:12
% @author Martin Noblia
% @email martin.noblia@openmailbox.org
%
% @brief
% Resumen de sistemas lineales.
% @detail
%
% Licence:
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or (at
% your option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License
%
%---------------------------------------------------------------------------
% begin
%---------------------------------------------------------------------------
% Resumen de sistemas lineales
%---------------------------------------------------------------------------
\section{Sistemas Lineales}

\subsection{Matrices}
Una matrix $A$ de tamanio $m \times n$ es un arreglo rectangular de $m \, n$ numeros
dispuestos en $m$ filas y $n$ columnas. Por ejemplo:
$
\begin{bmatrix}
   1 & 0 & 1\\
   0 & 1 & 0 \\
   1 & 3 & 7
 \end{bmatrix}
$
Una matriz generica de tamanio $m \times n$ la anotamos: $A=(a_{ij})$ de tal manera que
su elemento en la fila $i$ columna $j$ es $a_{ij}$. La fila $i$ de $A$ es:
$
\begin{bmatrix}
   a_{i1} & a_{i2} & a_{i3} & \cdots & a_{i\,n}
 \end{bmatrix}
$
y la columna $j$ de $A$ es:
$
\begin{bmatrix}
   a_{1j} \\ a_{2j} \\ a_{3j} \\ \vdots \\a_{n \, t}
 \end{bmatrix}
$


\section{The Benchmark: Computation of Shapley Effects} \label{comp_shap}

This section introduces Shapley effects for sensitivity analysis. Shapley effects will serve as a benchmark for evaluating the performance of the sensitivity measures derived by the Morris method.

\subsection{Shapley Values in Economics}

The Shapley value is a concept from cooperative game theory, introduced by \citet{S53}. It is a value that informs about how to fairly distribute the profit of a product that was created by a team effort. Fairly here means that any player receives as much of the gain as he or she contributed to the team effort. As individual contributions are not directly observed, \citet{S53} proposes the following value. The Shapley value ensures that every individual receives at least as much as if he or she had if acted independently \citep{IP19}.

Consider a game with $k$ players, where $K$ denotes the set of all players, the grand coalition. A coalition is a subset $J \subset K$. Let $- J$ denote the complement set of $J$, i.e. $- J = K \setminus{J}$. The corresponding game is defined by a coalition value function that maps each coalition $J$ to the value attained by this coalition, i.e. $val: 2^K \to \mathbb{R}_{\geq 0}$, where $2^K$ denotes the power set of $K$, i.e. the set of all subsets of $K$. It is generally assumed that $val(\emptyset) = 0$. The following definition is strongly inspired by the one found in \citet{PRB20}:

\begin{definition}

Given a coalition worth function $\text{val}$, the marginal contribution of player $i$ joining coalition $J$ is $\text{mar}(J, i)=\text{val}(J \cup \{i\}) - \text{val}(J)$. The Shapley value is then defined as
\begin{equation*}
\begin{split}
\phi_{i} (\text{val})& = \sum_{J \mid i \notin J} \frac{\vert J \vert ! (k - \vert J \vert - 1) ! }{ k !} (\text{val}(J \cup \{i\}) - \text{val}(J)) \\
& = \frac{1}{k} \sum_{J \mid i \notin J} \binom{k-1}{\vert J \vert}^{-1} \text{mar}(J, i).
\end{split}
\end{equation*}

\end{definition}

In other words, we consider every coalition of players and evaluates by how much the inclusion of player $i$ increases the overall profit of the coalition. This is achieved by subtracting the value generated by the members of coalition $J$ from the value created by the larger coalition that includes coalition $J$ and player $i$. In the context of a game, the marginal value for each coalition is divided among all members of this coalition, e.g. if the coalition has one member only, the entire marginal value is gained by this player. We can also interpret the Shapley value as the expected payoff from joining a coalition or from leaving the complementary coalition \citep{PRB20}.

\citet{S53} shows that $\phi_i$ is the only value satisfying all the following four axioms at the same time. Note that Shapley values normalised by total profit are considered.

\begin{itemize}
    \item Pareto efficiency: $\sum_{i=1}^{k}\phi_i=1$.
	\item Symmetry: If $val(J \cup {i})=val(J \cup {j})\ \forall\ J \subseteq K \setminus{\{i, j\}}$, then $\phi_i = \phi_j$.
	\item Linearity: $\phi_i(val_1 + val_2)=\phi_i(val_1)+\phi_i(val_2)$.
	\item Null-player: If $\forall J,\ mar(J, i) = 0$ holds then $\phi_i(val) = 0$.
\end{itemize}

Pareto efficiency ensures that nothing of the profit gained by the team is wasted. Normalised by the total profit, the Shapley value gives the share attained by each individual in the game. Symmetry implies that all players who contributed the same to the common product, receive the same payoff, reflecting the meritocratic principle. The null-player axiom ensures that players who do not contribute to the team effort at all do not receive any share of the profits. Especially axioms 1 and 4 are desirable in the context of the Shapley value as a variance-based sensitivity measure, as further discussed in the following subsection.

\subsection{Variance-based Sensitivity Analysis} \label{var_based_sa}

There are several purposes for which we can apply sensitivity methods in general. Note, that in sensitivity analysis we refer to input variables by the term factors \citep{R21}. In their textbook, \citet{STC04} summarise the following four possible objectives of sensitivity analysis.

Factors Prioritisation (FP): In the FP setting, we determine on which inputs applied, uncertainty reduction results into the largest reduction in output uncertainty. Sensitivity analysis determines the importance of an input variable. Applied to all inputs, we can derive a ranking of all inputs in order of importance. FP can guide research by prioritising inputs. Inputs are identified for which better experimental measurement can reduce output uncertainty the most, supposing that additional information costs the same for alle inputs.

Factors Fixing (FF): The FF setting allows us to determine the least influential inputs. These can then be fixed at a specific value while losing only a minimum of information in the model output. FF can also be seen as input screening. We would want to fix the least influential inputs to reduce dimensionality of the model and thus the complexity and computational burden.

Variance Cutting (VC): VC informs about which inputs to fix to arrive at a certain desired value of the output variance, under the condition that the smallest number of inputs are fixed. VC is most useful for risk assessment.

Factors Mapping (FM): If we care about the input importance in certain regions of output values only, we can apply FM. First, we classify output values into groups and only then employs the importance exercise. So, the inputs are determined that contribute the most to producing output values in a target region, e.g. we could be interested in a certain percentile of the output range. The term mapping stems from mapping the importance of the inputs to the categories of $Y$.

Sensitivity analysis does address more fundamental objectives of mathematical modelling and the analysis of systems that can be achieved directly from the above settings and are summarised in \citet{R21}. By sensitivity analysis, we can achieve or conduct scientific discovery, i.e. identification of causal relationships, dimensionality reduction, i.e. determination of the least important inputs, which is achieved by FF, data worth assessment, which relates to FP, and decision support \citep{R21}.

In global sensitivity analysis, where inputs are probabilistic in nature, we distinguish six classes of sensitivity analysis methods \citep{BP16}. The sensitivity indices discussed and applied in this work belong or are related to the area of variance-based sensitivity measures. Variance-based sensitivity measures are obtained by determining the expected reduction in output variance due to knowing input $i$ with certainty \citep{BP16}. These methods are based on the classical formula for the law of total variance
\begin{equation*}
V[Y]= V[E[Y \mid X_J]] + E[V[Y \mid X_J]]
\end{equation*}

\noindent assuming that $f(X) < \infty$, where the $V$ operator stands for the unconditional variance of $Y, V[\cdot \mid \cdot]$ for the conditional variance, and $E[\cdot \mid \cdot]$ denotes the conditional expectation. The above expression decomposes total variance into the explained and the unexplained component \citep{GM17}.

A variance-based sensitivity measure determines how much output variance is attributable to each input $i$ \citep{BP16}. Variance-based global sensitivity analysis is not applicable to decision variables, since global sensitivity analysis attaches a distribution to input variables, implying that inputs are uncertain \citep{SNS16}. Recall that due to this uncertainty in the inputs $X_K$ the output $Y$ is uncertain as well. $V[Y]$ measures this uncertainty in the output, where $V[Y]$ is taken according to the joint distribution of $G_K$. In the variance of the model output, there are three parts of variances; the one caused by every input in isolation, the one that is caused by interaction effects among inputs, and one that is due to input dependence.

\citet{S93} introduced the popular Sobol' indices. In the case of input dependence, Shapley effects are superior to Sobol' indices \citep{O14}. Sobol' indices are variance-based sensitivity measures that attribute the variance reduction to each subset $J \subset K$ using an Analysis of Variance (ANOVA) decomposition. To ensure uniqueness of the ANOVA decomposition employed by \citet{S53}, we need to assume independence of model inputs \citep{GM17}. Sobol' indices were introduced as a subset importance measure \citep{SNS16}. For the purposes of sensitivity analysis, we let the subsets be the single inputs, i.e. the subsets under considerations are singletons. The Sobol' indices are then defined as
\begin{align}
S_i &= V[Y]^{-1} V[E[Y \mid X_i]] \label{first_order_sobol}\\
S_i^T &= V[Y]^{-1}(V[Y] - V[E[Y \mid {X_{- i}}]])
\label[equation]{total_sobol}
\end{align}

\noindent where $X_{- i}$ is the subset of input variables without input $i$. What follows does apply to models with independent inputs only. The sensitivity measure $S_i$ is called the first-order sensitivity index. $S_i$ represents the share of output variance reduced by the isolated effect of input $i$, excluding contributions in variance reduction by interactions between input $i$ and the remaining $(K-1)$ inputs. The subtrahend in the nominator of \cref{total_sobol} can be seen as the expected variance reduction when $X_i$ is fixed at a certain value, i.e. if we know $X_i$ with certainty \citep{SNS16}. $S_i^T$ is called the total sensitivity index. $S_i^T$ complements $S_i$ in the sense that it measures the total effect of $X_i$ in the output variance, including interaction effects \citep{SNS16}. It can be considered the expected remaining output variance, when all values of the inputs are known, except for the value attached to $X_i$ \citep{SNS16}. By normalising both measures by $V[Y]$, it is clear that the values of $S_i$ and $S_i^T$ are in the interval $[0, 1]$, since the numerators in \cref{first_order_sobol,total_sobol} are always smaller than the total variance \citep{GM17}. For the relationship between $S_i$ and $S_i^T$ the weak inequality $S_i\ \le\ S_i^T$ holds true, while equality only holds when there are no interaction effects between $X_i$ and $X_{- i}$. Note that the terms indices and effects are used interchangeably.

Under input independence, the Sobol' indices have a clear interpretation. If $S_i$ is large, then the corresponding input $X_i$ is an influential input with respect to the output variance reduction \citep{GM17}. In contrast, a small first-order effect $S_i$ does not imply that $X_i$ is an uninfluential input, if strong interaction effects are present \citep{GM17}. As $S_i^T$ measures the total variance contribution by $X_i$, we can infer from a small $S_i^T$ that $X_i$ is indeed uninfluential \citep{GM17}. If so, $X_i$ could be fixed at a certain value without causing changes in the model output variance \citep{GM17}.

Evaluating $S_i$ and $S_i^T$ we can also learn something about the structure of the model we are analysing, always assuming that inputs are independent. The model structure can be determined by the sums $\sum_{i \in K} S_i$ and $\sum_{i \in K} S_i^T$ \citep{GM17}. If both sums are equal to one, interaction effects are negligible, since the model is additive in nature. The model is non-additive if $\sum_{i \in K} S_i < 1$ and $\sum_{i \in K} S_i^T > 1$ \citep{GM17}. Thus, it can be inferred that interaction effects cannot be ignored and play a role in the system under consideration.

Recall that the statements about the model structure and input importance do not hold if inputs are dependent. In the case of dependence, we cannot simply apply the ANOVA decomposition since it is no longer unique \citep{O14}. In the Rust model, there are two input variables, $RC$ and $\theta_{11}$. As one can see in \cref{model_setup}, there exists significant dependence between the inputs. Thus, Sobol' indices should not be used. Another variance-based sensitivity measure are the now popular Shapley effects, which can be used also in the context of dependence. They are derived in the following section.

\subsection{Shapley Effects for Sensitivity Analysis}

When applied as a sensitivity measure, the interpretation of the Shapley value changes. In the context of sensitivity analysis, \citet{SNS16} coined the term Shapley effects, which were first suggested as a variance-based sensitivity measure by \citet{O14}. $X_i$ is now interpreted as a model input instead of a player in a game. A coalition is now a subset of model inputs. \citet{O14} defines the function $\widetilde{val}$ as a function that assigns the explanatory power of this subset of inputs to this subset. That is, the function $\widetilde{val}$ assigns the conditional variance to a subset of inputs, $\widetilde{val}(J)=V[Y]^{-1}V[E[Y \mid X_J]]$ and $\widetilde{val}$ measures the reduction in $V[Y]$ due to the inputs in $J$ \citep{SNS16}. \citet{SNS16} show that the following alternative formulation of the value function leads to the same Shapley effect
\begin{equation*}
val(J)=E[V[Y \mid X_{- J}]].
\end{equation*}

\noindent $val(J)$ can be interpreted as the remaining variance of $Y$, given the values of the inputs in $- J$ are known. Both formulations satisfy the following two requirements
\begin{align*}
val(\emptyset)& = 0\\
val(K)& = V[Y].
\end{align*}

\noindent In words, the value of the empty input subset should be zero and the value of the set of all inputs should equal the entire output variance. I normalise Shapley effects by $val(K)=V[Y] $ such that they fall inside the unit interval. The most appealing properties of Shapley effects are that they satisfy the following two conditions (compare to axioms 1 and 4).
\begin{align*}
\sum_{i=1}^{k}\phi_i& = 1\\
\phi_i& \geq 0,\ \forall \ i=1, ..., k.
\end{align*}

\noindent So, the Shapley effects calculated for a model sum up to one and each Shapley effect is non-negative. Hence, the Shapley effects are input importance measures in terms of the expected output variance reduction induced by $X_i$. The non-negativity condition ensures that Shapley effects are always clearly interpretable. Note that due to the uncertainty in the computation process Shapley effects might be smaller than zero. Increasing the sample sizes mitigates this problem.

Shapley effects can be used to compare input importance, that is, inputs can be ranked according to their contribution to output variance reduction. Furthermore, the differences between values of Shapley effects can be interpreted.

Recall the three parts of model output variance as discussed in \cref{var_based_sa}: variance due to the isolated effect of an input (i.e. the main variance), due to interaction effects, and due to dependence among inputs. Shapley effects take all three into account. In this regard they differ from first-order and total Sobol' indices as defined in \cref{var_based_sa} \citep{O14}.

In comparison to Shapley effects we have to acknowledge that Sobol' indices can inform about the model structure as discussed in \cref{var_based_sa}. In addition, Sobol' indices address more sensitivity analysis settings than Shapley effects, if inputs are independent. Shapley effects can be applied to FF only, since they distribute the effect of interactions between inputs equally across all inputs contained in the current subset \citep{IP19}. FP cannot be precisely conducted by using Shapley effects, since we cannot distinguish between contributions of main variance and variance contributions due to interactions \citep{IP19}.

Shapley effects yield a single value for each input that serves as the sensitivity measure, as opposed to Sobol' indices, which yield the first-order and total effects., i.e. two measures per input. Especially when computing sensitivity indices for studies that evaluate scientific phenomena, having a single value per input that informs about the variance contribution is very useful \citep{SNS16}. Furthermore, when this measure considers main and interaction effects and can also handle input dependence, we have a very useful and versatile sensitivity measure.

Sobol' indices for dependent inputs have been proposed \citep{MTA15}. This strategy is based on the estimation of four sensitivity indices, instead of the two measures in the case of input independence, elevating the practical usefulness of Shapley effects even more. In case of input dependence, Sobol' indices require a complicated ANOVA decomposition, whereas Shapley effects do not rely on such variance decompositions \citep{IP19}. When applying Shapley effects, we would not even need to know whether input dependence or independence prevails.

\subsection{Algorithm for Shapley Effects} \label{comp_alg}

\begin{figure}[t]
	\caption{Uncertainty in Shapley Effects - $100$ Replicates}
    \label{boxplot_shapley}
	\begin{centering}
	\vspace*{-4mm}
	\begin{centering}
	\includegraphics[scale=0.9]{../figures/boxplot_shapley_effects_100.png}

	\end{centering}
	\end{centering}

	\small
	\textit{Notes:} Boxplots for 100 estimated Shapley effects for the inputs $RC$ and $\theta_{11}$ using the same number of Monte Carlo samples: $N_V=100$, $N_O=10$, and $N_I=3$.
\end{figure}

The algorithm for the computation of Shapley effects needs to allow for conditional sampling of dependent inputs. Otherwise, some of the advantages of Shapley effects cannot be exploited. I use Algorithm 1 from \citet{SNS16}.\footnote{An alternative algorithm has been recently proposed by \citet{PRB20} which uses mathematically more advanced concepts.}

Shapley effects consider all input subsets. To iterate over all subsets, \citet{SNS16} restate the equation for Shapley effects to iterate over all permutations of model inputs. For instance, let $k=5$. Then, $K=\{1,\ 2,\ 3,\ 4,\ 5\}$. There exist $5!$ permutations, where one example is $\pi'=(2,\ 4,\ 3,\ 5,\ 1)$. Let the set of all permutations of $K$ be denoted by $\Pi(K)$. Further, let $P_i(\pi)$ denote all inputs in permutation $\pi$, that come before input $i$. In the above example, if $i=3$, then $P_3(\pi')=\{2,\ 4\}$. Using the permutation representation, \citet{SNS16} state the marginal contribution due to input $i$ as $val(P_i(\pi) \cup\{i\}) - val(P_i(\pi))$. By considering all permutations of $K$, we can restate the equation for the Shapley effects for input $i$ as
\begin{equation*}
\phi_i=\sum_{\pi \in \Pi(K)} (k!)^{-1} (val(P_i(\pi) \cup\{i\}) - val(P_i(\pi))).
\end{equation*}

The algorithm of \citet{SNS16} exploits the fact that their permutation-based algorithm evades redundant model evaluations by going through the permutations beginning with the smallest subset. The contribution of the preceding subset is subtracted from the contribution of the current subset. The marginal contribution is then computed by writing
\begin{equation*}
val(P_{\pi(j)}(\pi) \cup \{\pi(j)\}) - val(P_{\pi(j)}(\pi)),
\end{equation*}

\begin{table}[t]
	\centering
	\caption{Descriptive Statistics Shapley Effects - $100$ Replicates}
	\label{shapley_descriptives}
	\begin{threeparttable}
	\centering
	\input{../figures/descriptives_shapley_replicates_100.tex}
	\begin{tablenotes}
	\small
	\item \textit{Notes:} Descriptive statistics for $100$ replicates of the Shapley effects. 95-percent confidence intervals are reported.
	\end{tablenotes}
	\end{threeparttable}
\end{table}

\noindent where $\pi(j)$ denotes the input at position $j$ in permutation $\pi$. In the above permutation $\pi'$, at position 2 we have input 4, i.e. $\pi'(2)=4$.

To see for which subsets the algorithm performs evaluations of $val$, consider the below example. For instance, following \citet{SNS16}, if $k=3$ and $\pi=(1, 3, 2)$, the algorithm computes
\begin{align*}
\Delta_1 &=val(\{1\})-val(\emptyset),\ set\ prevC=0, \\
\Delta_2 &=val(\{1,\ 3\})-prevC,\ set\ prevC=val(\{1,\ 3\}), \\
\Delta_3 &=val(\{1,\ 3,\ 2\})-prevC,\ set\ prevC=val(\{1,\ 3,\ 2\}).
\end{align*}

The algorithm implements three Monte Carlo simulations. There are $N_V$ Monte Carlo samples of model inputs which are evaluated to get an estimate of $V[Y]$. Since the algorithm needs to handle dependent inputs, \citet{SNS16} implement dependent sampling by an inner and an outer Monte Carlo simulation. To see why both Monte Carlo simulations are needed, fix a permutation $\pi$. Then, sample $N_O$ outer samples, that are unconditionally drawn. Given this set of unconditionally drawn outer samples, draw $N_I$ inner samples conditionally on the outer samples. That is, for each outer sample, we have $N_I$ inner samples. Thus, the computational cost in terms of number of model evaluations is given by $N_V+m \cdot N_I \cdot N_O \cdot (k-1)$, where $m$ is the number of permutations considered. In the exact setting of the algorithm, $m=\vert \Pi(K) \vert=k!$. If only a random subset of permutations should be considered, we set $m<k!$, which can be useful to reduce the computational burden if the number of inputs is large.

\subsection{Shapley Effects for the Rust Model} \label{shapley_rust_model}

I apply three different computational setups. I do so to, firstly, evaluate the performance of Shapley effects and, secondly, get the correct input ranking according to the sensitivity for the Rust model. When working with the algorithm presented by \citet{SNS16} in practice, it can be challenging to specify the sample sizes $N_O$ and $N_V$, since no guidance on how to allocate the computational budget to $N_V$ and $N_O$ is given.

The general computational setup applies to all three simulation studies. \citet{SNS16} recommend setting $m=\vert \Pi(K) \vert$, if computationally feasible. In order to reduce variance of the estimates of Shapley effects, they further recommend choosing $N_I=3$, while setting $N_O$ as large as possible, given the constraints on the computational budget. Since the Rust model has two inputs only, the number of permutations to be considered is two and thus very small. Hence, I set $m=2!=2$ and $N_I=3$. I run the estimation by using the implementation of the algorithm by the package \textit{econsa}, a Python package for sensitivity analysis \citep{OSE21}.

% Shapley replicates.

\begin{figure}[t]
	\caption{Convergence of Shapley Effects for the Rust Model}
    \label{shapley_convergence}
	\begin{centering}
	\vspace*{-4mm}
	\begin{centering}
	\includegraphics[scale=0.9]{../figures/convergence_shapley_effects_8.png}
	\end{centering}
	\end{centering}

	\small
	\textit{Notes:} Shapley effects estimated for different values of $N_O$, while setting $N_V=10\,000$ and $N_I=3$.
\end{figure}

Firstly, I estimate 100 Shapley effects for the inputs of the Rust model, $RC$ and $\theta_{11}$ using the same general setup as described in the preceding paragraph. I further set $N_V=100$ and $N_O=10$. Thus, the computational cost of my choice of Monte Carlo runs imply that 160 model evaluations are needed to estimate the Shapley effects. On my machine (Windows 10, i5 processor), one estimation run takes approximately 40 seconds.

The distribution of the 100 replicates is visualised by the boxplots in \cref{boxplot_shapley}. For further details on the estimated replicates, see \cref{shapley_descriptives}. The mean of $\phi_{RC}$ is $0.4163$ and for $\phi_{\theta_{11}}$ the mean value is $0.5837$. Shapley effects are estimated with a standard error of 0.0043.
Both, the boxplots, and the mean values show that $\theta_{11}$ is the more important input in terms of contributions to output variance. The confidence intervals at the 95-percent level, are quite large, but they do not overlap, indicating that the implied input importance ranking is robust. The lower value of $\phi_{RC}$ shows that $RC$ has less an impact on the output variance than $\theta_{11}$.

% True Shapley

Secondly, I estimate one set of Shapley effects for a large sample size. I chose to consider $N_V=100\,000$ and $N_O=10\,000$, which amount to a computational cost of $160\,000$ model evaluations. The resulting sensitivity measures are $\phi_{RC} = 0.4176$ and $\phi_{\theta_{11}} = 0.5823$. I refer to this set of sensitivity measures as the \textit{true} Shapley effects.

% Shapley Convergence

Thirdly, I estimate eight Shapley effects for different sample sizes to illustrate their behaviour as $N_O$ increases. For all the estimations I fix $N_V$ at $12\,500$, varying $N_O$ only. I consider $N_O \in \{200,\ 500,\ 800,\ 1\,000,\ 2\,000,\ 3\,000,\ 4\,000,\ 6\,000 \}$. The total computational cost for one estimation is thus given by $10\,000 + 6 \cdot N_O$, e.g. for $N_O=200$, the total computational cost amounts to $11\,200$ and for $N_O=6\,000$, the total computational cost amounts to $46\,000$ model evaluations. Results are visualised in \cref{shapley_convergence}. For each chosen value of $N_O$ there is a clear input ranking, indicating that $\theta_{11}$ is the more important input. Shapley effects are still relatively volatile, even for larger sample sizes. Details on the relative difference between estimates are shown in \cref{rel_diff_shapley}. \Cref{rel_diff_shapley} shows the percentage change in estimates given by $\frac{\phi_i^{n_o-1} - \phi_i^{n_o}}{\phi_i^{n_o}}$, for $i \in \{RC,\ \theta_{11}\}$ and $n_o$ denoting the different values of $N_O$ considered. % Relative differences do not steadily decline.

% Interpretation

To sum up, the input rankings are always the same: $\theta_{11}$ is the more important input for the Rust model. This holds true for all the estimations of Shapley effects presented above. Since both $\phi_i$ are far from zero, it is not recommended to fix any one of them, since both influence the output variance significantly. Otherwise we would assume an input to be deterministic which is subject to large uncertainty and has simultaneously a large influence on the model output.

\begin{table}[t]
	\centering
	\caption{Relative Difference Shapley Effects}
	\label{rel_diff_shapley}
	\begin{threeparttable}
	\centering
	% \hline
	\input{../figures/shapley_convergence_relative_difference_8.tex}
	\begin{tablenotes}
	\small
	\item \textit{Notes:} The percentage difference between Shapley effects for different values of $N_O$ while keeping $N_V$ fixed at $12\,500$ and $N_I$ at $3$. Percentage changes are calculated by $\frac{\phi_i^{n_o-1} - \phi_i^{n_o}}{\phi_i^{n_o}}$, for $i \in \{RC,\ \theta_{11}\}$ and $n_o$ denoting the different values of $N_O$.
	\end{tablenotes}
	\end{threeparttable}
\end{table}


\documentclass{article}

\usepackage{mathrsfs,amssymb,amsmath}

\begin{document}

\section{If $\mathscr{A}$ is a Banach algebra with identity and $a \in \mathscr{A}$ and is nilpotent (that is, $a^n=0$ for some $n$), then $\sigma(a) = \{0\}$}

Firstly, assume $a$ is invertible. Then

\begin{align*}
    a^n &= 0 \\
    (a^{-1})^n a^n &= (a^{-1})^n 0 \\
    1 &= 0
\end{align*}

a contradiction, so $0 \in \sigma(a)$.

Next, we need to show that $a-\alpha$ for any $\alpha \in \mathbb{C}$ is invertible.

If $1 + a + a^2 ...$ converges, it will converge to $1 / (1-a)$ by the geometric series. Since $a^n=0$, all terms $\ge n$ vanish, hence the series converges, and $1/(1-a) \in \mathscr{A}$

Since $\mathscr{A}$ is closed under multiplication, it also contains $1/(a-1)$, hence $a-1$ is invertible, so $1 \not \in \sigma(a)$.

TODO: Extend to the other $\alpha \in \mathbb{C} \setminus 0 $ (maybe some simple algebra trick?)

\end{document}


\chapter{Theory behind SVD}
\label{cha:svd-theory}

Let us begin by giving the formal definition of the SVD factorization,
which is in indeed a theorem (we will restrict ourselves to real
matrices, that is, to matrices whose entries belong to the field
\R{}). \\

\begin{theorem}[Singular Value Decomposition]
\label{thm:SVD}
Let $A$ be a real matrix of $n \times m$ \imply $\exists$ orthogonal matrices
$V$ ($n \times $n) and $U$  ($m \times m$), and diagonal matrix
$\Sigma$ ($m \times n$) \suchthat:

\[
A = U \Sigma \trans{V}
\]
\\
where $\Sigma$ has the following properties:
\begin{align*}
 & \Sigma =  diag(\sigma_1,\dots,\sigma_p), & \textds{for} p = min(n,m)  \\
 & \sigma_1 \ge \sigma_2 \ge \dots \ge \sigma_r > 0, & \textds{for} r = rank(A) \\
 & \sigma_{r+1} = \sigma_{r+2} = \dots = \sigma_p = 0 &
\end{align*}
\end{theorem}
\hfill

Note that in the \cref{thm:SVD}, we are considering diagonal
matrices on its more generic form that does not require them to be
square; the definition of diagonal matrix $M$ can simply be that any
element other than $M_{ii}$ becomes zero. \\

Before presenting the proofs, is convenient to provide more context
about the theory behind this matrix factorization (and probably also,
part of the motivation behind). \\

\input{svd-intuit.tex}

\section{The SVD proofs}
The rest of this chapter provides more theoretical background about
the SVD decomposition, in particular, it provides two different proofs of
\cref{thm:SVD}:

\begin{itemize}
  \item Algebraic proof using the Spectral Theorem.
  \item Geometric proof (implicitly using Compactness).
\end{itemize}
\hfill

Each one of those proofs is intended to bring a
different perspective, about such an important result as SVD is. The
list is not exhaustive of course, there could be many more ways of
proving it; but hopefully the short list presented here, will give the
reader an idea about the rich theory behind this decomposition. \\

As with any mathematical theorem, proving is done based on previous
results; since this is not a text book, we can not afford the luxury
of proving every auxiliary theorem we use. However, we made an effort
for at least mentioning explicitly the theorems; pointing to
references, when possible, about their respective proofs. For some few
cases (like the Spectral Theorem), we did include the proof of the
auxiliary theorem as well.

\input{svd-proof-spec.tex}
\input{svd-proof-geo.tex}


\section{Dimensional Analysis}
\subsection{Basic Dimensional Quantities and Units}
For most motions we will be considering, there are basically three dimensions of interests: length ($L$), mass ($M$) and time ($T$).
In general, the dimension of a physical quantity $X$ can be expressed using thsese three dimensions.
For example, the density can be expressed by $ML^{-3}$, and the force can be expressed by $MLT^{-2}$.
We are only going to consider the product of powers of the dimensional quantities.
We can then introduce units for the basic dimensional quantities.
Most likely we will use the SI unit system ($L=$m, $M=$kg, $T=$s).
For other quantities, we can form units out of the basic units we defined for the basic quantities.
\begin{example}
    To find the unit of the constant $G$ in Newton's Law of Gravitation, we can determine by writing each quantity in basic quantities, so we have $G=L^3T^{-2}M^{-1}$, therefore the unit for $G$ will be ${\rm m^3s^{-2}kg^{-1}}$.
\end{example}
The general principle is that dynamical or physical equations must work for any chosen system of units.
\subsection{Scaling}
Suppose I have a dimensional quantity $Y$ which depends on some other quantities $X_1,X_2,\ldots,X_n$.
Let the diensions of the quantity $Y$ be $L^aM^bT^c$, and $X_i$ has dimensions $L^{a_i}M^{b_i}T^{c_i}$.
We want to determine the dimensions of $Y$ from that of $X_i$.
So obviously we have $Y=C\prod_i X_i^{p_i}$, so
$$\begin{cases}
    a=\sum_ip_ia_i\\
    b=\sum_ip_ib_i\\
    c=\sum_ip_ic_i
\end{cases}$$
If $n=3$, then there is an unique solution iff $X_1,X_2,X_3$ are independent, so
$$\begin{vmatrix}
    a_1&a_2&a_3\\
    b_1&b_2&b_3\\
    c_1&c_2&c_3
\end{vmatrix}\neq 0$$
which happens most of the time.
Note that for general $n$ there must be a solution (not necessarily unique) if we assume that $Y$ does indeed depend on a subset of $\{X_i\}$.
So for $n<3$, there is an unique solution as well.\\
For $n>3$, however, we can choose $n-3$ dimensionless constants
$$\lambda_i=X_i/(X_1^{p_{i1}}X_2^{p_{i2}}X_3^{p_{i3}})$$
where $i=4,5,\ldots$, assuming $X_1,X_2,X_3$ are independent.
So
$$Y=C(\lambda_4.\lambda_5,\ldots)X_1^{p_1}X_2^{p_2}X_3^{p_3}$$
where $C$ is a dimensionless function.
This is sometimes known as Bridgemzn's Theorem.
\begin{example}
    Consider a simple pendulum.
    Let $d$ be the horizontal initial displacement, $m$ the mass, and $g$ the acceleration due to gravity, and $l$ the length of the string, and we want to find expression of the period $P$ in term of these.
    Speaking of dimensions,
    $$\begin{cases}
        [P]=T\\
        [d,l]=L\\
        [g]=LT^{-2}\\
        [m]=M
    \end{cases}$$
    Thus
    $$T=M^{p_1}L^{p_2}(LT^{-2})^{p_3}$$
    solve to get $p_1=0,p_2=1/2,p_3=-1/2$
    Hence
    $$P=C\left( \frac{d}{l} \right)\sqrt{\frac{l}{g}}$$
    For a dimensionless function $C$.\\
    Hence, if we scale $d,l$ by $2$, the period will be scaled by $\sqrt{2}$.
    Also $P$ is independent of $m$.
\end{example}
\begin{example}
    Taylor's estimate to the first atomic explosion.\\
    We want to estimate the radius of the fireball $R$ which has dimension $L$.
    $R$ depends on the time $t$ since the explosion which has dimension $T$.
    The density of air $\rho_0$ which has dimension $ML^{-3}$ is also involved.
    Lastly the energy of explosion $E$ having dimension $ML^2T^{-2}$.\\
    So by doing dimensional analysis, we immediately (since there are only $3$ depending dimensions) have $R\propto \sqrt[5]{Et^2/\rho_0}$.
    This has allowed Taylor to estimate the size of $E$.
\end{example}


\section{Probability distributions}

\subsection{Normal}

By contrast with substantial majority of books, the univariate normal distribution
can be derived form the multivariate normal distribution.
In this section we show how to obtain the univariate normal from the bivariate.

\begin{marginfigure}
  \includegraphics[width=\linewidth]{figures/04_normal.pdf}
  \caption{Black dots represent the gas molecules.
  The red dot stands for the one we catch.
  Its speed along the horizontal axis is $v_1$, i.e., the first component of
  the velocity vector, and its speed along the vertical axis is $v_2$.}
\end{marginfigure}

The original idea belongs to J.C. Maxwell who was wondering
what distribution the velocity of gas molecules follow.
The similar question was also bothering J.H.W. Herschel who was an astronomer
and was dealing with measurement errors in astronomical data.
Here we provide a proof of the theorem known today as Herschel-Maxwell's.

Assume there are gas molecules moving chaotically on a plane
and we can measure the velocity vector of one of them.
We will denote this vector as $V = \begin{pmatrix} X \\ Y \end{pmatrix}$
where $X$ and $Y$ stand for the horizontal and vertical components respectively.
Assume additionally that
\begin{enumerate}
  \item The joint distribution finction $f(x,y)$ does not depend on
  the vector $(X,Y)^T$ direction but depends on its length only;
  \item The orthogonal components of the velocity vector are independent;
  \item And we measure the velocity in such a way that $\Var(X) = 1$.
\end{enumerate}

\marginnote{
It is more common to introduce a standard normal distribution in terms of its PDF
\begin{definition}
A continuous random variable $\xi$ has a standard normal distribution
if its PMF is given by
\[
f_{\xi} (x) = \frac{1}{\sqrt{2\pi}}\exp\left(-\frac{x^2}{2}\right).
\]
\end{definition}
After that multivariate normal is defined.

\begin{definition}
Let $\xi_i \stackrel{iid}{\sim} \mathcal{N}(0, 1)$ then $\xi \sim \mathcal{N}(\vec{0}, I)$
where $\xi = \begin{pmatrix} \xi_1 \\ \vdots \\ \xi_n \end{pmatrix}$,
$I$ is $n \times n$ identity matrix, and its PMF is
\[
f_{\xi} (x_1, \ldots, x_n) = \frac{1}{(\sqrt{2\pi})^n}\exp\left(-\frac{x_1^2+\ldots+x_n^2}{2}\right).
\]
\end{definition}
And finally, location-scale transformations are applied.
}

\begin{theorem}
Assumptions (1), (2) and (3) are satisfied if and only if
$X \sim \mathcal{N}(0, 1)$, $Y \sim \mathcal{N}(0, 1)$
and $X$, $Y$ are independent.
\end{theorem}

\begin{proof}
First of all, consider a vector $V' = \begin{pmatrix} -Y \\ X \end{pmatrix}$, i.e.,
the original vector $V$ rotated $90^{\circ}$ counterclock-wise.
By the assumption (1), this operation did not change the distribution of $V$.
Hence, $V' \sim V$ which implies $-Y \sim X$ and $X \sim Y$.
It follows that
\[
\begin{cases}
\E(-Y) = \E(X) \\
\E(X) = \E(Y)
\end{cases}
\]
which holds for $\E(X) = \E(Y) = 0$ only.
One may notice that $\E(X)$ may not exist at all,
but we derive later the exact distribution of $X$.

Likewise, $\Var(X) = \Var(Y)$ and it follows from the assumption (3)
that $\Var(X) = \Var(Y) = 1$.

Next, we introduce the angle between $V$ and the horizontal axis $U$ and
the length of the velocity vector $R = \sqrt{X^2 + Y^2}$.
Obviously, $X = R \cos U$ and $Y = R \sin U$.
Note that since the joint distribution of $X$ and $Y$ depends only on
the length of vector $V$ the distribution function of $U$ can only be constant,
thus variable $U$ is uniform on the interval $(0, 2\pi)$.

Applying assumption (1) again, we conclude that the joint distribution function
can be written as a function of the length of the velocity vector, or equivalently
of the length squared:
\[
f(x,y) = h(x^2 + y^2).
\]
By the assumption (2), orthogonal components of $V$ are independent.
Hence, the joint PMF can be decomposed to the product of marginal ones:
\[
f(x,y) = f(x)f(y) = g(x^2)g(y^2)
\]
where the latter equality was written for convenience.
Putting everything together, we obtain
\[
h(x^2 + y^2) = g(x^2)g(y^2).
\]
Next, we take the derivative of both sides with respect to $y^2$ and
then substitute $y^2 = 0$ to get a constant $k$:
\begin{align*}
h'(x^2 + y^2) &= g(x^2)g'(y^2) \\
h'(x^2) &= g(x^2)g'(0) \\
h'(x^2) &= k \cdot g(x^2)
\end{align*}

\marginnote{
In order to obtain $k$ we computed
\begin{align*}
\E(X^2) &= \int_{-\infty}^{\infty} x^2 \sqrt{c} e^{kx^2} dx \\
&= \left. x \cdot \sqrt{c} e^{kx^2} \cdot \frac{k}{2} \right|_{-\infty}^{\infty} - \int_{-\infty}^{\infty} \sqrt{c} e^{kx^2} \cdot \frac{1}{2k} dx \\
&= - \frac{1}{2k} \int_{-\infty}^{\infty} \sqrt{c} e^{kx^2} \\
&= - \frac{1}{2k} \cdot 1 \\
&= 1.
\end{align*}
}

Solving the differential equation, we obtain
\[
h(x^2) = c e^{kx^2}, \quad c \in \mathbb{R}.
\]
So the joint PMF can be written as follows:
\[
f(x,y) = h(x^2 + y^2) = c e^{k(x^2+y^2)}
\]
and due to independece of $X$ and $Y$ the PMF of $X$ is
\[
f(x) = \sqrt{c} e^{kx^2}.
\]

\marginnote{
In order to obtain $c$ we computed:
\begin{align*}
\int_{-\infty}^{\infty} \int_{-\infty}^{\infty} e^{-\frac{x^2 + y^2}{2}} dx dy &= \int_{0}^{2\pi} \int_{0}^{\infty} e^{-\frac{r^2}{2}}r dr d\theta \\
&= \int_{0}^{2\pi} \left(\int_{0}^{\infty} e^{-u} du \right) d\theta \\
&= \int_{0}^{2\pi} 1 d\theta \\
&= 2 \pi.
\end{align*}
}

In order to find the constant $k$, we need to solve $\E(X^2) = 1$.
Computing the integral we obtain $k=-\frac{1}{2}$.

Finally, we need to normalize $f(x, y) = c e^{-\frac{x^2 + y^2}{2}}$ so as to
obtain $c$. Again, computing another integral,
we conclude that $c=(2\pi)^{-1}$ which finishes the proof.

Without assumption (3) variables $X$ and $Y$ are normal $\mathcal{N}(0, \sigma^2)$.
\end{proof}

Notice, that any other $\mathcal{N}(\mu, \sigma^2)$ can be obtained by applying
location-scale transformations.

The theorem can be generalized to the $n$-dimensional case.
\begin{theorem}\label{th:mvn}
The vector $z = \begin{pmatrix} z_1 \\ \vdots \\ z_n \end{pmatrix}$
follows the standard multivariate normal distribution and its components
are independent if and only if
\begin{enumerate}
  \item the function $f(z)$ depends on $\lVert z \rVert$ only,
  \item the projections of vector $z$ onto the orthogonal subspaces $A$ and $B$
  in $\mathbb{R}^n$ are independent.
\end{enumerate}
\end{theorem}

\subsection{Chi-squared}

\marginnote{
\begin{definition}\label{def:chi_traditional}
Let $z_i \stackrel{iid}{\sim} \mathcal{N}(0,1)$.
Then $Q$ follows the chi-squared distribution with $k$ degrees of freedom
if it can be written as
\[
Q = z_1^2 + z_2^2 + \ldots + z_k^2.
\]
\end{definition}

This definition is a particular case of the geometric one.
Consider projecting a vector $z = (z_1, z_2, \ldots, z_n)$ form $\mathbb{R}^n$
onto the~$k$-dimensional subspace $S$ of vectors which first $k$ coordinates
are arbitrary and all the rest are zeros. As a result we would get
\[
\hat z = (z_1, z_2, \ldots, z_k, 0, \ldots, 0).
\]
Squaring the length of the projection, we obtain
\[
Q = \lVert \hat z \rVert = z_1^2 + z_2^2 + \ldots + z_k^2.
\]
}

\begin{definition}\label{th:chi}
Consider a random vector $z \in \mathbb{R}^n$ which components are independent
and follow standard normal distribution, $z_i \sim \mathcal{N}(0,1)$.
Consider also a $k$-dimensional subspace $L$ in $\mathbb{R}^n$.
Let the projection of vector $z$ onto the subspace $L$ be $\hat z$ and
its length squared $Q$
\[
Q = \lVert \hat z \rVert^2 = \langle \hat z, \hat z \rangle = \hat z^T \hat z
\]
Then $Q$ follows the chi-squared distribution with $k$ degrees of freedom.
\end{definition}

\begin{theorem}
The definitions~\ref{def:chi_traditional} and \ref{th:chi} are equivalent.
\end{theorem}

\begin{proof}
First, it can be shown that the~projected vector $\hat z$ is the~original vector $z$
multiplied by the~projection matrix $H = X(X^T X)^{-1}X^T$ where the columns of $X$
are fixed linearly independent vectors $x_1, \ldots, x_k$ in $L$
or equivalently $\col X = \Lin(x_1, \ldots, x_k)$.
This matrix is  also often referred to as `hat-matrix'.
Then the statement in~the~theorem can be rewritten as follows:
\[
\hat z^T \hat z = (Hz)^T Hz = z^T H^T H z = z^T H^2 z = z^T H z,
\]
applying the idempotence property in the last step.

Another nice property of~the~hat-mattix is symmetry.
Thus, it can be decomposed as
\[
H = P D P^T,
\]
where we choose the vectors of matrix $P$ to be unit and orthogonal,
and $D = \diag{(\lambda_1, \ldots, \lambda_n)}$ where $\lambda_i$ is an eigenvalue of $H$.

\begin{marginfigure}
  \includegraphics[width=\linewidth]{figures/04_chi_squared_example.pdf}
  \caption{Consider a $3$-dimensional example, $\col X = \Lin(x_1, x_2)$ and $col^{\perp}X = \Lin(x_3)$.
  $H x_1 = x_1$ and $H x_2 = x_2$ since they are in $\col X$. However, $H x_3 = 0$ as $x_3 \perp \col X$.
  Projecting an arbitrary vector onto $\col X$ yileds $Hy = \hat y \in \Lin(x_1, x_2)$
  while projecting onto $\col^{\perp}X$ results in $(I-H)y = \hat{\hat y} \in \Lin(x_3)$.}
\end{marginfigure}

Since $H^2 = H$ the eigenvalues are either $0$ or $1$.
Recall that $H$ projects a vector onto $\col X$.
Then for any $x_i$, $i = 1, \ldots, k$, $H x_i = x_i \cdot 1$ since
any $x_i$ is already in $\col X$. This implies that $\lambda_1 = \ldots = \lambda_k = 1$.
There are also $n-k$ vectors in the subspace orthogonal to $\col X$.
So for any $x_i$, $i= k+1, \ldots, n$, the orthogonal projection yields zero.
We conclude that $\lambda_{k+1} = \ldots = \lambda_n = 0$.

Rewritting the theorem statement further, we obtain
\[
z^T H z = z^T P D P^T z = (P^T z)^T D (P^T z) = \tilde z^T D \tilde z = \tilde z_1^2 + \ldots + \tilde z_k^2.
\]
Now we explore $\tilde z$ given $z \sim \mathcal{N}(0, I)$:
\begin{align*}
&\tilde z = P^T z \\
&\E(\tilde z) = \E(P^T z) = P^T \E(z) = 0 \\
&\Var(\tilde z) = \Var(P^T z) = P^T \Var(z) (P^T)^T = P^T P = I
\end{align*}
So we conclude that $\tilde z_1^2 + \ldots + \tilde z_k^2 \sim \chi^2_k$.

\end{proof}

\subsection{Student's}

\marginnote{
A continuous random variable $T$ has Student's distribution with $k$ degrees
of freedom if it can be expressed as
\[
T = \frac{Z}{\gamma_k/\sqrt{k}},
\]
where $Z \sim \mathcal{N}(0,1)$, $\gamma_k \sim \chi^2_{k}$ and
$Z$, $\gamma_k$ are independent.
}

\begin{definition}
Let  $z = \begin{pmatrix} z_1 \\ \vdots \\ z_n \end{pmatrix}$
where $z_i \sim \mathcal{N}(0, \sigma^2), i=1, \ldots, n$ and are independent.
Let $L_1$ be 1-dimensional subspace in $\mathbb{R}^{n}$,
generated by unit-length vector $a$, $L_1 = \Lin(a)$.
Let $L_2$ be a subspace orthogonal to $L_1$.
Let $T$ be a scaled ratio of lengths:
\[
T = \frac{\langle a, z \rangle}{\lVert H_2 z \rVert / \sqrt{\dim L_2}}
\]
where $\langle a, x \rangle$ is the length of the projection of vector $z$ onto
1-dimensional subspace $L_1$ multiplied by plus or minus one,
$\lVert H_2 z \rVert$ — the length of the projection of vector $z$ onto $L_2$,
Then $T$ follows Student's distribution with $\dim L_2$ degrees of freedom.
\end{definition}

% Let us choose two orthogonal subspaces: one-dimensional $L_1$ and $k$-dimensional $L_2$.

Previously we showed that, the squared length of projection follows
the chi-squared distribution with the degrees of freedom equal to the dimension
onto which the vector was projected. Thus, $\langle a, z \rangle^2 = \lVert H_1 z \rVert^2 \sim \chi^2_1$
and $\lVert H_2 z \rVert^2 \sim \chi^2_{k}$.
Now we can express $T^2$ as a ratio of the per-dimension lengths squared:
\[
T^2 = \frac{\lVert H_1 z \rVert^2}{\lVert H_2 z \rVert^2 / \dim L_2}
\]
Taking the square root of both sides, we obtain:
\[
T = \frac{\langle a, z \rangle}{\lVert H_2 z \rVert / \sqrt{\dim L_2}} = \tg \varphi \sqrt{\dim L_2}
\]
The latter equality can be illustarted with a $3$-dimensional example (see Figure~\ref{fig:f_dist}).

\subsection{t-test}

In a simple linear regression model
\[
y = \beta_1 \mathbf{1} + \beta_2 x + \varepsilon
\]
the adjusted t-value $\frac{t}{\sqrt{n-2}}$ when $H_0: \beta_2 = 0$ is tested
can be expressed in terms of the angle between $y$ and $\hat y$ $\varphi$ and
is equal to $\ctg \varphi$.

Recall that the t-statistic is defined in the following way:
\[
t = \frac{\hat \beta - \beta}{se\left(\hat\beta\right)}
\]
Adjusting this formula for the null hypothesis $H_0: \beta_2 = 0$, we obtain
\begin{equation}\label{eq:tstat}
t = \frac{\hat \beta_2}{se\left(\hat\beta_2\right)}
\end{equation}
Then, we need to express $se\left(\hat\beta_2\right)$ in terms of vectors which can be
plotted. From standard OLS procedure it follows that
\begin{equation}\label{eq:varbeta2}
\Var(\hat \beta_2) = \frac{\sigma^2}{\sum\limits_{i=1}^n (x_i - \bar x)^2}
\end{equation}
Since actual $\sigma$ is unknown the estimator will be used instead:
\begin{equation}\label{eq:sigmaest}
\hat \sigma^2 = \frac{RSS}{n-2}
\end{equation}
Substituting \eqref{eq:varbeta2} and \eqref{eq:sigmaest} into \eqref{eq:tstat}
divided by $\sqrt{n-2}$, we obtain
\begin{align*}
\frac{t}{\sqrt{n-2}} &=
\frac{\hat \beta_2}{\sqrt{n-2}se\left(\hat\beta_2\right)} =
\frac{\hat \beta_2}{\sqrt{n-2}\frac{\hat \sigma}{\sqrt{\sum\limits_{i=1}^n (x_i - \bar x)^2}}} \\
&= \frac{\hat \beta_2 \sqrt{\sum\limits_{i=1}^n (x_i - \bar x)^2}}{\sqrt{n-2}\frac{\sqrt{\sum\limits_{i=1}^n (y_i - \hat y_i)^2}}{\sqrt{n-2}}} =
\frac{\hat \beta_2 \lVert x^c \rVert}{\sqrt{RSS}}
\end{align*}
where $ \lVert x^c \rVert = \sqrt{\sum_{i=1}^n (x_i - \bar x)^2}$ is the length of the
centred vector $x$.

Now the result can be demonstrated visually.
Again we will project $x$ and $y$ vectors onto the $\Lin^{\perp}(\mathbf{1})$ so as to
get their centred versions $x^c$ and $y^c$.
Then, we perform regression of $y$ onto $\Lin(x, \mathbf{1})$ which results in $\hat y$.
Following that, we project $\hat y = \hat \beta_1 \mathbf{1} + \hat \beta_2 x$ onto $\Lin^{\perp}(\mathbf{1})$
which yields $\hat \beta_2 x^c$.
After all, we translate $\sqrt{RSS}$ onto $\Lin^{\perp}(\mathbf{1})$.
These steps are demonstrated in Figure~\ref{fig:ttest_3d}.

Looking at Figure~\ref{fig:ttest_lin} which depicts the $\Lin^{\perp}(\mathbf{1})$,
we derive
\[
\ctg \varphi = \frac{\hat \beta_2 \lVert x^c \rVert}{\sqrt{RSS}} = \frac{t}{\sqrt{n-2}}
\]

\begin{figure}[ht!]
\begin{center}
\subfigure[]{
\includegraphics[width=0.45\linewidth]{figures/04_ttest.pdf}
\label{fig:ttest_3d}}
%\hspace{4ex}
\subfigure[]{
\includegraphics[width=0.45\linewidth]{figures/04_ttest_lin.pdf}
\label{fig:ttest_lin}}
\caption{\subref{fig:pcorr_t_x}: Regression of $y$ onto $\Lin(x, \mathbf{1})$ and appropriate projections;
\subref{fig:pcorr_t_y}: $\Lin^{\perp}(\mathbf{1})$.}
\end{center}
\end{figure}

\subsection{F-distribution}

\marginnote{
Generally, the following definition is given.
\begin{definition}
Let $\gamma_1 \sim \chi^2_{k_1}$, $\gamma_2 \sim \chi^2_{k_2}$,
$\gamma_1$, $\gamma_2$ independent.
Then
\[
\frac{\gamma_1/k_1}{\gamma_2/k_2} \sim F_{k_1, k_2}.
\]
\end{definition}
}

\begin{definition}\label{def:f}
Let $z = \begin{pmatrix} z_1 \\ \vdots \\ z_n \end{pmatrix}$
where $z_i \sim \mathcal{N}(0, \sigma^2)$ and are independent.
Let $L_1$, $L_2$ be orthogonal subspaces in $\mathbb{R}^n$.
Then
\[
F = \frac{\lVert H_1 z \rVert^2 / \dim L_1}{\lVert H_2 z \rVert^2 / \dim L_2} \sim F_{\dim L_1, \dim L_2},
\]
where $\lVert H_1 z \rVert^2$, $\lVert H_2 z \rVert^2$ are the squared lengths
of $z$ projected onto $L_1$ and $L_2$ respectively.
\end{definition}

Recall that by Theorem~\ref{th:mvn} the projections of a standard noraml vector
onto orthogonal subspaces are independent.
Thus, in terms of the Definition~\ref{def:f} $H_1 z$ and $H_2 z$ are independent.
Next, from the Definition~\ref{th:chi} where we defined the chi-squared distribution
it follows that the squared lengths of these projections follow
the chi-squared distribution with the number of degrees of freedom
equal to the dimension of the subspace onto which the vector was projected.
In other words, $\lVert H_1 z \rVert^2 \sim \chi^2_{\dim L_1}$,
$\lVert H_2 z \rVert^2 \sim \chi^2_{\dim L_2}$.

\begin{marginfigure}
\includegraphics[scale=0.7]{figures/04_f_dist_example.pdf}
\caption{F-distribution as the ratio of the projection lengths squared
adjusted to the dimensions of the subspaces.}
\label{fig:f_dist}
\end{marginfigure}

Taking the ratio of these length squared, we get the interpretaion
of the angle between the original vector $z$ and its projection onto $L_1$:
\[
\tg^2 \varphi = \frac{\lVert H_1 z \rVert^2}{\lVert H_2 z \rVert^2}.
\]
Adjusting this ratio to the degrees of freedom, we get the desired definition.

\subsection{F-test}

The significance of several coefficients at once can be tested with the F-test.
The F-statistic has the following form
\[
F = \frac{(RSS_{R} - RSS_{UR})/q}{RSS_{UR}/(n-k_{UR})}
\]
where indices $R$ and $UR$ stand for the restricted and unrestricted models
respectively, $n$ — number of observations, $k$ — number of regressors,
$q$ — number of equtions used in the null hypothesis.

\begin{marginfigure}
\includegraphics[scale=0.55]{figures/04_ftest.pdf}
\caption{F-statistic is proportional to the cotangent squared of $\varphi$,
where $a$ stands for $\sqrt{RSS_{UR}}$, $b$ — $\sqrt{RSS_{R} -RSS_{UR}}$,
$c$ — $\sqrt{RSS_{R}}$.}
\label{fig:ftest}
\end{marginfigure}

Due to plotting limitations, we consider the unrestricted model to be
\[
y = \beta_1 \mathbf{1}+ \beta_2 x + u
\]
and the restricted model to be
\[
y = \alpha_1 \mathbf{1} + v
\]
Note that there was a choice in the restricted models.

We perform both regressions in order to get the ressiduals and plot them
in Figure~\ref{fig:ftest}.
Adjusted to the degrees of freedom, the ratio can be expressed in terms of the
angle between two vectors, $\varphi$, as demonstrated in Figure~\ref{fig:ftest}
\[
F = \frac{(RSS_{R} - RSS_{UR})/q}{RSS_{UR}/(n-k_{UR})} =
\ctg^2 \varphi \cdot \frac{n - k_{UR}}{q}
\]


\section{Parameterized Surfaces}
\noindent
Parameterized surfaces are a natural of VVFs that map $\mathbb{R}^n \to \mathbb{R}^m$ where usually $n<m$.\\

\noindent
For example, a cylinder of radius 1 can be parameterized as $\vec{r}(u,v) = \langle\sin{u}, \cos{u}, v\rangle$. This particular surface maps $\mathbb{R}^2 \to \mathbb{R}^3$.\\
The paraboloid $z = x^2 + y^2$ can be parameterized as $\vec{r}(u,v)=\langle u, v, u^2+v^2 \rangle$.\\

\noindent
A general trick when trying to parameterize a surface is to substitute $u$ and $v$ for two variables like $x$ and $y$ and find an expression for the third variable in terms of the $u$ and $v$. Although this doesn’t always lead to the most useful parameterization, it can be a good starting point.\\

\noindent
For example, if we wanted to parameterize the surface $y^2=x^2+z^2$ from $y=1$ to $y=9$, we could use the general trick and get $\vec{r}(u,v) = \langle u,\sqrt{u^2+v^2},v\rangle$ where $1\leq u^2+v^2\leq 9^2$. Although this parameterization is technically correct, it is difficult to work with because the bounds for $u$ and $v$ are not independent.\\
Instead, we can recognize that the surface we are trying to parameterize has radial symmetry about the y-axis, and instead let $u$ be and angle and $v$ be a radius to get $\vec{r}(u,v) = \langle v\cos{u}, v, v\sin{u}\rangle$ where $0\leq u\leq 2\pi$ and $1\leq v\leq 9$. The parameterization now has independent bounds, which will make operations like integration much easier.


\chapter{The Energy Momentum Tensor}
In special relativity we have seen that the energy momentum tensor
$\tensor{T}{^\mu^\nu}$ is conserved or divergence free respectively, i.e.
\begin{equation}
\tensor{\partial}{_\mu}\tensor{T}{^\mu^\nu}=0\,.\label{eq:EMcons}
\end{equation}
The problem we are faced in general relativity is the very definition of local
energy. Because gravity surely contributes to the energy, a problem arises
as we can always transform to local flat space.
We start by revisiting the example of dust
\begin{example}[Dust]
\begin{equation}
\tensor{T}{^\mu^\nu}=\rho_0\tensor{u}{^\mu}\tensor{u}{^\nu}\,.
\end{equation}
In special relativity:
${\tensor{u}{^\mu}=\od{\tensor{x}{^\mu}}{\tau}=\gamma(1,\vec{v})\transpose}$,
${\tensor{T}{^0^0}=\rho_0\left(\od{t}{\tau}\right)^2}=\gamma^2\rho_0:=\rho$.
Where $\rho$ is the density with respect to an observer at rest. For the Volume
we have $V=\gamma^{-1}V_0$. For the Energy $E=\gamma\omega_0$. Then the density
is given by $\rho=\frac{E}{V}=\gamma^2\rho_0$. The conservation of
$\tensor{T}{^0^\nu}$ implies
\begin{equation}
\begin{split}
0&=\tensor{T}{^0^\nu_{,\nu}}\\
&=\tensor{T}{^0^0_{,0}}+\tensor{T}{^0^i_{,i}}\\
&=\tensor{\partial}{_t}\left(\rho_0\gamma^2\right)
+\tensor{\partial}{_i}\left(\rho_0\gamma^2\tensor{v}{^i}\right)\\
&=\tensor{\partial}{_t}\rho
+\tensor{\partial}{_i}\left(\rho \tensor{v}{^i}\right)\\
&=\dot{\rho}
+\boldsymbol{\nabla}\left(\rho \vec{v}\right)\,,
\end{split}
\end{equation}
the \emph{continuity equation}. For the remaining spatial components we get
\begin{equation}
\begin{split}
0&=\tensor{T}{^i^\nu_{,\nu}}\\
&=\tensor{T}{^i^0_{,0}}+\tensor{T}{^j^i_{,i}}\\
&=\dot{\rho}\tensor{v}{^i}
+\rho\tensor{\dot{v}}{^i}
+\tensor{v}{^i}\tensor{\partial}{_j}\left(\rho\tensor{v}{^j}\right)
+\tensor{\dot{v}}{^j}\rho\tensor{\partial}{_j}\tensor{v}{^i}\\
&=\tensor{v}{^i}\left[\dot{\rho}+\tensor{\partial}{_j}\left(\rho\tensor{\dot{v}}{^j}\right)\right]
+\rho\left(\tensor{\dot{v}}{^i}+\tensor{\dot{v}}{^j}\tensor{\partial}{_j}\tensor{v}{^i}\right)\\
&=\rho\left(\tensor{\dot{v}}{^i}+\tensor{\dot{v}}{^j}\tensor{\partial}{_j}\tensor{v}{^i}\right)\,,
\end{split}
\end{equation}
the \emph{Euler equation} for vanishing pressure (which was the key assumption
for dust). It is natural to generalize equation \eqref{eq:EMcons} to curved
space
\begin{equation}
\tensor{T}{^\mu^\nu_{;\nu}}=0\,.
\end{equation}
In expanded form
\begin{equation}
\begin{split}
0
&=\tensor{\nabla}{_\nu}\left(\rho_0\tensor{u}{^\mu}\tensor{u}{^\nu}\right)\\
&=\tensor{{\rho_0}}{_{;\nu}}\tensor{u}{^\mu}\tensor{u}{^\nu}
+\rho_0\tensor{u}{^\mu_{;\nu}}\tensor{u}{^\nu}
+\rho_0\tensor{u}{^\mu}\tensor{u}{^\nu_{;\nu}}\\
&=\tensor{u}{^\mu}\left(\rho_0\tensor{u}{^\nu_{;\nu}}+\tensor{{\rho_0}}{_{;\nu}}\tensor{u}{^\nu}\right)
+\rho_0\tensor{u}{^\mu_{;\nu}}\tensor{u}{^\nu} \label{eq:DustEnCons}
\end{split}
\end{equation}
We multiply both sides with $\tensor{u}{_\mu}$
\begin{equation}
\begin{split}
0
&=-\left(\rho_0\tensor{u}{^\nu_{;\nu}}+\tensor{{\rho_0}}{_{;\nu}}\tensor{u}{^\nu}\right)
+\rho_0\tensor{u}{^\nu}\tensor{u}{_\mu}\tensor{u}{^\mu_{;\nu}}\\
&=-\left(\rho_0\tensor{u}{^\nu_{;\nu}}
+\tensor{{\rho_0}}{_{;\nu}}\tensor{u}{^\nu}\right)
\end{split}
\end{equation}
If we plugg this back into equation \eqref{eq:DustEnCons} we get
\begin{equation}
\begin{split}
0&=\tensor{u}{^\nu}\tensor{\nabla}{_\nu}\tensor{u}{^\mu}\\
&=\tensor{u}{^\nu}\tensor{\partial}{_\nu}\tensor{u}{^\mu}
+\tensor{u}{^\nu}\cSym{\mu}{\nu}{\rho}\tensor{u}{^\rho}\\
&=\dod{\tensor{x}{^\nu}}{\tau}\dpd{\tensor{u}{^\mu}}{\tensor{x}{^\nu}}
+\cSym{\mu}{\nu}{\rho}\dod{\tensor{x}{^\nu}}{\tau}\dod{\tensor{x}{^\nu}}{\tau}\\
&=\dpd[2]{\tensor{x}{^\mu}}{\tau}
+\cSym{\mu}{\nu}{\rho}\dod{\tensor{x}{^\nu}}{\nu}\dod{\tensor{x}{^\nu}}{\tau}\\
\end{split}
\end{equation}
The geodesic equation \eqref{eq:geodeq}
\end{example}
\begin{remark}
This is a difference between electrodynamics and general relativity; dust moves
on geodesics, i.e.\ the path is determined by the field equations alone. In contrast
in electrodynamics an additional Force (Lorentz force) has to be
\emph{postulated} to describe the motion of test particles. The case is not
settled however e.g.\ it is unclear whether the paths of spin particles is also
determined by the field equations.
\end{remark}


\section*{Exercises}

\begin{ex}
  Solve each of the following systems of equations with scalars in
  $\Z_2$. If there is more than one solution, write the
  general solution in parametric form and also write down all of the
  solutions individually. How many solutions are there?

  \begin{equation*}
    (a)~
    \begin{mymatrix}{rrrr|r}
      0 & 1 & 1 & 1 & 0 \\
      1 & 0 & 0 & 1 & 1 \\
      1 & 1 & 1 & 0 & 1
    \end{mymatrix}
    \quad
    (b)~
    \begin{mymatrix}{rrr|r}
      0 & 1 & 1 & 1 \\
      1 & 0 & 1 & 1 \\
      1 & 1 & 0 & 1
    \end{mymatrix}
    \quad
    (c)~
    \begin{mymatrix}{rrrr|r}
      0 & 1 & 1 & 0 & 1 \\
      1 & 0 & 1 & 0 & 0 \\
      1 & 1 & 0 & 1 & 0
    \end{mymatrix}
    \quad
    (d)~
    \begin{mymatrix}{rrr|r}
      0 & 1 & 1 & 1 \\
      1 & 0 & 1 & 1 \\
      1 & 1 & 1 & 0
    \end{mymatrix}
  \end{equation*}
\end{ex}

\begin{ex}
  Solve each of the following systems of equations with scalars in
  $\Z_3$. How many solutions does each system have?

  \begin{equation*}
    (a)~
    \begin{mymatrix}{rrr|r}
      0 & 1 & 1 & 1 \\
      1 & 2 & 0 & 1 \\
      2 & 0 & 2 & 1
    \end{mymatrix}
    \quad
    (b)~
    \begin{mymatrix}{rrrr|r}
      2 & 1 & 2 & 1 & 0 \\
      0 & 2 & 1 & 1 & 2 \\
      1 & 0 & 0 & 1 & 1
    \end{mymatrix}
    \quad
    (c)~
    \begin{mymatrix}{rrr|r}
      1 & 2 & 0 & 2 \\
      1 & 0 & 1 & 1 \\
      1 & 1 & 1 & 0
    \end{mymatrix}
  \end{equation*}
\end{ex}

\begin{ex}
  Solve each of the following systems of equations with scalars in
  $\Z_5$.

  \begin{equation*}
    (a)~
    \begin{mymatrix}{rrrr|r}
      0 & 2 & 1 & 4 & 0 \\
      1 & 1 & 2 & 3 & 2 \\
      2 & 4 & 0 & 0 & 4
    \end{mymatrix}
    \quad
    (b)~
    \begin{mymatrix}{rrr|r}
      1 & 2 & 4 & 1 \\
      3 & 0 & 1 & 1 \\
      2 & 4 & 3 & 2
    \end{mymatrix}
  \end{equation*}
\end{ex}

\begin{ex}
  In $\Z_7$, calculate $1^{-1}$, $2^{-1}$, $3^{-1}$, $4^{-1}$,
  $5^{-1}$, and $6^{-1}$. Hint: write down the multiplication table.
\end{ex}

\begin{ex}
  Consider a game similar to Example~\ref{exa:button-game}, with 6
  lights arranged in a rectangle:
  \begin{center}
    \begin{tabular}{|c|c|c|}
      \hline
      \rule{0ex}{8.5mm}\includegraphics[width=7mm]{figures/lighton} &
      \rule{0ex}{8.5mm}\includegraphics[width=7mm]{figures/lighton} &
      \rule{0ex}{8.5mm}\includegraphics[width=7mm]{figures/lightoff} \\\hline
      \rule{0ex}{8.5mm}\includegraphics[width=7mm]{figures/lightoff} &
      \rule{0ex}{8.5mm}\includegraphics[width=7mm]{figures/lightoff} &
      \rule{0ex}{8.5mm}\includegraphics[width=7mm]{figures/lighton} \\\hline
    \end{tabular}
  \end{center}
  Again, each light doubles as a button. Pressing it toggles its own
  light, as well as all of its neighbors. Which buttons do you have to
  press to turn off all the light from the starting position shown
  above? Is the answer unique? Is every pattern of lights reachable
  from this starting position?
\end{ex}

\begin{ex}
  Solve each of the following systems of equations with scalars in the
  complex numbers.
  \begin{equation*}
    (a)~
    \begin{mymatrix}{ccc|c}
      1   & 1   & 1+i & 2    \\
      1+i & 2+i & 3i  & 3+2i \\
    \end{mymatrix}
    \quad
    (b)~
    \begin{mymatrix}{ccc|c}
      1   & i    & 1+i & -1+2i \\
      1+i & 2    & 1-i & 4+4i  \\
      1   & -1+i & -i  & 0     \\
    \end{mymatrix}
  \end{equation*}

  \begin{sol}
    \begin{enumerate}
    \item {\Rref}: $\begin{mymatrix}{ccc|c}
      1 & 0 & 1 & 1 \\
      0 & 1 & i & 1 \\
    \end{mymatrix}$. General solution: $x=1-t$, $y=1-it$, $z=t$.
    \item Solution: $x=1$, $y=1+i$, $z=i$.
  \end{enumerate}
  \end{sol}
\end{ex}