%&hylatex
%File: c:\paul\550.436s\hwkassign.tex Wed Feb 07 11:38:34 2001

\documentclass{article}[12pt]

\usepackage{graphicx}   %       Graphics bundle
\usepackage{pspicture}  %       PSPicture
\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\topmargin}{-0.4in}
\setlength{\topskip}{0.3in}    % between header and text
\setlength{\textheight}{9in} % height of main text
\setlength{\textwidth}{6.5in}    % width of text
\setlength{\oddsidemargin}{0in} % odd page left margin
\setlength{\evensidemargin}{0in} % even page left margin
\linespread{1.3}
\setlength{\parindent}{0pt}

\pagestyle{myheadings}
\usepackage{graphicx}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
\usepackage{color}
\usepackage{hyperref}

%\input{commands}

\begin{document}
\thispagestyle{empty}
\includegraphics{../../../psulogo_horiz_bw.eps}\hfill\includegraphics{../../../deptlogo}
\vspace{10pt}
\begin{center}
{\large\bf STAT 671}    \\*[5pt] {\Large Statistical Learning I}
\\*[12pt] {\large Fall 2019}
\\ {\large Homework 4}
\\ {\large Due November 13$^{th}$ at the beginning of class}
\end{center}
\vspace{1cm}
\noindent

This homework is an exan that was given during a previous iteration of this course. I have voluntarily kept the presentation as it was for the exam.
\noindent
Do good work.

\noindent
Best regards,
\section{Multivariate Fisher Kernel}
The Fisher kernel is a kernel for data in $\mathbb{R}^d$ which is based on a probabilistic model. Specifically, let $x \in \mathbb{R}^d$, and let $p_{\theta}$ be a probability density function indexed by a parameter vector $\theta \in \mathbb{R}^k$.  First, fix some $\theta_0 \in \mathbb{R}^k$ and define the Fisher score of a data point $x$, by $\phi(x)$, the gradient of the logarithm of $p_{\theta}$ evaluated at $\theta=\theta_0$. That is,
\begin{equation}
\phi(x)=\nabla_\theta \ln p_{\theta}(x) |_{\theta=\theta_0}
\end{equation}
Thus $\phi: \mathbb{R}^d \to \mathbb{R}^k$.

Next, define the Fisher information matrix as the following expected value:
\begin{equation}
I = E_{p_{\theta_0}}[\phi(X)\phi^T(X)]
\end{equation}
Note that $I$ is a $(k,k)$ matrix. You can use the fact that this matrix is symmetric and positive definite.
Finally, define the Fisher kernel as
\begin{equation}
K(x,y)=\phi(x)^T I^{-1} \phi(y)
\end{equation}
for any couple of points $(x,y)$, both in $\mathbb{R}^d$
\begin{enumerate}
\item Verify that $K$ is symmetric
\newpage
\item Verify that $K$ is positive definite
\newpage
\item
Consider the following multivariate Normal model with given invertible covariance matrix $\Lambda^{-1}$:
\begin{equation}
p_\theta(x)=(2\pi)^{-d/2}(\det{\Lambda})^{1/2}\exp\left(-\frac{1}{2}(x-\theta)^T\Lambda (x-\theta)\right)
\end{equation}
Show that
\begin{equation}
\phi(x)=\Lambda (x - \theta_0)
\end{equation}
\newpage
\item Compute the Fisher information matrix $I$ for this model
\newpage
\item Compute the Fisher kernel for this model
\newpage
\end{enumerate}
\section{Optimal ordering}
We consider a binary classification problem where the training set is $\mathcal{D}=\{(x_i,y_i), 1\leq i \leq n\}$, with $x_i \in \mathbb{R}^d$ and $y_i \in \{-1,+1\}$ is the class. For convenience, we consider the following subset of indices
\begin{eqnarray}
I_-&=&\{i, 1\leq i \leq n, y_i=-1\}\\
I_+&=& \{i, 1\leq i \leq n, y_i=+1\}
\end{eqnarray}
Moreover, notate $n_-$ the number of elements in $I_-$, and $n_+$ the number of elements in $I_+$. Thus
\begin{equation}
n_-+n_+=n
\end{equation}
 Our objective is to use $\mathcal{D}$ to construct a function $f:\mathbb{R}^d \to \mathbb{R}$ that assign larger values to the data points in the positive class than to the data points in the negative class while being smooth in some sense.

Thus, we propose to choose $f$ in a RKHS with a kernel K that minimizes the following functional:
\begin{equation}
J_0(f) = \frac{1}{n_- n_+}\sum_{i \in I_-}\sum_{j \in I_+} \mathbb{I}_{f(x_i)>f(x_j)} + \lambda ||f||_H^2
\end{equation}
 where $\mathbb{I}_u$ is the indicator function of the event $u$. It takes the value 1 if the event u occurs and 0 otherwise and $\lambda>0$.

Since $J_0$ is not convex, we propose instead to minimize
\begin{equation}
J(f) = \frac{1}{n_- n_+}\sum_{i \in I_-}\sum_{j \in I_+}\left(1-\left(f(x_j)-f(x_i)\right)\right) + \lambda ||f||_H^2
\end{equation}
\newpage
\begin{enumerate}
\item Show that the minimum is achieved for a function $f$ index by a parameter $\alpha \in \mathbb{R}^d$ and of the form
\begin{equation}
f(x)=\sum_{i=1}^n \alpha_i K(x_i,x)
\end{equation}
Note: do not invoke the representer theorem. Instead, use the key elements in the proof of this theorem applied to this particular case.
\newpage
\item Rewrite then $J(f)$ as a functional $J(\alpha)$ using the notation  $K$ for the $(n,n)$ matrix $K_{ij}=K(x_i,x_j)$ and $K_i$ for the $i^{th}$ column of $K$.
\newpage
\item Simplify further the expression $J(\alpha)$ using the notations:
\begin{eqnarray}
K_-&=&\frac{1}{n_-}\sum_{i \in I_-}K_i\\
 K_+&=&\frac{1}{n_+}\sum_{i \in I_+}K_i
\end{eqnarray}

\newpage
\item Compute $\nabla_\alpha J(\alpha)$, the gradient in $\alpha$ of $J(\alpha)$. Solve for $\alpha$, assuming that $K$
is invertible.
\newpage
\item Bonus question: Compute $f^*(x)$, where $f^*$ is the minimizer of $J(f)$ for the linear kernel $K(x,y)=x^Ty$. Use the notations
 \begin{eqnarray}
{x}_-&=&\frac{1}{n_-}\sum_{i \in I_-}x_i\\
{x}_+&=&\frac{1}{n_+}\sum_{i \in I_+}x_i
\end{eqnarray}
\end{enumerate}
\end{document}


\documentclass[colorlinks=true,pdfstartview=FitV,linkcolor=blue,
            citecolor=red,urlcolor=magenta]{ligodoc}

\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{longtable}
\usepackage{rotating}
\usepackage[usenames,dvipsnames]{color}
\usepackage{fancyhdr}
\usepackage{subfigure}
\usepackage{hyperref}
\usepackage{mathtools}

\ligodccnumber{T}{17}{00198}{}{v1}% \ligodistribution{AIC, ISC}

\setlength\parindent{24pt}

\title{Online Detector Characterization using Neural Networks}

\author{Roxana Popescu}

\begin{document}

\section{Introduction}

\indent

\par The data obained from LIGO has noise that comes from many sources. In order to be able to better distinguish signals from the noise, it is important to characterize the type of noise observed. Machine learning algorthms can be used to look for patterns within the data and to classify the data into different categories.

\par There are many sensors at the LIGO detectors that measure sources of noise. For example, there are several stations at each LIGO detector that measure seismic noise in different frequency channels in each of the X,Y, and Z directions. Within the data, there are different types of seismic noise such as earthquakes and anthropogenic noise.

\par In order to sort data, machine learning algorithms can use one of two approaches: classification or clustering. Classification algorithms search the data and sort the data into already defined categories. Clustering algorithms look for relationships within the data to create categories into which the data is sorted. Classification algorithms are part of supervised learning since the computer determines the structure of the data from data that is already provided. Clustering algorithms are part of unsupervised learning since the computer determines the structure of the data without any previous information. Clustering algorithms can be used to characterize the noise by identifying common characteristics within the noise depending on its sources and can further help with classification. \cite{Citation1}

\par Neural networks can be used to find relationships between the inputed data by using hidden layers of connections within the data. Recurrent neural networks are neural networks that use loops within them so that previous information can be retained. \cite{Citation1}

\section{Objectives}

\indent

\par The aim of this project is to characterize different sources of noise from LIGO using machine learning algorithms. First I  will test clustering algorithms on seismic data, and then implement a neural network to sort through the seismic noise data, as well as other noise data.

\section{Clustering Algorithms}

\subsection{K-means clustering}

\indent

\par The k-means clustering algorithm creates clusters by separating data points into k number of groups. The value of k is inputted into the algorithm. The clusters are determined by minimizing the inertia, or the within-cluster sum-of-squares. The inertia is a measure of how coherent the clusters are. By minimizing the intertia, the algorithm tries to minimize the difference between the mean value of a cluster and the values of points in the cluster. If a set of n samples x are inputted, the algorithm divides the samples into k clusters C. Each cluster is described by its mean \(u_j\), or centroid. The interia of a cluster is caluclated by the following expression:

\[\sum_{i=0}^{n} \min_{\mu_j \in  C}(\|x_j-\mu_i\|^2)\]

\par The inertia is not normalized, but lower values are better and zero is the optimum value. The inertia assumes that the clusters are convex and isotropic, and would not work well to cluster irregular or elongated clusters. \cite{Citation2}

\subsection{DBSCAN clustering}

\indent

\par The DBSCAN clustering algorithm creates clusters out of areas in the data of higher density. Unlike kmeans, it does not consider clusters to have any particular shapes, and the algorithm determines the number of clusters based on inputted parameters. Core samples are points that are in areas of high densities. The algorithm creates clusters around core samples so that the clusters consist of core samples, and non-core samples that are close to the core samples. The core samples are determined by two input parameters, the minimum samples and a specified distance, $\varepsilon$. A point is in the $\varepsilon$-neighborhood if the distance d from a point p to a point q is within a radius of of $\varepsilon$, as determined below:

\[N_\varepsilon(p):\{q|d(p,q) \leq \varepsilon\}\]

\par High density areas have the minimum sample of values within the $\varepsilon$-neighborhood. By increasing the number of minimum samples, and decreasing the distance, $\varepsilon$, a cluster's density is increased. \cite{Citation2}\cite{Citation3}

\section{Current Progress}

\indent

\par I have used kmeans clustering from the scikit-learn python package \cite{Citation2} to examine seismic BLRMS data. Figure \ref{fig:image1} shows a plot of clustered data from the six seismic bands in in the X direction. There are six clusters in this graph. The kmeans clustering algorithm has been able to pick out anthropogenic noise but does not identify earthquakes well. I tried to use kmeans to identify earthquakes as a cluster by using combinations of different data channels for the clustering and by clustering the derivatives of the data. However, I was unable to use kmeans to sort the earthquakes into identifiable clusters.

\par I then used the DBSCAN clustering algorithm from the scikit-learn python package \cite{Citation2} to cluster data from the earthquake channels. Figure \ref{fig:image2} shows a plot of the earthquake channels clustered into eleven clusters by the DBSCAN clustering algorithm. The peaks, which indicate earthquakes are all in the same cluster. However, while the DBSCAN algorithm appears to work well with earthquake channel data alone, it did not cluster the earthquakes when data from other channels was combined with the earthquake channel data.

\section{Future Progress}

\indent

\par The next step in my project is to quantitatively exaluate how well the clustering algorithms work. For the earthquake band data, one way to evaluate how well the clustering works is to compare the data to a list of known earthquakes. I will also cluster data from more sensors and try out other clustering algorithms. After seeing how well clustering algorithms work, the next part of the project is to implement neural networks to characterize the noise.

\begin{figure}[htbp]
\begin{center}
\includegraphics[width=1.3\textwidth,angle=90]{all_X_6_data_data.png}
\caption{Plot of data from six seismic channels in the X-direction clustered into 6 clusters using kmeans}
\label{fig:image1}
\end{center}
\end{figure}

\begin{figure}[htbp]
\begin{center}
\includegraphics[width=1.3\textwidth,angle=90]{dbscan_EQ_XYZ_data_data.png}
\caption{Plot of earthquake data from each directon clusted using DBSCAN}
\label{fig:image2}
\end{center}
\end{figure}

\begin{thebibliography}{9}

	\bibitem{Citation1}
	  Aurélien Géron,
	  \emph{Hands-On Machine Learning with Scikit-Learn and TensorFlow}.
	 O'Reilly Media Inc., (2017).

       \bibitem{Citation2}
         \url{http://scikit-learn.org/stable/modules/clustering.html}

       \bibitem{Citation3}
         \url{https://www.cse.buffalo.edu/~jing/cse601/fa12/materials/clustering_density.pdf}

\end{thebibliography}

\end{document}


% --------------------------------------------------------------
% This is all preamble stuff that you don't have to worry about.
% Head down to where it says "Start here"
% --------------------------------------------------------------

\documentclass[12pt]{article}

\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{float}
\usepackage{color}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{verbatim}
\usepackage{mathtools}

\graphicspath{{./FIGURES/}}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}

\newenvironment{theorem}[2][Theorem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{lemma}[2][Lemma]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{exercise}[2][Exercise]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{reflection}[2][Reflection]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{proposition}[2][Proposition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{corollary}[2][Corollary]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}

\begin{document}

% --------------------------------------------------------------
%                         Start here
% --------------------------------------------------------------

%\renewcommand{\qedsymbol}{\filledbox}

\title{Computational Methods}%replace X with the appropriate number
\author{Francisco Castillo\\Homework 6} %if necessary, replace with your course title

\maketitle
\section*{Problem 1}
\input{problem1}
\newpage
\section*{Problem 2}
\input{problem2}
\newpage
\section*{Problem 3}
\input{problem3}
\newpage
\section*{Problem 4}
\input{problem4}

%\begin{figure}[H]
%\centering     %%% not \center
%\hspace*{\fill}
%\subfigure[$f(x)=|x|^3$.]{\includegraphics[scale=0.5]{IMAGES/problem4a.eps}}
%\hfill
%\subfigure[$f(x)=exp\left(\frac{-1}{\sin{(2x^2)}}\right)$.]{\includegraphics[scale=0.5]{IMAGES/problem4b.eps}}
%\hspace*{\fill}

%\hspace*{\fill}
%\subfigure[$f(x)=\frac{1}{\sin{(1+x^2)}}$.]{\includegraphics[scale=0.5]{IMAGES/problem4c.eps}}
%\hfill
%\subfigure[$f(x)=\sinh{x}$.]{\includegraphics[scale=0.5]{IMAGES/problem4d.eps}}
%\hspace*{\fill}
%\caption{Error of the polynomial interpolation on Chebyshev nodes for the different functions.}
%\end{figure}

\end{document}


\documentclass[letterpaper,12pt]{article}
\usepackage{epsfig,latexsym,amsmath,amssymb,epic,eepic,psfrag,subfigure,float,euscript,array}
\usepackage[latin1]{inputenc}
\usepackage{standalone}
\usepackage{tikz,pgf,pgfplots}
\usepackage[margin=2.5cm]{geometry}
\usepackage[amssymb]{SIunits}

\newenvironment{exercise}[1][Uppgift]{\begin{trivlist} \item[\hskip
    \labelsep {\stepcounter{exerctr}\bfseries #1
      \arabic{exerctr}}]}{\end{trivlist}\vspace{10mm}}

\newcounter{exerctr}
\newcounter{abcctr}[exerctr]

\newcommand{\abc}{\noindent\vspace{1mm}\\ {\bf
    \stepcounter{abcctr}(\alph{abcctr})\ }}
\newcommand{\bbm}{\begin{bmatrix}}
\newcommand{\ebm}{\end{bmatrix}}
\newcommand{\point}[1]{\hfill {\bf (#1p)}\\ \vspace{-5mm}}
\newcommand{\ctrb}{\EuScript{S}}
\newcommand{\Lap}{\mathcal{L}}
\newcommand{\obsv}{\EuScript{O}}
\newcommand{\realdel}[1]{\text{Re}\left\{#1\right\}}
\newcommand{\imagdel}{\text{Im}}
\newcommand{\bC}{\mathbb{C}}
\newcommand{\bR}{\mathbb{R}}
\newcommand{\bmpv}{\begin{minipage}[t]}
\newcommand{\bmps}{\begin{minipage}[t]{45mm}}
\newcommand{\bmpm}{\begin{minipage}[t]{90mm}}
\newcommand{\bmpl}{\begin{minipage}[t]{\textwidth}}
\newcommand{\emp}{\end{minipage}}
\newcommand*{\zethree}{\big(z - \mexp{-3h}\big)}
\newcommand*{\mexp}[1]{\ensuremath{\mathrm{e}^{#1}}}

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}

\addtolength{\topmargin}{-1cm}
\textheight 23.5cm
%\oddsidemargin 0.61cm
%\evensidemargin 0.61cm

\def\OctaveG{tf([0.5 1], [1 0 -1])}

\title{Computerized control partial exam 2 (15\%)}
\author{Kjartan Halvorsen}

\begin{document}

\maketitle

\begin{description}
\item[Time] 2017-03-28 17:35 - 19:00
\item[Place] 5105
\item[Permitted aids] The single colored page with your own notes, table of Laplace transforms, calculator
\end{description}

All answers should be readable and well motivated (if nothing else is written). Solutions/motivations should be written on the provided spaces in this exam. Use the last page if more space is needed.

\begin{center}
{\Large Good luck!} \\
\end{center}

\noindent
\fbox{
\bmpl
{\bf Matricual and name:}\\
\vspace*{30mm}
\emp}

\clearpage

%-----------------------------------------------------------------

\subsection*{Problem 1 (60p)}
%----------------------
% RST design for sampled harmonic oscillator
%----------------------

\subsubsection*{(a) 40p}
The plant to be controlled in figure \ref{fig:2dof} is a harmonic oscillator with resonance frequency \unit{1}{\rad\per\second}.  In continuous-time it is described by the transfer function
\begin{equation}
G(s) = \frac{\omega_0^2}{s^2 + \omega_0^2}, \quad \omega_0 = 1.
\end{equation}
Zero-order-hold sampling gives the discrete-time model
\begin{equation}
H(z) = \frac{(1-\beta)(z+1)}{z^2 -2\beta z + 1}, \quad \beta = \cos( \omega_0 h).
\end{equation}
Use the value $\omega_0 h = 0.35$ which gives $\beta \approx 0.94$.

The following specifications on the closed-loop system are given:
\begin{itemize}
\item The closed loop system from the command signal to the output should have the characteristic polynomial
  \begin{equation}
    A_c(z) = (z-0.4)^2
  \end{equation}
  and unit static gain \(H_c(1) = \frac{B_c(1)}{A_c(1)} = 1\).
\item  All observer poles should be placed in the origin.
\item The controller polynomials should have as low degree as possible.
\end{itemize}

Determine the polynomials \(R(z)\), \(S(z)\) and \(T(z)\) in an RST-controller of the form in figure~\ref{fig:2dof}, such that the specifications are satisfied. You can assume the problem to be solved once you have determined $T(z)$ and have written up the correct linear equations in the unknown controller parameters of $R(z)$ and $S(z)$. You don't have to solve this system of equations. Hint: $R(z) = z + 0.495$.

\begin{figure}
\begin{center}
\includegraphics[width=0.7\linewidth]{../../homework/rst-block}
\caption{RST controller}
\label{fig:2dof}
\end{center}
\end{figure}

\noindent
\fbox{
\bmpl
{\bf Controller design:}\\
\vspace*{250mm}
%\vfill
\emp}

\subsubsection*{(b) 20p}

Determine the closed-loop pulse transfer function $H_{d}(z)$ from the disturbance $d$ to the output $y$, and calculate the steady-state error for constant disturbances, i.e.~calculate $\lim_{k\to\infty} y(k)$ for input signals $u_c=0$ and $d = 1$. Use $R(z) = z + 0.495$.

\noindent
\fbox{
\bmpl
{\bf Solution:}\\
\vspace*{120mm}
\emp}

%\clearpage
\subsection*{Problem 2 (40p)}
Instead of the 2-degrees-of-freedom structure of figure \ref{fig:2dof}, consider now that the harmonic oscillator is controlled using feedback from the error signal as in figure \ref{fig:feedback}.
\begin{figure}[b]
\begin{center}
     \begin{tikzpicture}[scale = 0.8, node distance=25mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]

     \node[coordinate] (refinput) {};
     \node[sumnode, right of=refinput, node distance=20mm] (sumerr) {\tiny $\sum$};
     \node[block, right of=sumerr] (controller) {$F(s)$};
     %\node[above of=controller, node distance=6mm] {controller};
     \node[block, right of=controller, node distance=35mm] (plant) {$\frac{\omega_0^2}{s^2 + \omega_0^2}$};
     \node[sumnode, right of=plant, node distance=24mm] (sum) {\tiny $\sum$};
     %\node[above of=tank, node distance=6mm] {motor};
     \node[coordinate, right of=sum, node distance=20mm] (output) {};
     \node[coordinate, above of=sum, node distance=12mm] (disturbance) {};

     \draw[->] (refinput) -- node[above, pos=0.3] {$u_c(t)$} (sumerr);
     \draw[->] (sumerr) -- node[above] {$e(t)$} (controller);
     \draw[->] (controller) -- node[above] {$u(t)$} (plant);
     \draw[->] (plant) -- (sum);
     \draw[->] (sum) -- node [coordinate] (measure)  {} node [above, near end] {$y(t)$} (output);
     \draw[->] (disturbance) -- node[right, pos=0.2] {$d(t)$} (sum);
     \draw[->] (measure) -- ++(0,-14mm) -| node[right, pos=0.95] {$-$} (sumerr);
     \end{tikzpicture}
     \caption{Feedback control from the error signal.}
     \label{fig:feedback}
   \end{center}
 \end{figure}

A lead-lag compensator has been designed in continuous-time. It has the transfer function
\begin{equation}
F(s) = \frac{15s + 3}{s + 7} \cdot \frac{1.5s + 1}{1.5s}
\end{equation}

\subsubsection*{(a) 20p}
Discretize the controller $F(s)$ using Tustin's approximation
\[ s = \frac{2}{h}\cdot\frac{z-1}{z+1} \]
and determine the poles and zeros of the discrete-time controller. Use the same sampling period $h=0.35$ as in the previous problem.

\noindent
\fbox{
\bmpl
{\bf Solution:}\\
\vspace*{170mm}
\emp}

\subsubsection*{(b) 10p}
Figure \ref{fig:sim} shows responses of the closed-loop systems obtained with the RST-controller and with the discretized lead-lag-controller, respectively.  Which response corresponds to which controller? Motivate your answer!

\noindent
\fbox{
\bmpl
{\bf Answer and motivation:}\\
\vspace*{80mm}
\emp}

\begin{figure}[hb]
\begin{center}
\includegraphics[width=0.9\linewidth]{RST_leadlag_sim-crop}
\caption{Response of the closed-loop system obtained with an RST controller and with a discretized lead-lag controller. At time $t=5h$ a step in the command signal $u_c(kh)$ occurs, and at $t=100h$ a step in the disturbance signal $d(kh)$ occurs. }
\label{fig:sim}
\end{center}
\end{figure}

\subsubsection*{(c) 10p}
Study figure \ref{fig:sim} and write down \textbf{three} relevant observations about the behaviour of the closed-loop systems. Suggest an improvement to the RST controller.

\noindent
\fbox{
\bmpl
{\bf Answer:}\\
\vspace*{100mm}
\emp}

\cleardoublepage

\noindent
{\bf If necessary,} you can continue your solutions on this sheet. Mark clearly which problem the solution corresponds to.

%\end{document}

\section*{Solutions}
\subsection*{Problem 1}

\subsubsection*{(a)}
This problem is quite straightforward RST design. There are no requirement that constant distubances on the output must be eliminated, and so we do not need to include an integrator in the feedback controller. The Diophantine equation is
\begin{align*}
A(z) R(z) + B(z) S(z) &= A_c(z)A_o(z).
\end{align*}
The order of the controller should be as low as possible, while still giving us sufficient flexibility to obtain the desired second order polynomial $A_c(z)=(z-0.4)^2 = z^2 - 0.8z + 0.16$. Since the polynomial $A(z)$ is of degree two, we have that the Diophantine equation will be of degree $n_R + 2$, and will give as many equations in the unknowns when we set the coefficients on both sides of the equality sign equal.

The controller is \(\frac{S(z)}{R(z)}\) which has \(2n_R + 1\) unknown coefficients when $S(z)$ and $R(z)$ are of the same degree. These coefficients are to be determined from the Diophantine equation, so we must have
\[ 2n_R + 1 = n_R + 2 \quad \Rightarrow \quad n_R = 1. \]
The left hand side of the Diophantine equation is of degree 3, so then we need a single observer pole in the origin, $A_o(z)=z$.
We can now set up the Diophantine equation
\[ (z^2 - 1.879z + 1)(z+r_1) + 0.061(z + 1)(s_0z + s_1) = (z^2 - 0.8z + 0.16)z\]
or
\[ z^3 + (r_1 + 0.061s_0 - 1.879)z^2 + (- 1.879r_1 + 0.061s_0 + 0.061s_1 + 1)z + r_1 + 0.061s_1 = z^3 - 0.8z^2 + 0.16z,\]
from which we get
\begin{align*}
 r_1 + 0.061s_0 &= -0.8+1.879\\
-1.879r_1 + 0.061s_0 + 0.061s_1 &= 0.16-1\\
r_1 + 0.061s_1 &= 0.
\end{align*}
This is sufficient solution for this part of the exercise. Actually solving the system of equations gives
\begin{align*}
r_1 &= 0.495\\
s_0 &= 9.63\\
s_1 &= -8.16
\end{align*}

With $T(z) = t_0 A_0(z)$, the closed-loop system becomes
\[ H_c(z) = \frac{T(z)B(z)}{A(z)R(z) + B(z)S(z)} =   \frac{t_0B(z)}{A_c(z)}. \]
Unit static gain is obtained with
\[ t_0 = \frac{A_c(1)}{B(1)} = \frac{0.36}{0.121} = 2.97. \]

The controller is thus
\begin{align*}
H_{fb}(z) &= \frac{S(z)}{R(z)} = \frac{9.63z - 8.16}{z + 0.495}\\
H_{ff}(z) &= \frac{T(z)}{R(z)} = \frac{2.97z}{z + 0.495}.
\end{align*}

\subsubsection*{(b)}
Using Mason's rule:
\begin{equation*}
\begin{split}
 H_d(z) &= \frac{1}{1 + \frac{B}{A}\cdot\frac{S}{R}} = \frac{A(z)R(z)}{A(z)R(z) + B(z)S(z)} \\
        &= \frac{A(z)R(z)}{A_c(z)A_o(z)} = \frac{(z^2 - 1.879z + 1)(z + 0.495)}{(z-0.4)^2z},
      \end{split}
\end{equation*}
which has static gain
\[ H_d(1) = \frac{(1 - 1.879 + 1)(1.495)}{0.36} = 0.503.\]
so
\begin{equation*}
\begin{split}
\lim_{k\to\infty} y(k) &= \lim_{z\to 1} (z-1) Y(z) = \lim_{z\to 1} (z-1) H_d(z) \frac{z}{z-1}\\
 &= H_d(1) = 0.503.
\end{split}
\end{equation*}

\subsection*{Problem 2}

\subsubsection*{(a)}

Inserting the expression for Tustin's approximation we get
\begin{equation*}
\begin{split}
F_d(z) &= F(s)|_{s = \frac{2}{h}\cdot\frac{z-1}{z+1}} \\
 &= \frac{ 15 \frac{2}{h}\cdot\frac{z-1}{z+1} + 3}{ \frac{2}{h}\cdot\frac{z-1}{z+1} + 7 } \cdot \frac{1.5\frac{2}{h}\cdot\frac{z-1}{z+1} + 1}{ 1.5\frac{2}{h}\cdot\frac{z-1}{z+1} } \\
&= \frac{\big(30(z-1) + 3\cdot 0.35(z+1)\big) \big( 3(z-1) + 0.35(z+1)\big)}{\big(2(z-1) + 7\cdot 0.35(z+1)\big)3(z-1)}\\
&= \frac{(31.05z -28.95)(3.35z - 2.65)}{3(4.45z + 0.45)(z-1)}.
\end{split}
\end{equation*}
There are two poles
\[ z = -\frac{0.45}{4.45} \approx -0.101 \quad \text{and} \quad z = 1\]
and two zeros
\[ z = \frac{28.95}{31.05} \approx 0.93 \quad \text{and} \quad z = \frac{2.65}{3.35} \approx 0.79. \]

\subsubsection*{(b)}

It is probably easiest to see the difference in the response to the disturbance at $t=100h$. The solid line has a stationary error, but the dashed has not. The RST controller has no integrator but the lead-lag compensator does. The integrator in the lead-lag compensator eliminates the constant disturbance. So, the solid line corresponds to the response of the RST controlled system, and the dashed line corresponds to the system controlled with a lead-lag compensator.

It can also be seen from the fact that the designed closed-loop system of the RST controller has real-valued poles. Such a system should not give the high overshoot of the dashed line.

\subsubsection*{(c)}

Suggested observations:
\begin{itemize}
\item The dashed line has significant overshoot. This suggests a small phase margin.
\item The solid line has no overshoot. This suggests real-valued poles.
\item The dashed line goes more slowly to the final value. This suggests the existence of a slow pole close to the origin.
\item The dashed line eliminates the constant disturbance, so the loop gain has infinite static gain, i.e.~it contains an integrator.
\item The solid line shows a persisting error when a disturbance is present.
\end{itemize}

The only real problem with the response of the RST controller is that the disturbance is not eliminated. We could fix this by introducing an integrator in the RST controller (incremental RST), i.e.~set
\[ R(z) = (z-1)\bar{R}(z)\]
and redo the design.
\end{document}


% ..........................................................................
% --------------------------------------------------------------------------
% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%              Crypto 2020
% /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\newpage
\hypertarget{Chapter_Crypto2020}{}
\chapter{Crypto 2020 --- Perspectives for Long-Term Cryptographic
         Security}\index{security!long-term}
\label{Chapter_Crypto2020}
\begin{sloppypar}
(Johannes Buchmann, Erik Dahmen, Alexander May and Ulrich Vollmer, TU Darmstadt, May~2007)\\
\end{sloppypar}

% \begin{abstract}Ever more powerful hardware and new
%   mathematical algorithms threaten to undermine
%   the security of cryptographic keys and schemes.
%   How long will the methods we use today be able
%   to keep what they promise?  And which
%   alternatives are on the horizon?
% \end{abstract}

Cryptography is a basic building block of all IT
security solutions.  Yet, for how long are the
cryptographic tools we use today going to remain
secure?  Is this time long enough to ensure the
confidentiality of medical data, to name just one
example?  Even in the short-term, the potential
for havoc is great if certain keys are broken.
Just think of the digital signatures that protect
the authenticity of automatic updates for the
Windows operating system.

\section{Widely used schemes}
\label{sec:the-weak}

In 1978, Rivest, Shamir and Adleman suggested the
RSA\index{RSA} public key encryption and signature
schemes~\cite{rivest/shamir/adleman:1978}.  RSA is
still the most widely used public key scheme.  The
security of RSA depends on the difficulty of
factoring so-called RSA moduli which are products
of two large prime numbers.  In their 1978 paper,
the inventors of RSA suggested the use of RSA
moduli with 200 decimal digits for long-term
security.  Later, the company RSA Security
published a list of RSA moduli of increasing size,
the RSA challenge numbers.  RSA Security offered
prizes totaling \$ 635,000 for the factorization
of these numbers, cf.\
\url{www.rsasecurity.com/rsalabs/}.

In 2005, that is 27 years after the invention of
RSA, Bahr, Boehm, Franke, and Kleinjung from
Bochum University managed to factor a 200 digit
RSA challenge number
(\url{www.mat.uniroma2.it/~eal/rsa640.txt}).  A
key with size originally thought to be secure for
a very long time was broken with a computation
that took them just five months.  This illustrates
the tremendous progress factoring technology has
made within the last 30 years.  This progress is
based on break-through mathematical ideas --- e.g.\
the number field sieve proposed by John
Pollard --- as well as significant developments in
computer hardware and software implementation
technology.\footnote{%
Please compare chapter \ref{SecurityRSA}
\hyperlink{SecurityRSA}{Considerations regarding the
security of the RSA algorithm}, and especially chapters
\ref{nt:NoteFactorization} and \ref{FactorizationResearch}.
}

In 2000, Lenstra and Verheul\index{Lenstra/Verheul}
developed an extrapolation formula that is supposed
to help us forecast the security\index{security!forecast}
one can achieve with RSA and other important
cryptographic schemes in the long
term (\url{www.keylength.com}).  The formula
suggests the use of 850 digit RSA moduli if one
wishes to protect data for the next 30 years.
This corresponds to a 3072 bit RSA key.

Yet, even a well thought out extrapolation formula
is no security guarantee!  At any time, a
brilliant mathematical idea can allow us to factor
large numbers easily, and destroy the security of
RSA.  In 1996, Peter Shor showed that a quantum
computer --- a new type of computer that leverages
the laws of quantum mechanics to speed up certain
types of computations --- can in principle be used
for the fast factorization of large numbers \cite{shor:1997}.
Despite intensive research in the area, it is
still too early to judge whether we are ever going
to be able to build quantum computers\index{quantum computer} of
sufficient capacity to apply Shor's algorithm to
numbers of relevant size.\footnote{%
Required qbits for attacks on RSA, DSA and ECDSA using key with a bit length n: \\
\vskip +1 pt
\begin{tabular}{|c|l|}
\hline
   RSA		&  2n + 3 \\
   DSA		&  2n + 3 \\
   ECDSA $2^n$	&  \~{}2n + 8 log n \\
   ECDSA p	&  \~{}4n \\
\hline
\end{tabular}
\vskip +6 pt
Please compare chapter 5.3 in
``SicAri -- Eine Sicherheitsplattform und deren Werkzeuge
f\"ur die ubiquit\"are Internetnutzung, KB2.1 -- Abschlussbericht,
\"Ubersicht \"uber Angriffe auf relevante kryptographische Verfahren'',
version 1.0, Mai 17, 2005,
Prof. Dr. Johannes Buchmann et al., TUD-KryptC and cv cryptovision GmbH
(\href{http://www.cdc.informatik.tu-darmstadt.de/~schepers/kb\_21\_angriffe.pdf}
 {\tt http://www.cdc.informatik.tu-darmstadt.de/\~{}schepers/kb\_21\_angriffe.pdf}) and the dissertation of Axel Schmidt at the same faculty.
}
Recent announcements of
significant progress in this area made by the
start-up company D-Wave (\url{www.dwavesys.com})
have been greeted with a lot of scepticism, even
ridicule.

The development of attacks on another frequently
used scheme called DSA (Digital Signature
Algorithm) and the Elliptic Curve Cryptography
(ECC) class of schemes moves in analogy to those
on RSA.  The security of these schemes depends on
the difficulty of computing discrete logarithms.
Even today, there is significant algorithmic
progress.  Quantum computers would render these
schemes insecure.

What's the state of affairs with the so-called
secret-key encryption schemes?  In 1977, DES was
introduced as the Data Encryption
Standard~\cite{DES-Standard:1977}.  Twenty-one
years later, the Electronic Frontier Foundation
(EFF) built the special purpose machine Deep Crack
which needed just 56 hours to break a DES key.
The problem with DES was that it used keys which
were too short.  It seems that the inventors of
DES did not foresee the speed of hardware
development.  The Advanced Encryption Standard
AES~\cite{AES-Standard:2002}, successor to DES, is
deemed secure at the moment even though there are
interesting, if still inefficient, methods to
attack AES with algebraic methods.

\section{Preparation for tomorrow}
\label{sec:preparations}

Is the security of today's cryptography measuring
up to its increasing importance?  The experience
shows: Carefully designed and implemented
cryptographic schemes have a life time of five to
twenty years.  Whoever uses RSA, ECC or AES for
short-term protection of data may feel safe.
Moreover, it is also possible to achieve long-term
authenticity, integrity and non-reputability of
data, e.g., using the multiple signature scheme
suggested by S\"onke Maseberg~\cite{maseberg-thesis:2002}.

However, current schemes cannot guarantee
long-term confidentiality.  And what is to be done in
twenty years from now?  What should we do if, quasi
over-night, unexpected mathematical progress
renders an important cryptographic scheme
insecure?  Three things are necessary to prepare
us for this event:

\begin{itemize}
\item a pool of secure alternative cryptographic schemes,
\item infrastructures that enable us to exchange
   one cryptographic scheme for another, easily
   and quickly, and
\item methods that ensure long-term confidentiality.
\end{itemize}

For many years, the cryptography group at the
Technische Universit\"at Darmstadt and its spin-off,
the company FlexSecure (\url{www.flexsecure.de}),
have worked to provide these tools.  The
trust center software FlexiTrust which is employed
by the German National Root Certification
Authority and the German Country Signing Authority
offers an infrastructure within which
cryptographic schemes can be easily exchanged.
The open source library FlexiProvider\index{FlexiProvider} implements a
multitude of cryptographic schemes.  Lately, we
have intensified our research into ``Post Quantum
Cryptography''\index{cryptography!post quantum}\index{post-quantum computing}\index{PQC} seeking
cryptographic schemes which
remain secure even in the event that powerful
quantum computers are built.

The security of public key cryptography
traditionally rests on the difficulty of the
solution of certain mathematical problems.  Today,
the following alternatives to the factorization and discrete
logarithm problems are discussed in depth:  the
decoding problem, the shortest and closest vector
problem in lattices, and the problem of solving
large systems of multivariate quadratic
equations.  It is conjectured that quantum
computers\index{quantum computer} offer little advantage if we try to
solve these problems efficiently.

\section{New mathematical problems}
\label{sec:problems}

Let us look at these alternatives a little more
closely.  The first encryption scheme based on the
decoding problem was proposed by
McEliece~\cite{mceliece:1978}\index{encryption!McEliece}.  The background:
Error-correcting codes are used to transmit or
store electronic data in such a way that they
remain undistorted even if a small number of bits
are changed in transit or on the storage media.
This property is used in, e.g., compact discs
(CDs).  The data on a CD can be reconstructed even
if the disc has been slightly scratched.

In a code-based encryption\index{encryption!code-based} scheme a message is
encrypted by adding a fixed number of errors to
(i.e. flipping a fixed numbers of bits of) the
encoded message.  Decoding requires knowledge of a
suitable decoding procedure which eliminates these
errors efficiently.  This method is the secret
key.  Code-based encryption is in general very
efficient.  At the moment, research focus on the
question which codes lead to secure encryption
schemes with keys which are as small as possible.

Encryption on the basis of lattice problems\index{encryption!lattice problems}
is very similar to that on the basis of
error-correcting codes.  Lattices are regular
structures of points in space.  For instance, the
points where the lines on squared paper cross form
a two-dimensional lattice.  For cryptographic
usage, the dimension of the lattices is chosen to
be much larger.  Encryption works as follows: The
plain-text is used to construct a lattice point
which is then slightly distorted in such a way
that it is no longer a lattice point, but close to
one.  Whoever knows a secret about the lattice is
able to find this lattice point in the vicinity of
the given point in space.  The lattice point in
turn yields the plain text.  A particularly
efficient lattice based encryption scheme is NTRU
Encrypt (\url{www.ntru.com})\index{encryption!lattice problems!NTR}.
However, because
NTRU was introduced fairly recently (in 1998), and
its specification underwent several changes due to
a variety of attacks, more cryptanalytic scrutiny
is required to achieve confidence in its security.

\section{New signatures}
\label{sec:signatures}

In 1979, Ralph Merkle proposed a remarkable
framework for new signature schemes in his PhD
thesis~\cite{merkle-thesis:1979}.
Contrary to all other signature schemes\index{signature!Merkle}, its
security does not rest on the difficulty of a
number-theoretic, algebraic or geometric problem.
The only thing it requires is something which
other signature schemes need anyway: a
cryptographically secure hash function and a
secure pseudo-random number generator.  Each new
hash function leads to a new signature algorithm.
In consequence, the Merkle scheme has the
potential to solve the problem of long-term
availability of digital signature schemes.

Merkle uses in his construction so-called One-Time
Signatures: Each new signature requires a new
signing key and a new verification key.  The idea
Merkle had was to reduce the validity of many
verification keys using a hash tree to the
validity of a unique public hash value.  When
generating keys for the Merkle scheme one has to
determine the number of signatures one can make
with it in advance.  For a long time this seemed a
significant disadvantage.  In
\cite{buchmann/coronado/dahmen/doering/klintsevich:2006},
however, a variant of Merkle's scheme was proposed
which allows to compute $2^{40}$ signatures with a
single key pair.

%\subsection{Quantum cryptography -- a loophole?}
\section{Quantum cryptography -- a way out of the impasse?}
\label{sec:quantum cryptography}\index{quantum cryptography}

From the point of view of today's state of the art
of cryptography, the problem of long-term
confidentiality remains unsolved: There is
\emph{no} practical method to protect the
confidentiality of an encrypted message over a
very long period of time.

One way out of that dilemma may be to employ
quantum cryptography: it allows for key agreement
schemes (of very long keys for one-time pads)
whose security is
guaranteed by the laws of quantum mechanics,
cf., e.g., \cite{bennett/brassard:1984b}.  At the
moment, however, quantum cryptography is still
rather inefficient, and it is unclear which
cryptographic functionalities can be implemented
on top of it.

\section{Conclusion}
\label{sec:conclusion}

What's on the balance sheet of today's cryptography?  We
have good tools to ensure short and medium term
security.  Software developers can employ these
tools in their applications with good conscience
as long as they make sure that components
can quickly be exchanged when they become
insecure.

In order to guarantee IT security for the future, too,
we need to prepare a portfolio of secure cryptographic
schemes.  This portfolio needs to contain schemes
which are suitable for the world of ubiquitous
computing with many less powerful computers.  It
also needs to contain schemes which remain secure
in the event that powerful quantum computers\index{quantum computer} are
built.  Several promising candidates have been
discussed in this article.  They need to be
studied carefully and prepared for use in everyday
scenarios.  The question how to ensure long-term
confidentiality remains an important open research
problem upon which cryptographic research should
focus.

\putbib
\addcontentsline{toc}{section}{Bibliography}   % To add it in Contents and PDF-Navigation


\documentclass{article}
\usepackage[a4paper,margin=1in,bottom=1in,top=1in]{geometry}
\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage[plain]{algorithm}
\usepackage{algpseudocode}
\usepackage{minted}
\usepackage{parskip}

%
% Basic Document Settings
%

\pagestyle{fancy}
\lhead{\hmwkAuthorName}
\chead{\hmwkClass\ (\hmwkClassInstructor\ --- \hmwkClassTime)}
\rhead{\hmwkTitle}
\lfoot{\lastxmark}
\cfoot{\thepage}

%
% Create Problem Sections
%

\newcommand{\enterProblemHeader}[1]{
    \nobreak\extramarks{}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
    \nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
}

\newcommand{\exitProblemHeader}[1]{
    \nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
    \stepcounter{#1}
    \nobreak\extramarks{Problem \arabic{#1}}{}\nobreak{}
}

\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}

\newenvironment{homeworkProblem}{
    \section{Problem \arabic{homeworkProblemCounter}}
    \setcounter{partCounter}{1}
    \enterProblemHeader{homeworkProblemCounter}
}{
    \exitProblemHeader{homeworkProblemCounter}
}

%
% Title Page
%

\title{
    \vspace{2in}
    \textmd{\textbf{\hmwkClass:\ \hmwkTitle}}\\
    \normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate\ at \hmwkDueTime}\\
    \vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \\ \hmwkClassTime\ --- \hmwkRoom}}
    \vspace{3in}
}

\author{\textbf{\hmwkAuthorName}\\SID: 430218864}
\date{}

\renewcommand{\part}[1]{\textbf{\large Part \Alph{partCounter}}\stepcounter{partCounter}\\}
\newcommand{\solution}{\subsection*{Solution}}

%
% Homework Details
%   - Title
%   - Due date
%   - Class
%   - Section/Time
%   - Instructor
%   - Author
%

\newcommand{\hmwkTitle}{Homework\ \#2}
\newcommand{\hmwkDueDate}{February 12, 2014}
\newcommand{\hmwkDueTime}{3:30pm}
\newcommand{\hmwkClass}{Calculus}
\newcommand{\hmwkClassTime}{Section A}
\newcommand{\hmwkRoom}{SIT 114}
\newcommand{\hmwkClassInstructor}{Professor Isaac Newton}
\newcommand{\hmwkAuthorName}{Harrison Conlin}

\begin{document}
\maketitle

\pagebreak

\begin{homeworkProblem}
    Suppose we would like to fit a straight line through the origin
    \\

    \part

    Find the least squares esimator for \(\hat{\beta_1}\) for the slope
    \\

    \solution

    To find the least squares estimator, we should minimize our Residual Sum
    of Squares, RSS:

    \pagebreak

    \part

    Calculate the bias and the variance for the estimated slope
    \\

    \solution

\end{homeworkProblem}

\pagebreak

\end{document}


\chapter{Track reconstruction for different energies and track densities}
The quality of the reconstruction of tracks depends on numerous factors such as the particle, the telescope, and the reconstruction software.
For the reconstruction of the proton tracks, the two most crucial properties are their energy, which influences their scatterings as well as the probability to deposit
energy in each sensor, and the particle density, which influences the number of possible combinations of clusters.
Both of these properties significantly affect the number and the quality of the reconstructed tracks, which raises the question, how Corryvreckan performs
under the variation of both of these properties.
In sections \ref{sec:energy} and \ref{sec:density}, the variation of the energy and the track density was investigated respectively.

To analyse the performance of Corryvreckan, the setup from section \ref{sec:setup} is used and tracks are fitted with the general broken lines algorithm
from the Tracking4D module.
The proton energies to be analysed are $\SI{50}{\mega\eV}$, $\SI{100}{\mega\eV}$, $\SI{200}{\mega\eV}$,
$\SI{1}{\giga\eV}$, $\SI{5}{\giga\eV}$, $\SI{20}{\giga\eV}$, and $\SI{180}{\giga\eV}$. For each value of these parameters a simulation with track densities
of 2, 5, 10, 25, and 50 protons per event and a total amount of 50000 protons is created. \\
The ratio of reconstructed tracks to the total number of tracks for each configuration is shown in table \ref{tab:study}. Here, the relative spatial cut applied is 15.1.

\begin{table}
  \centering
  \begin{tabular}{c | c c c c c c c}
    \toprule
     p/event &  $\SI{50}{\mega\eV}$ & $\SI{100}{\mega\eV}$ & $\SI{200}{\mega\eV}$ & $\SI{1}{\giga\eV}$ & $\SI{5}{\giga\eV}$ & $\SI{20}{\giga\eV}$ & $\SI{180}{\giga\eV}$ \\
    \midrule
     2   & 1 & 0.8924 & 0.8224 & 0.8241 & 0.7870 & 0.7790 & 0.7706  \\
     5   & 1 & 0.6328 & 0.5903 & 0.5853 & 0.5184 & 0.5050 & 0.5025  \\
     10  & 0.625 & 0.4038 & 0.3930 & 0.3842 & 0.3224 & 0.3149 & 0.3136  \\
     25  & 0.5 & 0.1823 & 0.1723 & 0.1740 & 0.1441 & 0.1409 & 0.1410  \\
     50  & 0.2727 & 0.0840 & 0.0755 & 0.0788 & 0.0681 & 0.0669 & 0.0674  \\
  \end{tabular}
  \caption{Ratio of true reconstructed tracks to the total number of reconstructed tracks for different proton energies and protons per event.}
  \label{tab:study}
\end{table}

An increasing track density and energy both cause the ratio to decrease with the track density being the dominant factor influencing this property. Especially for high energies,
the ratios seem to converge. The lack of simulated uncertainties in the detector setup,
the proton energy and the initial direction contribute to this result. However, high energy particles tend to have lower kink angles, which enables the use of
stricter spatial cuts to optimise the ratio of true and false tracks.
For a proton energy of $\SI{50}{\mega\eV}$, the number of protons depositing energy is low enough for no false combinatorics to arise for two and five
protons per event, indicating that the ratio of one is the consequence of limited statistics.


\documentclass[a4paper]{article}

\def\npart{IB}

\def\ntitle{Quantum Mechanics}
\def\nlecturer{J.\ M.\ Evans}

\def\nterm{Michaelmas}
\def\nyear{2017}

\input{header}

\theoremstyle{definition}
\newtheorem*{postulate}{Postulate}

\begin{document}

\input{titlepage}

\tableofcontents

\setcounter{section}{-1}
\section{Introduction}

Quantum mechaniccs is a radical generalisation of classical physics involving a new fundamental constant, \emph{Planck's constant},
\[
  \hbar = h/2\pi \approx 1.05\times 10^{-34} Js
\]

Profund new features of quantum mechanics include:
\begin{itemize}
\item Quantisation: Physical quantities such as energy may be restricted to discrete sets of values, or may appear only in specific amounts, called \emph{quanta}.
\item Wave-particle duality: Classical concepts of a particle and a wave are merged; they become different aspects of a single eneity that shows either particle-like or wave-like behaviour, depending on the circumstances.
\item Probability and uncertainty
\end{itemize}

Despite these radical changes, classical physics must be recovered in the limit $\hbar \to 0$ (which may require careful interpretation).

The followint sections provide some physical background and summarise key experimental evidence for these novel features of quantum mechanics.

\subsection{Light Quanta}

An electromagnetic (EM) wave, e.g. light, consists of quanta called \emph{photons}. Photons can be regarded as particles with energy, $E$, and momentum, $p$, related to frequence, $\nu$ or $\omega$, and wavelength $\lambda$, or wavenumber, $k$, according to
\begin{alignat*}{2}
  E &= h\nu &&= \hbar \omega \\
  p &= h/\lambda &&= \hbar k
\end{alignat*}

From the wave equation (satisfied by each EM field component)
\[
  c= \omega/k = \nu\lambda \: \text{or } E=cp
\]
and so the relations above are consistent with photons being particles of rest mass zero, moving with the speed of light, $c$.

Compelling evidence for the existence of photons is provided by the \emph{photoelectric effect}. Consider light or EM radiation ($\gamma$) of frequence $\omega$ incident on a metal surface. For certain metals and suitable frequencies this results in the emission of electrons ($e^-$) and their maximum kinetic energy $K$ can be measured.

Experiments find that
\begin{enumerate}
\item the rate at which electrons are emitted is proportional to the intensity of the radiation (the `brightness' of the source);
\item $K$ depends linearly on $\omega$ but \emph{not} on the intensity;
  \item for $\omega < \omega_0$, some critical value, \emph{no} electrons are emitted, irrespective of the intensity.
\end{enumerate}

These results are extremely hard to understand in terms of classical EM waves. However, they follow naturally from the assumption that the wave consists of photons, each with energy $E=\hbar\omega$, and with the intensity of the radiation proportional to the number of photons incident per unit time. Suppose that an electron is emitted as a result of absorbing a single photon with sufficiently high energy. If $W$ is the minimum energy needed to liberate an electron from the metal then
\[
  K=\hbar\omega-W
\]
is the maximum kinetic energy of an emitted electron if $\omega>\omega_0$, where $\omega_0=W/\hbar$, and no emission is possible if $\omega<\omega_0$. Furthermore, the rate at which electrons are emitted wil be proportional to the rate at which incident photons arrive, and hence the intensity.

The energy-frequency relation for photons was introduced by Planck and used to derive the \emph{black body spectrum}. This is the distribution of energy with frequency for EM radiation in thermal euqilibrium, a fundamental result in thermodynamics of far-reaching importance (understanding the \emph{cosmic microwave background}, for example). Einstein then applied the energy-frequency relation to explain the photoelectric effect. Further conclusive evidence for photons as particles, including the momentum-wavelength relation, came from subsequent experiments involving \emph{Compton scattering}.

Consider a photon of wavelength $\lambda$ colliding with an electron that is statioinary in the laboratory frame. Let $\lambda'$ be the wavelength of the photon after the collision and $\theta$ the angle through which it is deflected. Treating the photon as a massless relativistic particle, conservation of four-momentum imples
\[
  \lambda'-\lambda = \frac{h}{m_e c}(1-\cos \theta).
\]
This dependence of the change in wavelength (or decrease in energy) on the scattering angle $\theta$ can be verified experimentally (for X-rays or $\gamma$-rays, for instance).

\subsection{The Bohr Model of the Atom}

The \emph{Rutherford model} of the atom was proposed to explain the results of scattering experiments (e.g. alpha particles scattered by gold foil). The key assumption is that most of the mass of the atom is concentrated in a compact, positively-charged \emph{nucleus} (subsequently understood to consist of protons and neutrons), with light, negatively-charged electrons orbiting aroundit. The simplest case is the hydrogen atom, in which a single electron with charge $-e$ and mass $m_e$ orbits a nucleus consisting of a single proton with charge $+e$ and mass $m_p$. Since $m_p >> m_e$ it is a good approximation to assume that the proton is stationary, at the origin, say. The electron and proton interact via Coulomb's Law: the potential energy of the electron and the force it experiences are
\[
  V(r) = -\frac{e^2}{4\pi \epsilon_0} \frac{1}{r},\: \V F(\V r) = -\nabla V = -\frac{e^2}{4\pi \epsilon_0}\frac{1}{r^2} \hat{\V r}.
\]

The classical equations of motion for the electron imply that its angular momentum, $\V L = \V r \times \V p$, and its total energy,
\[
  E=\frac{1}{2}m_e v^2 - \frac{e^2}{4\pi\epsilon_0}\frac{1}{r},
\]
are constant. The orbits are therefore planar and they can be determined exactly. For any value of $E<0$ there is a closed orbit and the electron is \emph{bound} to the proton to form a hydrogen atom. For orbits with $E>0$ the electron eventually escapes to infinity: it is not bound to the proton.

Despite the success in accounting for Rutherford scattering, this model has a number of problems. The treatment is identical, mathematically, to planetary orbits governed by gravity but an importatnt additional feature of electromagnetism has been left out. An accelerating charge radiates energy and this means that the electron will actually spiral inwards towards the proton: this is not a good model of a stable atom.

There is also experimental evidence for complex discrete structure within atoms. This comes from \emph{line spectra}: brigh emission lines (from a hot sample) or dark absorption lines (if radiation is passed through a cooler sample), both occuring at certain characteristic wavelengths or frequencies. This suggests that an atom can emit or absorb radiation only at there particular frequencies or wavelengths, which correspond to photons with particular energies.

The \emph{Bohr model} restricts the classical orbits of the Rutherford model by postulating that the angular momentum of the electron obeys the \emph{Bohr quantisation condition}:
\[
  L = n\hbar, n=1,2,\ldots,
\]
with only these discrete values allowed. This might seem to be an unsatisfactory way to address the issue of stability, but it proves to be remarkably successful in reproducing the complex experimental data relating to line spectra.

Specialising to circular orbits, for simplicity, we have
\[
  F=m_e v^2/r, L=m_e rv.
\]
It is then straightforward to check that the quantisation condition leads to the following set of \emph{Bohr orbits}:
\begin{align*}
  r_n &= \frac{4\pi\epsilon_0\hbar^2}{m_e e^2}n^2 \\
  v_n &= \frac{e^2}{4\pi\epsilon_0\hbar}\frac{1}{n} \\
  E_n &= -\frac{1}{2}m_e (\frac{e^2}{4\pi\epsilon_0\hbar})^2\frac{1}{n^2},\: n =1,2,\ldots
\end{align*}
Note that the allowed energy levels are now discrete.

Suppose that an electron makes a transition between levels $n$ and $n'$ (with $n' > n$, say) accompanied by emission or absorption of a photon of frequency $\omega$. Then
\[
  \hbar\omega = E_{n'} - E_n = \frac{1}{2}m(\frac{e^2}{4\pi\epsilon_0\hbar})^2 (\frac{1}{n^2} - \frac{1}{n'^2}).
\]

This formula accounts for a vast amount of experimental data on spectral lines for hydrogen. The Bohr model also provides an estimate for the \emph{size} of the hydrogen atom $r_1 \approx 5.29\times 10^{-11} m$, the \emph{Bohr radius}. Despite these considerable successes, the origin of the Bohr quantisation condition seems obscure. A better explanation is needed.

\subsection{Matter Waves}

The relations used to associate particle properties ($E$ and $p$) to waves can also be used to associate wave properties ($\nu$ or $\omega$ and $\lambda$ and $k$) to particles. This applies not just to relativistic photons but also to non-relativisitic particles, electrons for example, and $\lambda$ is called the \emph{de Broglie wavelength} of the particle. A strong hint that this might be important for a better understanding of the Bohr quantisatoin condition comes from observing that for a circular orbit
\[
  L = rp = n\hbar \Leftrightarrow n\lambda = 2\pi r.
\]
The Bohr condition therefore says that the circumference of the orbit is exactly an integral number of de Broglie wavelengths (e.g. $n=3$ in the figure).

It can also be verified experimentally that electrons do indeed exhibit wave-like behaviour, and a helpful idealisaton is the \emph{double slit experiment}. Consider a source which emits a beam of electrons, a barrier with two slits that can be open or closed, and a screen on which the electrons are detected.

Suppose first that one slit is open and the other is closed, as in Figure. We cannot say with certainty where any particular electron will be detected, but after many electrons have been emitted, the number detected varies with transverse position according to the distributions shown. If \emph{both} slits are open, however, then the electrons produce (perhaps unexpectedly) an interference pattern (Fig).

This matches the interference pattern obtained for waves of wavelength $\lambda$ incident on a barrier, as shown in Fig. Consider a point $P$ at some fixed perpendicular distance from the barrier, and let $\delta$ be the difference of the distances to $P$ from each of the slits. Constructive interference occurs for $\delta=n\lambda$ while destructive interference occurs for $\delta=(n+1/2)\lambda$. The result is that the suare of the amplitude of the superposed waves varies as shown in Fig, as $P$ varies.

In diffraction expreiments with electrons, we cannot predict what will happen to any \emph{single} particle; the most that can be said is that it will be detected at a given position with a certain \emph{probability}. The diffraction pattern is conclusive evidence of interference and so confirms the existence of matter waves, and diffraction expreiments allow an experimental determination of the de Broglie wavelength. The results also suggest that the probability distribution for particles can be expressed as the square of the amplitude of a wave.

\section{Wavefunctions and Operators}

In the first few sections we consider quantum particle in one dimension and introduce some key ideas and three postulates for how to extract physical information from mathematical framework. Later we will state general axioms from which these follow.

\subsection{Wavefunctions and States}

A classical point particle in one dimensional has a position $x$ at each time. In quantum mechanis a particle has a \emph{state} at each time given by a complex-valued wavefunction $\psi(x)$.

\begin{postulate}[P1]
  \label{postulate:1}
  A measurement of position gives a result with probability density $|\psi(x)|^2$. In other words, $|\psi(x)|^2 \delta x$ is the probability that the particle is found between $x$ and $x+\delta x$. Equivalently, $\int_a^b |\psi(x)|^2 dx$ is the probability that the particle is found in $[a,b]$.
\end{postulate}

This requires that $\psi(x)$ is \emph{normalised}:
\[
  \int_{-\infty}^\infty |\psi(x)|^2 dx = 1.
\]

\begin{eg}[Gaussian wavefunction]
  Let $\psi(x) = C e^{-(x-x_0)^2/2\alpha}$ for some real $\alpha>0$.
  \begin{center}
  \begin{tikzpicture}
    \begin{axis}[
      ticks=none,
      axis equal image,
      axis lines=center,
      xmin=-1,
      xmax=7,
      ymin=-0.2,
      ymax=2,
      xlabel=$x$,
      ylabel=$|\psi(x)|^2$]
     \addplot[restrict x to domain=-1:7,color=red,samples=80]{exp{-(x-3)^2}};
    \end{axis}
  \end{tikzpicture}
  \end{center}
  \begin{align*}
    \int_{-\infty}^\infty |\psi(x)|^2 dx &= |C|^2 \int_{-\infty}^\infty e^{-(x-x_0)^2/\alpha} dx \\
    &= |C|^2 (\alpha\pi)^{1/2} \\
    &= 1
  \end{align*}
  So $\psi$ is normalised if $C=(\frac{1}{\alpha\pi})^{1/4}$. If $\alpha$ is small, there is a sharp peak around $x=x_0$, and it exhibits ``particle-like'' behaviour. If $\alpha$ is large, it is more spread out/diffused.
\end{eg}

It is convenient to deal more generaly with \emph{normalisable} wavefunctions satisfying
\[
  \int_{-\infty}^\infty |\psi(x)|^2 dx < \infty,
\]
i.e. the integral is finite/convergent. Then $\psi(x)$ and $\phi(x) = \lambda\psi(x)$ are physically equivalent and represent the same state for any $\lambda\neq0$. Provided $\psi$ is normalisable, we can choose $\lambda$ so that $\phi$ is normalised. But if $\psi$ is normalised already, $\phi(x) = e^{i\alpha}\psi(x)$ for any real $\alpha$ gives the same probability distribution $|\phi(x)|^2 = |\psi(x)|^2$. This means that quantum state is strictly an equivalence class of non-zero wavefunctions but in practice we often refer to $\psi(x)$ as ``the state''.

Any non-zero normalisable wavefunction $\psi(x)$ represents a physical state. For our purpose we can assume, unless we say otherwise,
\begin{assumption}\leavevmode
\begin{itemize}
\item $\psi(x)$ is smooth, i.e. can be differeniated any number of times, and
  \item $\psi(x) \to 0$ as $|x|\to\infty$.
\end{itemize}
\end{assumption}

If $\psi_1(x)$ and $\psi_2(x)$ are normalisble then so is
\[
  \psi = \lambda_1\psi_1 + \lambda_2\psi_2
\]
for any complex numbers $\lambda_1, \lambda_2$. Physically, this is the principle of superposition and mathematically, this endows the space of normalisable wavefunctions a complex vector space structure.

\begin{eg}[Superposition of Gaussians]
  Let $\psi(x) = B(e^{-x^2/2\alpha}+e^{-(x-x_0)^2/2\alpha})$. We can choose $B$ so that $\psi$ is normalised.
  \begin{center}
  \begin{tikzpicture}
    \begin{axis}[
      ticks=none,
      axis equal image,
      axis lines=middle,
      xmin=-3,
      xmax=5,
      ymin=-.2,
      ymax=2,
      xlabel=$x$,
      ylabel=$|\psi(x)|^2$]
     \addplot[restrict x to domain=-3:5, color=red,samples=80]{(exp{-x^2}/2+exp{-(x-3)^2}/2)^2};
    \end{axis}
  \end{tikzpicture}
  \end{center}

\end{eg}

\subsection{Operators and Observables}

A quantum state contains information about other physical quantities or \emph{observables}, such as momentum and energy, not just position. In quantum mechanics, each observable is represented by an \emph{operator} (denoted by a hat when necessary) acting on wavefunctions. For example:
\begin{itemize}
  \item position: $\hat x = x, (\hat{x}\psi)(x) = x\psi(x)$,
  \item momentum: $\hat{p} = -i\hbar \frac{d}{dx}, (\hat{p}\psi)(x) = -i\hbar\psi'(x)$,
  \item energy/Hamiltonian: $H = -\frac{1}{2m}\hat{p} + V(\hat{x}) = -\frac{\hbar^2}{2m}\frac{d^2}{dx^2} + V(x)$ for a particle of mass $m$ in a potential $V$.
  \end{itemize}

If we measure one of these quantities, what answers can we get and what are the probabilities? Partial answers are provides by P2 and P3.

\subsubsection{Expectation Value}

For any (normalisable) $\psi(x)$ and $\phi(x)$, define
\[
  (\psi, \phi) = \int_{-\infty}^\infty \psi(x)^* \phi(x) dx,
\]
the complex inner product on the vector space. For $\psi(x)$ normalised, define the \emph{expectation value} of an observable $Q$ in this state to be
\[
  \langle Q \rangle_\psi = (\psi, Q\psi) = \int_{-\infty}^\infty \psi^* Q\psi dx.
\]

Note
\[
  \langle \hat x \rangle_\psi = (\psi, \hat x \psi) = \int_{-\infty}^\infty x |\psi(x)|^2 dx,
\]
the standard expression for mean, or expected value of $x$, given by P1.

\begin{postulate}[P2]
  \label{postulate:2}
  For any observable, $\langle Q\rangle_\psi$ is the mean result (expected value) if $Q$ is measured many times (as times $N\to\infty$) with particle in state $\psi$ before each measurement.
\end{postulate}

Consider wavefunction
\[
  \phi(x) = \psi(x)e^{ikx}
\]
with $k$ a real constant. Clearly
\[
  |\phi(x)|^2 = |\psi(x)|^2
\]
so
\[
  \langle \hat x\rangle_\phi = \langle \hat x\rangle_\psi.
\]
But
\begin{align*}
  \langle\hat p\rangle_\phi &= \int_{-\infty}^\infty \phi^*(-i\hbar\phi')dx \\
  &= \int_{-\infty}^\infty \psi^*(-i\hbar\psi')dx + \hbar k\int_{-\infty}^\infty \psi^*\psi dx \\
  &= \langle \hat p\rangle_\psi + \hbar k
\end{align*}

\begin{eg}
  Let $\psi(x) = Ce^{-x^2/2\alpha}$, then $\langle\hat p\rangle_\psi = 0$ and $\psi(x) = Ce^{-x^2/2\alpha}e^{ikx}$ with $\langle\hat p\rangle_\phi = \hbar k$.
\end{eg}

If we accept P2 then the result in the example above accounts for the choice of momentum poperator \(\hat p = -i\hbar d/dx\).

\subsubsection{Eigenstates \& Eigenvalues}

\begin{definition}
  A state \(\psi \neq 0\) is an \emph{eigenstate} or \emph{eigenfunction} of an operator or observable \(Q\) with \emph{eigenvalue} \(q\) if
  \[
Q\psi = q\psi.
  \]
\end{definition}

\begin{postulate}[P3]
  If \(Q\) is measured when the particle is an eigenstate \(\psi\) as above, then the results is the eigenvalue \(q\) with probability $1$.
\end{postulate}

\begin{eg}\leavevmode
  \begin{enumerate}
  \item \(Q=\hat x\): no (continuous) eigenfunctions since \(\hat x \psi (x)= x\psi(x) = q\psi(x)\) implies that \(\psi(x)=0\) for \(x\neq q\).
  \item \(Q=\hat p=-i\hbar \frac{d}{dx}\): eigenfunctions obey \(-i\hbar \psi' = q\psi\) so \(\psi(x) = C e^{ikx}\) with \(q=\hbar k\). But this is not normalisable as \(|\psi(x)|^2 = |C|^2\) so we can't interpret this directly as wavefunction for a single particle on \(-\infty < x < \infty\). However, we could normalise it on an interval of length \(\ell\) by choosing \(C = 1/\sqrt{\ell}\) but then need to look carefully at boundary conditions on interval.
  \item \(Q = H\), Hamiltonian with a particular potential \(V(x) = \frac{1}{2} K x^2\), \(K > 0\): \(H=\frac{1}{2m}\hat p^2 + \frac{1}{2}K\hat x^2\) so the eigenfunction satisfies
    \[
H\psi = -\frac{\hbar^2}{2m} \psi'' + \frac{1}{2}K x^2\psi = E \psi.
    \]
    This is satisfied by
    \[
\psi(x) = C e^{-x^2/2\alpha}
\]
if we choose \(\alpha^2 = \hbar^2/Km\). It follows that
\[
E = \frac{\hbar}{2} \sqrt{\frac{K}{m}}
\]
is the energy eigenvalue.
  \end{enumerate}
\end{eg}

\begin{note}
  Classically for a fixed \(E\) we have \(|x| \leq (2E/K)^{1/2}\) but the wavefunction above gives non-zero probability density along the entire \(x\)-axis.
\end{note}

In general, the energy eigenvalue equation
\[
H\psi = -\frac{\hbar^2}{2m} \psi'' + V(x)\psi = E \psi
\]
for a particle of mass \(m\) in a potential \(V(x)\) determines states of definite energy and allowed energy values. This is the \emph{time-independent Schrödinger equation}. Solving this equation for hydrogen atom is our eventual aim.

\subsubsection{Some Comments}

\begin{enumerate}
\item We defined \(\langle Q\rangle_\psi = (\psi, Q\psi)\) in P2 for \(\psi\) normalised. If \(\psi\) is not normalised,
  \[
    \langle Q\rangle_\psi =  \frac{(\psi, Q\psi)}{(\psi, \psi)}.
    \]
  \item We defined \(Q=\hat x\) which reproduces the standard definiton of mean. For \(\hat p\) and \(H\) we can check explicitly (by taking complex conjugation and integrating by parts) that \(\langle \hat p \rangle_\psi\) and \(\langle H\rangle_\psi\) are real.
\item P3 is consistent with P2. Consider energy, for example,
  \begin{align*}
    H\psi = E\psi \Rightarrow (\psi, H\psi) &= \langle H\rangle_\psi\\
    &= (\psi, E\psi) = E
  \end{align*}
  if \(\psi\) is normalised. In other words, the measurement of energy gives result \(E\) with probability \(1\). The mean result is \(E\).
\item From $2$ and $3$ we can deduce that any eigenvalue of \(H\) is real.
\end{enumerate}

\subsection{Infinite Potential Well or Particle in a Box}

Define an infinite potential well
\[
  V(x) =
  \begin{cases}
    0 & |x| \leq a \\
    u & |x| > a
  \end{cases}
\]
\begin{center}
  \begin{tikzpicture}
  \begin{axis}[
    xtick={-1,1},
    xticklabels={\(-a\),\(a\)},
    yticklabels=none,
    axis equal image,
    axis lines=middle,
    xmin=-2,
    xmax=2,
    ymin=-.5,
    ymax=2,
    xlabel=$x$,
    ylabel=$V(x)$]
    \addplot[samples=20,color=blue](-1,x);
    \addplot[samples=20,color=blue](1,x);
  \end{axis}
\end{tikzpicture}
\end{center}
in limit \(u\to\infty\). The time-independent Schrödinger equation is
\begin{align*}
  -\frac{\hbar^2}{2m}\psi'' &= E\psi, |x| \leq a \\
  -\frac{\hbar^2}{2m}\psi'' +u \psi &= E\psi, |x| > a
\end{align*}
Taking limit \(u\to\infty\), the second equation suggests we must take \(\psi=0\) for \(|x| > a\), whose rationale will be addressed shortly. The appropriate boundary conditions are \(\psi=0\) for \(|x|=a\) and \(\psi\) continuous at \(x = \pm a\). So we are left to solve
\begin{align*}
  -\frac{\hbar^2}{2m} \psi'' &= E\psi, -a\leq x \leq a \\
  \psi(\pm a) &= 0
\end{align*}

For \(E>0\), set \(E=\hbar^2k/2m\) with \(k>0\) and we get
\[
\psi'' + k\psi =0.
\]
So
\begin{align*}
  &\psi = A\cos kx + B \sin kx \\
  &A\cos ka \pm B \sin ka = 0 \\
  &\text{or } A\cos ka = B\sin ka = 0
\end{align*}
so
\begin{align*}
  \text{either } B = 0 &, ka = \frac{n\pi}{2} \text{ for } n = 1,3,\ldots \\
  \text{or } A = 0 &, ka = \frac{n\pi}{2} \text{ for } n = 2,4,\ldots
\end{align*}
Hence
\[
E_n = \frac{\hbar^2\pi^2n}{8ma^2}
\]
for \(n=1,2,3,\ldots\). We obtain a discrete set of allowed energies, with normalised wavefunctions
\[
  \psi_n(x) = \sqrt \frac{1}{a} \genfrac{\{}{\}}{0pt}{} {\cos}{\sin} \frac{n\pi}{2a} x \text{ for } n \genfrac{\{}{}{0pt}{} {\text{odd}}{\text{even}}
\]

\end{document}


\documentclass{article}

\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{physics}
\usepackage[plain]{algorithm}
\usepackage{algpseudocode}

\usetikzlibrary{automata,positioning}

%
% Basic Document Settings
%

\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in

\linespread{1.1}

\pagestyle{fancy}
\lhead{\hmwkAuthorName}
\chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle}
\rhead{\firstxmark}
\lfoot{\lastxmark}
\cfoot{\thepage}

\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}

\setlength\parindent{0pt}

%
% Create Problem Sections
%

\newcommand{\enterProblemHeader}[1]{
    \nobreak\extramarks{}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
    \nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
}

\newcommand{\exitProblemHeader}[1]{
    \nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
    \stepcounter{#1}
    \nobreak\extramarks{Problem \arabic{#1}}{}\nobreak{}
}

\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}

%
% Homework Problem Environment
%
% This environment takes an optional argument. When given, it will adjust the
% problem counter. This is useful for when the problems given for your
% assignment aren't sequential. See the last 3 problems of this template for an
% example.
%
\newenvironment{homeworkProblem}[1][-1]{
    \ifnum#1>0
        \setcounter{homeworkProblemCounter}{#1}
    \fi
    \section{Problem \arabic{homeworkProblemCounter}}
    \setcounter{partCounter}{1}
    \enterProblemHeader{homeworkProblemCounter}
}{
    \exitProblemHeader{homeworkProblemCounter}
}

\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\bes}{\begin{equation*}}
\newcommand{\ees}{\end{equation*}}
\newcommand{\bea}{\begin{flalign*}}
\newcommand{\eea}{\end{flalign*}}
%
% Homework Details
%   - Title
%   - Due date
%   - Class
%   - Section/Time
%   - Instructor
%   - Author
%

\newcommand{\hmwkTitle}{Lecture \#3}
\newcommand{\hmwkDueDate}{\today}
\newcommand{\hmwkClass}{Trefethen and Bau}
\newcommand{\hmwkClassTime}{}
\newcommand{\hmwkClassInstructor}{}
\newcommand{\hmwkAuthorName}{\textbf{Aditya Vijaykumar}}

%
% Title Page
%

\title{
    %\vspace{2in}
    \textmd{\textbf{\hmwkClass:\ \hmwkTitle}}\\
    \normalsize\vspace{0.1in}\small{\hmwkDueDate\ }\\
%    \vspace{3in}
}

\author{\hmwkAuthorName}
\date{}

\renewcommand{\part}[1]{\textbf{\large Part \Alph{partCounter}}\stepcounter{partCounter}\\}

%
% Various Helper Commands
%

% Useful for algorithms
\newcommand{\alg}[1]{\textsc{\bfseries \footnotesize #1}}

% For derivatives
\newcommand{\deriv}[1]{\frac{\mathrm{d}}{\mathrm{d}x} (#1)}

% For partial derivatives
\newcommand{\pderiv}[2]{\frac{\partial}{\partial #1} (#2)}

% Integral dx
\newcommand{\dx}{\mathrm{d}x}

% Alias for the Solution section header
\newcommand{\solution}{\textbf{\large Solution}}

% Probability commands: Expectation, Variance, Covariance, Bias
\newcommand{\E}{\mathrm{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand{\Bias}{\mathrm{Bias}}

\begin{document}

\maketitle

%\pagebreak

\begin{homeworkProblem}
    For something to be a vector norm it should satisfy three conditions. We list down these three conditions and see if $\norm{\vdot}_W = \norm{Wx}$ does indeed satisfy them,
    \begin{itemize}
    	\item $\norm{x}_W \ge 0$. This is automatically satisfied by the definition of the norm.
    	\item $\norm{x}_W = 0 $ iff $x=0$. As $W$ is a nonsingular matrix by assumption, this property is satisfied as well.
    	\item $\norm{\alpha x}_W = \abs{\alpha} \norm{x}_W$. As $\alpha$ is just a multiplicative constant and $W$ is indeed a matrix, this property is satisfied as well.
    \end{itemize}

    Hence, $\norm{\vdot}$ is a vector norm.
\end{homeworkProblem}

\begin{homeworkProblem}
	By the definition of $\norm{A}$, $\norm{A} \ge \norm{Ax}, \forall \text{ unit vectors }x$

	\textcolor{red}{DO this problem}
\end{homeworkProblem}

\begin{homeworkProblem}
	\textbf{Part (a)}\\
	$$\norm{x}_\infty = \sqrt{x_0^2} \le \sqrt{x_0^2 + \sum_{i \ne 0} x_i^2} \le \norm{x}_2$$ Equality is achieved for any vector having only one element.
	\\

	\textbf{Part (b)}\\
	$$\norm{x}_2 = \sqrt{\sum_i x_i^2} \le \sqrt{m (\max x_i)^2}\le \sqrt{m}\norm{x}_\infty$$ Equality is achieved for any vector having elements with the same absolute value.\\

	\textbf{Part (c)}\\
\end{homeworkProblem}
\end{document}


\documentclass[main.tex]{subfiles}

\begin{document}
\subsection{Define the notion of space constructible function $f \text{ : } \mathbb{N} \rightarrow \mathbb{N}$. Give an example of such a function and explain why it is so}

\subsection{Knowing that the equivalence between extended regular expressions is ExpSpace-Complete, show by applying the space hierarchy theorem that this problem can not be solved in deterministic polynomial time, nor in nondeterministic polynomial time}

\subsection{Define the notion of Turing machine with oracle. Define the set of lan guages that can be solved in $\text{P}^\text{SAT}$ , define a language that belongs to this set and which is not believed to be in NP (explain why)}

\subsection{What do we know about the relations between the complexity classes P, NP, PSPACE, EXPTIME, and EXPSPACE? Explain}

\end{document}


\documentclass{beamer}
%\documentclass[handout]{beamer}
%\documentclass{article}
%\usepackage{beamerarticle}

\mode<presentation>
{
    %\usetheme{Warsaw}
    %\usetheme{Frankfurt}
    \usetheme[subsection=false]{Dresden}
    %\usecolortheme{dove}
    \usecolortheme{beaver}
    \useinnertheme{circles}

    \setbeamercovered{dynamic}
    % If you wish to uncover everything in a step-wise fashion, uncomment
    % the following command:
    %\beamerdefaultoverlayspecification{<+->}
    %\pgfdeclareimage[height=0.6cm]{university-logo}{IFT.jpg}
    %\logo{\pgfuseimage{university-logo}}
}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}

\title[Bifurcation diagrams]{Tutorial on Qualitative analysis and Bifurcation diagrams}

\author[Renato Coutinho]{Renato Mendes Coutinho (IFT - Unesp)}

\date[SSSMB 2014] % (optional, should be abbreviation of conference name)
{
    {\footnotesize \texttt{renatomc@ift.unesp.br}}\\
\vspace{0.5cm}S\~ao Paulo\\February, 2014}

\begin{document}

\begin{frame}
    \titlepage
\end{frame}

\begin{frame}{}
    \tableofcontents
\end{frame}

\section{Introduction}

\begin{frame}{I have a model! What now?}
    \pause
    \begin{block}{Principle I}
        I have equations, so I want solutions!
    \end{block}
    \pause
    \vfill
    We will use as example a nice and simple model that we all should care
    about: the next step in predator--prey (or consumer--resource) models: the
    \textbf{Rosenzweig--MacArthur} model.
\end{frame}

\begin{frame}{The Rosenzweig--MacArthur model}
    \begin{itemize}
        \item Includes the same ingredients as the Lotka-Volterra equations,
        \item plus a carrying capacity for the resource,
        \item and plus a saturation in the predation rate.
    \end{itemize}
    \pause
    \begin{align*}
        \frac{dR}{dt} &= rR \left( 1 - \frac{R}{K} \right) - \frac{a R C}{1+ahR} \\
        \frac{dC}{dt} &= \frac{e a R C}{1+ahR} - d C
    \end{align*}
\end{frame}

\begin{frame}{Rosenzweig--MacArthur model solutions}
    \begin{itemize}
        \item By Principle I, we want the solution of the model.
        \item We resort to numerical integration, but then\ldots which
            parameters should I use? And which initial conditions?
        \item For now, let's just guess some parameters, and pick a few
            different initial conditions.
        \item
            \includegraphics[height=1.5ex]{ipynblogo.png}
            \pause
        \item It seems that initial conditions don't matter for the final
            long-term solution: a fixed point.
    \end{itemize}
\end{frame}

\section{``Visual'' qualitative analysis}

\begin{frame}{The phase space flow and the fixed point}
    \begin{itemize}
        \item The differential equations define a flow in the phase space: at
            each point, there's a direction the solution must follow when it
            goes through that point.
        \item
            \includegraphics[height=1.5ex]{ipynblogo.png}
            \pause
        \item The size (the magnitude) of the arrows become small near
            the fixed point.
        \item That is, at the fixed point, $\frac{dC}{dt} = 0$ and
            $\frac{dR}{dt} = 0$.
        \item The flow spirals towards the center, so any initial condition
            approaches the center.
    \end{itemize}
\end{frame}

\begin{frame}{Messing a little with the parameters\ldots}
    \begin{itemize}
        \item We have seen that predator-prey systems tend to oscillate, but in this
            case, the long-term solution is stationary.
        \item Let's, for example, increase the carrying capacity $K$ a little.
        \item
            \includegraphics[height=1.5ex]{ipynblogo.png}
            \pause
        \item Now the arrows inside spirals outward, and the flow outside
            spirals inward, towards a \textbf{limit cycle}.
        \item The fixed point is still there (the arrows' sizes go to zero
            in the center), but now the solution moves away from it.
        \item We say that the fixed point became \textbf{unstable}.
        \item A change in the stability of a fixed point is a
            \textbf{bifurcation}.
    \end{itemize}
\end{frame}

\begin{frame}{Varying a parameter systematically: the bifurcation diagram}
    \begin{itemize}
        \item Changing the values of parameters haphazardly, it may be hard to
            see and to synthesize what happens in the system.
        \item Let's imagine you change the value of a parameter by a very
            small value:
        \pause
        \item the expectation is that the solution changes only a tiny bit.
        \item But if we sweep a range of values in small steps, we will see a
            parameter value where the solution attains a new behavior: the bifurcation
            point.
        \item Let's do this increasing the resource carrying capacity $K$:
            what do you expect it is going to happen?
        \item
            \visible<2>{\includegraphics[height=1.5ex]{ipynblogo.png}}
    \end{itemize}
\end{frame}

\begin{frame}{The paradox of enrichment}
    \begin{itemize}
        \item For very small $K$, the predator is extinct,
        \item for intermediate $K$, the solution goes to a fixed point (the
            minimum and maximum of the solution have the same value!)
        \item and for high $K$, there are oscillations with amplitudes that
            increase with $K$.
            \pause
        \item The ``paradox of enrichment'' means that boosting
            the resource population can lead to extinction either of the
            resource or of the consumer (or both), because the solution passes
            closer and closer to zero.
    \end{itemize}
\end{frame}

\section{Systems that depend explicitly on time}

\begin{frame}{Seasonal consumer resource dynamics}
    \begin{itemize}
        \item In certain situations, we may want to include explicit temporal
            dependence into our models.
        \item Seasonality, environmental fluctuations and experimental
            manipulation are some clear reasons why you would need that.
        \item Let's see what happens when we take our Rosenzweig-MacArthur
            model and introduce a seasonal growth rate $r = r_0 (1+\alpha
            \sin(2\pi t/T))$
        \item We are going to make a small perturbation ($\alpha$ small), so
            we shouldn't see much happening.
        \item
            \includegraphics[height=1.5ex]{ipynblogo.png}
    \end{itemize}
\end{frame}

\begin{frame}{A resonance diagram}
    \begin{itemize}
        \item The population oscillates together with the seasonal variation,
            even though the system with $K=10$ didn't oscillate -- but the
            amplitude is small.
        \item We now do a kind of bifurcation diagram, but now what we vary is
            the \textbf{frequency of the external oscillations}.
        \item
            \includegraphics[height=1.5ex]{ipynblogo.png}
            \pause
        \item There's a sharp peak in the amplitude around a certain
            frequency. This is called a \textbf{resonance}.
        \item If we go back to the first plot (with $K=10$ without seasonal
            fluctuations), we find that the period of the oscillations in the
            transient is around 23.
        \item No, not a coincidence\ldots
    \end{itemize}
\end{frame}

\section{A few comments}

\begin{frame}{What if there are more than 2 equations?}
    \begin{itemize}
        \item In that case, the phase space has more than 2 dimensions and
            doesn't fit into a nice 2-d plot.
        \item You can still try to plot planes of the phase space, specially
            ones containing the fixed points of interest.
        \item Bifurcation diagrams are still very much useful: you don't have
            to plot all the curves to characterize the solution.
    \end{itemize}
\end{frame}

\begin{frame}{What if I want to explore a 10-dimensional parameter
    space?}
    \begin{itemize}
        \item Avoid that: you can reduce the number of parameters
            rescaling your variables (adimensionalizing)
        \item You can also restrict the values considered based on data and on
            careful judgement: not every parameter has the same relevance to
            the outcomes.
    \end{itemize}
    \pause

    But I still have 10 parameters left!

    \begin{itemize}
        \item Well, Good luck!
        \item You will probably have to sample the space, rather than
            go through the whole thing. A recommended method is to use
            so-called
            \href{http://en.wikipedia.org/wiki/Latin_hypercube_sampling}{Latin Hypercube
            samples},
            that uses a random sampling while ensuring a roughly
            regularly-spaced distribution.
    \end{itemize}
\end{frame}

\begin{frame}{}
    Thanks for your attention!

    \vspace{4ex}
    All the code for the solutions and plots shown are available at
    \href{http://ecologia.ib.usp.br/ssmb/doku.php?id=2014:courses:kraenkel:start}{the
    wiki of the course}
\end{frame}

\end{document}