\documentclass[12pt]{article}
\usepackage{amsfonts}
\usepackage{bm}

% bold math italic font
\newcommand{\mbf}[1]{\mbox{\boldmath $#1$}}

% symbol used for sqrt(-1)
\newcommand{\Ci}{{\rm i}}

\newcommand{\C}{\mathbb{C}}
\newcommand{\R}{\mathbb{R}}

\newcommand{\var}{\rm Var}
\newcommand{\trace}{\rm Tr}

\newcommand{\code}[1]{{\tt{#1}}}

\newcommand{\rotation}[3]{{\ensuremath{ {\bf R}^{#3}_{#1}({#2}) }}}

\newcommand{\boost}[1][1]{{\ensuremath{ {\bf B}_{\bm{\hat {#1}}}(\gamma) }}}
\newcommand{\rotat}[1][1]{{\ensuremath{ {\bf R}_{\bm{\hat {#1}}}(\phi) }}}

\newcommand{\pauli}[1]{\ensuremath{ {\bm\sigma}_{\rm #1} }}
\newcommand{\para}[1][ ]{\ensuremath{ {\Phi}_{{\rm PA}{#1}} }}

\newcommand{\model}[1][ ]{\ensuremath{{\bm\rho}_j({{\bf T}_{#1}};{\mbf{a}}) }}
\newcommand{\obs}{\ensuremath{ {\bm\rho}_{j,i} }}

\begin{document}

\noindent
\large
{\sc psrchive} Implementation Notes \\ [2mm]
\normalsize
Willem van Straten \\
7 October 2013

\section*{Basis-independent Ideal Feed Assumption}

This document defines the equations used to derive the
polarimetric response based on the ideal feed assumption
(implemented by the {\tt SingleAxisSolver} class
in {\sc psrchive}).
%
In the ideal feed approximation to calibration, it is assumed that the
Jones matrix has the form
%
\[
{\bf J}=\left( \begin{array}{cc}
z_0 & 0 \\
0 & z_1
\end{array}\right)
\]
%
where $z_0$ and $z_1$ are the complex gains applied to each receptor.
%
This Jones matrix may be represented using its polar decomposition,
\[
{\bf J} = J \; \boost \rotat
\]
where $J=(\det{\bf J})^{1/2}$, \boost\ is a Hermitian matrix (or boost
transformation) and \rotat\ is a unitary matrix (or rotation
transformation).  Note that both the boost and rotation are parameterized
by a single unit vector, $\bm{\hat 1}$ (the {\it single axis}).
%
The absolute phase of the signal is lost during detection; therefore,
the phase of the complex-valued $J$ may be arbitrarily chosen, and $J$
may be replaced by the real-valued gain, $G=|J|$.  The instrumental
response is then completely described by the absolute gain $G$,
differential gain $\gamma$, and differential phase $\phi$.

The boost transformation affects only the total intensity and the
component of the polarization vector that is parallel to $\bm{\hat 1}$,
leaving the component of the polarized flux that is perpendicular to
$\bm{\hat 1}$ unchanged.  Conversely, the rotation transformation
affects only the polarized flux perpendicular to $\bm{\hat 1}$, leaving
the component that is parallel to $\bm{\hat 1}$ and the total intensity
unchanged.

In principle, any set of input and output Stokes parameters can be
used to measure the ideal feed parameters, so long as there is
sufficient polarization perpendicular to $\bm{\hat 1}$ to constrain
the differential phase.  In practise, a 100\% linearly polarized signal is
generated using a noise diode that is coupled such that it induces an
in-phase response with equal amplitude in each receptor; see the
discussion of {\bf Calibrator Phase} in van Straten et al. (2010; PASA
27, 104) for more details.

\subsection*{Derivation of Solution}

Let $S=[S_0,\bm{S}]$ represent the expected (or input) Stokes
parameters of a known calibrator source and
$S^\prime=[S_0^\prime,\bm{S}^\prime]$ represent the observed (or
output) Stokes parameters.  It is useful to decompose both
polarization vectors into their components parallel and perpendicular
to the primary (single) axis; e.g.
\[
\bm{S_\parallel} = (\bm{S \cdot \hat 1}) \bm{\hat 1} = S_1\bm{\hat 1}
\]
\[
\bm{S_\perp} = \bm{S} - \bm{S_1} = S_2\bm{\hat 2} + S_3\bm{\hat 3}
\]
%
Then the cosine and sine of the angle of rotation about $\bm{\hat 1}$ between input and output
states are given by
%
\[
\bm{S_\perp \cdot S_\perp^\prime} = |\bm{S_\perp}| |\bm{S_\perp^\prime}| \cos2\phi
\]
\[
(\bm{S_\perp \times S_\perp^\prime}) \bm{\cdot \hat 1} = |\bm{S_\perp}| |\bm{S_\perp^\prime}| \sin2\phi
\]
such that
\begin{equation}
\tan2\phi = { {S_2 S_3^\prime - S_3 S_2^\prime} \over S_2 S_2^\prime + S_3 S_3^\prime  }
\end{equation}
Transformation by $G$\boost\ results in
\begin{eqnarray*}
S_0^\prime = G^2 \left( S_0 \cosh2\gamma + S_1 \sinh2\gamma \right) \\
S_1^\prime = G^2 \left( S_0 \sinh2\gamma + S_1 \cosh2\gamma \right)
\end{eqnarray*}
from which it is trivial to derive
\begin{equation}
\tanh2\gamma = { {S_0 S_1^\prime - S_1 S_0^\prime} \over S_0 S_0^\prime - S_1 S_1^\prime  }
\end{equation}
and
\begin{equation}
G^2 = { {S_0^\prime S_0^\prime - S_1^\prime S_1^\prime} \over S_0 S_0 - S_1 S_1 }
\end{equation}
\end{document}


% This LaTeX was auto-generated from an M-file by MATLAB.
% To make changes, update the M-file and republish this document.

\subsection*{draw\_dp.m}

\begin{par}
\textbf{Summary:} Draw the double-pendulum system with reward, applied torques, and predictive uncertainty of the tips of the pendulums
\end{par} \vspace{1em}

\begin{verbatim}  function draw_dp(theta1, theta2, f1, f2, cost, text1, text2, M, S)\end{verbatim}
    \begin{par}
\textbf{Input arguments:}
\end{par} \vspace{1em}
\begin{verbatim}theta1     angle of inner pendulum
theta2     angle of outer pendulum
f1         torque applied to inner pendulum
f2         torque applied to outer pendulum
cost       cost structure
  .fcn     function handle (it is assumed to use saturating cost)
  .\ensuremath{<}\ensuremath{>}      other fields that are passed to cost
text1      (optional) text field 1
text2      (optional) text field 2
M          (optional) mean of state
S          (optional) covariance of state\end{verbatim}
\begin{par}
Copyright (C) 2008-2013 by Marc Deisenroth, Andrew McHutchon, Joe Hall, and Carl Edward Rasmussen.
\end{par} \vspace{1em}
\begin{par}
Last modified: 2013-03-07
\end{par} \vspace{1em}

\begin{lstlisting}
function draw_dp(theta1, theta2, f1, f2, cost, text1, text2, M, S)
\end{lstlisting}

\subsection*{Code}

\begin{lstlisting}
l = 0.6;
xmin = -2*l;
xmax = 2*l;
umax = 2;
height = 0;

% Draw double pendulum
clf; hold on
sth1 = sin(theta1); sth2 = sin(theta2);
cth1 = cos(theta1); cth2 = cos(theta2);
pendulum1 = [0, 0; -l*sth1, l*cth1];
pendulum2 = [-l*sth1, l*cth1; -l*(sth1-sth2), l*(cth1+cth2)];
plot(pendulum1(:,1), pendulum1(:,2),'r','linewidth',4)
plot(pendulum2(:,1), pendulum2(:,2),'r','linewidth',4)

% plot target location
plot(0,2*l,'k+','MarkerSize',20);
plot([xmin, xmax], [-height, -height],'k','linewidth',2)
% plot inner joint
plot(0,0,'k.','markersize',24)
plot(0,0,'y.','markersize',14)
% plot outer joint
plot(-l*sth1, l*cth1,'k.','markersize',24)
plot(-l*sth1, l*cth1,'y.','markersize',14)
% plot tip of outer joint
plot(-l*(sth1-sth2), l*(cth1+cth2),'k.','markersize',24)
plot(-l*(sth1-sth2), l*(cth1+cth2),'y.','markersize',14)
plot(0,-2*l,'.w','markersize',0.005)

% % Draw sample positions of the joints
% if nargin > 7
%   samples = gaussian(M,S+1e-8*eye(4),1000);
%   t1 = samples(3,:); t2 = samples(4,:);
%   plot(-l*sin(t1),l*cos(t1),'b.','markersize',2)
%   plot(-l*(sin(t1)-sin(t2)),l*(cos(t1)+cos(t2)),'r.','markersize',2)
% end

% plot ellipses around tips of pendulums (if M, S exist)
try
  if max(max(S))>0
    [M1 S1 M2 S2] = getPlotDistr_dp(M, S, l, l);
    error_ellipse(S1,M1,'style','b'); % inner pendulum
    error_ellipse(S2,M2,'style','r'); % outer pendulum
  end
catch

end

% Show other useful information
% plot applied torques
plot([0 f1/umax*xmax],[-0.3, -0.3],'g','linewidth',10)
plot([0 f2/umax*xmax],[-0.5, -0.5],'g','linewidth',10)
% plot reward
reward = 1-cost.fcn(cost,[0, 0, theta1, theta2]',zeros(4));
plot([0 reward*xmax],[-0.7, -0.7],'y','linewidth',10)
text(0,-0.3,'applied  torque (inner joint)')
text(0,-0.5,'applied  torque (outer joint)')
text(0,-0.7,'immediate reward')
if exist('text1','var')
  text(0,-0.9, text1)
end
if exist('text2','var')
  text(0,-1.1, text2)
end

set(gca,'DataAspectRatio',[1 1 1],'XLim',[xmin xmax],'YLim',[-2*l 2*l]);
axis off
drawnow;
\end{lstlisting}


\input{structure.tex}
\usepackage{bm}
\usepackage{braket}
\graphicspath{{6_fig/}}
\title{第六章\ 量子纠缠和量子信息}

\begin{document}

\maketitle

\textbox{Alice's more adventures in the quantum wonderland}{
    Alice continues to find more about her electron friends:
    \tenum{
        \item \label{item:handstand}
        \marginnote{\includegraphics[width=0.35\textwidth]{cat_super_export}\newline Sorry, the above state does not look like an electron. Suppose it is an electron and we will make it clearer later.}
        superposition of a ``standing'' electron and a ``handstand'' electron is a ``lied-down'' electron. The head direction of the lied-down electron depends on the coefficient of the superposition.
        \item \label{item:information-memory}Alice has very good memory. But she finds it a nightmare trying to remember the relations between a handful of electrons.
        \item \label{item:epr}Alice can show that a measurement of an electron light years away can \emph{immediately} affect the electron state around her. But this superluminal ``quantum information'' does not conflict the causality of special relativity.
        \item \label{item:bell}Alice wants to find out the origin of randomness of the quantum world -- is it due to any hidden local objects that she cannot see? Her electron friends are able to falsify this for her.
    }
}

\mtextbox{Why use spin for entanglement?}{
    In principle, we would use the familiar position and momentum for entanglement. However, theoretically, continous states are difficult to deal with. Operationally, position eigenstates spread and momentum eigenstates run away. Thus it is much easier (though still extremely difficult) to construct actual devices with spin about quantum entanglement, as the theoretical basis of quantum information and quantum computing.
}
\textbox{Two approaches to the same quantum mechanics}{
    Quantum mechanics can be learned in two ways:
    \tenum{
        \item By first studying the classically most familiar object. The previous Part corresponds to this approach, focusing on the position and momentum of a particle.
        \item By first studying the simplest quantum object. In this part, we will introduce a feature ``spin'' of a quantum particle, with no classical counterpart.
    }
    \tcblower
    Though these two types of systems appear very different, they follow the same quantum mechanical laws.
}

\section{Spin}\label{sec:spin}

\subsection{The Stern-Gerlach Experiment}

Before stepping into the quantum mechanical world again, let us review a concept which has classical counterpart: the magnetic moment.

\textbox{The magnetic moment\index{magnetic moment}}{
    An object with a magnetic dipole moment (or magnetic moment for short) $\bm{\mu}$ has a magnetic potential energy $U$ when it is put in a magnetic field $\mathbf{B}$\marginnote{Thus, if the magnetic field is inhomogeneous, there is a force acting on the magnetic moment: $\mathbf{F}=-\partial U / \partial \mathbf{r}$.}:
    \begin{align} \label{eq:magnetic-moment}
        U = - \bm{\mu} \cdot \mathbf{B}~.
    \end{align}
    \tcblower
    In our classical world, we are familiar with magnetic moments, and the simplest example is a magnet. A magnetic can be attracted (or repulsed) by another magnetic because of \eqref{eq:magnetic-moment}. Other examples of classical magnetic moment include rotating charges.
}

\textbox{Do atoms have magnetic moment? The Stern-Gerlach experiment\index{Stern-Gerlach experiment}}{
    Let
    \marginnote{\begin{center}
        \includegraphics[width=0.35\textwidth]{sgexp}
    \end{center}}
    us now \emph{measure} the magnetic moment of atoms. Consider a beam of hot silver atoms passing through an \emph{inhomogeneous} magnetic field, and the out-going silver atoms leave records on a screen. (The condition ``hot'' indicates that the atoms in the beam have random orientations.)

    If we use our \emph{classical} experience to imagine the hot beam of silver atoms. What do we expect? We expect that the result on the screen would be one of the following:
    \tenum{
        \item If silver atoms have no magnetic moment: we still have one beam of silver atoms; the external magnetic field has no effect on the beam.
        \item If silver atoms have nonzero classical magnetic moment: Imagine each silver atom is a magnet with random (and continuously variable) orientation. These magnets experience different forces depending on their orientations, and thus in the limit that there are many magnets, the beam will spread in a continous way.
    }
    \tcblower
    What is the \emph{actual} outcome of the Stern-Gerlach experiment?

    One beam splits into two beams with equal strength.

    The split of the beam indicates that a silver atom has a magnetic moment $\bm{\mu}$. However, why the split is discrete, instead of continuous?
}

\textbox{The quantum mechanical interpretation of the Stern-Gerlach experiment}{
    We observe two quantum mechanical aspects of the silver atom from the experiment:
    \tenum{
        \item The magnitude $|\bm{\mu}|$ of the silver atom is quantized and cannot vary continuously.
        \item \label{item:sg-exp-direction}What about the direction $\hat{\bm{\mu}}$? We have two observations:
    }
    \titem{
        \item First, from rotational invariance of the laws of nature, and statistical property of the hot beam, we expect that \emph{before measurement}, i.e. before coming to the external magnetic field, for each silver atom $\bm{\mu}$ should point to random directions.
        \item However, the external magnetic field \emph{measures} the $z$-component of the magnetic moment $\mu_z$ of the atoms, and thus the state of each atom collapses to one of the two eigenstates with eigenvalue $\pm |\bm{\mu}|$, respectively.
    }
    \tcblower
    These explains the Stern-Gerlach experiment.

    Let us now call the two eigenstates of the magnetic moment in the $z$-direction
    \begin{align}
        \ket{\uparrow} \mbox{ with eigenvalue } |\bm{\mu}| \mbox{, and } \ket{\downarrow} \mbox{ with eigenvalue } - |\bm{\mu}| .
    \end{align}
}

\textbox{The other orientations are superpositions of $\ket{\uparrow}$ and $\ket{\downarrow}$}{
    What about states with other orientations, for example the states pointing inward $\ket{\otimes}$, outward $\ket{\odot}$, left $\ket{\leftarrow}$ and right $\ket{\rightarrow}$?

    As discussed above, after measurement along the $z$-direction, they collapse into states $\ket{\uparrow}$ and $\ket{\downarrow}$. They thus should be superpositions of $\ket{\uparrow}$ and $\ket{\downarrow}$.
    \tcblower
    To further confirm this idea, one can string two Stern-Gerlach experiments in a row:
    \tenum{
        \item The first magnetic field is in the $y$-direction.
        \item We put another magnet with magnetic field in the $z$-direction before observing the outcome on the screen.
    }
    The outcome of the experiment is: after passing the first magnet, the beams split into two with $\ket{\otimes}$, outward $\ket{\odot}$ states; and each beam further split into $\ket{\uparrow}$ and $\ket{\downarrow}$ after passing the second magnet. Again, the split beams have equal strength.

}

\textbox{From atoms to electrons}{
    An electron itself also have magnetic moment. However, if we have used an electron in the Stern-Gerlach experiment, the dominate effect will be the Lorentz force and the magnetic moment is too small to observe. In fact, the magnetic moment of the silver atom comes from the magnetic moment of its outermost (5s) electron, thus indeed shows that the electron has magnetic moment.
}

\mtextbox{Nothing is spinning}{
    The name ``spin'' seems misleading: it provides an intuition that the electron is spinning classically, and thus has a magnetic moment (a spinning charged ball indeed has a magnetic moment classically).
    \tcblower
    However, for an electron, the spin is a fundamental and instric feature. The electron just has magnetic moment and angular momentum as an instrinic quantum phenomena, because:
    \mtitem{
        \item No experiment shows the electron is actually rotating.
        \item If one uses a rotating ball to explain spin, the rotation speed on the surface of the ball is faster than light, which is not possible.
    }
}
\textbox{Spin and angular momentum\index{spin}}{
    Further experiments show that the magnetic moment of a quantum particle is related to its angular momentum. For an electron,
    \begin{align}
        \mathbf{L} = \frac{1}{2} \frac{m_e}{(-e)} \bm{\mu}~,
    \end{align}
    where $e$ and $m_e$ are charge and mass of an electron, respectively.
    \tcblower
    For historical reasons, the intrinsic magnetic moment of an electron is called ``spin''. In fact, the term ``spin'' is more general than magnetic moment for fundamental particles. Because neutral particles like photons have intrinsic angular momentum as well, but no magnetic moment.
}

\subsection{The Quantum Mechanics of Spins}

In this subsection, we summarize the quantum properties of the spin system. This is a nice application of the quantum mechanics part, and a foundation for studying entanglement.

\textbox{Basis and some other spin states\index{spin states:basis}}{
    In \marginnote{
        For spin, there are only two ``fundamental'' states $\ket{\uparrow}$ and $\ket{\downarrow}$ (basis in the quantum sense). In classical mechanics there are states pointing to all directions, which are all fundamental and cannot be reduced to each other.
        \mnewline
        The other states, say, $\ket{\rightarrow}$, can be written as a linear superposition of $\ket{\uparrow}$ and $\ket{\downarrow}$. In classical mechanics, we can never imagine that up plus down could be equal to right. This explains \ref{item:handstand} in Alice's continued adventures.
    }
    the quantum mechanical language, the indication of equal strength beams in a sequence of Stern-Gerlach experiments is
    \begin{align}\label{eq:eq-strength-spins}
        \ket{\rightarrow, \leftarrow, \otimes, \odot} =  \frac{1}{\sqrt{2}} \left( \ket{\uparrow} + e^{i\phi}\ket{\downarrow} \right) ~.
    \end{align}
    The phase turns out to indicate the freedom to choose y and z axes when the x axis is specified. It is convenient to choose:
    \begin{align}
    & \ket{\rightarrow} =  \frac{1}{\sqrt{2}} \left( \ket{\uparrow} + \ket{\downarrow} \right)~,
    && \ket{\leftarrow} =  \frac{1}{\sqrt{2}} \left( \ket{\uparrow} - \ket{\downarrow} \right)~, \\
    & \ket{\otimes} =  \frac{1}{\sqrt{2}} \left( \ket{\uparrow} + i \ket{\downarrow} \right)~,
    && \ket{\odot} =  \frac{1}{\sqrt{2}} \left( \ket{\uparrow} - i \ket{\downarrow} \right)~.
    \end{align}
}

\textbox{A qubit of information\index{qubit}}{
    A spin state can be thought as the building blocks of information -- a quantum bit (qubit for short) of information. This is because the state has two basis $\ket{\uparrow}$ and $\ket{\downarrow}$. This is to be compared to that a state taking 0 or 1 contains one classical bit of information.

    How much information is contained in a qubit?
    \marginnote{If we write $\ket{\psi} = \alpha \ket{\uparrow} + \beta \ket{\downarrow}$, we note that normalization of states require $ |\alpha|^2 + |\beta|^2 = 1$, and the overall phase is not relevant. Thus we are left with two real parameters.}

    We need to generalize \eqref{eq:eq-strength-spins}, since in \eqref{eq:eq-strength-spins}, $\ket{\uparrow}$ and $\ket{\downarrow}$ have equal strength. In general this may not be true. Thus, a general state should be
    \begin{align}
        \ket{\psi} = \cos(\theta/2) \ket{\uparrow}
        + e^{i\phi} \sin(\theta/2) \ket{\downarrow}~,
    \end{align}
    where $0\leq\theta\leq \pi$, $0\leq \phi<2\pi$. Thus a qubit of information spans a sphere, known as the Bloch sphere.
}

\textbox{Spin states in state vectors\index{spin states: state vectors}}{
    Superpositions and linear operators have the math structure of linear algebra. Thus, one can use vectors to represent spin states, and use matrices to represent operators on them. If we choose $\ket{\uparrow}$ and $\ket{\downarrow}$ as the basis, we can write down the states in the $z$, $x$, $y$ directions as:
    \begin{align} \label{eq:spinmat}
    &\ket{\uparrow} = \begin{pmatrix}1\\0\end{pmatrix}~,
    &&\ket{\downarrow} = \begin{pmatrix}0\\1\end{pmatrix}~,\nonumber \\
    &\ket{\rightarrow} = \frac{1}{\sqrt 2} \begin{pmatrix}1\\1\end{pmatrix}~,
    &&\ket{\leftarrow} = \frac{1}{\sqrt 2} \begin{pmatrix}1\\-1\end{pmatrix}~,\nonumber \\
    &\ket{\otimes} = \frac{1}{\sqrt 2} \begin{pmatrix}1\\i\end{pmatrix}~,
    &&\ket{\odot} = \frac{1}{\sqrt 2} \begin{pmatrix}1\\-i\end{pmatrix}~.
    \end{align}
}

\mtextbox{The analogue for wave functions}{
    Here we are using ``matrix mechanics'' for spins -- find a basis and express things in vectors and matrices. In the Part of Quantum Mechanics, we represent states by wave functions. They are equivalent. For the wave function of the position of a particle, we can write $\psi(x)$ as
    \begin{align*}
        \ket{\psi} =
        \begin{pmatrix}
            \vdots \\
            \psi(x_1) \\
            \psi(x_2) \\
            \psi(x_3) \\
            \vdots
        \end{pmatrix}~,
    \end{align*}
    Then up to normalization factors,
    \begin{align*}
        \braket{\psi|\chi} = \int dx ~ \psi^*(x) \chi(x)~.
    \end{align*}
}
\textbox{Inner products of spin states\index{spin states: inner products}}{
    One can define inner products of the state vector. In the matrix sense, if
    \begin{align}
    \ket{\psi} = \begin{pmatrix}a\\b\end{pmatrix}~,
    \qquad
    \ket{\chi} = \begin{pmatrix}c\\d\end{pmatrix}~,
    \end{align}
    define
    \begin{align}
    \bra{\psi} = \begin{pmatrix}a\\b\end{pmatrix}^\dagger
    = (a^*, b^*)~,
    \end{align}
    then
    \begin{align}
    \braket{\psi|\chi} =
     %\begin{pmatrix}a\\b\end{pmatrix}^\dagger
     (a^*, b^*) \begin{pmatrix}c\\d\end{pmatrix} = a^*c + b^* d~.
    \end{align}
}

\textbox{Normalization and orthogonality of spin states}{
    The normalization conditions of spin states are
    \begin{align}
        \braket{\uparrow|\uparrow} = \braket{\downarrow|\downarrow}
        = \braket{\rightarrow|\rightarrow} = \braket{\leftarrow|\leftarrow}
        = \braket{\otimes|\otimes} = \braket{\odot|\odot} = 1   ~,
    \end{align}
    And the corresponding pair of states are orthogonal to each other:
    \begin{align}
        \braket{\uparrow|\downarrow}
      = \braket{\rightarrow|\leftarrow}
      = \braket{\otimes|\odot} = 0   ~.
    \end{align}
    All these conditions can be tested from our construction \eqref{eq:spinmat}.
}

\textbox{Operators for spin measurements in $z$ and $x$, $y$ directions\index{spin states: operators for measurements}}{
    Given the states which have definite spin (spin eigenstates), one can now construct the spin operators, which measures the spin of the state and gives values $\pm 1$.

    One can test that the operators are\marginnote{The trick for a systematic construction is $\sigma_3 = (+1) \times \ket{\uparrow}\bra{\uparrow} + (-1) \times \ket{\downarrow}\bra{\downarrow}$, and similarly for $\sigma_1$ and $\sigma_2$.
    \mnewline
    Here we have defined spin up and down having spin +1 and -1, respectively. In more conventional setup electrons have spins $\pm \hbar/2$. These factors are introduced to compare with the familiar concept of angular momentum. Here we will not include these $\hbar/2$ factors.}
    \begin{align}
    \sigma_3 = \begin{pmatrix}1&0\\0&-1\end{pmatrix}~,
    \quad
    \sigma_1 = \begin{pmatrix}0&1\\1&0\end{pmatrix}~,
    \quad
    \sigma_2 = \begin{pmatrix}0&-i\\i&0\end{pmatrix}~.
    \end{align}
    These operators correspond to the measurements of spin in the $z$, $x$ and $y$ directions, respectively. These operators are known as Pauli matrices.
}

\textbox{Operators for spin measurements in a general direction}{
    From Pauli matrices, it is straightforward to build operators for measurements in a general direction $\hat n$:
    \begin{align}
    \sigma(\hat n) \equiv \sum_i {\hat n}_i \sigma_i = \hat n \cdot \bm{\sigma}~.
    \end{align}
    \tcblower
    For example, a measurement along 45$^\circ$ direction of the $x$-$z$ plane is
    \begin{align}
    \frac{\sigma_1 + \sigma_3}{\sqrt{2}}  ~.
    \end{align}
}

\textbox{Probability for a measurement to get a particular outcome: $z$ direction}{
    For a spin state $\ket{\psi}$, when measuring the spin of the $z$-direction, the probability to find the spin up state $\ket{\uparrow}$ is \marginnote{To be more precise, in $1+\sigma_3$, the 1 is a shorthand of the identity matrix.}
    \begin{align}
    P_\uparrow = \bra{\psi} \frac{1+\sigma_3}{2} \ket{\psi}~.
    \end{align}
    This is because, the spin state $\ket\psi$ can be in general decomposed into
    \begin{align}
    \ket\psi = \alpha \ket{\uparrow} + \beta \ket{\downarrow}~.
    \end{align}
    Note that\marginnote{Thus $\frac{1+\sigma_3}{2}$ is the projection operator of the spin-up state.}
    \begin{align}
    \frac{1+\sigma_3}{2} \ket{\uparrow} = \ket{\uparrow}~, \frac{1+\sigma_3}{2} \ket{\downarrow}=0~.
    \end{align}
    Thus
    \begin{align}
    \bra{\psi} \frac{1+\sigma_3}{2} \ket{\psi} = |\alpha|^2~,
    \end{align}
    which is indeed the probability of finding $\ket{\uparrow}$ according to the measurement postulate.
}

\textbox{Probability for a measurement to get a particular outcome: general directions\index{spin states: projection operators}}{
    In general, for the same reason, the probability to find a spin $\ket\psi$ along the $\hat n$ direction after a corresponding measurement is
    \begin{align}
        P_{\hat n} = \bra{\psi} \frac{1+\sigma(\hat n)}{2} \ket{\psi}~.
    \end{align}
}
\mtextbox{Pauli matrices and rotation}{
    In addition to the physical meaning of measurements, there is another physical meaning of Pauli matrices: rotation. The $\sigma_1$, $\sigma_2$, $\sigma_3$ Pauli matrices acting on spin states will rotate the spin along the $x$, $y$, $z$ axis for 180 degrees, respectively. For example, you can understand (up to a phase) how $\sigma_1$, $\sigma_2$, $\sigma_3$ act on $\ket{\uparrow}$ and $\ket{\downarrow}$ using rotation.
    \tcblower
    Why Pauli matrices can mean both measurements and rotations? Mathematically, Pauli matrices are both Hermitian (for measurement) and unitary (for rotation as a transformation).
}
\textbox{Pauli matrices acting on spin states\index{Pauli matrices}}{
    As promised, $\ket{\uparrow}$ and $\ket{\downarrow}$ are eigenstates of $\sigma_3$, such that
    \begin{align}
    \sigma_3 \ket{\uparrow} = \ket{\uparrow}~,
    \quad
    \sigma_3 \ket{\downarrow} = - \ket{\downarrow}~.
    \end{align}
    And it is interesting to note that (as can be tested by direct matrix calculation)
    \begin{align}
    \sigma_1 \ket{\uparrow} = \ket{\downarrow}~,
    \quad
    \sigma_1 \ket{\downarrow} = \ket{\uparrow}~,
    \quad
    \sigma_2 \ket{\uparrow} = i \ket{\downarrow}~,
    \quad
    \sigma_2 \ket{\downarrow} = -i \ket{\uparrow}~.
    \end{align}
}

\section{Multiple Spins and Their Entanglement} \label{sec:entanglement}

\subsection{Multiple Spins, Entanglements, and Quantum Computing}

The last section may not have surprised you since you have already learned some quantum mechanics. However, once we consider two spins, things become surprising again.

\mtextbox{Meaning of states with two arrows}{
    By writing the state $\ket{ab}$ (where $a,b=\uparrow, \downarrow$), we mean just two states $\ket{a}\ket{b}$ considered together. When taking inner products, we take them separately. For example,
    $$
        \braket{cd|ab} = \braket{c|a}\braket{d|b}~,
    $$
    And when we act an operator, we will specify the operator acts on which of the two spin. Mathematically, one can generalize the description with the tensor product of matrices, which is beyond the scope of the present course.
}

Here for simplicity, the two spins are not interacting -- there is no force between them. If we were studying classical mechanics, if two subsystems are not interacting with each other, we can just consider them together for free. Once we know both subsystems, we know the whole system. However, in quantum mechanics, things are different due to the principle of superposition.

\textbox{States with two spins}{
    In a classical world, if we have two spins, each can be in states $\ket{\uparrow}$ and $\ket{\downarrow}$, when considering them together, we get 4 possible states: $\ket{\uparrow\uparrow}, \ket{\uparrow\downarrow}, \ket{\downarrow\uparrow}, \ket{\downarrow\downarrow}$.

    However, in quantum mechanics, superpositions tells that the above 4 states are orthogonal to each other, and thus linear independent. A general state can be written as
    \begin{align}\label{eq:two-qubits}
        \ket{\psi} = \alpha_1 \ket{\uparrow\uparrow} + \alpha_2 \ket{\uparrow\downarrow} + \alpha_3 \ket{\downarrow\uparrow} + \alpha_4 \ket{\downarrow\downarrow}~.
    \end{align}
    \mtextbox{More on quantum information}{
        (Optional) Here we are talking about ``information'' in a sloppy way. The discussion can be made precise with a density matrix
        $$
            \rho = \sum_i p_i \ket{\psi_i}\bra{\psi_i}~,
        $$
        where $p_i$ is the classical probability for the system being in state $i$.
        Then a whole theory of quantum information can be constructed as a generalization of classical information theory, by considering $\rho$ as a generalization of a list of probabilities. For example, von Neumann entropy $S=-\mathrm{tr} (\rho \ln \rho)$ generalizes the classical Shannon entropy $S = - \sum_i p_i \ln p_i$.
    }
    The state contains two qubits of information.
}
\textbox{Entanglement: How much information is contained in two qubits?\index{entanglement}}{
    We have computed that each qubit is described by $2\times 2 - 2 = 2$ (two complex parameters deducting normalization and overall phase) real parameters.

    Considering two qubits together, how many real parameters do we need to describe two qubits?

    Naively, we may expect: each qubit is described by 2 parameters and thus two qubits would be described by 4. Is it correct?

    \tcblower

    In Eq.~\eqref{eq:two-qubits}, there are 4 complex parameters. Deducting normalization and an overall phase, we have $4\times 2 - 2 = 6$ real parameters.

    What are the two unexpected parameters? They describe the entanglement of the two states -- more information when considering the two states together than separately. This is a pure quantum effect and thus hard to imagine or explain classically. You can find the math just in the number counting in this box, and we will discuss some physics about it in the remainder of this section.
}

\needspace{0.2\textheight}
\mtextbox{Realistic quantum computing}{
    Now quantum computers are becoming real. But building a quantum computer challenges the science and technology today. For a quantum computer to work, one needs:
    \mtitem{
        \item Construct the qubits and keep them coherent (maintain the information from quantum entanglement).
        \item Construct quantum gates to operate on qubits.
        \item Design mechanism to correct possible errors from realistic operation.
        \item Design quantum algorithms. See \href{http://math.nist.gov/quantum/zoo/}{Quantum Algorighm Zoo} for currently known quantum algorithms.
    }
}
\textbox{From $n$ spins to quantum computing\index{quantum computing}\index{quantum information}}{
    How much information is contained in $n$ qubits? We will have $2^n$ basis vectors and thus a general state is described by $2^{n+1} - 2$ real parameters. This explains observation \ref{item:information-memory} of Alice's continued adventures.

    This is exponentially different from classical bits! For $n$ classical bits, the bits can describe \emph{one integer number} with range from $1$ to $2^n$. But $n$ qubits can describe more than $2^n$ numbers. Thus, qubits contain much more information in entanglements -- the information grows exponentially with the number of qubits.

    Further, it is possible to manipulate the qubits with ``quantum gates''. For example, the Hadamard gate
    \begin{align}
      \ket{\uparrow} \rightarrow \ket{\rightarrow}~,\qquad \ket{\downarrow} \rightarrow \ket{\leftarrow}
    \end{align}
    and the the ``controlled-NOT'' gate:
    \begin{align}
      \ket{\uparrow\uparrow} \rightarrow \ket{\uparrow\uparrow}~,~~
      \ket{\uparrow\downarrow} \rightarrow \ket{\uparrow\downarrow}~,~~
      \ket{\downarrow\uparrow} \rightarrow \ket{\downarrow\downarrow}~,~~
      \ket{\downarrow\downarrow} \rightarrow \ket{\downarrow\uparrow}~.
    \end{align}

    With quantum information and logical gates to manipulate the information, we get quantum computers!
}

\textbox{Measurements and corresponding operators}{
    For multiple qubits, here we limit our attention to measurements which operates separately on each individual qubit. And for simplicity we consider 2 qubits only.

    The independent measurements can be represented by two set of Pauli matrices, one acting on particle 1 (not affecting particle 2) and the other acting on particle 2 (not affecting particle 1). Let us use $\sigma_i$ to denote the Pauli matrices on particle 1, and use $\tau_i$ to denote the Pauli matrices on particle 2. For example,
\begin{align}
  \sigma_1  \ket{\uparrow\downarrow} = \ket{\downarrow\downarrow} ~, \qquad
  \tau_1  \ket{\downarrow\downarrow} = \ket{\downarrow\uparrow}~.
\end{align}
As $\sigma_i$ and $\tau_i$ act on different spin states, the order of operation $\sigma_i$ and $\tau_i$ commutes. For example, $\sigma_1 \tau_1 \ket{\psi} = \tau_1 \sigma_1 \ket{\psi}$.

As the two measurements are independent, the probability to find particle 1 in direction $\hat n$ and particle 2 in direction $\hat m$ (by measuring corresponding directions) in a state $\ket{\psi}$ is
\begin{align}
  \bra{\psi} \frac{1+\sigma(\hat n)}{2} \frac{1+\tau(\hat m)}{2} \ket{\psi}~.
\end{align}
}

\subsection{The Einstein-Podolsky-Rosen (EPR) Paradox}

Einstein, though a pioneer of quantum mechanics, has a life-long concern about quantum mechanics. In his philosophy, ``God does not play dice.'' He did not believe that a theory having fundamental randomness would be the complete description of nature. Along this line of thought, in 1935, Einstein, Podolsky and Rosen (EPR) posed the strongest challenge to quantum mechanics.

\textbox{The EPR state}{
    Let us first prepare a state (known as the ``singlet state'')
\begin{align}
  \ket{s} = \frac{1}{\sqrt{2}} \left ( \ket{\uparrow\downarrow} - \ket{\downarrow\uparrow} \right )~,
\end{align}
and take the two particles far apart each other. This is possible. For example, a spin-less particle at rest can decay into two particles with opposite spins, and these two particles can fly as far apart as one wants, before they interact with anything else.
}

\textbox{The correlated measurements}{
    Suppose Alice and Bob are light years away from each other. The decay event happens in their middle. Later, Alice receives particle 1 and Bob receives particle 2. They measure the spin of the particles along the $z$-direction immediately after receiving the particles. What will they see?

    We already have the theory to answer this question technically:
    \begin{align}
    & P_{\uparrow\uparrow} = \bra{s} \frac{1+\sigma_3}{2} \frac{1+\tau_3}{2} \ket{s} = 0~,
    && P_{\downarrow\downarrow} = \bra{s} \frac{1-\sigma_3}{2} \frac{1-\tau_3}{2} \ket{s} = 0~, \nonumber\\
    & P_{\uparrow\downarrow} = \bra{s} \frac{1+\sigma_3}{2} \frac{1-\tau_3}{2} \ket{s} = \frac{1}{2} ~,
    && P_{\downarrow\uparrow} = \bra{s} \frac{1-\sigma_3}{2} \frac{1+\tau_3}{2} \ket{s} = \frac{1}{2} ~.
    \end{align}

    In words, both Alice and Bob will find that they have equal chance to find the state having spin up or down. It seems random. But if they meet and compare notes, they will find that their results are totally \emph{correlated} -- if one gets up, the other must get down.

    It is interesting to note that, the above correlation does not depend on the direction that Alice and Bob measure the state. As long as they are measuring the same direction (any $\hat n$), if one gets up, the other must get down. This correlation (without any interactions) is the physical indication of entanglements.
}

\textbox{Does quantum mechanics contradict relativity?\index{EPR paradox}}{
    At
    \marginnote{This explains observation \ref{item:epr} of Alice's continued adventures.}
    first sight, in EPR, information is transmitted faster than light. Thus it contradicts causality in special relativity. This is the EPR paradox.
    \tcblower
    However, there is actually nothing wrong. Before Alice and Bob meet, they consider their own results \emph{random}. Thus Alice cannot encode any information (classical information) in what she choose to measure and let Bob know immediately.
}

\textbox{Is EPR trivial?}{
    There are many apparent superluminal correlations, which are trivial. For example,
    \tenum{
        \item When a child is born, his/her father immediately becomes a father no matter how far away he is. \label{item:correlation-father}
        \item I pack an apple and an orange into the two boxes. Alice and Bob randomly pick one of them. Then they separate in space. Their measurement about what's in the box will have complete correlation. \label{item:hidden-vars}
    }
    Clearly, these types of correlations cannot send information either. However, is EPR similar to these types of trivial correlations?

    \tcblower

    EPR is not any of them.

    \ref{item:correlation-father} is more trivial. There is correlation, but the correlation is not observable (but rather just a definition) before the father gets any information about the born of the child.

    \ref{item:hidden-vars} is not what happened in EPR, either. In the case of \ref{item:hidden-vars}, Alice and Bob has mutual information,
    \marginnote{
        The mutual information in the apple-orange case is
        $
        I(X;Y) \equiv \sum_{x,y} p(x,y) \log \frac{p(x,y)}{p(x)p(y)}
         = \log 2
        $. This is just one bit of information in information theory (where the base of log is usually chosen to be 2).
    }
    which is similar to the case of EPR. However, the mutual information is classical information, instead of quantum entanglement.

    If Alice choose to measure the spin along the $x$ axis, but Bob still measure long $z$ axis, then their results will not have any correlation (or any further correlations no matter they choose to measure whatever in addition). Whether their results have correlation depends on what they choose to measure.

    You may not feel satisfied with this explanation -- by measuring different axes, you may argue that one of Alice and Bob destroyed the correlations (recall the collapse of wave function). So this argument is trying to hide (destroy) the difference between EPR and apple-orange instead of trying to compare them honestly.

    Also,
    \mtextbox{Classical hidden variables}{There are lots of randomness in the classical world due to conditions out of control. For example, when a dice is played, the outcome is (classically) in principle determined by initial condition of the air, perturbations in the air, mechanical property of the desk, etc. But it's too hard to understand these variables to predict the behavior of the dice.\tcblower
    Quantum randomness is fundamentally different, as we will see later.}
    what if we generalize \ref{item:hidden-vars}? The generalization along this line is known as ``local hidden variable theories''. They are theories with hidden variables which are not (yet) observable.

    Is it possible to design a better local hidden variable theory (where the randomness of quantum mechanics is due to some variables not-yet-observable), where the ``random'' outcome of EPR (and similarly other quantum measurements) is in fact determined when the two spins were together? And after the states fly apart, each state follow classical logic separately?

    We will show in the next subsection that EPR is indeed intrinsically different from apple-orange in \ref{item:hidden-vars}, and further, no local hidden variable theories can exist.
}

\subsection{The Bell's Inequality and its Violation}

\textbox{Defining a local hidden variable theory in general\index{hidden variable theories}}{
    A local hidden variable theory need to satisfy the follows:
    \tenum{
        \item \emph{Hidden variables}. The apparent quantum behavior follows from some classical logic (where some parts of the system may be hidden so the rest appear random).
        \item \emph{Local}. Space-like measurements do not affect each other.
    }
}

\textbox{A piece of classical logic}{

    Let us prepare many copies of identical EPR pairs. We classify each EPR pair using three classification criteria of states $A$, $B$ and $C$.

    One consequence of the classical logic is: \marginnote{\includegraphics[width=0.4\textwidth]{classical_logic}}
    \begin{align}\label{eq:classical-logic}
    {\color{red}N(A, \neg B)} + {\color{blue}N(B, \neg C)} \geq {\color{brown}N(A, \neg C)}~,
    \end{align}
    where $N(\cdots)$ denotes the number of states satisfying condition $\cdots$, and $\neg$ denotes ``not''. This relation is illustrated in the figure to the right, where $A$, $B$, $C$ are denoted by circles and the colored contours denote corresponding terms in the above equation.
    \tcblower
    If you consider classical objects and assign, e.g.  $A$: apple (instead of orange); $B$: red (instead of yellow); $C$: sweet (instead of sour). Then \eqref{eq:classical-logic} will always be satisfied. What about EPR pairs with quantum entanglement?
}

\textbox{Testing the classical logic upon the singlet state\index{Bell inequality}}{
    Now let us give meanings of $A$, $B$ and $C$, applying on a singlet state, as measurements by Alice:

$A$: Measure particle 1 along the $z$-axis and get positive spin.

$B$: Measure particle 1 along $45^\circ$ in $x$-$z$ plane and get positive spin.

$C$: Measure particle 1 along the $x$-axis and get positive spin.

Interestingly, $\neg A$, $\neg B$ and $\neg C$ can be related to measurements by Bob of particle 2 because of the complete anti-correlation:

$\neg A$: Measure particle 2 along the $z$-axis and get positive spin.

$\neg B$: Measure particle 2 along $45^\circ$ in $x$-$z$ plane and get positive spin.

$\neg C$: Measure particle 2 along the $x$-axis and get positive spin.

Eq.~\eqref{eq:classical-logic} with the above conditions is known as the Bell inequality (John Stewart Bell 1964).

\mtextbox{Why EPR violates Bell inequality?}{
    By violating \eqref{eq:classical-logic}, we are not saying that EPR pairs are not logical. Rather, we cannot assume that each particle in the EPR pair already has features $A$, $B$ and $C$ before the measurement. This is totally different from the apple-orange example.
}

Now it is straightforward to construct probabilities of the events in \eqref{eq:classical-logic}. The probabilities become number of events after a large number of measurements.

\begin{align}
  P(A, \neg B) = \bra{s} \frac{1+\sigma_3}{2} \frac{1+ \frac{\tau_1+\tau_3}{\sqrt{2}}  }{2}   \ket{s} = \frac{1}{4} \left ( 1-\frac{1}{\sqrt 2}  \right )
  \simeq 0.073~.
\end{align}
\begin{align}
  P(B, \neg C) = \bra{s} \frac{1+ \frac{\sigma_1+\sigma_3}{\sqrt{2}}  }{2} \frac{1+\tau_1}{2}   \ket{s} = \frac{1}{4} \left ( 1-\frac{1}{\sqrt 2}  \right )
  \simeq 0.073~.
\end{align}
\begin{align}
  P(A, \neg C) = \bra{s} \frac{1+ \sigma_3}{2} \frac{1+\tau_1}{2}   \ket{s} = \frac{1}{4} = 0.25~.
\end{align}

Clearly,
\marginnote{This explains observation \ref{item:bell} of Alice's continued adventures.}
the classical logic \eqref{eq:classical-logic} is violated in this state. Thus the quantum information stored in the entanglement cannot be mimicked by any local hidden variables.
}

\section{Epilogue: Summary and What's Next}

\textbox{Further reading about the content}{
    \titem{
        \item The main reference of this part is Susskind and Friedman, \href{https://www.amazon.com/Quantum-Mechanics-Theoretical-Leonard-Susskind/dp/0465062903}{Quantum Mechanics: The Theoretical Minimum}.
        \item For more information about spin: Sakuri, \href{https://www.amazon.com/Modern-Quantum-Mechanics-Revised-Sakurai/dp/0201539292/ref=sr_1_2?s=books&ie=UTF8&qid=1504076022&sr=1-2&keywords=quantum+mechanics+modern}{Modern Quantum Mechanics}, Chapter 1
        \item For similar content and other Bell-like experiments: Baumann, \href{
            http://www.damtp.cam.ac.uk/user/db275/concepts/Concepts.pdf}{Lecture Notes on Modern Physics}, Chapter 2.
        \item If you'd like to dive deeper in quantum information, read the \href{http://theory.caltech.edu/~preskill/ph229/}{lecture notes by Preskill}.
    }
}

\textbox{What happens next?}{
    Quantum information and quantum computing are fast developing frontiers in research. It is definitely interesting to study them further in quantum mechanics and related courses.
}

\section{Exercises}

\textbox{E\wref{sec:spin}.1 Spin eigenstates}{
    Find the eigenstates and eigenvalues of $\sigma(\hat n)$.
}

\textbox{E\wref{sec:entanglement}.1 Computational details for the Bell inequality}{
    Compute the probabilities $P(A, \neg B)$, $P(B, \neg C)$ and $P(A, \neg C)$.
}

\printindex

\end{document}


\chapter{Open problems in homotopy type theory}
We list only the open problems of synthetic homotopy theory, omitting the open problems related to the semantics of homotopy type theory.
\begin{itemize}
\item Compute the homotopy groups of the spheres.
\item Define the Grassmannians.
\item Prove Freyd's generating hypothesis
\item Hurewicz theorem
\item Barratt-Priddy theorem
\item (Semi-)simplicial types.
\item Ring structure on the sphere spectrum
\item Higher Van Kampen theorems
\item Higher Blakers-Massey theorems
\item Find a delooping of $\sphere{3}$, and define the octonionic Hopf fibration.
\end{itemize}


\chapter*{Appendix}

\section*{Random numbers}

\subsection*{32-bits version}
\begin{verbatim}
     A C-program for MT19937, with initialization improved 2002/1/26.
     Coded by Takuji Nishimura and Makoto Matsumoto.

     Before using, initialize the state by using init_genrand(seed)

     Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
     All rights reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:

       1. Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.

       2. Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in the
          documentation and/or other materials provided with the distribution.

       3. The names of its contributors may not be used to endorse or promote
          products derived from this software without specific prior written
          permission.

     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\end{verbatim}

\subsection*{64-bits version}
\begin{verbatim}
     A C-program for MT19937-64 (2004/9/29 version).
     Coded by Takuji Nishimura and Makoto Matsumoto.

     This is a 64-bit version of Mersenne Twister pseudorandom number
     generator.

     Before using, initialize the state by using init_genrand64(seed)

     Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura,
     All rights reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:

       1. Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.

       2. Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.

       3. The names of its contributors may not be used to endorse or promote
          products derived from this software without specific prior written
          permission.

     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

     References:
     T. Nishimura, ``Tables of 64-bit Mersenne Twisters''
       ACM Transactions on Modeling and
       Computer Simulation 10. (2000) 348--357.
     M. Matsumoto and T. Nishimura,
       ``Mersenne Twister: a 623-dimensionally equidistributed
         uniform pseudorandom number generator''
       ACM Transactions on Modeling and
       Computer Simulation 8. (Jan. 1998) 3--30.
\end{verbatim}


\section{Literature Review}
\label{lit}

In this section, we review the specific forecasting methods that make up our
    forecasting system.
We group them into classical statistics and ML models.
The two groups differ mainly in how they represent the input data and how
    accuracy is evaluated.

A time series is a finite and ordered sequence of equally spaced observations.
Thus, time is regarded as discrete and a time step as a short period.
Formally, a time series $Y$ is defined as $Y = \{y_t: t \in I\}$, or $y_t$ for
    short, where $I$ is an index set of positive integers.
Besides its length $T = |Y|$, another property is the a priori fixed and
    non-negative periodicity $k$ of a seasonal pattern in demand:
$k$ is the number of time steps after which a pattern repeats itself (e.g.,
    $k=12$ for monthly sales data).


\subsection{Bank currency}

Alice has 10 shells at her bank. If she wants to pay Bob 10 shells for something, she can either take out and give him physical shells or inform the bank of a transfer.

If the bank allowed her to withdraw a claim on 10 shells, she could give this to Bob. This is how cash works.

\subsection{Types of money}

The supply of money has increased through the use of fractional reserves at the bank. There are different definitions of the money supply:

\begin{itemize}
\item M0: physical cash outside of banks (90 in our example above)
\item MB: all cash (100)
\item M1: M0 and bank deposits (120)
\end{itemize}

There are also additional measures, with increasing scope.

If Alice puts some of the money lent to her in the bank, this could have been lent out, recursively.

\(Total money supply = \dfrac{Base money}{Reserve ratio}\)

The \(money multiplier\), the ratio of total money supply to base money is equal to \(\dfrac{1}{Reserve ratio}\)


\section{Computational Structure of a Region-Based DFA}
\FloatBarrier
\begin{flushright}
    \textit{Scribed by Arpit Saxena}
\end{flushright}

\begin{enumerate}
    \item {
        Identify transfer function of each region (and sub-region)

        \textbf{Bottom-up pass:}
        \begin{enumerate}
            \item Basic blocks transfer function derived from individual
            statement's transfer functions
            \item Loop body's transfer function from basic block's transfer
            function
            \item Loop's from loop body's, \ldots
        \end{enumerate}
    }
    \item {
        Compute the dataflow values at each program point by using the summary
        transfer functions (for entire regions)

        \textbf{Top-down analysis}: Descend down the region hierarchy
        for internal points
    }

\end{enumerate}

\begin{figure}[H]
    \centering
    \subfloat[\label{fig:m120:ex1:a}] {{
        \tt
        \begin{tikzpicture}[->,
            node distance = 12mm,
            start chain = going below,
            box/.style = {draw,rounded corners,fill=white,
                on chain,align=center},
            unbox/.style = {on chain,align=center},
            edge/.style = {midway}]
            \coordinate[on chain] (begin);
            \node[box] (b1) {
                sum = 0\\
                Q1 --- \\
                i = 0 \\
                P1 ---
            };
            \node[box] (b2) {
                P2 --- \\
                i < n
            };
            \node[unbox,below left=of b2] (b3) {exit};
            \node[box,below=of b2] (b4) {sum += i \\ i++};
            \path[]
                (begin) edge (b1)
                (b1) edge (b2)
                (b2) edge node[edge, left] {F} (b3)
                    edge node[edge, right] {T} (b4);
            \draw (b4.230) -| ++(0.6,-0.3) -| ([xshift=5mm]b2.east) |-
            ([yshift=3mm]b2.50) -- (b2.50);
        \end{tikzpicture}
    }}
    \subfloat[\label{fig:m120:ex1:b}] {{
        \tt
        \begin{tikzpicture}[->,
            node distance = 12mm,
            start chain = going below,
            box/.style = {draw,rounded corners,fill=white,
                on chain,align=center},
            unbox/.style = {on chain,align=center},
            edge/.style = {midway}]
            \coordinate[on chain] (begin);
            \node[box](b1) {sum = 0 \\ i = 0};
            \node[box](b2) {loop body \\ region};
            \node[unbox](b3) {exit};
            \path[]
                (begin) edge (b1)
                (b1) edge (b2)
                (b2) edge (b3);
            \draw (b2.230) -| ++(0.6,-0.3) -| ([xshift=5mm]b1.east) |-
            ([yshift=5mm]b1.50) -- (b1.50);

        \end{tikzpicture}
    }}
    \subfloat[\label{fig:m120:ex1:c}] {{
        \tt
        \begin{tikzpicture}[->,
            node distance = 12mm,
            start chain = going below,
            box/.style = {draw,rounded corners,fill=white,
                on chain,align=center},
            unbox/.style = {on chain,align=center},
            edge/.style = {midway}]
            \coordinate[on chain] (begin);
            \node[box](b1) {sum = 0 \\ i = 0};
            \node[box](b2) {loop region};
            \node[unbox](b3) {exit};
            \path[]
                (begin) edge (b1)
                (b1) edge (b2)
                (b2) edge (b3);
        \end{tikzpicture}
    }}
    \subfloat[\label{fig:m120:ex1:d}] {{
        \tt
        \begin{tikzpicture}[->,
            node distance = 12mm,
            start chain = going below,
            box/.style = {draw,rounded corners,fill=white,
                on chain,align=center},
            unbox/.style = {on chain,align=center},
            edge/.style = {midway}]
            \coordinate[on chain] (begin);
            \node[box](b1) {Procedure \\ Region};
            \node[unbox](exit) {exit};
            \path[]
                (begin) edge (b1)
                (b1) edge (exit);
        \end{tikzpicture}
    }}
    \caption{A Region Hierarchy\\ Note that P1, P2, \ldots\ are program points}
    \label{fig:m120:ex1}
\end{figure}

In figure \autoref{fig:m120:ex1:b}, the loop body's transfer function
would be:

{
    \centering
    \tt
    f\textsubscript{b}(m) = m' \\
    m'(i) = m(i) + 1 \\
    m'(sum) = m(sum) + m(i) \\
}

Based on f\textsubscript{b}, we'll try to create a summary transfer
function for the entire loop.

In figure \autoref{fig:m120:ex1:c}, the loop's transfer function would be

{
    \tt
    \centering
    m\textsuperscript{l} = f\textsubscript{l}(m) \\
    m\textsuperscript{l}(i) = max(m(i), n) \\
    m\textsuperscript{l}(sum) = m(sum) + $\sum_{j=m(i)}^{n-1} j$ \\
}

Note that if initially $i \geq n$, then the loop is not even entered, which
is the reason for having max in the second equation.

All iterations of the loop have been summarised as a single transfer function
f\textsubscript{l}, and it is a sophisticated symbolic analysis which may not
be possible for every loop. In that case, we have a fallback option of just
executing a basic DFA.

For figure \autoref{fig:m120:ex1:d}, we use the fact that we know at start of loop
region that \texttt{m(i) = 0, m(sum) = 0} and get the following transfer
function

{
    \tt
    \centering
    m\textsuperscript{p} = f\textsubscript{p}(m) \\
    m\textsuperscript{p}(i) = n \\
    m\textsuperscript{p}(sum) = n * (n - 1) / 2 \\
}

Note that the transfer function doesn't need to be a closed form function. It
only needs to be a computable (terminating) function.
E.g.: Trivial solutions based on fixed point (terminating because the lattices
have finite height).

Suppose we wanted to compute value at P1 (refer to \autoref{fig:m120:ex1}).

In top-down fashion, we start from the procedure region. If we needed Q1,
then f\textsubscript{1} (which transfer function for the first basic block
in figure \autoref{fig:m120:ex1:c}) would only give summary of the basic block.
So, we'll apply transfer function of \texttt{sum = 0}.

In general, at every level of the hierarchy: Compute the DFA values on that level
of the hierarchy and we'll get boundary values of next-level regions. If we're
interested in an internal point of a region, we can use DFA value computed at
beginning of the region to get value internal to the region.

To compute value at P\textsubscript{2}:
\begin{itemize}
    \item Run DFA on procedure region
    \item Get value at beginning of loop region (P1). Note it's different
    from P2 because the former is executed only once while the latter is entered
    at every loop iteration.
    \item Using P1, we find value at P1 at next level of the hierarchy.
    \[Val[P_1] \wedge f_b(f_1(m_0)) \wedge f_b^2(f_1(m_0)) \wedge \ldots\]
\end{itemize}


\subsection{\tsolver Features}

\begin{frame}
  \frametitle{Incrementality and Backtrackability}

  \scriptsize

  \tsolver is asked to check consistency on sets of constraints that evolve {\bf incrementally}
  because of BCP and Decide actions
  $$
    \babst{\mu} = \{\ \dec{x = 0}{0},\ \dec{x < y}{0},\ \dec{x + y = z}{1}\ \}
  $$
  and can be backtracked because of Conflict Analysis and Backtracking
  $$
    \babst{\mu} = \{\ \dec{x = 0}{0}, \dec{x < y}{0}\ \}
  $$
  \vfill
  \pause
  Everything happens in a stack-based fashion: constraints are pushed and popped on $\babst{\mu}$
  in a LIFO order
  \vfill
  For efficiency, \tsolver should be able to
  \begin{itemize}
    \item reason incremetally: check of consistency of $\{ \dec{x = 0}{0},\ \dec{x < y}{0},\ \dec{x + y = z}{1}\ \}$ should reuse
          as much as possible the computation already spent for checking $\{ \dec{x = 0}{0}, \dec{x < y}{0} \}$
    \pause
    \item backtrack efficiently: going back from $\{ \dec{x = 0}{0},\ \dec{x < y}{0},\ \dec{x + y = z}{1}\ \}$ to
	  $\{ \dec{x = 0}{0}, \dec{x < y}{0} \}$ should be done quickly and without losing information
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Minimal Conflicts}

  \scriptsize

  It is desirable for the \tsolver to return {\bf minimal conflicts}

  \vfill
  Consider the assignment
  $$\babst{\mu} = \{ x - y \leq 0,\ y - z \leq 0,\  \ldots (1000 \mbox{ other constratints }) \ldots, z - x \leq -1,\ \}$$
  according to our basic procedure we would add the clause $\neg \babst{\mu}$ to the SAT-solver
  \vfill
  \pause
  However we see that
  $$\babst{\nu} = \{ x - y \leq 0,\ y - z \leq 0, z - x \leq -1 \}$$
  is already a minimal reason for the
  \T-unsatisfiability, and $\neg \babst{\nu}$ is a clause with $3$ literals instead of $1003$.
  We call these reasons \tconflicts
  \vfill
  A \tconflict is {\bf minimal} if it does not contain redundant \tatoms
  \vfill
  \pause
  Small clauses are more retrictive than big clauses, and they therefore reduce SAT search
\end{frame}

\begin{frame}
  \frametitle{Theory Propagation}

  \scriptsize

  So far we have seen that \tsolver is {\bf passive} as far as the search is concerned:
  \begin{itemize}
    \item SAT is the master that drives the search
    \item \tsolver is queried to confirm that the search is correct from the point of view of \T
  \end{itemize}
  However, consider the following scenario
  $$\babst{\mu} = \{ \ldots, \dec{x > 0}{2},\ \dec{y > 0}{3} \}$$
  and assume that
  \begin{itemize}
    \item BCP has completed
    \item There is a \tatom $x + y > 0$ that is currently not assigned (i.e., it is not in $\babst{\mu}$)
  \end{itemize}
  Also we know that in \T the following implication holds
  $$
    ( x > 0 ) \wedge ( y > 0 ) \rightarrow ( x + y > 0 )
  $$
  Then we can do a {\bf Theory Propagation}, i.e., we can expand the assignment as
  $$
    \babst{\mu} = \{ \ldots, \dec{x > 0}{2},\ \dec{y > 0}{3}, \dec{(x+y > 0)}{3} \}
  $$
  thus avoiding a Decision in SAT

\end{frame}

\begin{frame}
  \frametitle{The CDCL(\T) Procedure}

  \scriptsize

  \vfill

  \begin{tabbing}
  as \= a \= a \= a \= as \= asdfsdfasdfasdfasdfasdfasdfasdfasdfasdf \= \kill
  \> class {\sc Theory};                         \> \> \> \> \> // \tsolver \\
  \\
  \> $dl = 0$; $trail = \{\ \}$;                                  \> \> \> \> \> // Decision level, assignment\\ \\
  \> while ( $true$ ) \\ \\
  \> \> if ( {\sc BCP}( ) == conflict )                                    \> \> \> \> // Do BCP until possible \\
  \> \> \> if ( $dl == 0$ ) return $unsat$;                             \> \> \> // Unresolvable conflict \\
  \> \> \> $C,dl =$ {\sc AnalyzeConflict}( );                           \> \> \> // Compute conf. clause, and dec. level \\
  \> \> \> {\sc AddClause}( $C$ );                                      \> \> \> // Add $C$ to clause database \\
  \> \> \> {\sc BacktrackTo}( $dl$ );                                   \> \> \> // Backtracking (shrinks $trail$) \\
  \> \> else if ( {\sc Theory.Check}( $trail$ ) == unsat )      \> \> \> \> // \tsolver check \\
  \> \> \> \textcolor{red}{$\babst{\nu}$ = {\sc Theory.GetConflict}( );}             \> \> \> // Retrieve \tconflict \\
  \> \> \> {\sc AddClause}( $\neg \babst{\nu}$ );                  \> \> \> // Add clause that is now unsat \\
  \> \> \textcolor{red}{else if ( {\sc Theory.CanPropagate}( ) )}        \> \> \> \> // Can do some propagations ? \\
  \> \> \> \textcolor{red}{$\rho$ = {\sc Theory.Propagate}( );}                      \> \> \> // Retrieve propagations \\
  \> \> \> \textcolor{red}{$trail = trail \cup \rho$;}                               \> \> \> // Extend assignment \\
  \> \> else \\
  \> \> \> if ( ``all variables assigned'' ) return $sat$;              \> \> \> // $trail$ holds satisfying assignment \\
  \> \> \> $l = $ {\sc Decision}( );                                    \> \> \> // Do another decision \\
  \> \> \> $trail = trail \cup \{ l \}$; \\
  \> \> \> $dl = dl + 1$;                                               \> \> \> // Increase decision level \\
  \end{tabbing}

  \vfill

\end{frame}

\begin{frame}
  \frametitle{The CDCL(\T) Procedure}

  \begin{columns}
    \begin{column}{.35\textwidth}
      \vspace{-70pt}
      \scalebox{.3}{\input{cdcl.pdf_t}}
    \end{column}

    \begin{column}{.60\textwidth}
      \vspace{70pt}
      \scalebox{.3}{\input{cdclt.pdf_t}}
    \end{column}

  \end{columns}

\end{frame}


\appendix
\chapter{Appendix A: Reconfigurable moderator in TAP core}
\label{appex:geometries}

\renewcommand{\thetable}{A.\arabic{table}}
\setcounter{table}{0}
\renewcommand{\thefigure}{A.\arabic{figure}}
\setcounter{figure}{0}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table}[h!]
	\caption{Geometric details for the full-core 3D model of the \gls{TAP}
	with various moderator rod assemblies configurations. }
	\begin{tabularx}{\textwidth}{ X X X X}
		\hline
		Case & Number of ZrH$_{1.66}$ & \gls{SVF} & Moderator-to-\\
		     & rods in the quarter core   &          & fuel ratio			\\
		     \hline
		1 (\gls{BOL}) &  347          & 0.917204 & 0.09027              \\
		2    &        406             & 0.903126 & 0.10727              \\
		3    &        427             & 0.898115 & 0.11344              \\
		4    &        505             & 0.879503 & 0.13700              \\
		5    &        576             & 0.862563 & 0.15933 		        \\
		6    &        633             & 0.848962 & 0.17791      	    \\
		7    &		  681			  & 0.837509 & 0.19402	            \\
		8    &        840             & 0.799571 & 0.25067              \\
		9    &        880             & 0.790026 & 0.26578              \\
		10   &        900             & 0.785254 & 0.27347              \\
		11   &        988             & 0.764257 & 0.30846 		        \\
		12   &        1126	          & 0.731329 & 0.36737      	    \\
		13   &		  1338	    	  & 0.680744 & 0.46898	            \\
		14   &		  1498			  & 0.642567 & 0.55626	            \\
		15 (\gls{EOL})& 1668          & 0.602004 & 0.66112              \\
		\hline
	\end{tabularx}
	\label{tab:tap_adjustable_core}
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\begin{figure}[htp!] % replace 't' with 'b' to
	\centering
	\includegraphics[width=\textwidth]{appex/tap_406-681.png}
	\caption{An $XY$ section of the \gls{TAP} model at horizontal midplane for
	the first six years of operation (excluding startup moderator rods
	configuration) with the \gls{SVF} between 0.91 and 0.84. The number in the
	top-right corner of each figure indicates the number of moderator rods in
	the case.}
	\label{fig:tap-406-681}
\end{figure}

\newpage
\begin{figure}[htp!] % replace 't' with 'b' to
	\centering
	\includegraphics[width=0.9\textwidth]{appex/tap_840-1668.png}
			\vspace{-3mm}
	\caption{An $XY$ section of the \gls{TAP} model at horizontal midplane the
	\gls{SVF} between 0.8 and 0.6. The number in the top-right corner of
	each figure indicates the number of moderator rods in the case.}
	\label{fig:tap-840-1668}
\end{figure}


\chapter{Point estimates of probability distributions}


\par
\section{Data Structure}
\label{section:SolveMap:dataStructure}
\par
The {\tt SolveMap} structure has the following fields.
\begin{itemize}
\item
{\tt int symmetryflag} : symmetry flag
\begin{itemize}
\item {\tt SPOOLES\_SYMMETRIC}
      -- symmetric $(U^T + I)D(I + U)$ factorization
\item {\tt SPOOLES\_HERMITIAN}
      -- hermitian $(U^H + I)D(I + U)$ factorization
\item {\tt SPOOLES\_NONSYMMETRIC}
      -- nonsymmetric $(L + I)D(I + U)$ factorization
\end{itemize}
\item
{\tt int nfront} -- number of fronts
\item
{\tt int nproc} -- number of threads or processes
\item
{\tt int *owners} -- vector mapping fronts to owning threads or
processes
\item
{\tt int nblockUpper} -- number of submatrices in the upper triangle
\item
{\tt int *rowidsUpper} -- vector of row ids for the upper triangle
\item
{\tt int *colidsUpper} -- vector of column ids for the upper triangle
\item
{\tt int *mapUpper} -- map from submatrices to threads or processes
\item
{\tt int nblockLower} -- number of submatrices in the lower triangle
\item
{\tt int *rowidsLower} -- vector of row ids for the lower triangle
\item
{\tt int *colidsLower} -- vector of column ids for the lower triangle
\item
{\tt int *mapLower} -- map from submatrices to threads or processes
processes
\end{itemize}


\subsubsection{Pixel Formats}
\label{subsubsec:pixel_format}
% \todo[inline]{Citations, Document, that only 8bits are used? No.}
% (https://en.ids-imaging.com/tl_files/downloads/techtip/TechTip_18MP-color-sensor-as-mono_EN.pdf)

The Baumer industrial camera VCXU-13C uses the digital image sensor PYTHON1300 from ON Semiconductor and allows for the use of monochrome, raw and color pixel formats (see chapter \ref{sec:camera}).
The digital image sensor itself has 1280 $\times$ \SI{1024}{px} that acquire brightness with a bit depth of \SI{10}{bit}.
In order to capture color images, a color filter is applied to each individual pixel.
These red, green and blue (RGB or BGR) color filters only transmit light with a particular wavelength.
Due to the fact that the luminance perception of the human eye is most sensitive to green light, twice as many green filters are used as red and blue filters.
The color filters are arranged in a Bayer color matrix $B$, as shown in figure \ref{subfig:bayerrg} \cite{dcs}.

There are several modifications of the Bayer pattern that can be achieved by simply shifting the pixels around.
The pattern in figure \ref{subfig:bayergr} is achieved by shifting the initial pattern one pixel to the left, whereas the pattern in figure \ref{subfig:bayergb} is achieved by shifting the pattern one pixel up.

The different Bayer patterns are usually named after the color of the elements $B_{1,1}$, $B_{1,2}$, $B_{2,1}$ and $B_{2,2}$.
This results in the four possible patterns \texttt{RGGB}, \texttt{GRBG}, \texttt{GBRG} and \texttt{BGGR}.

However, there exist different naming conventions for the different Bayer patterns.
Baumer labels the Bayer patterns after the color of the elements $B_{1,1}$ and $B_{1,2}$, resulting in the name \texttt{BayerRG} for figure \ref{subfig:bayerrg}.
The Open Computer Vision Library (OpenCV) labels them after the elements $B_{2,2}$ and $B_{2,3}$, resulting in the name \texttt{BayerBG} for the same figure \ref{subfig:bayerrg} \cite{baumer_opencv}.

In order to create an RGB color image from the raw Bayer pattern image, a demosaicing (also ``debayering'') algorithm is necessary.
The Baumer industrial camera VCXU-13C is able to transform the raw sensor data into the respective RGB or BGR values in real time.
Another possibility is to do the required color space transformation with the OpenCV function \texttt{cv::cvtColor}.
Since OpenCV uses the BGR instead of the standard RGB color space, the required color space conversion code is \texttt{cv::COLOR\_BayerBG2BGR}.
This will convert the raw Bayer pattern image into a BGR image \cite{opencv_csc}.

\begin{figure}[ht]
  \centering
  \begin{subfigure}[b]{0.3\textwidth}
    \centering
    \includegraphics[scale=1]{bayerrg}
    \caption{\texttt{RGGB} (Baumer \texttt{BayerRG})}
    \label{subfig:bayerrg}
  \end{subfigure}
  \begin{subfigure}[b]{0.3\textwidth}
    \centering
    \includegraphics[scale=1]{bayergr}
    \caption{\texttt{GRBG} (Baumer \texttt{BayerGR})}
    \label{subfig:bayergr}
  \end{subfigure}
  \begin{subfigure}[b]{0.3\textwidth}
    \centering
    \includegraphics[scale=1]{bayergb}
    \caption{\texttt{GBRG} (Baumer \texttt{BayerGB})}
    \label{subfig:bayergb}
  \end{subfigure}
  \caption{Bayer color matrices $B$}
  \label{fig:bayer}
\end{figure}