\documentclass[serif,xcolor=pdftex,dvipsnames,table,hyperref={bookmarks=false,breaklinks}]{beamer}

\input{../config.tex}

\settitlecard{8}{Numerical Linear Algebra 2}

\begin{document}

\maketitlepage

% \section{Announcements}
% \subsection{Foo}
%
%
% \begin{frame}[t]{Announcements}
% 	\begin{itemize}
% 		\item Assignment 3 is due tonight at 11:55pm.
% 		\item Quiz 4 will go out tonight.
% 		\item Assignment 4 will go out in the next couple of days.
% 		\item Guest lecturer on Tuesday.
% 	\end{itemize}
% \end{frame}

\section{Numerical Linear Algebra 2}
\subsection{Foo}

\begin{frame}[t]{Matrix Inversion}
	% Review
	% Where it is used
	Review: An $n\times n$ square matrix $A$ is said to be \textbf{invertible} if there exists an $n \times n$ matrix $B$ such that:

	$$ AB = BA = I$$

	where $I$ is the identity matrix. If $B$ exists it is called the \textbf{inverse} and is denoted $A^{-1}$. Matrix inversion is the process of finding $A^{-1}$ for a given matrix $A$.
\end{frame}

\begin{frame}[t]{Matrix Inversion: Applications}
	\begin{itemize}[<+->]
		\item Matrix inverses appear in statistics frequently. Part of the reason for this is because of the appearance of a matrix inverse in the PDF of the multivariate normal distribution.

		$$ \mathcal{N}(x;\mu,\Sigma) \propto \exp\left(-\frac{1}{2}(x-\mu)^T \Sigma^{-1}(x - \mu)\right) $$
		\item The analytical solution for least-squares linear regression involves a matrix inverse.
		\item Matrix inversion plays a fundamental role in many computer graphics routines.
		\item Matrix inversion is a subroutine for many more complex linear algebra computations.
	\end{itemize}
\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% Description
	\begin{itemize}[<+->]
		\item Many algorithms exist for inverting a matrix.
		\item We will analyze one of the fundamental algorithms called \textbf{Gauss-Jordan Elimination}.
		\item \textbf{Gaussian Elimination} is a method for solving equations of the form $Ax = b$ where $A$ is a matrix, $b$ is a vector, and we are solving for the vector $b$.
		\item Gaussian elimination can be thought of as a systematic application of simple substitution rules.
		\item Gauss-Jordan elimination is the application of this idea to the equation $AX = I$ where now $X$ is a matrix rather than a vector.
	\end{itemize}
\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	We'll start with a simple example: Let $A$ be the following $2 \times 2$ matrix.

	\pause
	$$A = \begin{bmatrix}[rr]
    	1 & 3 \\
		2 & 5
	\end{bmatrix}$$

	\pause
	Our goal is to find the inverse.
	\pause
	$$A^{-1} = \begin{bmatrix}[rr]
    	-5 & 3 \\
		2 & -1
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	We begin by writing $A$ in the following augmented form:

	\pause
	$$A = \begin{bmatrix}[rr|rr]
    	1 & 3 & 1 & 0\\
		2 & 5 & 0 & 1
	\end{bmatrix}$$

	\pause
	We then apply elementary row operations until the left side is equal to the identity matrix. Elementary row operations include:
	\pause
	\begin{itemize}[<+->]
		\item Scaling a row by a non-zero constant.
		\item Adding a scaled row to another row.
		\item Swapping two rows (we will not use this).
	\end{itemize}

	\pause
	If we are able to do this without getting a row of all zeros on the left, then the right side will be $A^{-1}$. If at any point we get a row with all zeros, then the matrix has no inverse.

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rr|rr]
    	1 & 3 & 1 & 0\\
		2 & 5 & 0 & 1
	\end{bmatrix}$$

	\pause
	$$R_2 \leftarrow R_2 - 2R_1$$

	\pause
	$$\begin{bmatrix}[rr|rr]
    	1 & 3 & 1 & 0\\
		0 & -1 & -2 & 1
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rr|rr]
    	1 & 3 & 1 & 0\\
		0 & -1 & -2 & 1
	\end{bmatrix}$$

	\pause
	$$R_2 \leftarrow -R_2$$

	\pause
	$$\begin{bmatrix}[rr|rr]
    	1 & 3 & 1 & 0\\
		0 & 1 & 2 & -1
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rr|rr]
    	1 & 3 & 1 & 0\\
		0 & 1 & 2 & -1
	\end{bmatrix}$$

	\pause
	$$R_1 \leftarrow R_1 - 3R_2$$

	\pause
	$$\begin{bmatrix}[rr|rr]
    	1 & 0 & -5 & 3\\
		0 & 1 & 2 & -1
	\end{bmatrix}$$

	\pause
	\centering
	\Huge{Done!}
\end{frame}

% \begin{frame}[t]{Gauss-Jordan Elimination}
% 	% 2x2 example
% 	$$\begin{bmatrix}[rr|rr]
%     	1 & 0 & -5 & 3\\
% 		0 & 1 & 2 & -1
% 	\end{bmatrix}$$
%
% 	\pause
% 	\centering
% 	\Huge{Done!}
%
% \end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	With such a small matrix it is hard to get a sense for what the steps are:
	\pause
	\begin{itemize}[<+->]
		\item For each row $i$ from top to bottom:
		\begin{itemize}[<+->]
			\item Scale the row so that the diagonal entry equals 1.
			\item Subtract a scaled version of row $i$ from each row below $i$ so that the $i$th column in each of these rows is $0$.
			\item This eliminates all entries below the diagonal and sets the diagonal to ones.
		\end{itemize}
		\item Repeat this process from the bottom up, this time eliminating entries above the diagonal.
	\end{itemize}
\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$A = \begin{bmatrix}[rrr]
    	2 & 3 & 0\\
		1 & -2 & -1\\
		2 & 0 & -1
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rrr|rrr]
    	2 & 3 & 0 & 1 & 0 & 0\\
		1 & -2 & -1 & 0 & 1 & 0\\
		2 & 0 & -1 & 0 & 0 & 1
	\end{bmatrix}$$

	\pause
	\begin{align*}
		R_1 &\leftarrow \frac{1}{2}R_1\\
	\end{align*}

	\pause
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		1 & -2 & -1 & 0 & 1 & 0\\
		2 & 0 & -1 & 0 & 0 & 1
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		1 & -2 & -1 & 0 & 1 & 0\\
		2 & 0 & -1 & 0 & 0 & 1
	\end{bmatrix}$$

	\pause
	\begin{align*}
		R_2 &\leftarrow R_2 - R_1\\
		R_3 &\leftarrow R_3 - 2R_1\\
	\end{align*}

	\pause
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & -\frac{7}{2} & -1 & -\frac{1}{2} & 1 & 0\\
		0 & -\frac{6}{2} & -1 & -1 & 0 & 1
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & -\frac{7}{2} & -1 & -\frac{1}{2} & 1 & 0\\
		0 & -\frac{6}{2} & -1 & -1 & 0 & 1
	\end{bmatrix}$$

	\pause
	\begin{align*}
		R_2 &\leftarrow -\frac{7}{2}R_2\\
	\end{align*}

	\pause
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & 1 & \frac{2}{7} & \frac{1}{7} & -\frac{2}{7} & 0\\
		0 & -\frac{6}{2} & -1 & -1 & 0 & 1
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & 1 & \frac{2}{7} & \frac{1}{7} & -\frac{2}{7} & 0\\
		0 & -\frac{6}{2} & -1 & -1 & 0 & 1
	\end{bmatrix}$$

	\pause
	\begin{align*}
		R_3 &\leftarrow R_3 + \frac{6}{2}R_2\\
		R_3 &\leftarrow -7R_3
	\end{align*}

	\pause
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & 1 & \frac{2}{7} & \frac{1}{7} & -\frac{2}{7} & 0\\
		0 & 0 & 1 & -4 & -6 & -7
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & 1 & \frac{2}{7} & \frac{1}{7} & -\frac{2}{7} & 0\\
		0 & 0 & 1 & -4 & -6 & -7
	\end{bmatrix}$$

	\pause
	\begin{align*}
		R_2 &\leftarrow R_2 - \frac{2}{7}R_3\\
		R_1 &\leftarrow R_1 + 0R_3\\
	\end{align*}

	\pause
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & 1 & 0 & -1 & -2 & 2\\
		0 & 0 & 1 & -4 & -6 & -7
	\end{bmatrix}$$

\end{frame}

\begin{frame}[t]{Gauss-Jordan Elimination}
	% 2x2 example
	$$\begin{bmatrix}[rrr|rrr]
    	1 & \frac{3}{2} & 0 & \frac{1}{2} & 0 & 0\\
		0 & 1 & 0 & -1 & -2 & 2\\
		0 & 0 & 1 & -4 & -6 & -7
	\end{bmatrix}$$

	\pause
	\begin{align*}
		R_1 &\leftarrow R_1 - \frac{3}{2}R_2\\
	\end{align*}

	\pause
	$$\begin{bmatrix}[rrr|rrr]
    	1 & 0 & 0 & 2 & 3 & -3\\
		0 & 1 & 0 & -1 & -2 & 2\\
		0 & 0 & 1 & -4 & -6 & -7
	\end{bmatrix}$$

	\pause
	\centering
	\Huge{Done!}

\end{frame}

\begin{frame}[t]{Gauss-Jordan Complexity}
	% Complexity
	% n multiplications
	% n multiplications
	% (n - i)*n additions
	\pause
	\begin{itemize}[<+->]
		\item When you scale a row so that its diagonal is one, how many multiplications do we perform? How many times do we do this?
		\begin{itemize}[<+->]
			\item $n$ multiplications. One per item in the row.
			\item $n$ times. Once per row.
		\end{itemize}
		\item When performing a row reduction (adding one scaled row to another), how many multiplications and additions do we perform? How many many rows to we add row $i$ to?
		\begin{itemize}
			\item $n$ multiplications. (technically $n-i$)
			\item $n$ additions. (technically $n-i$)
			\item We add row $i$ to all rows below row $i$, so $n-i$ times.
		\end{itemize}
	\end{itemize}
\end{frame}

\begin{frame}[t]{Gauss-Jordan Complexity}
	\begin{align*}
		\onslide<1->{\text{No. Operations } &= 2\sum_{i=1}^{n}\left(n + 2n(n-i)\right)\\}
		\onslide<2->{&= 2\sum_{i=1}^{n}\left(n + 2n^2 - 2ni\right)\\}
		\onslide<3->{&= 2\left[\sum_{i=1}^{n}n + 2\sum_{i=1}^{n}n^2 - 2\sum_{i=1}^{n}ni\right]\\}
		\onslide<4->{&= 2\left[n^2 + 2n^3 - 2n\frac{n(n+1)}{2}\right]\\}
		\onslide<5->{&= 2\left[n^2 + 2n^3 - n^3 + n^2\right]\\}
		\onslide<6->{&= 4n^2 + 2n^3} \onslide<7>{= \mathcal{O}(n^3)}
	\end{align*}

\end{frame}

\begin{frame}[t]{Advanced Matrix Inverse Algorithms}
	% Description
	As with matrix multiplication, more sophisticated algorithms exist the have complexity between $n^2$ and $n^3$.
\end{frame}

\begin{frame}[t]{Estimating the complexity of NumPy Matrix Inverse}
	% Fit a line
	The algorithm used by NumPy is not well documented. How could we estimate its complexity? \pause(Hint: We know the complexity is approximately a monomial (e.g. $\mathcal{O}(n^3)$)).

	\pause
	\begin{align*}
		\text{Run time } &\approx Cn^b\\
		\log(\text{Run time}) &\approx \log(C) + b\log(n)
	\end{align*}

	\pause
	Solution:
	\begin{enumerate}
		\item Run a bunch of tests for different $n$ and record the run times.
		\item Fit a line to the $\log$ run times. The slope will be the degree of the polynomial and the intercept will be the logged constant.
	\end{enumerate}

\end{frame}

\begin{frame}[t]{Estimating the complexity of NumPy Matrix Inverse}
	% Fit a line
	\centering
	\Huge{Demo}
\end{frame}

\begin{frame}[t]{Eigenreview}
	% Description
	% Eigen Review
	Let $A$ be a square $n\times n$ matrix, then the $\mathbf{v}$ is an \textbf{eigenvector} of $A$ if

	$$A\mathbf{v} = \lambda\mathbf{v}$$

	for some constant $\lambda$ known as an \textbf{eigenvalue}. \textbf{Eigen decomposition} is the process of finding the eigenvalue/eigenvector pairs of a matrix.
\end{frame}

\begin{frame}[t]{Eigen Decomposition: Applications}
	% Description
	% Eigen Review
	\begin{itemize}[<+->]
		\item Eigen decompositions are used in many practical applications:
		\begin{itemize}[<+->]
			\item Google's PageRank computes the largest eigenvalue/vector pair.
			\item Principal Components Analysis (PCA) is used in many data analysis settings to reduce the dimensionality of a dataset and reduce collinearity.
			\item Spectral clustering is used in machine learning and computer vision for clustering data points and parts of images. Spectral clustering requires calculating the Eigen decomposition of a similarity matrix.
		\end{itemize}
	\end{itemize}
\end{frame}

\begin{frame}[t]{Eigen Decomposition: Eigenfaces}
	% Description
	% Eigen Review
	\begin{itemize}[<+->]
		\item One of the seminal early pieces of work in computer vision worked by compressing images into eigenvectors.
		\item The basic idea was to calculate the number of images by number of images image covariance matrix and computing the eigenvectors of this matrix.
		\item The result is one eigenvector for each image.
		\item The most well known application was facial recognition where each image was of a face, hence eigenfaces.
	\end{itemize}

	\pause
	\centering
	\includegraphics[height=1in]{{../Figures/Eigenfaces}.png}
\end{frame}

\begin{frame}[t]{Eigen Decomposition: The Power Method}
	% Description
	The Power method is a method for calculating the eigenvalue corresponding to the greatest eigenvalue. Many other methods for calculating the full set of eigenvalues are generalizations of this method.

	\pause
	\begin{block}{The Power Method}
		\begin{enumerate}[<+->]
			\item Given an $n\times n$ matrix $A$, choose a random initial vector $b_0$.
			\item Then, under some mild assumptions, the following sequence will converge to the dominant eigenvector:

			$$\frac{Ab_0}{\norm{Ab_0}},\frac{A^2b_0}{\norm{A^2b_0}},\frac{A^3b_0}{\norm{A^3b_0}},...$$
		\end{enumerate}
	\end{block}

\end{frame}

\begin{frame}[t]{Eigen Decomposition: Complexity}
	% Description
	If we were to calculate matrix matrix powers $A^k$ directly using matrix multiplication, what is the complexity of calculating $A^k$?

	\pause
	\begin{itemize}
		\item Answer: We would need to perform $k$ matrix multiplications, thus using Strassen's this would take $\approx\mathcal{O}(kn^{2.807})$.
	\end{itemize}

	\pause
	Fortunately, there is a better way. We can use the following interative algorithm:

	$$b_{k} = \frac{A^kb_0}{\norm{A^kb_0}} = \frac{A(A^{k-1}b_0)}{\norm{A(A^{k-1}b_0)}} = \frac{Ab_{k-1}}{\norm{Ab_{k-1}}}$$

	\pause
	What is the complexity of computing $Ab_{k-1}$?

	\pause
	\begin{itemize}
		\item The power method has complexity $\mathcal{O}(n^2)$ \textbf{per iteration}.
	\end{itemize}
\end{frame}

\begin{frame}[t]{Inversion and Decomposition in Action: Linear Regression}
	% Linear Regression Derivation
	Let $X \in \mathbb{R}^{n\times m}$ be a $n \times m$ matrix of data cases (i.e. design matrix) and let $y \in \mathbb{R}^n$ be a length $n$ vector of real values. Then in ordinary least squares linear regression, we have the following model:

	$$y = \beta X + \epsilon$$

	where $\epsilon$ is a normally distributed vector of noise. \pause Then using Maximum Likelihood Estimation, we estimate $\hat{\beta}$ as

	$$\hat{\beta} = \argmin_\beta (\beta X - y)^T(\beta X - y)$$

\end{frame}

\begin{frame}[t]{Inversion and Decomposition in Action: Linear Regression}
	% Linear Regression Derivation
	The solution to this minimization problem can be found by taking the gradient with respect to $\beta$, setting it to zero, and solving. The results is:

	$$\hat{\beta} = (X^T X)^{-1}X^Ty$$

	\pause
	\begin{itemize}[<+->]
		\item We can solve this using just matrix inversion and matrix multiplication.
		\item The advanced linear algebraist may have noticed that $(X^T X)^{-1} X^T$ is called the \textbf{Moore-Penrose pseudoinverse}.
		\item There are specialized algorithms for computing the Moore-Penrose pseudoinverse.
		\item Part of Assignment 4 will be implementing and comparing linear regression using straight inversion vs. pseudoinversion.
	\end{itemize}

\end{frame}

% \begin{frame}[t]{Inversion and Decomposition in Action: Linear Regression}
% 	% Demo
% 	\centering
% 	\Huge{Demo}
% \end{frame}

\begin{frame}[t]{Linear Algebra in NumPy}
	NumPy has a sub-module called \textbf{numpy.linalg} which implements the following groups of methods:
	\pause
	\begin{itemize}[<+->]
		\item Products: inner, outer, matrix, etc.
		\item Decompositions: Cholesky, QR, SVD, Eigen
		\item Special numbers: rank, norm, determinant, etc.
		\item Solvers: Inversion, solve $Ax = b$, least squares, pseudoinversion, etc.
		\item Plus a few more...
	\end{itemize}
\end{frame}

\begin{frame}[t]{Numerical Linear Algebra: Major Takeaways}
	\begin{itemize}[<+->]
		\item If you continue to do numerical computing, you will likely find yourself using some of these linear algebra computations.
		\item Keep the approximate complexities for the major methods in mind so that you know what is feasible in your programs.
		\begin{itemize}[<+->]
			\item For example: Directly solving linear regression with 1,000 instances is feasible, but 1,000,000 might not be. In this case you should consider a different method.
		\end{itemize}
		\item As a rule of thumb, assume $\mathcal{O}(n^3)$ runtime.
		\item Approximations for many of these computations exist that are good enough in many cases.
	\end{itemize}
\end{frame}

% \begin{frame}[t]{Eigen Decomposition: QR Algorithm}
% 	% Description
% \end{frame}
%
% \begin{frame}[t]{Eigen Decomposition: QR Algorithm}
% 	% Description
% \end{frame}

% \section{Sparse Matrices}
% \subsection{Foo}

\end{document}


%%% Template originaly created by Karol Kozioł (mail@karol-koziol.net) and modified for ShareLaTeX use

\documentclass[a4paper,11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}

\renewcommand\familydefault{\sfdefault}
\usepackage{tgheros}
\usepackage[defaultmono]{droidmono}

\usepackage{amsmath,amssymb,amsthm,textcomp}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tikz}

\usepackage{geometry}
\geometry{left=25mm,right=25mm,%
bindingoffset=0mm, top=20mm,bottom=20mm}

\linespread{1.3}

\newcommand{\linia}{\rule{\linewidth}{0.5pt}}

% custom theorems if needed
\newtheoremstyle{mytheor}
    {1ex}{1ex}{\normalfont}{0pt}{\scshape}{.}{1ex}
    {{\thmname{#1 }}{\thmnumber{#2}}{\thmnote{ (#3)}}}

\theoremstyle{mytheor}
\newtheorem{defi}{Definition}

% my own titles
\makeatletter
\renewcommand{\maketitle}{
\begin{center}
\vspace{2ex}
{\huge \textsc{\@title}}
\vspace{1ex}
\\
\linia\\
\@author \hfill \@date
\vspace{4ex}
\end{center}
}
\makeatother
%%%

% custom footers and headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{Object Tracking}
\cfoot{}
\rfoot{Page \thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%

% code listing settings
\usepackage{listings}
\lstset{
    language=Matlab,
    basicstyle=\ttfamily\small,
    aboveskip={1.0\baselineskip},
    belowskip={1.0\baselineskip},
    columns=fixed,
    extendedchars=true,
    breaklines=true,
    tabsize=4,
    prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
    frame=lines,
    showtabs=false,
    showspaces=false,
    showstringspaces=false,
    keywordstyle=\color[rgb]{0.627,0.126,0.941},
    commentstyle=\color[rgb]{0.133,0.545,0.133},
    stringstyle=\color[rgb]{01,0,0},
    % numbers=left,
    % numberstyle=\small,
    % stepnumber=1,
    % numbersep=10pt,
    % captionpos=t,
    escapeinside={\%*}{*)}
}

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

\begin{document}

\title{The Extended Kalman Filter}

\author{Mehdi Raza Khorasani, Habib University}

\date{26/6/2021}

\maketitle

\section*{Introduction}
The extended Kalman Filter is an extension to the Kalman Filter Algorithm. The KF algorithm is defined for Discrete time Linear time invariant systems (DT LTI), which are of the form:
\begin{equation}
    x_k = Fx_{k-1} + V_k
\end{equation}
\begin{equation}
    y_k = Hx_{k} + W_k
\end{equation}
The algorithm fails when the system cannot be represented as $(1)$ and $(2)$. The extended KF approach suggests that we linearize the system and obtain a linear approximation, and then develop a KF algorithm for it. The following lines describe how a non linear system can be linearized and a KF algorithm can be applied to it.
\subsection*{The discrete time non-linear system}
Consider a non-linear system, defined by the following equations:
\begin{equation}
    x_k = f(x_{k-1}) + V_k
\end{equation}
\begin{equation}
    y_k = h(x_{k}) + W_k
\end{equation}
where, $V_k$ and $W_k$ is white uncorrelated Gaussian noise defined as follows:

\begin{equation*}
    V_k \sim (0, Q_k)
\end{equation*}
\begin{equation*}
    W_k \sim (0, R_k)
\end{equation*}

\section*{The EKF Algorithm}
The algorithm of the EKF consists of linearlizing the plant about the optimal value and consecutively applying the baysian estimation steps. Similarly, the observations are also linearized about the optimal value. The following lines summarize the filtering algorithm:

\begin{enumerate}
    \item
    Linearization: Compute the Jacobian of $f$ at $\hat{x}_{k-1|k-1}$ i.e. about the last optimal estimate of $x_k$:
    \begin{equation*}
        F_k = \nabla_{X^T} f(x) \mid_{x = \hat{x}_{k-1|k-1}}
    \end{equation*}

    \item
    State Prediction: Compute Predicted mean and co-variance matrix:
    \begin{equation*}
        \hat{x}_{k|k-1} = f(\hat{x}_{k-1|k-1})
    \end{equation*}
    \begin{equation*}
        P_{k|k-1} = F_k P_{k-1|k-1} F_k^T + Q_k
    \end{equation*}

    \item
    Linearization: Compute the jacobian of $h$ at $\hat{x}_{k|k-1}$ i.e. about the estimate of $x$ given the last estimate:
    \begin{equation*}
        H_k = \nabla_{X^T} h(x) \mid_{x = \hat{x}_{k|k-1}}
    \end{equation*}

    \item
    Measurement Prediction: Compute predicted mean, covariance and Kalman gain:
    \begin{equation*}
        \hat{y}_{k|k-1}  = h(\hat{x}_{k|k-1})
    \end{equation*}
    \begin{equation*}
        S_k = H_k P_{k|k-1} H_k^T + R_k
    \end{equation*}
    \begin{equation*}
        K_k = P_{k|k-1} H_k^T S_k^{-1}
    \end{equation*}

    \item
    Estimation: Compute the posterior mean and co-variance as follows:
    \begin{equation*}
        \hat{x}_{k|k} = \hat{x}_{k|k-1} + K_k(y_k - \hat{y}_{k|k-1})
    \end{equation*}
    \begin{equation*}
        P_{k|k} = P_{k|k-1} - K_k H_k P_{k|k-1}
    \end{equation*}
\end{enumerate}

\section*{Simulation}
We simulate the non-linear system observed by a Radar. The system and radar are governed by the following equations:

\begin{equation}
    \boldsymbol{x_k} =
    \begin{bmatrix}
    x_k\\
    y_k\\
    \phi_k
    \end{bmatrix} =
    \begin{bmatrix}
    x_{k-1} + T v_k cos(\phi_{k-1}) \\
    y_{k-1} + T v_k sin(\phi_{k-1}) \\
    \phi_{k-1} + T\omega_k
    \end{bmatrix} +
    \begin{bmatrix}
    V_{1, k}\\
    V_{2, k}\\
    V_{3, k}
    \end{bmatrix}
\end{equation}
\begin{equation}
    \boldsymbol{y_k} =
    \begin{bmatrix}
    \sqrt{x_k^2+y_k^2}\\
    tan^{-1}\frac{y_k}{x_k}
    \end{bmatrix}
\end{equation}
where $v_k$, $\omega_k$ are the linear and angular velocities of the object respectively and $T$ is sampling time. They are taken as constants:
\begin{equation*}
    v_k = 0.1, \\ \omega_k = 0.01, \\ T = 0.05
\end{equation*}
\subsection*{Algorithm}

\subsubsection{Initialization}
\begin{enumerate}
    \item
    The co-variance Matrix of process Noise was taken as follows:
\begin{equation*}
    Q_k =
    \begin{bmatrix}
    1e^{-6} & 0 & 0\\
    0 & 1e^{-6} & 0 \\
    0 & 0 & 1e^{-6}
    \end{bmatrix}
\end{equation*}

    \item The co-variance Matrix of Radar Noise was taken as follows:
\begin{equation*}
    R_k =
    \begin{bmatrix}
    1e^{-4} & 0 & 0\\
    0 & 1e^{-4} & 0 \\
    0 & 0 & 1e^{-4}
    \end{bmatrix}
\end{equation*}

    \item
    $\mathbf{MATLAB}$'s $randn()$ function was used to generate the the noise vectors $V_k$ and $W_k$ of dimensions $3\times 1$ and $2 \times 1$ respectively.

    \item
    Compute the true value of $x_k$ and $y_k$ from the model's equation (5) and (6) to simulate the non-linear object and Radar.

\end{enumerate}

\subsubsection{Linearization}
\begin{enumerate}
    \item
    The pseudo function for this step is as follows:
    \begin{lstlisting}
        F_k = F_jacobian(T, vk, xhat_km1)
    \end{lstlisting}

    \item The jacobian of $f$ is computed as follows:
    \begin{equation*}
         F_k = \begin{bmatrix}
         \frac{\partial f_1}{\partial x_k} & \frac{\partial f_1}{\partial y_k} & \frac{\partial f_1}{\partial \phi_k} \\
         \frac{\partial f_2}{\partial x_k} & \frac{\partial f_2}{\partial y_k} & \frac{\partial f_2}{\partial \phi_k} \\
         \frac{\partial f_3}{\partial x_k} & \frac{\partial f_3}{\partial y_k} & \frac{\partial f_3}{\partial \phi_k}
         \end{bmatrix}_{\mathbf{x} = \hat{x}_{k-1|k-1}}
    \end{equation*}
    where:
    \begin{equation*}
        \begin{bmatrix}
            f_1 \\
            f_2 \\
            f_3
        \end{bmatrix}
        =
        \begin{bmatrix}
            x_{k-1} + Tv_k \cos(\phi_{k-1})\\
             y_{k-1} + Tv_k \sin(\phi_{k-1})\\
             \phi_{k-1} + Tw_k
        \end{bmatrix}_{\mathbf{x} = \hat{x}_{k-1|k-1}}
    \end{equation*}

     substituting values and taking respective partial derivatives, we get:
    \begin{equation*}
         F_k = \begin{bmatrix}
         1 & 0 & -Tv_k \sin{\phi_{k-1}} \\
         0 & 1 & Tv_k \cos{\phi_{k-1}} \\
         0 & 0 & 1
         \end{bmatrix}_{\mathbf{x} = \hat{x}_{k-1|k-1}}
    \end{equation*}
\end{enumerate}

\subsubsection{State Prediction}
\begin{enumerate}
    \item
    Pseudo function for this step is:
     \begin{lstlisting}
        [xhat_predict, P_predict] = state_predict(xhat_km1, P_km1, F_k,  Q_k, vk, wk, T)
    \end{lstlisting}
    \item The mean is predicted by substituting $\hat{x}_{k-1|k-1}$ directly in $f$ of equation (5)
    \item The co-variance is predicted as described earlier.

\end{enumerate}

\subsubsection{Linearization}
\begin{enumerate}
    \item
    The pseudo function for this step is as follows:
    \begin{lstlisting}
        H_k = H_jacobian(xhat_predict)
    \end{lstlisting}

    \item The jacobian of $h$ is computed similar to what was described earlier. It comes out to be:
    \begin{equation*}
         H_k = \begin{bmatrix}
         -\frac{x_k}{\sqrt{x_k^2+y_k^2} } & \frac{x_k}{\sqrt{x_k^2+y_k^2} } & 0 \\
         \frac{-y_k}{x_k^2+y_k^2} & \frac{x_k}{x_k^2+y_k^2} & 0
         \end{bmatrix}_{\mathbf{x} = \hat{x}_{k|k-1}}
    \end{equation*}
\end{enumerate}

\subsubsection{Measurement Prediction}

    The pseudo function for this step is as follows:
    \begin{lstlisting}
        [yhat_last,K_k] = measurement_predict(xhat_predict, H_k, P_predict, R_k)
    \end{lstlisting}

\subsubsection{Estimation}
    The pseudo function for this step is as follows:
    \begin{lstlisting}
        [xhat_optimal,P_optimal] = estimate(y_k, yhat_predict, P_predict, H_k, K_k)
    \end{lstlisting}

\subsection*{Results}
The true trajectory, sensor observations and predicted trajectory are plotted in figure 1. As can be observed, the EKF algorithm is able to rightly and accurately able to localize the non-linear object.
\begin{figure}[h]
    \centering
    \includegraphics[scale = 1.0]{results.eps}
    \caption{Trajectory of Non linear Object}
    \label{fig:my_label}
\end{figure}

\end{document}


\documentclass{article}
\pagestyle{empty}
\usepackage{amsmath,amssymb,amsfonts,soul}
\usepackage{graphicx}
\usepackage{multicol}
\setlength{\oddsidemargin}{0in} \setlength{\evensidemargin}{0in}
\setlength{\topmargin}{0in} \setlength{\textheight}{8.5in}
\setlength{\textwidth}{6.5in}

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
	\hskip -\arraycolsep
	\let\@ifnextchar\new@ifnextchar
	\array{#1}}
\makeatother

\begin{document}
\begin{flushleft}
	\bfseries{MATH 260, Linear Systems and Matrices, Fall `14}\\
	\bfseries{Activity 3:  Elementary Row Operations}\\
%	\bfseries{Honor Code:} \hspace{3.5in}\bfseries{Names:}\\
\end{flushleft}
\begin{flushleft}

\section*{Algebra Warmup}
Solve the following system of equations by elimination. Everytime you add two equations, or multiply by numbers, right out explicitly what you are adding together or multiplying by on the left.

\vspace{0.25in}

\begin{center}
$\begin{array}{rrrrrcr}
x&+&y&+&z&=&3\\
2x&-&2y&-&z&=&-9\\
-x&+&y&-&z&=&3
\end{array}
$
\end{center}

\newpage

\section{Turning Systems into Matrices}

Linear Algebra is a mathematical field which allows fast and easy solving of systems of linear equations by denoting operations on the entire system succinctly.  Notice that it was rather messy to work with all of those equations in the warmup excercise; imagine doing that for 5 or 10 variables and equations. There are two notations we use in Linear Algebra to condense systems: \textit{Matrix-Vector Form} and \textit{Augmented Matrices}. Let's turn the system from the warmup into Matrix-Vector Form:

\vspace{0.2in}

a) First, we'll identify all the variables of the system and put them together into one column vector of size $3 \times 1$: $\vec{\textbf{x}}=\begin{bmatrix} x\\y\\z\end{bmatrix}$

\vspace{0.2in}

b) Make a matrix of the variables' coefficients; we'll call it \textbf{A}.  It should have size $3 \times 3$.  Write it out. What would $\textbf{A}\cdot\vec{\textbf{x}}$ be?

\vspace{1.5in}

c) Write the values on the right-hand sides of the $=$ as a $3 \times 1$ column vector.  Call it $\vec{\textbf{b}}$.

\vspace{1in}

d) Using the vectors $\vec{\textbf{x}}$, $\vec{\textbf{b}}$ and the matrix \textbf{A}, express the system of equations from the warmup as a single matrix-vector equation.

\vspace{1.5in}

e) Augmented Matrix form is where we just the coefficients (\textbf{A}) and the right-hand-side ($\vec{\textbf{b}}$). We write is as: $[\textbf{A}|\vec{\textbf{b}}]$. Generally, we actually write out the numbers, as we want to manipulate the augemented matrix.  Write out the full augmented matrix for this system (it should be a $3 \times 4$ matrix with a vertical line before the last column).

\newpage

\section{Row Operations}

The main reason we want an augemented matrix is to use it for solving systems. One way to solve the system is by doing row operations to get it into \textit{row echelon form} (REF) or \textit{reduced row echelon form} (RREF). We'll define these in a bit, once we are comfortable with operations...\\

\vspace{0.1in}

\hrulefill \\
\noindent
There are three basic row operations we can perform (see page 134 of the text):\\
$R_i$ means row \textit{i} before an operation while $R_i^*$ denotes row \textit{i} after an operation.\\
1) Row swap between row \textit{i} and row \textit{j}, denoted: $R_i \leftrightarrow R_j$\\
2) Multiply a row \textit{i} by a constant \textit{c} ( with $c\neq 0$) , denoted: $R_i^*=c R_i$\\
3) Add a (multiple) of a row to another row, denoted: $R_i^*= R_i+c R_j$\\
\hrulefill \\

\vspace{0.1in}

\noindent

Lets try these out with our augmented matrix version of the warmup problem:

\vspace{0.2in}

a) Perform the following row operations in sequence:\\

\vspace{0.1in}

$\begin{array}{c}
\\
\\
R_2 \leftrightarrow R_3\\
\\
\\
\\
\end{array}
$
\hspace{0.55in}
$\begin{bmatrix}[ccc|c]
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\end{bmatrix}$
\hspace{0.2in}
$\begin{array}{c}
\\
\\
\\
\\
R_3^*=R_3+2 R_2\\
\end{array}
$
\hspace{0.25in}
$\begin{bmatrix}[ccc|c]
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\end{bmatrix}$\\
\vspace{0.1in}
$\begin{array}{c}
\\
\\
R_2^* = R_1 + R_2\\
\\
\end{array}
$
\hspace{0.25in}
$\begin{bmatrix}[ccc|c]
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\end{bmatrix}$
\hspace{0.2in}
$\begin{array}{c}
\\
\\
R_2^*= \frac{1}{2}R_2\\
\\
R_3^*= -\frac{1}{3}R_3\\
\end{array}
$
\hspace{0.5in}
$\begin{bmatrix}[ccc|c]
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}& \hspace{0.2in}\\
& & & \\
\end{bmatrix}$\\
\vspace{0.1in}
You should now have an augmented matrix with 8 non-zero entries.  The first non-zero entry in each row should also be a positive 1.  Now, let's convert this augmented matrix back into equations...\\
\vspace{0.1in}
b) Rewrite your final augmented matrix below, without the brackets or line (but leave space between each number). Now, beside each number in column 1 put an `$x$', column 2 a `$y$' and column 3 a `$z$'. Where the vertical line was, put an `=' sign.

\vspace{1.25in}

c) How does this compare to what you got for the warmup?  How do the row operations compare to what you did to solve by elimination?

\vspace{1.5in}

\newpage
\section{REF and RREF}

The matrix we got at the end of 2a was in \textit{row echelon form}. A matrix in REF has the following traits (see page 136 of the text):

\begin{enumerate}
	\item Any zero rows are at the bottom
	\item The leftmost non-zero entry of each non-zero row equals 1.\\
 (This entry is called its \textbf{pivot} or \textbf{leading 1}.)
	\item Each pivot is further to the right than the pivot in the row above it.
\end{enumerate}

a) Determine if each of the following matrices is in REF or not. If not, perform row operations to turn it into REF.\\

\vspace{0.1in}
\begin{center}
$\textbf{M}=\begin{bmatrix}
0 & 0 & 2\\
1 & 3 & 1
\end{bmatrix}
$
\hspace{0.2in}
$\textbf{T}=\begin{bmatrix}
1 & 3 & 0 & -1 \\
0 & 0 & 1 & -2
\end{bmatrix}$\\
\end{center}

\vspace{2.5in}

\textit{Reduced row echelon form} (RREF) is a even more strict form for matrices to take, which adds an additional property to the three above:\\
\vspace{0.1in}
\hrulefill \\
\indent 4. Each pivot is the only non-zero entry in its column.\\
\vspace{-3pt}
\hrulefill \\
\vspace{0.1in}
Matrix \textbf{T} from (a) is actually in RREF.\\

b) What additional row operation(s) are required to turn matrix \textbf{M} into RREF?

\newpage

\section{Bringing it Together}

Take the following system of equations, write it first in matrix-vector from, then as an augmented matrix. Finally, use row operations to turn it into RREF:

\begin{center}
$\begin{array}{rrrrrrr}
x_1 & + & x_2 & + & 2 x_3 & = & 1\\
2 x_1 & - & x_2 & + & x_3 & = & 2\\
4 x_1 & + & x_2 & + & 5 x_3 & = & 4
\end{array}$
\end{center}

\end{flushleft}
\end{document}

Fall 2014 - Capaldi A/Activities/Activity03_ElemRowOps.tex


\chapter{\projcur Programs}
% \section{Program}
\section{Ridgelet Transform}
\subsection{im\_radon}
\index{im\_radon}
Program {\em im\_radon} makes an (inverse-) Radon transform of a square
$n \times n$ image.
The output file which contains the transformation has a
suffix, .rad. If the output file name
given by the user does not contain this suffix, it is automatically
added. The ``.rad'' file is a FITS format file, and can be manipulated by
any package implementing the FITS format, or can be converted to another
format using the {\em im\_convert} program.
For the two first Radon transform methods, the user can change the
number of directions and the resolution. For other methods, the
number of directions and the resolution are fixed, and the
x and y options are not valid. Options f, w and s allow the user to perform
a filtering-backprojection. They are valid only when the selected Radon
method is the second one. ``w'' fixes the width of the filter and the
``s'' is the sigma parameter of the Gaussian filter.
{\bf
\begin{center}
 USAGE:  im\_radon  options image\_in trans\_out
\end{center}}
where options are:
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-m type\_of\_radon\_method]}
{\small
\begin{enumerate}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item  Radon transform (resp.\ backprojection) in spatial domain. \\
       By default, the output image is a $2n \times n$ image.
\item  Radon projection in spatial domain and reconstruction in Fourier domain.
       By default, the output image is a $2n \times n$ image.
       The reconstruction is available only for image with
       a size $n$ being a power of 2.
\item  Radon transformation and reconstruction in Fourier space
       (i.e.\ Linogram). \\
       The output is a
       $2n \times n$ image. The number of rows is multiplied by two.
\item  Finite Radon Transform. \\
       The output image is a $(n+1) \times n$ image. The input image size $n$
       must be a prime number.
\item  Slant Stack Radon transform. \\
       The output image has twice the number of rows and twice the number
       of columns of the input image.
       The output is a $2n \times 2n$ image.
       The reconstruction is not available with this transform.
\end{enumerate}}
Default is Radon transformation and reconstruction in Fourier space.

\item {\bf [-y OutputLineNumber]} \\
For the RADON transform, OutputLineNumber = number of projection,
 and default is twice the number of input image rows. Only valid for Radon
methods 1 and 2.\\
% For the inverse RADON transform, OutputLineNumber = number of lines,
% and default is the input image column number.

\item {\bf [-x OutputColumnNumber]} \\
For the RADON transform, OutputLineNumber = number of pixels per projection,
and default is the input image column number. Only valid for Radon
methods 1 and 2.\\
% For the inv. RADON transform, OutputLineNumber = number of column,
% and default is the input image column number.

\item {\bf [-r]} \\
Inverse Radon transform.
\item {\bf [-f]} \\
Filter each scan of the Radon transform. Only valid for Radon
method 2.
\item {\bf [-w FilterWidth]} \\
Filter width. Only valid for Radon
method 2. Default is 100.
\item {\bf [-s SigmaParameter} \\
 Sigma parameter for the filtering. Only valid for Radon
method 2. Default is 10.
\item {\bf [-v]} \\
Verbose. Default is no
\end{itemize}

\subsubsection*{Examples:}
\begin{itemize}
\item im\_radon image.fits trans\\
Apply the Radon transform to an image.
\item im\_info -r trans.rad rec\\
 Reconstruct an image from its Radon transform.
\end{itemize}

\subsection{rid\_trans}
\index{rid\_trans}
Program {\em rid\_trans} makes the  ridgelet transform
(and the inverse when -r option is set).
The output file which contains the transformation has a
suffix, .rid. If the output file name
given by the user does not contain this suffix, it is automatically
added. The ``.rid'' file is a FITS format file, and can be manipulated by
any package implementing the FITS format, or can be converted to another
format using the {\em im\_convert} program.
The default transform is the second one
(RectoPolar Ridgelets using a  FFT based WT).
The two first transform are based on the RectoPolar
(i.e. linogram) radon transform, but the first applies a standard
bi-orthogonal wavelet transform (WT) on the Radon image rows, while the
second uses the Fourier-based WT which introduces a redundancy of 2.
For an $n \times n$ image, the output has $2n$ lines and $n$ column
with the first transform, and is a $2n \times 2n$ image for the second.
When the overlapping is set, the size is doubled in each direction.

{\bf
\begin{center}
 USAGE: rid\_trans options image\_in trans\_out
\end{center}}
where options are:

\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-t type\_of\_ridgelet]}
\begin{enumerate}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.
\item RectoPolar Ridgelet Transform using a FFT based Pyramidal WT.
\item Finite ridgelet transform.
\end{enumerate}
Default is 2.
\item {\bf [-n number\_of\_scale]} \\
 Number of scales used in the wavelet transform.
 Default is automatically calculated.
\item {\bf [-b BlockSize]} \\
Block Size. Default is image size.
\item {\bf [-i]} \\
Print statistical information about each band. Default is no.
\item {\bf [-O]} \\
 No block overlapping. Default is no. When this option is set, the
 number of rows and columns is multiplied by two.
\item {\bf [-r]} \\
Inverse Ridgelet transform.
\item {\bf [-x]} \\
 Write all bands separately as images in the FITS format with prefix 'band\_j'
(j being the band number).
\item {\bf [-v]} \\
Verbose. Default is no
\end{itemize}

\subsubsection*{Examples:}
\begin{itemize}
\item rid\_transform image.fits trans\\
Apply the Ridgelet transform to an image.
\item rid\_transform -r trans.rid rec\\
 Reconstruct an image from its Ridgelet transform.
\end{itemize}

\subsection{rid\_stat}
\index{rid\_stat}
Program {\em rid\_stat} makes the  ridgelet transform, and
gives statistical information on the ridgelet coefficients.
At each scale, it caculates the standard deviation, the skewness,
the kurtosis, the minimum, and the maximum. The output file is a
fits file containing a two-dimensional array $T[J-1,5]$ ($J$ being the
number of scales), with the following syntax:
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item $T[j,0] = $ standard deviation of the jth ridgelet band.
\item $T[j,1] = $ skewness of the jth ridgelet band.
\item $T[j,2] = $ kurtosis of the jth ridgelet band.
\item $T[j,3] = $ minimum of the jth ridgelet band.
\item $T[j,4] = $ maximum of the jth ridgelet band.
\end{itemize}
The last ridgelet scale is not used.
If the ``-A'' option is set, these statistics are calculated only for
the ridgelet coefficients relative the specified angle.
{\bf
\begin{center}
 USAGE: rid\_stat options image\_in trans\_out
\end{center}}
where options are:

\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-t type\_of\_ridgelet]}
\begin{enumerate}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.
\item RectoPolar Ridgelet Transform using a FFT based Pyramidal WT.
\item Finite ridgelet transform.
\end{enumerate}
Default is 2.
\item {\bf [-n number\_of\_scale]} \\
 Number of scales used in the wavelet transform.
 Default is automatically calculated.
\item {\bf [-b BlockSize]} \\
Block Size. Default is 16.
\item {\bf [-O]} \\
   Use overlapping block. Default is no.
\item {\bf [-A Angle]} \\
 Statistics for a given angle. The value must be given  in degrees.
 Default is no, statistics are calculated from all coefficients.
\item {\bf [-v]} \\
Verbose. Default is no
\end{itemize}

\subsubsection*{Example:}
\begin{itemize}
\item rid\_stat -v  image.fits tabstat\\
\end{itemize}

\subsection{rid\_filter}

Program {\em rid\_filter} filters an image using the ridgelet transform.
\begin{center}
 USAGE:  rid\_filter options image\_in imag\_out
\end{center}
where options are
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-t type\_of\_ridgelet]}
\begin{enumerate}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.
\item RectoPolar Ridgelet Transform using a FFT based pyramidal WT.
\item Finite ridgelet transform.
\end{enumerate}
Default is 2.
\item {\bf [-n number\_of\_scale]} \\
 Number of scales used in the wavelet transform.
 Default is automatically calculated.
\item {\bf [-h]} \\
Apply the ridgelet transform only on the high frequencies.
Default is no.

\item {\bf [-b BlockSize]} \\
Block Size. Default is image size.

\item {\bf [-F FirstDetectionScale]} \\
 First detection scale. Default is 1.

% \item {\bf [-i NbrIter]}  \\
%  Number of iteration for the constraint reconstruction.
%   Default is no.
% \item {\bf [-G RegulParam]}  \\
%   Regularization parameter for the constraint reconstruction.
%  Default is 0.2.
% \item {\bf [-C ConvergParam]}  \\
%  Convergence parameter. Default is 1.

\item {\bf [-s Nsigma]} \\
False detection rate. The false detection rate for a detection is given
\begin{eqnarray}
\epsilon =  \mbox{erfc}( NSigma / \sqrt{2})
\end{eqnarray}
{\em Nsigma} parameter allows us to express the false detection rate
even if it is not Gaussian noise. \\
Default is 3.

\item {\bf [-g sigma]} \\
Gaussian noise: sigma = noise standard deviation.  \\
 Default is automatically estimated.

\item {\bf [-p]} \\
Poisson noise.

\item {\bf [-O]}  \\
Do not apply block overlapping. By default, block overlapping is used.

\item {\bf [-v]} \\
Verbose.
\end{itemize}
\subsubsection*{Examples:}
\begin{itemize}
\item rid\_filter  image.fits fima\\
Filter an image using all default options.
\item rid\_filter -h -s5 image.fits fima\\
Five sigma filtering, filtering only the high frequencies.
\end{itemize}

\section{Curvelet Transform}
\subsection{cur\_trans}
\index{cur\_trans}
Program {\em cur\_trans} determines the  curvelet transform
(and the inverse when -r option is set).
The output file which contains the transformation has a
suffix, .cur. If the output file name
given by the user does not contain this suffix, it is automatically
added. The ``.cur'' file is a 3D FITS format file, and can be manipulated by
any package implementing the FITS format.
The curvelet transform uses the ridgelet transform, and the default
ridgelet transform is the RectoPolar one with a FFT based pyramidal WT.

{\bf
\begin{center}
 USAGE: cur\_trans options image\_in trans\_out
\end{center}}
where options are:
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-t type\_of\_ridgelet]}
\begin{enumerate}
\baselineskip=0.4truecm
\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.
\item RectoPolar Ridgelet Transform using a FFT based pyramidal WT.
\item Finite ridgelet transform.
\end{enumerate}
Default is 2.
\item {\bf [-n number\_of\_scale]} \\
 Number of scales used in the 2D wavelet transform.
 Default is 4.
\item {\bf [-N number\_of\_scale]} \\
 Number of scales used in the ridgelet transform.
 Default is automatically calculated.
\item {\bf [-b BlockSize]}  \\
Block Size. Default is 16.
\item {\bf [-r]}  \\
Inverse Curvelet transform.
\item {\bf [-i]}  \\
Print statistical information about each band. Default is no.
\item {\bf [-O]}  \\
 Block overlapping. Default is no.
\item {\bf [-x]} \\
 Write all bands separately as images in the FITS format with prefix 'band\_j'
(j being the band number).
\item {\bf [-v]} \\
Verbose. Default is no.
\end{itemize}

\subsubsection*{Examples:}
\begin{itemize}
\item cur\_trans -i image.fits trans\\
Curvelet transform of an image.
\item cur\_trans -r  trans.cur rec\\
Image reconstruction from its curvelet transform.
\end{itemize}

\subsection{cur\_stat}
\index{cur\_stat}
Program {\em cur\_stat} determines the  curvelet transform, and
gives statistical information on the curvelet coefficients.
At each scale, it caculates the standard deviation, the skewness,
the kurtosis, the minimum, and the maximum. The output file is a
FITS file containing a two-dimensional array $T[J-1,5]$ ($J$ being the
number of bands), with the following syntax:
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item $T[j,0] = $ standard deviation of the jth ridgelet band.
\item $T[j,1] = $ skewness of the jth ridgelet band.
\item $T[j,2] = $ kurtosis of the jth ridgelet band.
\item $T[j,3] = $ minimum of the jth ridgelet band.
\item $T[j,4] = $ maximum of the jth ridgelet band.
\end{itemize}
{\bf
\begin{center}
 USAGE: cur\_stat options image\_in trans\_out
\end{center}}
where options are:
\begin{itemize}
\baselineskip=0.4truecm
\item {\bf [-n number\_of\_scale]} \\
 Number of scales used in the wavelet transform.
 Default is automatically calculated.
\item {\bf [-b BlockSize]} \\
Block Size. Default is 16.
\item {\bf [-O]} \\
   Use overlapping block. Default is no.
\item {\bf [-v]} \\
Verbose. Default is no
\end{itemize}

\subsubsection*{Example:}
\begin{itemize}
\item cur\_stat -v  image.fits tabstat\\
\end{itemize}

\subsection{cur\_filter}
\index{cur\_filter}

Program {\em cur\_filter} filters an image using the curvelet transform.
\begin{center}
 USAGE:  cur\_filter options image\_in imag\_out
\end{center}
where options are
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-t type\_of\_ridgelet]}
\begin{enumerate}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item RectoPolar Ridgelet Transform using a standard bi-orthogonal WT.
\item RectoPolar Ridgelet Transform using a FFT based Pyramidal WT.
\item Finite ridgelet transform.
\end{enumerate}
Default is 2.
\item {\bf [-n number\_of\_scale]} \\
 Number of scales used in the 2D wavelet transform.
 Default is 4.

\item {\bf [-N number\_of\_scale]} \\
 Number of scales used in the ridgelet transform.
 Default is automatically calculated.

\item {\bf [-b BlockSize]}  \\
Block Size. Default is 16.

\item {\bf [-g sigma]} \\
Gaussian noise: sigma = noise standard deviation.  \\
 Default is automatically estimated.

\item {\bf [-s Nsigma]} \\
False detection rate. \\
Default is 3.

\item {\bf [-O]}  \\
Do not apply block overlapping. By default, block overlapping is used.

\item {\bf [-P]}  \\
 Supress the positivity constraint. Default is no.

\item {\bf [-I NoiseFileName]}  \\
If the noise is stationary, the program can estimate the correct
thresholds from a realization of the noise.

\item {\bf [-v]} \\
Verbose
\end{itemize}

\subsubsection*{Examples:}
\begin{itemize}
\item cur\_filter image.fits sol\\
Curvelet filtering of an image.
\item cur\_filter -n 5 -s4  image.fits sol\\
Curvelet filtering of an image, using five resolution levels, and
a 4-sigma detection.
\end{itemize}

\subsection{cur\_colfilter}
\index{cur\_colfilter}

Program {\em cur\_colfilter} filters a
color image using the curvelet transform.
\begin{center}
 USAGE:  cur\_colfilter options image\_in imag\_out
\end{center}
where options are
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-n number\_of\_scale]} \\
 Number of scales used in the 2D wavelet transform.
 Default is 4.

\item {\bf [-N number\_of\_scale]} \\
 Number of scales used in the ridgelet transform.
 Default is automatically calculated.

\item {\bf [-b BlockSize]}  \\
Block Size. Default is 16.

\item {\bf [-g sigma]} \\
Gaussian noise: sigma = noise standard deviation.  \\
 Default is automatically estimated.

\item {\bf [-s Nsigma]} \\
False detection rate. \\
Default is 3.

\item {\bf [-O]}  \\
Do not apply block overlapping. By default, block overlapping is used.

\item {\bf [-v]} \\
Verbose
\end{itemize}

\subsubsection*{Example:}
\begin{itemize}
\item cur\_colfilter image.fits sol\\
Curvelet transform of a color image.
\end{itemize}

\subsection{cur\_contrast}
\index{cur\_contrast}

Program {\em cur\_contrast} filters a color image using the curvelet transform.
\begin{center}
 USAGE:  cur\_contrast options image\_in imag\_out
\end{center}
where options are
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-n number\_of\_scales]} \\
Number of scales used in the wavelet transform.
Default is 4.
\item {\bf [-N number\_of\_scales]} \\
Number of scales used in the ridgelet transform.
Default is automatically calculated.
\item {\bf [-b BlockSize]} \\
Block size used by the curvelet transform. Default is 16.
\item {\bf [-O]} \\
Use overlapping block. Default is no.
\item {\bf [-g sigma]} \\
Noise standard deviation. Only used when filtering is performed.
Default is automatically estimated.
\item {\bf [-s NSigmalLow]} \\
 Coefficient $<$ NSigmalLow*SigmaNoise is not modified.
 Default is   5.
\item {\bf [-S NSigmalUp]} \\
 Coefficient $>$ NSigmalUp*SigmaNoise is not modified.
 Default is  20.
\item {\bf [-M MaxCoeff]} \\
If MaxBandCoef is the maximum coefficient in a given curvelet band,
 Coefficient $>$ MaxBandCoef*MaxCoeff is not modified.
 Default is 0.5.
\item {\bf  [-P P\_parameter]} \\
Determine the degree on non-linearity. P must be in ]0,1[.
Default is 0.5.
\item {\bf [-T P\_parameter]} \\
 Curvelet coefficent saturation parameter. T must be in [0,1].
Default is 0.
\item {\bf [-c]} \\
By default a sigma clipping is performed. When this option is set, no
sigma clipping is performed.
\item {\bf [-K ClippingValue]} \\
Clipping value. Default is 3.
\item {\bf [-L Saturation]} \\
Saturate the reconstructed image.
A coefficient larger than Saturation*MaxData is set to Saturation*MaxData.
Default is  1. If L is set to 0, then no saturation is applyied.
\end{itemize}

\subsubsection*{Examples:}
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item cur\_contrast image.fits image\_out.fits\\
Enhance the contrast using the curvelet transform.
\item cur\_contrast -O image.fits image\_out.fits\\
Enhance the contrast using the curvelet transform and block overlapping.
\item cur\_contrast -M 0.8 image.fits image\_out.fits\\
Enhance more the contrast.
\end{itemize}

\subsection{cur\_colcontrast}
\index{col\_colcontrast}
The program {\em col\_colcontrast} enhances the contrast of a color image
using the curvelet transform.
The command line is:
{\bf
\begin{center}
 USAGE: cur\_colcontrast option in\_image out\_image
\end{center}}
where options are:
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item {\bf [-n number\_of\_scales]} \\
Number of scales used in the wavelet transform.
Default is 4.
\item {\bf [-N number\_of\_scales]} \\
Number of scales used in the ridgelet transform.
Default is automatically calculated.
\item {\bf [-b BlockSize]} \\
Block size used by the curvelet transform. Default is 16.
\item {\bf [-O]} \\
Use overlapping block. Default is no.
\item {\bf [-g sigma]} \\
Noise standard deviation.
Default is automatically estimated.
\item {\bf [-s NSigmalLow]} \\
 Coefficient $<$ NSigmalLow*SigmaNoise is not modified.
 Default is   5.
\item {\bf [-S NSigmalUp]} \\
 Coefficient $>$ NSigmalUp*SigmaNoise is not modified.
 Default is  20.
\item {\bf [-M MaxCoeff]} \\
If MaxBandCoef is the maximum coefficient in a given curvelet band,
 Coefficient $>$ MaxBandCoef*MaxCoeff is not modified.
 Default is 0.5.
 \item {\bf  [-P P\_parameter]} \\
Determine the degree of non-linearity. P must be in ]0,1[.
Default is 0.5.
\item {\bf [-T P\_parameter]} \\
 Curvelet coefficent saturation parameter. T must be in [0,1].
Default is 0.
\item {\bf [-c]} \\
By default a sigma clipping is performed. When this option is set, no
sigma clipping is performed.
\item {\bf [-K ClippingValue]} \\
Clipping value. Default is 3.
\item {\bf [-L Luminance\_Saturation]} \\
Values in the luminance map which are
larger than Saturation*MaxData are set to Saturation*MaxData.
Default is  1.
\end{itemize}

\subsubsection*{Examples:}
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item cur\_colcontrast image.tiff image\_out.tiff\\
Enhance the contrast using the curvelet transform.
\item cur\_colcontrast -n 5 image.tiff image\_out.tiff\\
Ditto, but use five scales instead of four.
\item cur\_colcontrast -M 0.9 image.tiff image\_out.tiff\\
Enhance more the contrast.
\end{itemize}

\section{Combined Filtering}
\subsection{cb\_filter}
\index{cb\_filter}
Program {\em cb\_filter} filters an image corrupted by Gaussian noise by
 the combined filtering method. By default, the undecimated  bi-orthogonal WT
 and the curvelet transform are used. The number of iterations is defaulted
 10. In general, the algorithm converges with less than six iterations.
If the ``-T'' option is set, the Total Variation is minimized instead of
the $l_1$ norm of the multiscale coefficients.
A deconvolution can also be performed using the ``-P'' option. In this
case, a division is first done in Fourier space between the
input image and the point spread function. All Fourier components with
a norm lower than $\epsilon$ (default value is $10^{-3}$) are set to zero.
Then the deconvolved image is filtered by the combined filtering method
using the new noise properties (still Gaussian, but not white).

{\bf
\begin{center}
 USAGE: cb\_filter options image\_in trans\_out
\end{center}}
where options are:
\begin{itemize}
\baselineskip=0.4truecm
\itemsep=0.1truecm
 \item {\bf [-t TransformSelection]}
\begin{enumerate}
\baselineskip=0.4truecm
\itemsep=0.1truecm
\item A trous algorithm
\item Bi-orthogonal WT with 7/9 filters
\item Ridgelet transform
\item Curvelet transform
\item Mirror Basis WT
% \item Multiscale Ridgelet
%\item Cosinus transform
%\item Pyramidal Median transform
\end{enumerate}

\item {\bf [-n number\_of\_scales]} \\
Number of scales used in the \`a trous wavelet transform
%, the PMT and
 and the curvelet transform.
% Number of ridgelet in the multi-ridgelet transform.
Default is 4.

\item {\bf [-b BlockSize]}  \\
 Block Size in the ridgelet transform.
Default is image size.
% Starting Block Size in the multi-ridgelet transform. Default is 8.

\item {\bf [-i NbrIter]}  \\
Number of iterations. Default is 10.

\item {\bf [-F FirstDetectionScale]} \\
First detection scale in the ridgelet transform.
Default is 1.

\item {\bf [-k]} \\
Kill the last scale in ridgelet. % , and multiscale ridgelet transform.
Default no.

\item {\bf  [-K]} \\
Kill last scale in the \`a trous algorithm and the curvelet. % and the PMT
Default no.

\item {\bf  [-L FirstSoftThreshold]} \\
First soft thresholding value. Default is 0.5.

\item {\bf  [-l LastSoftThreshold]} \\
Last soft thresholding value. Default is 0.5.

\item {\bf  [-u]} \\
 Number of undecimated scales in the WT.
 Default is 1.

\item {\bf [-s Nsigma]} \\
False detection rate. Default is 4.

\item {\bf [-g sigma]} \\
Gaussian noise: sigma = noise standard deviation.  \\
 Default is automatically estimated.

% \item {\bf [-p]} \\
% Poisson Noise. Default is no (Gaussian).

\item {\bf [-O]}  \\
No block overlapping. Default is no.

\item {\bf [-T]}  \\
 Minimize the Total Variation instead of the L1 norm.

\item {\bf [-P PsfFile]}  \\
Apply a deconvolution using the PSF in the file PsfFile.

\item {\bf [-e Eps]}  \\
 Remove frequencies with $|P P^*| < \epsilon $.
 Default is $10^{-3}$.

\item {\bf [-C TolCoef]}  \\
 Default is 0.5.

\item {\bf [-v]} \\
Verbose. Default is no.
\end{itemize}

\subsubsection*{Example:}
\begin{itemize}
\item cb\_filter image.fits sol\\
Image filtering by the combined filtering method, using both
the curvelet and wavelet transform.
\end{itemize}


\chapter{Introduction}

In machine learning problem
settings, we
are often presented with data
but additionally have
information about how the
data was collected or generated.
Furthermore, we may have
knowledge or access
to domain expertise that
could inform a learning algorithm.
Traditionally,
one way of incorporating
prior knowledge or domain
expertise into machine
learning algorithms
is by formulating them as probabilistic
graphical models, which
offer flexible avenues for
incorporating assumptions about data.
Take, for example, if we are
tasked with discovering
clusters in a dataset, but have
prior knowledge that
the features of the data are
disentangled or independent,
we can incorporate that
information into the
prior distribution
over cluster components.

This strategy, however,
has major downsides,
namely that the types
of assumptions that
can be incorporated
into probabilistic graphical
models have been historically
limited to generative models in which
Bayesian inference is tractable.
Thus, in scenarios where
the data is high-dimensional
and exhibits complex structure,
we are forced to make
restrictive assumptions
that enable tractable inference,
but limit the capacity
of our model.

On the other hand,
neural networks have emerged
as a dominant force
in machine learning,
thanks to their
ability to scale to large datasets
and their empirical success on complex
data like images and text.
Incorporating prior knowledge
or domain expertise into
deep learning approaches
has often taken the form of
custom neural network layers or
architectures that are tailored
to the task at hand,
and although these strategies
have seen empirical success,
they are often ad-hoc
solutions and do not
leverage the explicit assumptions
and modeling of uncertainty that
probabilistic graphical models offer.
Combining deep learning
methods with probabilistic graphical
models has thus been
recent topic of interest
with many open problems
and challenges.

Much work has gone into investigating
which models are tractable
and how to approximate
intractable ones.
One of the most prominent
methods to emerge in unsupervised learning
is the variational autoencoder \citep[VAE; ][]{Kingma2014, Rezende2014},
which frames autoencoding
as a probabilistic latent variable model.
The VAE models
through a generative process
where latent codes are sampled
from a prior distribution,
and are then passed through a
neural network decoder.
The encoder is used for inference,
approximating the posterior
distribution of codes given data.

The VAE is a stepping stone
for incorporating
neural networks into
statistical learning,
but in its original form,
has very simple assumptions.
The statistical learning literature,
on the other hand, has
explored a wide variety of
models and structures for data.
In this thesis, we
motivate and discuss
the use of Bayesian structured priors
and the algorithmic challenges
in incorporating them
with deep generative models.
The combination
of a Bayesian structured
prior with a VAE
results
in a class of models called
Bayesian structured representation learning
models.

In Part I, we introduce the
core ideas and foundations for Bayesian structure
learning and present a contribution
in the space of interactive structure learning.
In Part II, we motivate and discuss
algorithms and models used in Bayesian structured
representation learning.


\section{Kinematic ages}
\subsection{Calculating velocity dispersions}
\label{sec:velocity_dispersion}

A kinematic age can be calculated from the velocity dispersion, \ie\ standard
deviation, of a group of stars.
These velocity dispersions can then be converted into an age using an AVR
\citep[\eg][]{holmberg2009, yu2018}.
Kinematic ages represent the {\it average age} of a group of stars and are
most informative when stars are grouped by age.
If a group of stars have similar ages, their kinematic age will be close
the age of each individual.
On the other hand, the kinematic age of a group with large age variance will
not provide much information about the ages of individual stars.
Velocity distributions themselves do not reveal whether a group of stars have
similar or different ages, since either case the velocities are
Gaussian-distributed.
Fortunately however, we can group \kepler\ stars by age using the implicit
assumption that underpins gyrochronology: that stars with the same rotation
period and color are the same age.
% We discuss the implications of this assumption and cases where it doesn't
% apply in the Discussion of this paper (section \ref{sec:discussion}).

In this paper, we use the kinematic ages published in \citet{lu2021}.
In that work, the kinematic age of each star in our sample was calculated by
placing it in a bin with other stars with similar rotation periods, effective
temperatures, absolute Gaia magnitudes and Rossby numbers.
The kinematic age of each star was estimated by calculating the velocity
dispersions of stars with these similar parameters, then using an AVR to
calculate a corresponding age \citep{yu2019}.
The bin size was optimized using a number of Kepler stars with asteroseismic
ages.

We used the \citet{yu2018} AVR to convert velocity dispersion to age.
This relation was calibrated using the ages and velocities of red clump stars.
They divided their sample into metal rich and poor subsets, and calibrated
separate AVRs for each, plus a global AVR.
Their AVR is a power law:
\begin{equation}
    \sigma_{vz} = \alpha t ^\beta,
\end{equation}
where $\alpha$ and $\beta$ take values (6.38, 0.578) for metal rich stars
(3.89, 1.01) for metal poor stars, and (5.47, 0.765) for all stars.

We used 1.5$\times$ the Median Absolute Deviation (MAD) of velocities, which
is a robust approximation to the standard deviation and is less sensitive to
outliers.
Velocity outliers could be binary stars or could be generated by
underestimated parallax or proper motion uncertainties.

Figure \ref{fig:kin_and_clusters} displays the data we used to calibrate our
gyrochronology model in \prot-\teff\ space.
Kepler field stars are shown as small points, and cluster stars are larger
points with black outlines.
Points are colored by either their kinematic ages or cluster ages.
The left- and right-hand panels have a linear and logarithmic y-axis,
respectively.

\begin{figure}
\caption{
    The calibration data.
Kepler field stars are shown as small points, and cluster stars are larger
points with black outlines.
Points are colored by either their kinematic ages or cluster ages.
The left- and right-hand panels have a linear and logarithmic y-axis,
respectively.
}
  \centering \includegraphics[width=1\textwidth]{kin_and_clusters_log_lin}
\end{figure}


\chapter{Nomenclature}
\markboth{NOMENCLATURE}{}

\textbf{{\large Upper-case Roman}}

\begin{longtable}[l]{ll}
$\mathcal{B}$ & Solid body governing equation\tabularnewline
$C_D$ & Drag coefficient\tabularnewline
$C_L$ & Lift coefficient\tabularnewline
$C_s$ & Smagorinsky model constant\tabularnewline
$\mathcal{CC}$ & Correlation coefficient\tabularnewline
$D$ & Cylinder diameter\tabularnewline
$E$ & Kinetic energy \tabularnewline
$\mathcal{F}$ & Fluid governing equation\tabularnewline
$F_x$ & Drag force\tabularnewline
$F_y$ & Lift force\tabularnewline
$H$ & Helicity \tabularnewline
$II, III$ & Non-zero invariants of the anisotropic Reynolds-stress tensor \tabularnewline
$K_\epsilon$ & BDIM convolution kernel \tabularnewline
$L$ & Characteristic length\tabularnewline
$L_{11}$ & Integral lengthscale\tabularnewline
$L_a$ & Spanwise-averaging length\tabularnewline
$L_z$ & Cylinder span\tabularnewline
$M$ & Number of time steps\tabularnewline
$\mathcal{M}$ & Meta-equation combining fluid and solid governing equations\tabularnewline
$N$ & Number of grid points\tabularnewline
$P$ & Spanwise-averaged pressure\tabularnewline
$R$ & Ratio of mean vortex-stretching term to mean vortex-advection term\tabularnewline
$Re$ & Reynolds number \tabularnewline
$\mathcal{S}$ & 3-D Navier--Stokes spatial operator \tabularnewline
$\tilde{\mathcal{S}}$ & 2-D Navier--Stokes spatial operator \tabularnewline
$\mathcal{S}^R$ & Perfect closure \tabularnewline
$S_{ij}$ & Rate-of-strain tensor \tabularnewline
$St$ & Strouhal number \tabularnewline
$\vect{U}$ & Spanwise-averaged velocity vector field \tabularnewline
$U$ & Characteristic velocity\tabularnewline
$U$ & Spanwise-averaged velocity component along the $x$ spatial direction\tabularnewline
$U_\infty$ & Free-stream velocity\tabularnewline
$V$ & Spanwise-averaged velocity component along the $y$ spatial direction\tabularnewline
$W$ & Spanwise-averaged velocity component along the $z$ spatial direction\tabularnewline
$\mathrm{X}_n$ & Model input set\tabularnewline
$\mathrm{Y}_n$ & Model output set\tabularnewline
$Z$ & Enstrophy \tabularnewline
\end{longtable}

\textbf{{\large Lower-case Roman}}

\begin{longtable}[l]{ll}
$b_{ij}$ & Anisotropic Reynolds-stress tensor \tabularnewline
$d$ & Distance function\tabularnewline
$f_s$ & Vortex-shedding frequency \tabularnewline
$\vect{h}$ & Force vector field combining convective and viscous forces\tabularnewline
$k$ & Turbulence kinetic energy \tabularnewline
$p$ & Pressure field \tabularnewline
$\vect{r}$ & Distance vector\tabularnewline
$r$ & Radial direction in the cylindrical coordinates frame\tabularnewline
$t$ & Time\tabularnewline
$t^*$ & Convective time ($t$ scaled with $U$ and $L$)\tabularnewline
$\vect{u}$ & Velocity vector field\tabularnewline
$u$ & Velocity component along the $x$ spatial direction\tabularnewline
$\vect{u}_b$ & Velocity boundary condition on solid walls\tabularnewline
$\vect{u}_s$ & Straining velocity vector field\tabularnewline
$\vect{u}_v$ & Columnar vortex velocity vector field\tabularnewline
$v$ & Velocity component along the $y$ spatial direction\tabularnewline
$w$ & Velocity component along the $z$ spatial direction\tabularnewline
$\vect{x}$ & Spatial coordinates vector \tabularnewline
$x$ & Spatial coordinate aligned with the principal (streamwise) flow direction\tabularnewline
$y$ & Spatial coordinate aligned with the transverse (crossflow) flow direction\tabularnewline
$z$ & Spatial coordinate aligned with the lateral (spanwise) flow direction\tabularnewline
\end{longtable}

\textbf{{\large Upper-case Greek}}

\begin{longtable}[l]{ll}
$\Gamma$ & Circulation\tabularnewline
$\Delta$ & LES filter size\tabularnewline
$\vect{\Omega}$ & Spanwise-averaged vorticity vector field \tabularnewline
$\Omega$ & A general spatial domain \tabularnewline
$\Omega_f$ & Fluid subdomain \tabularnewline
$\Omega_b$ & Solid body subdomain \tabularnewline
\end{longtable}

\textbf{{\large Lower-case Greek}}

\begin{longtable}[l]{ll}
$\gamma$ & Rate of strain\tabularnewline
$\delta_{ij}$ & Kronecker delta tensor \tabularnewline
$\delta t$ & Temporal resolution\tabularnewline
$\delta x$ & Spatial resolution\tabularnewline
$\delta_\epsilon$ & Zeroth-moment of the BDIM convolution kernel \tabularnewline
$\epsilon$ & Turbulence dissipation rate \tabularnewline
$\epsilon_T$ & Trapezoidal quadrature error \tabularnewline
$\vect{\zeta}^R$ & Spanwise-stress residual vector in the spanwise-averaged VTE \tabularnewline
$\eta$ & Invariant of the anisotropic Reynolds-stress tensor \tabularnewline
$\eta$ & Kolmogorov lengthscale \tabularnewline
$\theta$ & Angular direction in the cylindrical coordinates frame\tabularnewline
$\theta_l$ & Lower separation angle on the cylinder surface\tabularnewline
$\theta_u$ & Upper separation angle on the cylinder surface\tabularnewline
$\vect{\kappa}$ & Wavenumber vector\tabularnewline
$\kappa$ & Wavenumber\tabularnewline
$\lambda_z$ & Spanwise correlation length \tabularnewline
$\mu$ & Dynamic viscosity\tabularnewline
$\nu$ & Kinematic viscosity\tabularnewline
$\nu_{e}$ & Effective kinematic eddy viscosity in iLES\tabularnewline
$\nu_{t}$ & Kinematic eddy viscosity\tabularnewline
$\xi$ & Invariant of the anisotropic Reynolds-stress tensor \tabularnewline
$\rho$ & Density\tabularnewline
$\sigma$ & Standard deviation\tabularnewline
$\tau$ & Turbulence timescale\tabularnewline
$\vect{\tau}_{ij}^R$ & Spanwise-stress residual tensor\tabularnewline
$\vect{\tau}_{ij}^r$ & Anisotropic spanwise-stress residual tensor\tabularnewline
$\chi_{12}$ & Two-point correlation function\tabularnewline
$\vect{\omega}$ & Vorticity vector field\tabularnewline
$\vect{\omega}_v$ & Columnar vortex vorticity vector field\tabularnewline
\end{longtable}

\textbf{{\large Acronyms}}

\begin{longtable}[l]{ll}
2-D & Two-Dimensional\tabularnewline
3-D & Three-Dimensional\tabularnewline
ANN & Artificial Neural Network \tabularnewline
BDIM & Boundary Data Immersion Method \tabularnewline
CNN & Convolutional Neural Network \tabularnewline
DNS & Direct Numerical Simulation \tabularnewline
EVM & Eddy-Viscosity Model \tabularnewline
FLOP & FLoating-point OPerations\tabularnewline
FSI & Fluid-Structure Interaction\tabularnewline
HPC & High-Performance Computing \tabularnewline
IB & Immersed Boundary\tabularnewline
iLES & implicit Large-Eddy Simulation\tabularnewline
KLB & Kraichnan--Leith--Batchelor\tabularnewline
LES & Large-Eddy Simulation\tabularnewline
ML & Machine-Learning\tabularnewline
MIMO & Multiple-Input Multiple-Output \tabularnewline
PBML & Physics-Based Machine Learning\tabularnewline
PS & Power Spectrum\tabularnewline
QUICK & Quadratic Upstream Interpolation for Convective Kinematics\tabularnewline
RANS & Reynolds-Averaged Navier--Stokes\tabularnewline
ReLU & Rectified Linear Unit \tabularnewline
RNN & Recurrent Neural Network \tabularnewline
SANS & Spanwise-Averaged Navier--Stokes\tabularnewline
SGS & SubGrid Scale\tabularnewline
SSR & Spanwise-Stress Residual\tabularnewline
TKE & Turbulence Kinetic Energy\tabularnewline
VIV & Vortex-Induced Vibrations\tabularnewline
VTE & Vorticity Transport Equation\tabularnewline
\end{longtable}


\documentclass[a4paper]{article}

\def\npart{III}

\def\ntitle{3 Manifolds}
\def\nlecturer{S.\ Rasmussen}

\def\nterm{Lent}
\def\nyear{2019}

\input{header}

\renewcommand{\boundary}{\partial}
\renewcommand{\b}{\boundary}
\newcommand{\interior}{\ocirc}
\renewcommand{\P}{{\mathbb P}}
\newcommand{\immerse}{\looparrowright}
\DeclareMathOperator{\grad}{grad}

\begin{document}

\input{titlepage}

\tableofcontents

\setcounter{section}{-1}

\section{Why 3?}

\subsection{Motivation}

\paragraph{Poincare conjecture (1904)}

Question: how can we distinguish \(S^3\) fom other 3-manifolds? The strategy is to find an invariant that distinguishes \(S^3\). The frst guess is homology but

\begin{theorem}[Poincare]
  There exists a closed oriented 3-manifold \(P\) with \(H_*(P) \simeq H_*(S^3)\) but with \(P \ncong S^3\).
\end{theorem}

\begin{notation}
  We use \(\cong\) to denote homeomorphism and \(\simeq\) to denote isomorphism.
\end{notation}

This is proven in the following way: first invent the fundamental group \(\pi_1\), then construct \(P\), which is now known as (-1)-Dehn surgery on left-handed trefoil knot \(K_T \subseteq S^3\). Finally show that \(|\pi_1(P)| = 120, |\pi_1(S^3)| = 1\) and \(H_*(P) \simeq H_*(S^3)\).

\subsection{Homotopy}

\paragraph{Review of homotopy theory}

homotopy, fundamental groups and higher homotopy groups, homotopy equivalence, weak homotopy equivalence

\paragraph{Homotopy vs.\ homology}

Let \(X\) and \(Y\) be path-connected topological spaces.

\begin{theorem}[Hurewicz]\leavevmode
  \begin{enumerate}
  \item \(H_1(X, \Z) \simeq \pi_1(X)/[\pi_1(X), \pi_1(X)]\).
  \item If \(\pi_i(X) = 1\) for \(i = \{1, \dots, n\}\) then
    \begin{align*}
      H_i(X) &= 0 \text{ for } i \leq n, i \neq 0 \\
      H_{n + 1} &\simeq \pi_{n + 1}(X)
    \end{align*}
  \end{enumerate}
\end{theorem}

\begin{theorem}[Whitehead]
  If \(X, Y\) are CW complexes. Then a weak homotopy equivalence of \(X\) and \(Y\) is also a homotopy equivalence.
\end{theorem}

\begin{theorem}[Whitehead-homology variant]
  Suppose \(X, Y\) are simply-connected CW complexes. If the induced homomorphisms \(f_*: H_k(X; \Z) \to H_k(Y; \Z)\) are isomorphisms for all \(k \leq \dim X\) then \(f: X \to Y \) is a homotopy equivalence.
\end{theorem}

\begin{theorem}
  Any homotopy equivalence \(f: X \to Y\) induces isomorphisms on homology, cohomology, cohomology ring structure (for any coefficients).
\end{theorem}

\subsection{*Simplifications in higher dimension}

Let \(\mathcal C\) be the smooth category when \(n \geq 5\) and topological category \(n \geq 4\).

\begin{theorem}[Whitney trick]
  Suppose \(\dim X = n\) where \(n \geq 4\) and \(P, Q \subseteq X\) are \(\mathcal \C\)-embedded submanifolds and \(\dim P + \dim Q = \dim X\). Then \(P, Q\) can be locally \(\mathcal C\)-isotoped so that the geometric intersection number equal to the absolute value of algebraic intersection of \(P, Q\). Note that algebraic intersection number is signed while teh geometric counterpart is not.
\end{theorem}

\begin{convention}
  When we say topological embeddings we always mean locally flat embeddings, which will be defined later in the course.
\end{convention}

\begin{definition}[\(h\)-cobordism]
  Let \(W\) with \(\boundary W = X_1 \amalg X_2\) be a cobordism from \(X_1\) to \(X_2\). \(W\) is an \emph{\(h\)-cobordism} if the embeddings \(X_i \embed W\) are homotopy equivalences.
\end{definition}

\begin{convention}
  All manifolds are compact connected and oriented unless otherwise stated.
\end{convention}

\begin{theorem}[\(h\)-cobordism]
  Suppose \(\dim X_i = n, \dim W = n + 1\), \(W\) is a \(h\)-cobordism from \(X_1\) to \(X_2\). If \(\pi_1(X_i) = \pi_1(W) = 1\) and \(n \geq 4\) then \(W\) is \(\mathcal C\)-isomorphic to \(X_1 \times [0, 1]\).
\end{theorem}

\subsection{Generalised Poincare conjecture}

Poincare conjecture: if \(S\) is compact oriented \(3\)-manifold homotopy equivalent to \(S^n\), then does \(S \cong S^n\)?

Generalised Poincare conjecture: if \(S\) is compact oriented \(n\)-manifold homotopy equivalent to \(S^n\), then does \(S \cong S^n\)?

It turns out for \(n \geq 4\), the generalised Poincare conjecture is a corollary of \(h\)-cobordism theorem. Sketch of proof for \(n \geq 5\): suppose \(S\) is homotopy equivalent to \(S^n\), Then \(\pi_*(S) \simeq \pi_*(S^n), H_*(S) \simeq H_*(S^n)\). Delete two balls from \(S\) to obtain \(W \cong S \setminus \interior B_1^n \amalg \interior B_2^n\). Claim that \(W\) is a \(h\)-cobordism: apply Mayer-Vietoris with \(A = W, B = B_1^n \amalg B_2^n\). Then \(A \cap B = S^{n - 1} \amalg S^{n - 1} =_{\text{htp}} W \amalg \{0, 1\}, A \cup B = S, A \amalg B = W \).

\[
  \begin{tikzcd}
    H_n(S^{n - 1} \amalg S^{n - 1}) \ar[r] & H_n(W \amalg \{0, 1\}) \ar[r] & H_n(S) \ar[dll, out=0, in=180] \\
    H_{n - 1}(S^{n - 1} \amalg S^{n - 1}) \ar[r] & H_{n - 1}(W \amalg \{0, 1\}) \ar[r] & H_{n - 1}(S)
  \end{tikzcd}
\]

The first term vanishes because of dimension, the second term vanishes because \(W\) is not closed. By homotopy equivalence we get
\[
  \begin{tikzcd}
    0 \ar[r] & \Z \ar[r] & \Z \oplus \Z \ar[r] & H_{n - 1}(W \amalg \{0, 1\}) \ar[r] & 0
  \end{tikzcd}
\]
We can compute that \(H_{n - 1}(W \amalg \{0, 1\}) \simeq \Z\). It is an exercise to show that there is an induced isomorphism on homology \(H_k(S^n_i) \to H_k(W)\) for each \(k\). Moreover \(\pi_1(W) = 1\) so \(S^n_i \to W\) are homotopy equivalent.

Therefore \(W \cong S^{n - 1} \times [0, 1]\) So \(S \cong B_1^n \cup W \cup B_2^n\). By Alexander trick map on a \(S^{n - 1}\) can be extended \emph{topologically} to a map on \(B^n\) with \(\boundary B^n = S^n\). Extends this homeomorphism over the two balls.

Note that this only applies to topological category and smooth generalised Poincare conjecture is still open in \(n \geq 4\).

\subsection{Why not higher than 5?}

Moral: homotopy-theoretic techniques can be used to answer most/many questions about topology or smooth structures in dimension \(\geq 5\).

\section{Lecture 2: Why 3-manifolds? + Embeddings/Knots}

\subsection*{Active research areas}

\begin{enumerate}
\item An interaction with 4-dimensional manifolds (smooth/symplectic/complex structures)
\begin{enumerate}
\item Dimension reduction reduces 4-dimensional invariant to 3-dimensional ones (that are fancier ``categorified'') and maps induced by cobordisms.
\item symplectic form \(\omega\) on \(X^4\) \(\implies\) \emph{contact structure} \(\xi\) on \(Y = \b X\).
\item Stein structure (complex/symplectic structure) on \(X\) \(\implies\) Stein-fillable contact structure.
\item Normal complex structure sin \((X, 0)\) is a real cone over \(Y = \)Linkm(X, 0.
\end{enumerate}

\item Geometric group theory: fundamental groups, especially of 3-manifolds:

prime, atoroidal non lens space 3 manifolds \(\iff\) fundmental groups of such 3-manifolds.

\item 2-dimensional structure
  \begin{enumerate}
  \item contact stucture: \(\xi\) everywhere nonintegrable \(2\)-lane field. ``tight'' contact structure classification
  \item minimal genus representatives of embedded surfaces, or knot genus. This is better understood. Thurston norm. The 4-dimensional analogue is still open.
  \item Foliations. Taut folations classification. Seifert fibered
  \end{enumerate}

\item 1-dimensional structure: knots and links
  \begin{enumerate}
  \item embedddings \(\amalg_i S^1_i \embed S^3\). Every 3-manifold can be realised as \emph{Dehn surgery} on  a link \(L \embed S^3\). Thus the theory of knot theory is richer that of 3-manifold. We study 3-manifolds via knot invariants (WIlten-Reshetikhin-Turaev invariant).
  \item Relations to other areas
    \begin{enumerate}
    \item Chern-Simons knot invarints: \(K \subseteq S^3\) \(\iff\) Gromov-Witten invariants on \(O(-1) \underbrace{\oplus}_{\C\P^1} O(-1)\).
    \item Homfly homology of \(n\)str braids \(\iff\) DC sheaves on \(\operatorname{HIlb}^n(\C)\).
    \item Khovanov homology of links in \(S^3\) \(\iff\) DC sheaves on other spaces.
    \end{enumerate}
  \end{enumerate}
\end{enumerate}

\subsection{Course themes}

\begin{enumerate}
\item Decompositions/Constructions of 3-manifolds.
  \begin{enumerate}
  \item surface decompositions/constructures
    \begin{enumerate}
    \item prime decomposition --- cut along essential \(S^2\)
    \item JSJ decomposition --- cut along essential \(T\).
    \item Mapping tori \(\iff\) surface fibrations.
    \end{enumerate}
  \item quotient spaces
    \begin{enumerate}
    \item Hyperbolic quotients
    \item quotients of \(S^7\). Seifert fibration
    \item Morse theoretic
      \begin{enumerate}
      \item handle decomposition
      \item Heegaard splittings/diagrams
      \end{enumerate}
    \item Dehn surgery on links
    \end{enumerate}
  \end{enumerate}
\item Structure + Invariants for 3-manifolds
  \begin{enumerate}
  \item Knots \& links
    \begin{enumerate}
    \item complement \(S^3 \setminus K\)
    \item \(\pi_1(S^3 \setminus K)\)
    \item Alexander polynomials + Turaev torsion
    \end{enumerate}
  \item Essential/incompressible embedded surfaces, Thurston norm
  \item Foliations
  \end{enumerate}
\end{enumerate}

\section{Embeddings}

\begin{definition}[link]\index{link}
  A \emph{link} is an embedding \(L = \amalg_i S^1_i \embed S^3\) considered up to isotopy. This embedding is either smooth or topoogical and locally flat. These two notions are equivalent.
\end{definition}

Let \(X\) and \(Y\) be topological manifolds.

\begin{definition}[topological embedding]\index{topological embedding}
  A \emph{topological embedding} \(X \embed Y\) is a map \(X \embed Y\) which is a homeomorphism onto its image.
\end{definition}

\begin{definition}[immersion]\index{immersion}
  If \(X\) and \(Y\) are also smooth then a map \(f: X \to Y\) is an \emph{immersion} if \(d_xf: T_xX \to T_{f(x)}Y\) is injective for all \(x \in X\).
\end{definition}

As a consequence of inverse function theorem, any immersion is locally an embedding.

\begin{definition}[smooth embedding]\index{smooth embedding}
  A \emph{smooth embedding} is a topological embedding that is also an immersion.
\end{definition}

\begin{corollary}
  If \(X, Y\) are smooth compact then any bijective immersion is an embedding.
\end{corollary}

\begin{theorem}[Moise]\index{Moise theorem}
  There is a canonical correpondence between topological structures and smooth structures on 3-manifolds.
\end{theorem}

Thus 3-manifolds up to homeomorphism bijects to 3-manifolds up to diffeomorphism.

\begin{definition}[local flatness]\index{local flatness}
  A topologically embedded submanifold \(X \subseteq Y\) is \emph{locally flat} at \(x \in X\) if \(x\) has a neighbourhood \(x \in U \subseteq Y\) with homeomorphisms \((U \cap X, U) \cong (\R^{\dim X}, \R^{\dim Y})\).

  A \emph{locally flat embedding} is locally flat everywhere.
\end{definition}

\begin{convention}
  From now on any embedding is smooth or locally flat.
\end{convention}

\begin{definition}[regular neighbourhood]\index{regular manifolds}
  A \emph{regular neighbourhood} of an embedded submanifold \(X \subseteq Y\) is a tubular/collar neighbourhood if the embedding is smooth/topologically flat.
\end{definition}

In 3-dimensions normal bundles are trivial so a regular neighbourhood \(\nu(X)\) is just \(D^2 \times X \embed Y\) if \(\dim X = 1\) and \(D^1 \times X \embed Y\) if \(\dim Y = 2\).

In particular, neighbourhood of a not \(K \embed S^3\) is just a solid torus \(D^2 \times S^1 \embed S^3\).

\section{Lecture 3: Link diagrams \& Alexander Skein relations}

\begin{eg}
  Wild knot: not locally flat embedding
\end{eg}

\begin{definition}[isotopy]\index{isotopy}
  An \emph{isotopy} in category \(\mathcal C\) from \(f_1\) to \(f_2: X \to Y\) is a homotopy through maps of type \(\mathcal C\).
\end{definition}

The point is, all knots (including wild knot) are isotopic through non-locally flat embeddings to an unknot, and all knots are homotopic to an unknot so we want to exclude the ``bad'' homotopies where a knot can cross itself.

\subsection{Knot and link diagrams}

\begin{definition}[link]\index{link}
  A \emph{link} is an (oriented) embedding \(\iota: \coprod_i S_i^1 \embed S^3\) of (oriented circles), considered up to isotopy.
\end{definition}

\begin{definition}[link projection]
  A \emph{link projection} is an immersion \(L \immerse \Gamma \embed \R^2\), induced by
  \[
    \begin{tikzcd}
      L \ar[r, hook] \ar[d, "p|_L"] & S^3 \setminus \{x_0\} \ar[r, "\cong"] & \R^3 \ar[r, "\cong"] & \R^2 \times \R \ar[d, "p"] \\
      \Gamma \ar[rrr] & & & \R^2
    \end{tikzcd}
  \]
  such that \(x_0 \notin L\) and \(p|_L\) is an embedding except at double point singularities.
\end{definition}

This aweful looking definition is just a formalisation of a familiar concept that facilitates the study of knots:

\begin{definition}[link diagram]\index{link diagram}
  A \emph{link diagram} \(D = (\Gamma, \text{crossing} (D))\) of a link \(L \subseteq S^3\) is an embedded graph \(\Gamma \embed \R^2\) from a link projection of \(D\), together with decorations at double points to label crossings. We draw a gap in the lower strand.
\end{definition}

\begin{theorem}[Reidemeister moves]\index{Reidemeister moves}
  Let \(D_1\) and \(D_2\) be link diagrams for respective links \(L_1, L_2 \subseteq S^3\). Then \(L_1\) and \(L_2\) are isotopic if and only if \(D_1\) and \(D_2\) are related by some combination of the fuollowing moves:
\end{theorem}

It is more important to know that such moves exist than what they actually are.

\subsection{Alexander Skein relation}

To compute the alexander polynomial, you first choose an orientation for the link \(L \subseteq S^3\). However, the resulting polynomial is independent of choice of orientation for knots.

\begin{theorem}[Alexander]\index{Alexander polynomial}
  The \emph{Alexander polynomial}
  \[
    \Delta: \{\text{link diagram}\} \to \Z[t^{-1/2}, t^{1/2}]
  \]
  is specified by 2 conditions:
  \begin{enumerate}
  \item normalisation: \(\Delta(u) = 1\) where \(u\) is the unknot.
  \item Skein relation: \(\Delta(negative crossing) - \Delta(positive crossing) = \Delta(oriented resolution) (t^{-1/2} - t^{1/2})\) for all \(c \in \text{crossing}(D)\).
  \end{enumerate}
  \(\Delta(D_1) = \Delta(D_2)\) if \(D_1\) and \(D_2\) are diagrams for isotopic links.
\end{theorem}

\begin{theorem}[equivalence of Alexander polynomial]
  Later we will define an Alexander polynomial for 3-manifolds with \(b_1 > 0\). With respect to this definition,
  \[
    \Delta_{\text{link}}(L) = \Delta_{\text{3-manifold}}(S^3 \setminus L)
  \]
  for any link \(L \subseteq S^3\).
\end{theorem}

\section{Handle decompositions from Morse Singularities}

Handles: index \(k\)-handles are tubular neighbourhood of \(k\)-cell CW complex, also are neighbourhoods of Morse critical points.

\subsection{Morse functions}

Let \(X \to \R\) be a smooth function on a smooth manifold \(X\).

\begin{definition}[Hessian, critial point]\index{Hessian}\index{critcal point}
  \(\textrm{Hess}_p(x)\) is the Hessian of \(f\) at \(p\), which is local coordintes is
  \[
    \left(
      \frac{\partial^2 f}{\partial x_i \partial x_J}|_{x = p}
    \right)_{ij}.
  \]

  \(\textrm{crit} f\) is the set of critical points of \(f\), i.e.\ \(\{p \in X: \frac{\partial f}{\partial x_i} = 0 \text{ for all } i\}\), or more invariantly, \(df = 0\).
\end{definition}

\begin{definition}[Morse function]\index{Morse function}
  A smooth function \(f: X \to \R\) on an \(n\)-manifold \(X\) is \emph{Morse} if
  \begin{enumerate}
  \item every critical point of \(f\) is isolated. (If \(X\) is compact then this implies that critical points are finite)
  \item \(\textrm{Hess}_p f\) is nongenerate at each \(p \in \textrm{crit} f\), if and only if \(\det \neq 0\), if and only if has all nonzero eigenvalues.
  \end{enumerate}
\end{definition}

\subsection{Morse singularities}

A list of descriptions of Morse functions:

\begin{enumerate}
\item If \(f: X \to \R\) is Morse, then a Taylor series expansion around a critical point \(p \in \textrm{crit} f\) looks like
  \[
    f(x) = f(p) + \frac{1}{2} \sum x_i x_j \frac{\partial^2 f}{\partial x_i x_j}\Bigg|_p + \text{ higher order terms}
  \]
\item \(\textrm{Hess}_p f\) is nondegenerate means that we can rescale coordinates so that all eigenvalues are \(\pm 1\).
\item Since partial derivatives commute, \(\textrm{Hess}_p f\) is symmetric. Thus by linear algebra it is diagonalisable and we can write
  \[
    f(x) = f(p) - \sum_{i = 1}^k x_i^2 + \sum_{i = k + 1}^n x_i^2 + \text{ higher order terms}.
  \]
\end{enumerate}

\begin{lemma}[Morse lemma]
  Let \(X\) be a smooth manifold and \(f: X \to \R\) Morse. One can choose coordinates \(x\) centred at \(p \in \textrm{crit} f\) such that
  \[
    f(x) = f(p) - sum_{i = 1}^k x_i^2 + \sum_{i = k + 1}^n x_i^2.
  \]
\end{lemma}

\begin{proof}
  Use implicit function theorem.
\end{proof}

\begin{definition}[index]
  The \emph{index} \(\operatorname{ind}_p f\) of a Morse function \(f: X \to \R\) at a critical point \(p\) is
  \[
    \operatorname{ind}_p f = \# \text{ negative eigenvalues of } \textrm{Hess}_p,
  \]
  which is the \(k\) above.
\end{definition}

Thus Morse lemma says that index is the (only?) invariant of Morse functions.

Moral: there is a standard local model for each index \(k\) Morse critical point.

See printed notes

\begin{definition}[\(k\)-handle]
  An index \(k\)-handle, or just \(k\)-handle, or \(n\)-dimensional \(k\)-handle is the closure of a tubular neighbourhood of an index \(k\) critical point.
  \(H_k^m \cong \nu(x) \cong D^k \times D^{n - k} \supseteq \interior B^k\).
\end{definition}

Note that the corners in \(D^k\) and \(D^{n - k}\) are different

\section{Lecture 5: Handles from cells, Heegard diagrams}

Cell ecomplex interpretation

\begin{definition}[handle, core, cocore]\index{handle}\index{core}\index{cocore}
  An \emph{\(n\)-dimension \(k\)-handle} \(H^n_k\) or \emph{index \(k\)-handle} is a product decomposition
  \[
    H^n_k \cong D^k \times D^{n - k} \cong B^n
  \]
  of the closed \(n\)-ball into a \(k\)-dimensional \(k\)-cell \emph{core} \(D^k\) and \emph{cocore} \(D^{n - k}\).
\end{definition}

If you choose a metric, the core \(D^k\) is fat and the cocore \(D^{n - k}\) is thin.

\begin{definition}[attaching region, belt region]\index{attaching region}\index{belt region}
  The boundary \(\b H^n_k\) of an \(n\)-dimensional \(k\)-handle decomposes as
  \begin{align*}
    \b H^n_k
    &\cong \b(\text{core} \times \text{cocore}) \\
    &\cong \b(\text{core}) \times \text{cocore} \cup \text{core} \times \b(\text{cocore}) \\
    &\cong \underbrace{\b D^k \times D^{n - k}}_{\text{attaching region}} \cup \underbrace{D^k \times \p D^{n - k}}_{\text{belt region}}
  \end{align*}
\end{definition}

In a cell complex, we attach a \(k\)-cell \(D^k\) by gluing its boundary \(\b D^k \cong S^{k - 1}\) to the cell-complex we have built so far.

\[
  \text{attaching region} (H^n_k)
  \cong \overline{\nu(\p D^k)}
  \cong \overline{\nu S^{k - 1}}
  \cong \p D^k \times D^{n - k}
\]

\begin{definition}[handle attachment]\index{handle attachment}
  The attachment of a \(k\)-handle \(H^n_k\) to an \(n\)-manifold \(X\) to product an \(n\)-manifold \(X'\) is induced by a \emph{\(k\)-handle attachment} cobordism \(Z\) from \(- \b X\) to \(\b X'\).
  \[
    Z = (\b X \times I) \cup_{\text{a.r.}} H^n_r.
  \]
  We have
  \[
    \p X' \cong (\p X \setminus \text{a.r.} (H^n_k)) \cup (\text{b.r.} (H^n_k)).
  \]
\end{definition}

As \(\p X \times I\) deformation retracts to \(\p X\), we have
\[
  X' \cong X \cup Z \cong X \cup H^n_k.
\]

\begin{convention}
  We usually say that we attach a handle along the \emph{core} of the attaching region.
\end{convention}

\begin{definition}[attaching/belt sphere]
  \begin{align*}
    \text{attaching region} (H^n_k)
    &\cong \text{core}(\text{attaching region}(H^n_k)) \\
    &\cong \text{core}(\p D^k \times D^{n - k}) \\
    &\cong \p D^k
  \end{align*}
  \begin{align*}
    \text{belt region} (H^n_k)
    &\cong \text{core}(\text{belt region}(H^n_k)) \\
    &\cong \p D^{n - k}
  \end{align*}
\end{definition}

Convention reexpressed: to attach a \(k\)-handle, we specify where the \emph{attaching sphere} will be glued.

Morse interpretation, revisited

\begin{definition}[gradient]
  Choose a Riemannian metric \(g\) on a smooth \(n\)-manifold \(X\). Let \(f: X \to \R\) be a smooth function. the gradient \(\grad f \in \Gamma(TX)\) of \(f\) is the vector field satisfying
  \[
    g(\grad f, V) = df(V)
  \]
  for \(V \in \text{Vect} X = \Gamma(TX)\).
  Locally,
  \[
    g_x((\grad f)_x, V_x) = df_x(V_x).
  \]
  In local coordinates,
  \[
    \grad f = \sum g^{ik} \frac{\partial f}{\partial x^k}e_i
  \]
  where \(e_i = \frac{\partial  }{\partial x^i}\).
\end{definition}

Idea: invariant object from partials of \(f\), \(df = \sum \frac{\partial f}{\partial x^i} \w dx^i\). To get a vector field, need a bilinear form to dualise \(df\). \(\grad f\) comes from bilinear form (metric), and Hamiltonian vector field \(f\) comes from symplectic form.

Moral (Morse theorey intepretation)

Q: In what sense \(H^n_k \cong \overline{\nu(x)}\), \(x \in \text{crit} f, \text{ind}_x f = k\)?

A: Gradient flow at the boundary of \(H^n_k\): \(\grad f\) flows into attaching region \(H^n_k\), into \(x \in \text{crit} f\) in \(k\) directions. \(\grad f\) flows out of belt region \(H^n_k\), out of \(x\) in \(n - k\) directions.

For example, for
\[
  f = - \sum_{i = 1}^k x_i^2 + \sum_{j = k + 1}^n x_j^2
\]

\printindex
\end{document}

% https://www.dpmms.cam.ac.uk/~sr727/2019_3manifolds


\chapter{Markov's inequality and Chebyshev's inequality}