\section{Imputation methods and Algorithms} \label{secMethods}

Consider a dataset $\bm{Z}$ of dimensionality $n \times p$, with $n$ observations (rows) and
$p$ variables (columns).
Assume that the first $t$ $(t \leq p)$ variables of $\bm{Z}$ have missing values.
These $t$ variables are part of some substantive model of scientific interest (e.g. a linear
regression model), and are target of imputation.
The subset of $\bm{Z}$ containing variables $z_1$ to $z_t$ is referred to as the $n \times t$ matrix $\bm{T}$.
The remaining $n \times (p-t)$ subset of $\bm{Z}$ contains variables that are not target of imputation.
These variables constitute a pool of possible \emph{auxiliary} variables that could be used to improve
the imputation procedure.
Let $\bm{A}$ denote this set of auxiliary variables so that $\bm{Z} = (\bm{T}, \bm{A})$.
For a given $z_j$ variable, with $j = (1, ..., p)$, denote its observed and missing components
by $z_{j, obs}$ and $z_{j, mis}$, respectively.
Let $\bm{Z}_{-j} = (z_1, ..., z_{j-1}, z_{j+1}, ..., z_{p})$ be the collection of $p-1$ variables in
$\bm{Z}$ excluding $z_j$.
Denote $\bm{Z}_{-j, obs}$ and $\bm{Z}_{-j, mis}$ the components of $\bm{Z}_{-j}$ corresponding to the
data units in $z_{j, obs}$ and $z_{j, mis}$, respectively.

\subsection{Multiple Imputation by Chained Equations}

Assume that $\bm{Z}$ is the result of $n$ random samples from a multivariate distribution defined by
an unknown set of parameters $\bm{\theta}$.
The chained equations approach obtains the posterior distribution of $\bm{\theta}$ by sampling iteratively
from conditional distributions of the form $P(z_{1}|\bm{Z}_{-1}, \bm{\theta}_{1})$ $...$
$P(z_{t}|\bm{Z}_{-t}, \bm{\theta}_{t})$, where $\bm{\theta}_{1}$ $...$ $\bm{\theta}_{t}$ are imputation model
parameters specific to the conditional densities of each variable with missing values.

More precisely, the MICE algorithm takes the form of a Gibbs sampler where the $m$th iteration $(m = 1, ..., M)$
successively draws, for each $j$th target variable ($j = 1, ..., t$), from the following distributions:
%
	\begin{align}
	\hat{\bm{\theta}}_{j}^{(m)} &\sim
		p(\bm{\theta}_j | z_{j, obs}, \bm{Z}_{-j, obs}^{(m)})
		\label{eq_pd}\\
	z_{j, mis}^{(m)} &\sim
		p(z_{j, mis} | \bm{Z}_{j, mis}^{(m)}, \hat{\bm{\theta}}_{j}^{(m)})
		\label{eq_ppd},
	\end{align}
%
where $\hat{\bm{\theta}}_{j}^{(m)}$ and $z_{j, mis}^{(m)}$ are draws from the parameters full conditional posterior
distribution \eqref{eq_pd} and the missing data posterior predictive distribution \eqref{eq_ppd}, respectively.
After convergence, $D$ different sets of values sampled from the predictive distribution are kept as imputations
and $D$ differently imputed data sets are obtained.
Any substantive model can then be fit to each dataset, and estimates can be pooled appropriately using Rubin's rules
\citep{rubin:1987}.

Generally speaking, for each variable $z_j$ target of imputation, a researcher needs to define a set of
observed variables that will be included in $\bm{Z}_{-j}^{(m)}$.
The high-dimensional imputation methods compared in this paper and described below follow the general MICE framework,
but they differ in the elementary imputation methods they use to define equations \eqref{eq_pd} and \eqref{eq_ppd}.
Each of them has a different way of processing the large number of auxiliary variables provided to the
imputation algorithm to allow a maximal inclusive strategy while avoiding its usual obstacles.

\subsubsection{MICE with fixed ridge penalty (bridge)}
	This approach uses as elementary imputation method the Bayesian imputation under the normal linear model
	procedure as presented by \citeauthor{vanBuuren:2018} (\citeyear[p. 68, algorithm 3.1]{vanBuuren:2018}).
	In this approach, the sampling of each $\hat{\bm{\theta}}_{j}^{(m)}$ in equation \eqref{eq_pd} relies on the
	inversion of the cross-product of the observed data matrix $\bm{Z}_{j, obs}^{(m)}$.
	By adding a biasing ridge penalty $\kappa$, singularity of the cross-product matrix can be circumvented and the
	sampling scheme is possible even if $\bm{Z}_{j, obs}^{(m)}$ is afflicted by high collinearity and $n$ is not
	substantially larger than $p$.

	The value of $\kappa$ is usually chosen close to zero (e.g. $\kappa = 0.0001$), as values larger than $0.1$
	may introduce systematic bias \citep[p. 68]{vanBuuren:2018}.
	However, larger values may be necessary to invert the observed data matrix cross-product in certain scenarios.
	In the present work, the value of $\kappa$ was decided by means of a cross-validation procedure.

\subsubsection{MICE with Bayesian lasso (blasso)}
	A high-dimensional Bayesian lasso imputation algorithm was proposed by \cite{zhaoLong:2016}, but it was tested only
	in a univariate missing data context.
	The method relies on the Bayesian lasso model, a regular Bayesian multiple regression with prior specifications
	that allow to interpret the mode of the posterior distribution of the regression coefficients as lasso estimates
	\citep{parkCasella:2008, hans:2009}.
	Given data with sample size $n$, consider the dependent variable $y$ and a set of predictors $X$.
	The Bayesian Lasso linear regression specification we used within the blasso imputation algorithm is that specified
	by \cite{hans:2010}:
%
	\begin{align}
	% Likelihood equation
		p(y|\beta, \sigma^2, \tau) &= \textrm{N}(y|X\beta, \sigma^2I_n) \label{eqn:dens} \\
	% Prior for regression coefficients
		p(\beta_j|\tau, \sigma^2, \rho) &=
			(1 - \rho) \delta_0 \beta_j +
			\rho \left( \frac{\tau}{2\sigma} \right) \times
			\textrm{exp} \left( \frac{-\tau \norm{\beta}_1}{\sigma} \right) \label{eqn:bprior} \\
	% Hyperprior for error variance
		\sigma^2 &\sim \textrm{Inverse-Gamma}(a, b) \label{eqn:sigprior} \\
	% Hyperprior for penalty parameter
		\tau &\sim \textrm{Gamma}(r, s) \label{eqn:tauprior} \\
	% Hyperprior for sparsity parameter
		\rho &\sim \textrm{Beta}(g, h) \label{eqn:rhoprior}
	\end{align}
%
	The expression in equation \eqref{eqn:dens} represents the density function of a multivariate normal random variable
	with mean $X\beta$ and covariance matrix $\sigma^2I_n$, evaluated at $y$.
	The prior expressed in equation \eqref{eqn:bprior} is the expansion on the \cite{parkCasella:2008} double exponential
	prior developed by \cite{hans:2010} to accommodate for uncertainty regarding the value of the regression coefficients
	and the model sparsity.
	Finally, equations \eqref{eqn:sigprior} to \eqref{eqn:rhoprior} represent hyper priors for the residual variance
	$\sigma^2$, the penalty parameter $\tau$, and the sparsity parameter $\rho$.
	The blasso imputation algorithm used here is a standard MI MCMC sampler that replaces equation \eqref{eq_pd} with the
	full conditional posterior distributions derived by \citet{hans:2010}, based of the prior specifications in equations
	\eqref{eqn:sigprior} to \eqref{eqn:rhoprior}, and uses posterior parameters draws to sample plausible values from the
	predictive distributions of the missing data for equation \eqref{eq_ppd}.

	The R code to perform blasso imputation is based on the Bayesian Lasso R Package \emph{blasso} \citep{blasso} and can
	be found on the main author's GitHub page.
	For a detailed description of the algorithm for Bayesian Lasso Multiple Imputation in a univariate
	missing data context we recommend reading \cite{zhaoLong:2016}.

\subsubsection{Direct Use of Regularized Regression (DURR)}
	As proposed by \cite{zhaoLong:2016} and \cite{dengEtAl:2016}, Frequentist Regularized Regression can be
	directly used in a MICE algorithm to perform multiple imputation of high dimensional data.
	At iteration $m$, for a target variable $\bm{z}_j$, the DURR algorithm uses as building blocks of the
	MICE framework the following two steps:

	\begin{itemize}

	\item Generate a bootstrap sample $\bm{Z}^{*(m)}$ by sampling with replacement from $\bm{Z}$,
		and train a regularized linear regression model (such as Lasso regression) with
		$\bm{z}_{j,obs}^{*(m)}$ as outcome and $\bm{Z}_{-j,obs}^{*(m)}$ as predictors.
		This produces a set of parameter estimates (regression coefficients and error variance)
		$\hat{\bm{\theta}}_{j}^{(m)}$ that can be considered as a sample from equation \eqref{eq_pd}.

	\item Predict $\bm{z}_{j,mis}$, based on $\bm{Z}_{-j, mis}$ and $\hat{\bm{\theta}}_{j}^{(m)}$,
		to obtain draws from the posterior predictive distribution of the missing data equation
		\eqref{eq_ppd}.

	\end{itemize}

\subsubsection{Indirect Use of Regularized Regression (IURR)}
	While DURR performs simultaneously model trimming and parameter estimation in equation \eqref{eq_pd},
	another approach is to use regularized regression exclusively for model trimming, and to follow it
	with a standard multiple imputation procedure \citep{zhaoLong:2016, dengEtAl:2016}.
	At iteration $m$, the IURR algorithm performs the following steps for each target variable:
%
	\begin{itemize}
%
	\item Fit a multiple linear regression model using a regularized regression method with $\bm{z}_{j,obs}$ as
		dependent variable and $\bm{Z}_{-j,obs}^{(m)}$ as predictors (compared to DURR, the original data are
		used, not a bootstrap sample).
		In this model, the regression coefficients that are \emph{not} shrunk to 0 identify the active
		set of variables that will be used as predictors in the actual imputation model.

	\item Obtain Maximum Likelihood Estimates of the regression parameters and error variance in the linear
		regression of $\bm{z}_{j,obs}$ on the active set of predictors in $\bm{Z}_{-j,obs}^{(m)}$ and
		draw a new value of these coefficients by sampling from a multivariate normal distribution
		centered around these MLEs\footnote{The sampling notation is the same used by \cite{dengEtAl:2016}.}:
%
		\begin{equation}\label{eq_MLEpd}
		(\hat{\bm{\theta}}_{j}^{(m)}, \hat{\sigma}_{j}^{(m)}) \sim N(\hat{\bm{\theta}}_{MLE}^{(m)},
			\hat{\bm{\Sigma}}_{MLE}^{(m)})
		\end{equation}
%
		so that equation \eqref{eq_MLEpd} corresponds to equation \eqref{eq_pd} in the general MICE framework.

	\item Impute $\bm{z}_{j,mis}$ by sampling from the posterior predictive distribution based
		on $\bm{Z}_{j,mis}^{(m)}$ and the parameters posterior draws $(\hat{\bm{\theta}}_{j}^{(m)},
		\hat{\sigma}_{j}^{(m)})$.
%
	\end{itemize}

\subsubsection{MICE with PCA (MI-PCA)}
	By extracting Principal Components (PCs) from the auxiliary variables, it is possible to summarise the information
	contained in this set with just a few components.
	A few PCs can then be used as predictors in a standard MICE algorithm in a low dimensional setting.
	The Multiple Imputation with Principal Component Analysis (MI-PCA) imputation procedure can be summarized as follows:

	\begin{itemize}

	\item Extract the first principal components that cumulative explain at most 50\% of the variance
		in the auxiliary variables $\bm{A}$, and collect them in a new data matrix $\bm{A}'$;
	\item Replace the set of auxiliary variables $\bm{A}$ in $\bm{Z}$ with $\bm{A}'$ to obtain
		$\bm{Z}' = (\bm{T}, \bm{A}')$;
	\item Use the standard MICE algorithm with the Bayesian imputation under the normal linear model
		\citep[p. 68, algorithm 3.1]{vanBuuren:2018} as elementary imputation method to obtain multiply
		imputed datasets from the low dimensional $\bm{Z}'$.
	\end{itemize}

	Note that if missing values are present in the set of auxiliary variables, one can fill them in with a
	stochastic single imputation (SI) algorithm of choice.
	MI is preferred to SI because it accounts for the uncertainty regarding the missing values when producing
	standard errors.
	As the extraction of PCs does not require the estimation of standard errors, SI suffices.
	This method is inspired by \cite{howardEtAl:2015} and the \emph{PcAux} R-package \citep{PcAux} that
	implements and developed its ideas.

\subsubsection{MICE with decision trees (MI-CART and MI-RANF)}
	The MI-CART imputation method \citep{burgetteReiter:2010} is a MICE algorithm that uses classification and regression
	trees (CART) to define the conditional distributions used in the MI Gibbs sampler.
	Given an outcome variable $y$ and a set of predictors $X$, CART is a nonparametric recursive partitioning technique
	that models the relationship between $y$ and $X$ by sequentially splitting observations in subsets of units with
	relatively homogeneous $y$ values.
	At every splitting stage, a CART algorithm searches through all predictor variables in $X$ to find the best binary
	partitioning rule to predict $y$.
	The resulting collection of binary splits can be visually represented by a decision tree structure where each terminal
	node (or \emph{leaf}) represents the conditional distribution of $y$ for units that satisfy the splitting rules.

	In MI-CART, at the $m$-th iteration for a target variable $z_j$, a CART model is trained to predict $z_{j, obs}$ based on
	$\bm{Z}_{-j, obs}^{(m)}$.
	Every observation with a missing value on $z_j$ belongs to a terminal node of this CART model, depending on their values of
	$\bm{Z}_{-j, mis}^{(m)}$.
	Sampling from the $z_{j, obs}$ in a terminal node corresponds to sampling from the missing data posterior predictive
	distribution.
	The implementation of MI-CART used in this paper corresponds to the one presented by \cite{dooveEtAl:2014}
	(p. 95, algorithm 1) and the \emph{impute.mice.cart()} R function from the \emph{mice} package.

	In MI-RANF, at the $m$-th iteration for a target variable $z_j$, $k$ bootstrap samples are drawn from the complete
	dataset and $k$ single trees are fitted.
	In each bootstrap sample, only a small random group of input variables is used to find the best split at each node.
	All $k$ trees are used to compose the pool of candidates from which imputations are drawn.
	Bootstrapping and random input selection introduce the model and imputation uncertainty in the imputation procedure,
	as required by a proper MI procedure.
	For greater details on the algorithms, the reader may consult \cite{dooveEtAl:2014} (algorithm A.1, p. 103).
	The programming of the algorithm was heavily inspired by the \emph{impute.mice.rf()} function in the
	R package \emph{mice}.

\subsubsection{MICE optimal model (MI-OP)}
	When dealing with a large set of possible predictors for the imputation models, a common recommendation in the MI
	literature is to decide which predictors to include by following three criteria \citep[p. 168]{vanBuuren:2018}:
	\begin{enumerate}

	\item include all the variables that are part of the analysis models;
	\item include all the variables that are related to the non-response;
	\item include all the variables are correlated with the variables target of imputation.

	\end{enumerate}

	In practice, researchers can never be sure that the second requirement is entirely met, as there is no way to know exactly
	which variables are responsible for missingness.
	However, if we knew which predictors were essential for the imputation models, we could use this information to specify
	optimal imputation models.
	With simulated data, we have perfect knowledge over which variables are involved in the missing data mechanisms.
	MI-OP is an ideal specification of the MICE algorithm that uses as elementary imputation strategy a low dimensional
	univariate Bayesian imputation under the normal linear model and uses this knowledge to include only the relevant
	predictors in the imputation models.

\subsection{Single data strategies}

\subsubsection{missForest}
	Most research on high-dimensional data imputation has focused on applications for DNA
	genetics data where the goal is to allow the use of large datasets for high-dimensional
	predictive algorithms, rather than inferential analysis.
	For this reason, a variety of single imputation machine learning algorithms have been proposed
	and compared \citep{deAndradeSilvaHruschka:2009, stekhovenBuhlmann:2011}.

	In this study, we consider the missForest imputation method proposed by \cite{stekhovenBuhlmann:2011},
	which is a popular non-parametric imputation approach that can accommodate for large numbers of predictors,
	can handle mixed data type of the missing variables, and has been robustly implemented in a popular
	R-package \citep{missForest}.
	The approach consists of an iterative imputation that first trains a random forest on observed values, and then
	uses it to impute the missing values by averaging the predictions from its different trees.
	As a single imputation method we do not expect it to perform well for inferential tasks, at least compared to
	the other high dimensional MI methods discussed here.

\subsubsection{Complete Case Analysis (CC)}
	By default, most data analysis software either ignore the presence of missing values or default to list wise
	deletion: only complete cases are used for the analysis \citep{R:2020, pandas:2020}.
	As a default behaviour of most analysis tools, Complete Cases Analysis remains a popular missing data treatments
	in the social sciences, despite its known flaws (\citeauthor{rubin:1987}, \citeyear{rubin:1987}, p. 8;
	\citeauthor{vanBuuren:2018}, \citeyear{vanBuuren:2018}, p. 9, \citeauthor{baraldiEnders:2010},
	\citeyear{baraldiEnders:2010}).
	Therefore, this method was included as a reference point.

\paragraph{Gold Standard}
	Finally, in simulation and resampling studies, the analysis models can be fitted to the fully observed data.
	Results obtained in this fashion are referred to here and in the results tables as the Gold Standard method.
	They represent the counterfactual analysis that would have been performed if there had been no missing data.


\subsection*{Integral Curves }

If smooth curve $ \begin{aligned} & \quad \\
 c:  & I \to M \\
 c(t) & = p \end{aligned}$ \\
$\forall \, t \in I ,  \, c' \equiv c'(t) \in T_{c(t)}M \equiv T_p M$ \\

If $X$ vector field on $M$, \\
integral curve of $X$ is differentiable $c: I  \to M$ s.t. \\
\quad $\forall \, t \in I$, $c'(t) \equiv \dot{c} = X_{c(t)} = X_p$  \\

EY  \\
\[
\begin{aligned}
  & c:I \to M \\
  & c(t) = p  \\
  & \varphi c(t) = \varphi(p) \Longrightarrow \begin{aligned} & c^i(t) = x^i(t) \\
    & \dot{c}^i(t) = \dot{x}^i(t) \end{aligned} \\
  X_p = X^i(p) \frac{ \partial }{ \partial x^i } \equiv X^i \frac{ \partial }{ \partial x^i } = \dot{c}^i \frac{ \partial }{ \partial x^i }
\end{aligned}
\]

\[
\begin{gathered}
  f: M \to \mathbb{R} \\
  X_p f = X_p f(p) = X_pf \varphi^{-1} \varphi(p) = X_(f\varphi^{-1})(x^j) = X^i \frac{ \partial f}{ \partial x^i }(x^j) \equiv X^i(p)  \frac{ \partial f}{ \partial x^i}(x^j) = \dot{c}^i \left. \frac{ \partial f}{ \partial x^i} \right|_p = \frac{d}{dt}( f \circ c)(t)
\end{gathered}
\]

Example 9.1.  (Integral Curves)

\begin{enumerate}
\item[(a)] Let $X = \frac{ \partial }{ \partial x}$, $(x,y) \in \mathbb{R}^2$

\[
\begin{gathered}
  c(t) = (x(t), y(t)) = x \partial_x + y\partial_y \\
  c' = \dot{x} \partial_x + \dot{y} \partial_y = \partial_y   \Longrightarrow \dot{y} = 0 \quad \, y = b \\
  \dot{x} = 1 \quad \quad \, x = a+t \\
  c = (a+t ,b)
\end{gathered}
\]

\item[(b)] $X = x\partial_x - y \partial_x$.  Comparing the components of these vectors, we see that this is equivalent to

\[
\begin{gathered}
  \begin{aligned}
    \dot{x} & = -y \\
    \dot{y}  & = x \end{aligned} \Longrightarrow \begin{aligned}
    y & = a \sin{t} + b\cos{t} \\
    x & = a\cos{t} - b\sin{t} \end{aligned}
\end{gathered}
\]

\end{enumerate}

\begin{proposition}[9.2] Let smooth vector field $X$ on smooth $M$, \\
$\forall \, p \in M$, $\exists \, \epsilon > 0 $, $\exists \, $ smooth $c:(-\epsilon, \epsilon) \to M$ i.e. integral curve of $X$ starting at $p$ \end{proposition}

\begin{proof}
  existence from Thm. D.1
\end{proof}

\begin{lemma}[9.3] (Rescaling Lemma)
$\widetilde{ c}(t) = c(at)$ integral curve of $aX$, where $\widetilde{I} = \lbrace t | at \in I \rbrace$
\end{lemma}
\begin{proof} Let smooth $f$ defined in neighborhood of $\widetilde{c}(t_0)$ \\
e.g. of rescaling  - $2t = 2\cdot 1 = 2 \quad \, a=2$

\[
\begin{gathered}
  \widetilde{c}(t) = c(at) = c(\tau) = p \in M \\
  \dot{ \widetilde{c}}(t) f = \frac{d}{dt} (f\circ \widetilde{c})(t) = \frac{d}{dt} (f\varphi^{-1})( \varphi\widetilde{c}(t)) = \frac{d}{dt} (f\varphi^{-1})(\varphi c(at) ) = \frac{d}{dt} (f\varphi^{-1})(c^i(at)) = \left. \frac{ \partial f}{ \partial x^i} \right|_p \frac{dc^i}{ d\tau}(\tau)a = a \frac{d}{d \tau}(f\circ c)(\tau) = aX_p f
\end{gathered}
\]

\end{proof}

\begin{lemma}[9.4] (Translation Lemma)
\[
\begin{aligned}
  & \widetilde{I} = \lbrace t | t + a \in I \rbrace \\
  & \widetilde{c}(t) = c(t+a)
\end{aligned}
\]

\end{lemma}

\exercisehead{9.5}
\begin{proof}
\[
\begin{aligned}
&  \widetilde{c}(t) = c(t+a) = c(\tau) = p \in M \\
&  \dot{ \widetilde{c}}(t) f = \frac{d}{dt} (f\circ \widetilde{c})(t) = \frac{d}{dt} f(\widetilde{c}(t)) = \frac{d}{dt} f(c(t+a) ) = \left. \frac{ \partial f}{ \partial x^i } \right|_p \frac{d c^i(\tau) }{ d\tau } = \dot{c}^i(\tau)  \left. \frac{ \partial f}{ \partial x^i } \right|_p = X^i_p \left. \frac{ \partial f}{ \partial x^i} \right|_p = X_p f
\end{aligned}
\]
\end{proof}

\begin{proposition}[9.6] (Naturality of Integral curves)
  Suppose smooth $F: M \to N$ \\
  \quad Then $\begin{aligned} & \quad \\
    & X \in \mathfrak{X}(M) \\
    & Y \in \mathfrak{X}(N) \end{aligned}$ \quad \, $F$-related iff $F$ takes integral curves of $X$ to integral curves of $Y$
\end{proposition}

\begin{proof}
Recall
\[
X,Y \, F-\text{related means } \, dF(X) =Y
\]

Let $\gamma = Fc$
\[
\dot{\gamma} = \frac{d}{dt} (F\circ c)(t) = (dF)(\dot{c}) = dF(X) = Y
\]

$\Longrightarrow \gamma $ integral curve of $Y$ \\

if $\gamma = Fc$ integral curve of $Y$, $\dot{\gamma} = Y$.  \quad $q = F(p)$.  $p=c(t)$

\[
\begin{gathered}
  Yg= Y_qg = Y^j \left. \frac{ \partial g}{ \partial y^j } \right|_q = \dot{\gamma}^j(t) \left. \frac{ \partial g}{ \partial y^j } \right|_{F(p)} = \frac{d}{dt} (F\circ c ) \left. \frac{ \partial g}{ \partial y^j } \right|_{F(p)} = \frac{ \partial y^j}{ \partial x^k } \dot{c}^k(t) \left. \frac{ \partial g}{ \partial y^j } \right|_q = \frac{ \partial y^j}{ \partial x^k} X^k_p \left. \frac{ \partial g}{ \partial y^j } \right|_q = (F_* X)g = dF(X)g \\
\Longrightarrow dF(X) = Y
\end{gathered}
\]
\end{proof}

\subsection*{Flows }

Let $X \in \mathfrak{X}(M)$ \\
Suppose $\forall \, p \in M$, $\exists \, !$ \, integral curve starting at $p$, $\phi^{(p)}: \mathbb{R} \to M$ \\
$\forall \, t \in \mathbb{R}$, define $\begin{aligned} & \quad \\
  & \phi_t: M \to M \\
  & \phi_t(p) = \phi^{(p)}(t) \end{aligned}$

\[
\theta_0(p) = \theta^{(p)}(0) = p
\]

EY: $\phi_t$ pushes $p$ to $\phi^{(p)}(t)$ over time interval $t$ \\

translation lemma implies $t\mapsto \phi^{(p)}(t+s)$ is integral curve of $X$ starting at $q = \phi^{(p)}(s)$  \\

assuming uniqueness of integral curves, $\phi^{(p)}(t) = \phi^{(p)}(t+s)$, so

\[
\begin{gathered}
  \phi_t \circ \phi_s(p) = \phi_{t+s}(p) \\
  \phi_0(p) = \phi^{(p)}(0) = p
\end{gathered}
\]

$\Longrightarrow \phi : \mathbb{R}\times M \to M$ is an action of additive group $\mathbb{R}$ on $M$.  \\

define \emph{ global flow } on $M$ (1-parameter group action) - cont. left $\mathbb{R}$-action on $M$, i.e. \\
\quad cont. $\phi : \mathbb{R} \times M \to M$ s.t. $\forall \, s,t \in \mathbb{R}$, $\forall \, p M$

\begin{equation}
\begin{aligned}
& \phi(t, \phi(s,p) ) = \phi(t+s, p )
& \phi(0,p) = p
\end{aligned} \quad \quad \quad \, (9.2)
\end{equation}

given global flow $\phi$ \\

$\forall \, t \in \mathbb{R}$, define cont. $\begin{aligned} & \quad \\
  & \phi_t: M \to M \\
  & \phi_t(p) \to \phi(t,p)
\end{aligned}$
\[
\xrightarrow{ (9.2) } \begin{gathered}
  \phi_t \cdot \phi_s = \phi_{t+s} \\
  \phi_0 = 1_M
\end{gathered}
\]

$\phi_t : M \to M$ homeomorphism; if flow smooth, $\phi_t$ diffeomorphism.   \\

$\forall \, p \in M$, define $ \begin{aligned} & \quad \\ & \phi^{(p)}:\mathbb{R} \to M \\ & \phi^{(p)}(t) = \phi(t,p) \end{aligned}$ \\

$\phi^{(p)}$ is orbit of $p$ under group action.

smooth global flow $\theta:\mathbb{R} \times M \to M$ \\
\quad $\forall \, p \in M$, define $V_p \in T_pM$
\[
V_p = (\theta^{(p)})'(0)
\]

\begin{proposition}[9.7] Let smooth global flow $\phi: \mathbb{R}\times M \to M$ on smooth $M$ \\
infinitesimal generator $X$ of $\phi$ \quad $\begin{aligned} & \quad \\
  & p \mapsto X_p \\
  & X_p  = \dot{\phi}^{(p)}(0) \end{aligned}$ \quad is smooth vector field on $M$, and $\forall \, \phi^{(p)}$, $\phi^{(p)}$ integral curve of $X$
\end{proposition}

\begin{proof}
  Show $X$ smooth.  Use Prop. 8.14,  \\
$f$ smooth on open $U\subseteq M$, $f:U\to \mathbb{R}$

\[
Xf(p) = X_pf = \dot{\phi}^{(p)}(0) f \equiv ( \dot{\phi}^{(p)}(0) )[f] = \left. \frac{d}{dt} ( f\circ \phi^{(p)} ) \right|_{t=0} = \frac{ \partial }{ \partial t} \left. (f\circ \phi(t,p) ) \right|_{t=0}
\]

$f\circ \phi(t,p) = f(\phi(t,p))$ smooth function of $(t,p)$ by composition, so $\partial_t(f\circ \phi)$ smooth. So $Xf$ smooth, so $X$ smooth.   \\

Let $q = \phi^{(p)}(a) = \phi_a(p)$

\begin{equation}
  \phi^{(q)}(t) = \phi_t(q) = \phi_t( \phi_a(p)) = \phi_{t+a}(p) = \phi^{(p)}(t+a) \quad \quad \quad \, (9.4)
\end{equation}

\begin{equation}
  X_qf = \dot{\phi}^{(q)}(0)f = \dot{\phi}^{(q)}(0)[f] = \frac{d}{dt} \left. (f \circ \phi^{(q)}(t)) \right|_{t=0} = \frac{d}{dt} \left. (f\circ \phi^{(p)}(t+a) ) \right|_{t=0} = \dot{\phi}^{(p)}(a) f = X_{ \phi^{(p)}(a) } f \quad \quad \quad \, (9.5)
\end{equation}

\end{proof}

So by def., $\phi^{(p)}(t)$ integral curve of $X$

\subsubsection*{ The Fundamental Theorem on Flows }

flow domain for $M$ is open $\mathcal{D} \subseteq \mathbb{R} \times M$ s.t. $\forall \, p \in M$, $\mathcal{D}^{(p)} = \lbrace t \in \mathbb{R} | (t,p) \in \mathcal{D} \rbrace$ is an open interval containing $0$.  \\

\textbf{flow} on $M$ is cont. $\phi : \mathcal{D} \to M$ s.t. group laws :
\begin{equation}
  \forall \, p \in M, \, \phi(0, p ) = p \quad \quad \quad \, (9.6)
\end{equation}

\begin{equation}
  \begin{aligned} & \quad \\
    & \forall \, s \in \mathcal{D}^{(p)} \\
    & \forall \, t \in \mathcal{D}^{ (\phi(s,p))} \end{aligned} \quad \text{ s.t. } s + t \in \mathcal{D}^{(p)}, \quad \quad \, \phi(t, \phi(s,p) ) = \phi(t+s, p ) \quad \quad \quad \, (9.7)
\end{equation}

\begin{proposition}[9.11] If $\phi: \mathcal{D} \to M$ smooth flow, \\
then infinitesimal generator $X$ of $\phi$ smooth vector field and $\forall \, \phi^{(p)}$ integral curve of $X$
\end{proposition}

\begin{proof}
Recall that  \\
\emph{infinitesimal generator} $X$ of $\phi$, $\begin{aligned} & \quad \\
  & p \mapsto X_p \\
  & X_p = \dot{\phi}(0) \end{aligned}$ \quad now on open $\mathcal{D}$, $\mathcal{D} \subseteq \mathbb{R} \times M$ s.t. $\forall \, p \in M$, $\mathcal{D}^{(p)} = \lbrace t \in \mathbb{R} | (t,p) \in \mathcal{D} \rbrace$ open, \\

given $\phi$ smooth flow, \\
\quad $\phi(t,q)$ defined and smooth $\forall \, (t,q)$ sufficiently close to $(0,p)$ since $\mathcal{D}$ open.  With $f$ smooth on open $U$ in this open neighborhood of $(0,p)$,

\[
\Longrightarrow Xf(p) = \left. \frac{ \partial }{ \partial t } (f \circ \phi(t,p)) \right|_{t=0}
\]

$f\phi$ smooth (by composition), so $\partial_t f\phi$ smooth, so $X$ smooth itself around $\forall \, p \in M$.   \\

Suppose $t\in \mathcal{D}^{(p)}$ \\
$\mathcal{D}^{(p)}$, $\mathcal{D}^{ (\phi_t(p))} = \mathcal{D}^{(q)}$ open (by def.)

$\phi_{\Delta t}\phi_t(p) = \phi_{ \Delta t + t }(p)$ by def. of flow.

\end{proof}

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=2em, column sep=4.8em, minimum width=2em]
  {
\mathfrak{X}(M) &  \\
M &  \\
\mathcal{D} &       M \\
\mathcal{D}^{(p)} & \\
};
  \path[->]
  (m-2-1) edge node [above] {$$} (m-1-1)
  edge node [above] {$\phi_t$} (m-3-2)
  (m-3-1) edge node [auto] {$$} (m-2-1)
  edge node [below left] {$\phi$} (m-3-2)
  edge node [auto] {$$} (m-4-1)
  (m-4-1) edge node [below] {$\phi^{(p)}$} (m-3-2)
  (m-3-2) edge node [right] {$\left. \frac{ \partial }{ \partial t} \right|_{t=0} = \left. \frac{d}{dt} \right|_{t=0}$} (m-1-1)
;
\end{tikzpicture} \quad \quad \quad \, \begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=2em, column sep=4.8em, minimum width=2em]
  {
X_p &  \\
p &  \\
(t,p)       &       \phi(t,p) = \phi^{(p)}(t) = \phi_t(p) \\
t & \\
};
  \path[|->]
  (m-2-1) edge node [above] {$$} (m-1-1)
  edge node [above] {$\phi_t$} (m-3-2)
  (m-3-1) edge node [auto] {$$} (m-2-1)
  edge node [below left] {$\phi$} (m-3-2)
  edge node [auto] {$$} (m-4-1)
  (m-4-1) edge node [below] {$\phi^{(p)}$} (m-3-2)
  (m-3-2) edge node [right] {$\left. \frac{ \partial }{ \partial t} \right|_{t=0} = \left. \frac{d}{dt} \right|_{t=0}$} (m-1-1)
;
\end{tikzpicture}

\begin{theorem}[9.12] (Fundamental Theorem on Flows)
  Let smooth vector field $X$ on smooth manifold $M$.  \\
$\exists \, ! \, \, $ smooth maximal flow $\phi : \mathcal{D} \to M$ whose infinitesimal generator is $X$ (recall $\begin{aligned} & \quad \\
    & p \mapsto X_p \\
    & X_p = \dot{\phi}{(0)} \end{aligned}$) s.t.
\begin{enumerate}
\item[(a)] $\forall \, p \in M$, curve $\phi^{(p)} : \mathcal{D}^{(p)} \to M$ is unique maximal integral curve of $X$ starting at $p$.
\item[(b)] If $s\in \mathcal{D}^{(p)}$, then $\mathcal{D}^{(\phi(s,p))}$ is interval $\mathcal{D}^{(p)}-s = \lbrace t - s | t\in \mathcal{D}^{(p)} \rbrace$
\item[(c)] $\forall \, t \in \mathbb{R}$, $M_t$ open in $M$, and $\phi_t:M_t \to M_{-t}$ diffeomorphism with inverse $\phi_{-t}$
\end{enumerate}
\end{theorem}

\begin{proof}
From Proposition 9.2 ($\forall \, p \in M$, $\exists \, \epsilon > 0$, \, $\exists \, $ smooth $c:(-\epsilon, \epsilon) \to M$, i.e. integral curve $X$ starting at $p$) \\

Suppose $c,\widetilde{c} : I \to M$ \, 2 integral curves of $X$, open $I$ s.t. $c(t_0) = \widetilde{c}(t_0)$ for some $t_0 \in I$ \\
Let $S = \lbrace t | t \in I, \text{ s.t. } c(t) = \widetilde{c}(t) \rbrace$ \\
Clearly $S \neq \emptyset$ since $c(t_0) = \widetilde{c}(t_0)$ \quad (hypothesis) \\
\quad $S$ closed in $I$ by continuity (of $c, \widetilde{c}$) \\
Suppose $t_1 \in S$ \\
\quad $c(t_1) = \widetilde{c}(t_1)=p$
Then in smooth coordinate neighborhood around $p=c(t_1)$, \, $c, \widetilde{c}$ both solutions to same ODE with same initial conditions $c(t_1) = \widetilde{c}(t_1) = p$ \\

By uniqueness part of Thm. D.1, $c\equiv \widetilde{c}$ on interval containing $t_1$ \\
\quad $\Longrightarrow S $ \, open in $I$. \\
Since $I$ connected, $S=I$ \quad ($S$ clopen) \\
$c= \widetilde{c} \quad \, \forall \, t \in I$ \\
Thus, $\forall \, c , \widetilde{c}$ \, that agrees at 1 pt. agree on common domain.   \\

$\forall \, p \in M$, let $\mathcal{D}^{(p)} = \bigcup_{\alpha} I_{\alpha}$, open $I_{\alpha} \subseteq \mathbb{R}$
\quad s.t. $0 \in I_{\alpha}$, and integral curve $\begin{aligned} & \quad \\
  & c_{\alpha} : I_{\alpha} \to M \\
  & c_{\alpha}(0) = p \end{aligned}$ \, starting at $p$ is defined.  \\

define $\begin{aligned} & \quad \\
  & \phi^{(p)}: \mathcal{D}^{(p)} \to M  \\
  & \phi^{(p)}(t) = c(t) \end{aligned}$ \, where $c$ is any integral curve s.t. $c(0) = p$ and $c$ defined on $I_{\alpha}$ s.t. $0,t \in I_{\alpha}$. \\

since all integral curves agree at $t$ by argument above, $\phi^{(p)}$ well-defined \\
\quad \quad and is obviously unique maximal integral curve starting at $p$.   \\

Let $\mathcal{D} = \lbrace (t,p) \in \mathbb{R} \times M | t \in \mathcal{D}^{(p)} \rbrace$ \\
define $\begin{aligned} & \quad \\
  & \phi :\mathcal{D} \to M \\
  & \phi{(t,p)} = \phi^{(p)}{(t)} \equiv \phi_t{(p)} \end{aligned}$ (notation for last statement)  \\

By def. $\phi$ satisfies (a): $\forall \, p \in M$, $\exists \, ! \, $ maximal integral curve of $X$, $\phi^{(p)}$, starting at $p$.  \\

Fix $p\in M$, $s \in \mathcal{D}^{(p)}$ \\
write $q = \phi{ (s,p) } = \phi^{(p)}(s)$ \\

define $\begin{aligned} & \quad \\
  & \widetilde{c}: \mathcal{D}^{(p)} -s \to M \\
  & \widetilde{c}(t) = \phi^{(p)}(t+s) \, \text{ s.t. } \, \widetilde{c}{(0)} = \phi^{(p)}(s) = q \end{aligned}$ \\

By translation lemma (9.4), $\begin{aligned} & \quad \\
  & \widetilde{c}{(t)} = c{(t+s)} \\
  & \widetilde{I} = \lbrace t | t+s \in I \rbrace \end{aligned}$ \quad \, e.g. $\begin{aligned} & \quad \\
  & I = (-2,6) , \, \, s = 1 \\
  & \widetilde{I} = (-3,5) \end{aligned}$ \quad \, $\widetilde{c}(t)$ also integral curve of $X$.

By uniqueness of ODE solutions, \\
\quad $\widetilde{c}$ agrees with $\phi^{(q)}$ on their common domain, \\
\quad \quad equivalent to second group law (9.7)
\[
\widetilde{c}{(t)} = \phi^{(p)}{ (t+s)} = \phi{(t+s,p)} = \phi^{(q)}{(t)} = \phi{(t,q)} = \phi{(t,\phi{(s,p) }) }
\]

\end{proof}

\begin{lemma}[9.19] \textbf{(Escape Lemma)}
Suppose smooth $M$, $V\in \mathfrak{X}(M)$.  \\
If $\gamma: J \to M$ maximal integral curve of $V$ s.t. domain $J$ has finite least upper bound $b$, \\
\phantom{ \quad \, } then $\forall \, t_0 \in J$, $\gamma([t_0,b))$ not contained in any compact subset of $M$
\end{lemma}

\begin{proof}
See Problem 9-6.  Solution there.
\end{proof}

\subsection*{Flowouts}

Suppose smooth $M$, $S\subseteq M$ embedded $k$-dim. submanifold. \\
smooth $V \in \mathfrak{X}(M)$ s.t. $V$ nowhere tangent to $S$.  \\
Let $\theta:\mathcal{D} \to M$ be flow of $V$  \\
Let $\mathcal{O} = (\mathbb{R}\times S) \bigcap \mathcal{D}$ \\
\phantom{Let } $\Phi= \left. \theta \right|_{\mathcal{O}}$
\begin{enumerate}
\item[(a)] $\Phi : \mathcal{O} \to M$ immersion
\item[(b)] $\frac{ \partial }{ \partial t} \in \mathfrak{X}(\mathcal{O})$ is $\Phi$-related to $V$
\item[(c)] $\exists \, $ smooth $\delta >0$, $\delta : S \to \mathbb{R}$ s.t. \\
$\left. \Phi \right|_{\mathcal{O}_{\delta}}$ injective, where $\mathcal{O}_{\delta} \subseteq \mathcal{O}$ flow domain.
\begin{equation}
  \mathcal{O}_{\delta} = \lbrace (t,p) \in \mathcal{O} | |t| < \delta(p) \rbrace \quad \quad \quad \, (9.9)
\end{equation}
Thus $\Phi(\mathcal{O}_{\delta})$ immersed submanifold of $M$ containing $S$. $V$ tangent to $\Phi(\mathcal{O}_{\delta})$
\item[(d)] If $S$ codim. $1$, $\left. \Phi \right|_{\mathcal{O}_{\delta}}$ diffeomorphism onto open submanifold of $M$
\end{enumerate}

\subsection*{Flows and Flowouts on Manifolds with Boundary }

\subsection*{Lie Derivatives }

\begin{equation}
  D_vW(p) = \left. \frac{d}{dt} \right|_{t=0} W_{p+tv} = \lim_{t\to 0} \frac{ W_{p+tv} - W_p }{t} \quad \quad \quad \, (9.15)
\end{equation}

\[
D_vW(p) = D_vW^i(p) \left. \frac{ \partial }{ \partial x^i } \right|_p
\]

\textbf{Lie derivative of $W$ with respect to $V$ }

\begin{equation}
  (\mathcal{L}_VW)_p = \left. \frac{d}{dt} \right|_{t=0} d(\theta_{-t})_{\theta_t(p)}(W_{\theta_t(p)}) = \lim_{t \to 0} \frac{ d(\theta_{-t})_{\theta_t(p)}(W_{\theta_t(p)}) - W_p }{ t } \quad \quad \quad \, (9.16)
\end{equation}

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=2em, column sep=6.8em, minimum width=2em]
  {
\mathfrak{X}(M) & \mathfrak{X}(M)  \\
\mathfrak{X}(M) &   \\
M    &       M \\
};
  \path[->]
  (m-3-1) edge node [above] {$$} (m-2-1)
  edge node [above] {$\phi_t$} (m-3-2)
  (m-3-2) edge node [auto] {$$} (m-1-2)
  edge [bend left] node [auto] {$\phi_{-t}$} (m-3-1)
  (m-1-2) edge node [above] {$d(\phi_{-t})=(\phi_{-t})_*$} (m-1-1)
;
\end{tikzpicture} \quad \quad \quad \, \begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=2em, column sep=6.8em, minimum width=2em]
  {
d(\phi_{-t})_{\phi_t(p)}(W_{\phi_t(p)}) & W_{\phi_t(p)}  \\
W_p   &    \\
p    &       \phi_t(p) \\
};
  \path[|->]
  (m-3-1) edge node [above] {$$} (m-2-1)
  edge node [above] {$\phi_t$} (m-3-2)
  (m-3-2) edge node [auto] {$$} (m-1-2)
  edge [bend left] node [auto] {$\phi_{-t}$} (m-3-1)
  (m-1-2) edge node [above] {$d(\phi_{-t})=(\phi_{-t})_*$} (m-1-1)
;
\end{tikzpicture}

\begin{lemma}[9.36]
  Suppose smooth $M$ with or without $\partial$, \, $V, W \in \mathfrak{X}(M)$ \\
If $\partial M \neq \emptyset$, assume $v$ trangent to $\partial M$ \\
Then $\exists \, $ smooth $(\mathcal{L}_VW)_p$ \, $\forall \, p \in M$
\end{lemma}

\begin{proof}
  $\forall \, (t,x ) \in J_0 \times U_0$, \\
  matrix $d(\theta_{-t})_{\theta_t(x)}: T_{\theta_t(x)}M \to T_xM$
\[
\left( \frac{ \partial \theta^i}{ \partial x^j}(-t, \theta(t,x)) \right)
\]

Therefore,
\[
d(\theta_{-t})_{\theta_t(x)}(W_{\theta_t(x)}) = \frac{ \partial \theta^i}{ \partial x^j}(-t,\theta(t,x)) W^j(\theta(t,x)) \left. \frac{ \partial }{ \partial x^i} \right|_x
\]

\end{proof}

\exercisehead{9.37}

Given $V = v^i \frac{ \partial }{ \partial x^i}$ with constant coefficients (i.e. $v^i$ constant)

\[
\begin{aligned}
  & \dot{\theta}^{(x)}(t) = V \\
  & \dot{\theta}^i(t) = v^i  \\
  & \theta^i(t)= v^it + x^i
\end{aligned} \quad \quad \Longrightarrow \quad
\frac{ \partial \theta^i}{ \partial x^j} = \delta^i_{ \, \, j}
\]

\[
\begin{gathered}
\frac{d}{dt} W^i(\theta(t,x))  = \frac{ \partial W^i}{ \partial y^j}(v^j)
\end{gathered}
\]

From the proof of Lemma 9.36,
\[
\begin{gathered}
  d(\theta_{-t})_{\theta_t(x)}(W_{\theta_t(x)}) = \frac{ \partial \theta^i}{ \partial x^j}(-t,\theta(t,x)) W^j(\theta(t,x)) \left. \frac{ \partial }{ \partial x^i} \right|_x = \\
 = \delta^i_{ \, \, j} W^j(\theta(t,x)) \left. \frac{ \partial }{ \partial x^i} \right|_x  = W^i(\theta(t,x)) \left. \frac{ \partial }{ \partial x^i} \right|_x
\end{gathered}
\]
From (9.16)
\[
\begin{gathered}
  (\mathcal{L}_VW)_p = \left. \frac{d}{dt} \right|_{t=0} d(\theta_{-t})_{\theta_t(p)}(W_{ \theta_t(p) } ) = v^j \frac{ \partial W^i}{ \partial x^j} \left. \frac{ \partial }{ \partial x^i} \right|_p = D_VW^i(p) \left. \frac{ \partial }{ \partial x^i} \right|_p = D_VW(p)
\end{gathered}
\]

\hrulefill

\begin{theorem}[9.38] If smooth $M$, and $V,W \in \mathfrak{X}(M)$,
\[
\mathcal{L}_VW = [V,W]
\]
\end{theorem}

\begin{corollary}[9.39]
  \begin{enumerate}
    \item[(a)]
    \item[(b)]
    \item[(c)]
    \item[(d)]
    \item[(e)]
\end{enumerate}
\end{corollary}

\exercisehead{9.40}

  \begin{enumerate}
    \item[(a)] \[
\mathcal{L}_VW = [V,W] = -[W,V] = \mathcal{L}_WV
\]
    \item[(b)]
    \item[(c)]
    \item[(d)]
    \item[(e)]
\end{enumerate}

\hrulefill

Prop. 9.41 is about derivative of $d(\theta_{-t})_{\theta_t(p)}(W_{\theta_t(p)})$ at other times

\begin{proposition}[9.41] Suppose smooth $M$ with or without $\partial$ and $V, W \in \mathfrak{X}(M)$ \\
If $\partial M \neq \emptyset$, assume $V$ tangent to $\partial M$ \\
Let $\theta$ flow of $V$.  \\

$\forall \, (t_0,p)$ in domain of $\theta$

\[
\left. \frac{d}{dt} \right|_{t=t_0} d(\theta_{-t})_{\theta_t(p)}(W_{\theta_t(p)})  = d(\theta_{-t_0}) ( (\mathcal{L}_VW)_{\theta_{t_0}(p)} )
\]
\end{proposition}

\subsection*{ Commuting Vector Fields }

\subsection*{ Time-Dependent Vector Fields }

Let smooth manifold $M$

\textbf{time-dependent vector field on $M$}, $V$ \\
\quad cont. $V: J \times M \to TM$, interval $J \subseteq \mathbb{R}$ \\
\quad \quad s.t.
\[
V(t,p) \in T_p M \quad \, \forall \, (t,p) \in J \times M
\]
i.e. $\forall \, t \in J$, \\
$\begin{aligned}
  & V_t : M \to TM \\
  & V_t(p) = V(t,p) \end{aligned}$ is a vector field on $M$

EY : 20150226

\textbf{time-dependent vector field on $M$}, $V$ is \\
\phantom{ \quad \quad \, }  $\begin{aligned}
& \quad \\
 \text{ cont. } & V : J \times M \to TM \quad \, \text{ interval } J \subseteq \mathbb{R} \\
  & V(t,p) \in T_p M \quad \, \forall \, (t,p) \in J \times M \end{aligned}$

i.e.  $\forall \, t \in J$ \\
$\begin{aligned}
& \quad \\
  & V_t : M \to TM \\
  & V_t(p) = V(t,p ) \in \mathfrak{X}(M) \end{aligned}$

\textbf{integral curve of $V$ } is diff. $\begin{aligned}
& \quad \\
  & \gamma : J_0 \to M \\
  & \dot{\gamma}(t) = V(t,\gamma(t)) \quad \, \forall \, t \in J_0 \end{aligned}$ \quad \, where $J_0 \subset J $ s.t.

$\forall \, X \in \mathfrak{X}(M)$, determines time dependent vector field $V: \mathbb{R} \times M \to TM$ by
\[
V(t,p) = X_p
\]

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=3.2em, column sep=4.8em, minimum width=3.2em]
  {
& \mathfrak{X}(\mathbb{R}\times M) = T\mathbb{R}\oplus TM     & TM   \\
J \times M & \mathbb{R} \times M &  M\\
& \mathcal{E} \subseteq J \times J \times M         &       M \\
& \mathcal{E}^{(t_0,p)}                            & \\
};
  \path[->]
  (m-2-2) edge node [left] {$\widetilde{V}$} (m-1-2)
         edge node [auto] {$V$} (m-1-3)
          edge node [above] {$$} (m-2-3)
  (m-3-2) edge node [auto] {$$} (m-2-2)
          edge node [auto] {$$} (m-2-3)
          edge node [below left] {$\psi$} (m-3-3)
          edge node [auto] {$$} (m-4-2)
          edge node [auto] {$\widetilde{\theta}$} (m-2-1)
  (m-4-2) edge node [below] {$\psi^{(t_0,p)}$} (m-3-3)
  (m-2-3) edge node [right] {$\psi_{tt_0}$} (m-3-3)
          edge node [right] {$X$} (m-1-3)
  (m-1-3) edge node [above] {$\oplus T\mathbb{R}$} (m-1-2)
  (m-2-1) edge node [above] {$t=t_0$} (m-2-2)
          edge node [auto] {$\left. \frac{ \partial }{ \partial t} \right|_{t=t_0}$} (m-1-2)
;
\end{tikzpicture} \quad \quad \quad \,

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=3.2em, column sep=4.8em, minimum width=3.2em]
  {
& \left. \frac{ \partial }{ \partial t} \right|_{t=t_0} \widetilde{\theta} = \widetilde{V}_{(t_0,p)} = \left( \left. \frac{ \partial }{ \partial s} \right|_{t_0}, V(t_0,p) \right) & V(t_0,p) = X_p  \\
\widetilde{\theta}(t,(t_0,p)) = (\alpha(t,(t_0,p)), \beta(t,(t_0,p)))  & (t_0,p)        & p  \\
& (t,t_0,p)       &       \psi(t,t_0,p) = \psi^{(t_0,p)}(t)  \\
& t & \\
};
  \path[|->]
 (m-2-2) edge node [left] {$\widetilde{V}$} (m-1-2)
         edge node [auto] {$V$} (m-1-3)
          edge node [above] {$$} (m-2-3)
  (m-3-2) edge node [auto] {$$} (m-2-2)
          edge node [auto] {$$} (m-2-3)
          edge node [below left] {$\psi$} (m-3-3)
          edge node [auto] {$$} (m-4-2)
          edge node [auto] {$\widetilde{\theta}$} (m-2-1)
  (m-4-2) edge node [below] {$\psi^{(t_0,p)}$} (m-3-3)
  (m-2-3) edge node [right] {$\psi_{tt_0}$} (m-3-3)
          edge node [right] {$X$} (m-1-3)
  (m-1-3) edge node [above] {$+ \left. \frac{\partial}{\partial s} \right|_{t_0}$} (m-1-2)
  (m-2-1) edge node [above] {$t=t_0$} (m-2-2)
          edge node [auto] {$\left. \frac{ \partial }{ \partial t} \right|_{t=t_0}$} (m-1-2)
;
\end{tikzpicture}

with \[
\begin{gathered}
\left. \frac{ \partial }{ \partial t}\right|_{t=t_0} \widetilde{\theta}( t,(t_0,p)) = \left. \left( \frac{ \partial \alpha }{\partial t}(t,(t_0,p)), \frac{\partial \beta}{ \partial t}(t,(t_0,p))  \right)\right|_{t=t_0} = (1, V(t_0,p))
\end{gathered}
\]

EY : 20150725 I don't like Lee's choice of notation.  Let me rewrite the above diagrams:

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=3.2em, column sep=4.8em, minimum width=3.2em]
  {
& \mathfrak{X}(\mathbb{R}\times M) = T\mathbb{R}\oplus TM     & TM   \\
J \times M & \mathbb{R} \times M &  M\\
& \mathcal{E} \subseteq J \times J \times M         &       M \\
& \mathcal{E}^{(t,p)}                            & \\
};
  \path[->]
  (m-2-2) edge node [left] {$\widetilde{V}$} (m-1-2)
         edge node [auto] {$V$} (m-1-3)
          edge node [above] {$$} (m-2-3)
  (m-3-2) edge node [auto] {$$} (m-2-2)
          edge node [auto] {$$} (m-2-3)
          edge node [below left] {$\psi$} (m-3-3)
          edge node [auto] {$$} (m-4-2)
          edge node [auto] {$\widetilde{\theta}$} (m-2-1)
  (m-4-2) edge node [below] {$\psi^{(t,p)}$} (m-3-3)
  (m-2-3) edge node [right] {$\psi_{st}$} (m-3-3)
          edge node [right] {$V_t$} (m-1-3)
  (m-1-3) edge node [above] {$\oplus T\mathbb{R}$} (m-1-2)
  (m-2-1) edge node [above] {$s=0$} (m-2-2)
          edge node [auto] {$\left. \frac{ \partial }{ \partial s} \right|_{s=0}$} (m-1-2)
;
\end{tikzpicture} \quad \quad \quad \,

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=3.2em, column sep=4.8em, minimum width=3.2em]
  {
& \left. \frac{ \partial }{ \partial s} \right|_{s=0} \widetilde{\theta} = \widetilde{V}_{(t,p)} = \left( \left. \frac{ \partial }{ \partial t} \right|_{s=0}, V(t,p) \right) & V(t,p) = V_t(p)  \\
\widetilde{\theta}(s,(t,p)) = (\alpha(s,(t,p)), \beta(s,(t,p)))  & (t,p)        & p  \\
& (s,t,p)       &       \psi(s,t,p) = \psi^{(t,p)}(s)  \\
& s & \\
};
  \path[|->]
 (m-2-2) edge node [left] {$\widetilde{V}$} (m-1-2)
         edge node [auto] {$V$} (m-1-3)
          edge node [above] {$$} (m-2-3)
  (m-3-2) edge node [auto] {$$} (m-2-2)
          edge node [auto] {$$} (m-2-3)
          edge node [below left] {$\psi$} (m-3-3)
          edge node [auto] {$$} (m-4-2)
          edge node [auto] {$\widetilde{\theta}$} (m-2-1)
  (m-4-2) edge node [below] {$\psi^{(t,p)}$} (m-3-3)
  (m-2-3) edge node [right] {$\psi_{st}$} (m-3-3)
          edge node [right] {$V_t$} (m-1-3)
  (m-1-3) edge node [above] {$+ \left. \frac{\partial}{\partial t} \right|_{s=0}$} (m-1-2)
  (m-2-1) edge node [above] {$s=0$} (m-2-2)
          edge node [auto] {$\left. \frac{ \partial }{ \partial s} \right|_{s=0}$} (m-1-2)
;
\end{tikzpicture}

with \[
\begin{gathered}
\left. \frac{ \partial }{ \partial s}\right|_{s=0} \widetilde{\theta}( s,(t,p)) = \left. \left( \frac{ \partial \alpha }{\partial s}(s,(t,p)), \frac{\partial \beta}{ \partial s}(s,(t,p))  \right)\right|_{s=0} = (1, V(t,p))
\end{gathered}
\]

\begin{theorem}[9.48] \textbf{(Fundamental Theorem on Time-Dependent Flows)} \\
Let $M$ smooth manifold \\
open $J \subseteq \mathbb{R}$ \\
$V: J \times M \to TM$ smooth time-dependent vector field on $M$ \\
$\exists \, $ open $\mathcal{E} \subseteq J\times J \times M$, smooth $\psi : \mathcal{E} \to M$ called time-dependent flow of $V$ s.t.

\begin{enumerate}
\item[(a)] $\forall \, t_0 \in J$, \, $\forall \, p \in M$, \\
open $\mathcal{E}^{(t_0,p)} = \lbrace t \in J | (t,t_0, p) \in \mathcal{E}_0 \rbrace$ s.t. $t_0 \in \mathcal{E}^{(t_0, p)}$ \\
smooth curve $\begin{aligned}
  & \quad \\
  & \psi^{(t_0,p)}: \mathcal{E}^{(t_0,p)} \to M \\
  & \psi^{(t_0,p)}(t) = \psi(t,t_0,p) \end{aligned}$ \\
is unique maximal integral curve of $V$ with $\psi^{(t_0,p)}(t_0) = p$
\item[(b)] If $ \begin{aligned}
  & \quad \\
  & t_1 \in \mathcal{E}^{(t_0,p)} \\
  & q = \psi^{(t_0,p)}(t_1) \end{aligned}$

then $\begin{aligned}
  & \quad \\
  & \mathcal{E}^{(t_1,q)} = \mathcal{E}^{(t_0,p)} \text{ and } \\
  & \psi^{(t_1,q)} = \psi^{(t_0,p)} \end{aligned}$
\item[(c)] $\forall \, (t_1,t_0) \in J \times J $ \\
$M_{t_1,t_0} = \lbrace p \in M | (t_1,t_0, p) \in \mathcal{E} \rbrace$ open in $M$ and \\
  $\begin{aligned}
  & \quad \\
  & \psi_{t_1t_0} : M_{t_1t_0} \to M \\
  & \psi_{t_1t_0}(p) = \psi(t_1,t_0,p) \end{aligned}$
is a diffeomorphism from $M_{t_1t_0}$ onto $M_{t_0t_1}$ with inverse $\psi_{t_0t_1}$
\item[(d)] If $p \in M_{t_1t_0} $, $\psi_{t_1t_0}(p) \in M_{t_0t_1}$, \\
then $p\in M_{t_2 t_0}$ and
\begin{equation}
\psi_{t_2t_1} \psi_{t_1t_0}(p) = \psi_{t_2t_0}(p) \quad \quad \quad \, (9.18)
\end{equation}
\end{enumerate}

\end{theorem}

\begin{proof}
Consider smooth vector field $\begin{aligned}
& \quad  \\
  & \widetilde{V} \in \mathfrak{X}(J \times M ) \text{ defined by } \\
  & \widetilde{V}_{(s,p)} = \left( \left. \frac{ \partial }{ \partial s } \right|_s, V(s,p) \right) \end{aligned}$ \\

identify $T_{(s,p)}(J \times M)$ with $T_sJ \oplus T_pM$ (Prop. 3.14)

Let $\begin{aligned}
& \quad \\
  & \widetilde{\theta} : \widetilde{\mathcal{D}} \to J \times M \\
  & \widetilde{\theta}(t,(s,p)) = (\alpha(t,(s,p)) , \beta(t,(s,p)) ) \end{aligned}$ \quad \, flow of $\widetilde{V}$

then $\begin{aligned}
 & \quad \\
  & \alpha: \widetilde{D} \to J \\
  & \beta: \widetilde{D} \to M \end{aligned}$ s.t.

\[
\begin{aligned}
  & \frac{ \partial \alpha}{ \partial t}(t,(s,p) ) = 1 \quad \quad \, & \alpha(0,(s,p)) = s \\
  & \frac{ \partial \beta}{ \partial t}(t,(s,p)) = V(\alpha(t,(s,p)), \beta(t,(s,p))) \quad \quad \, & \beta(0,(s,p)) = p
\end{aligned}
\]
$\Longrightarrow \alpha(t,(s,p)) = t+s$ so
\begin{equation}
  \frac{ \partial \beta}{ \partial t}(t,(s,p)) = V(t+s,\beta(t,(s,p)) \quad \quad \quad \, (9.19)
\end{equation}
\end{proof}

Let $\begin{aligned}
  & \quad \\
  & \mathcal{E} \subseteq \mathbb{R} \times J \times M \text{ defined } \\
  & \mathcal{E} = \lbrace (t,t_0, p) | (t-t_0, (t_0,p) ) \in \widetilde{\mathcal{D}} \rbrace \end{aligned}$

$\mathcal{E}$ open because $\widetilde{\mathcal{D}}$ is. \\
since $\alpha: \widetilde{D} \to J$, if $(t,t_0, p) \in \mathcal{E}$, then $t= \alpha(t-t_0,(t_0,p)) \in J$, implies $\mathcal{E} \subseteq J \times J \times M$ \\
$\mathcal{E}$ open so $M_{t_1t_0} = \lbrace p \in M | (t_1,t_0, p) \in \mathcal{E} \rbrace$ open.

define $\begin{aligned} & \quad \\
  & \psi : \mathcal{E} \to M \\
  & \psi(t,t_0,p) = \beta(t-t_0,(t_0,p))
\end{aligned}$

EY : 20150725 Remark: Out of the proof immediately above, there are a number of takeaways that really \emph{should} be mentioned.

Let's collect the facts:
\[
\begin{aligned}
  & \widetilde{\theta}(s,(t,p)) = (\alpha(s,(t,p)), \beta(s,(t,p)) ) := \widetilde{\theta}^{(t,p)}(s) \\
  & \widetilde{\theta}(0,(t,p)) = (\alpha(0,(t,p)), \beta(0,(t,p)) ) = (t,p) \\
  & \frac{ \partial \alpha}{ \partial s}(s,(t,p)) = 1 \\
  & \frac{ \partial \beta }{ \partial s}(s,(t,p)) = V(\alpha(s,(t,p)), \beta(s,(t,p))) \text{ so } \\
  & \alpha(s,(t,p)) = s+t \\
  & \frac{ \partial \beta}{ \partial s}(s,(t,p)) = V(s+t,\beta(s,(t,p)) ) \\
  & \left. \frac{ \partial }{ \partial s} \right|_{s=0} \widetilde{\theta}(s,(t,p)) = \left. \left( \frac{ \partial \alpha }{ \partial s}(s,(t,p)) , \frac{ \partial \beta}{ \partial s}(s,(t,p)) \right) \right|_{s=0} = (1,V(t,p)) = \frac{d\widetilde{\theta}^{(t,p)}}{ds}(s=0) := \widetilde{V}_{(t,p)}
\end{aligned}
\]

Also, we can write the flow $\widetilde{\theta}_s$ as
\[
\widetilde{\theta}^{(t,p)}(s) = \widetilde{\theta}(s,(t,p)) = \widetilde{\theta}_s(t,p) = (\alpha(s,(t,p)),\beta(s,(t,p))) = (s+t, \beta(s,(t,p)))
\]

Now consider the Lie derivative:

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=2em, column sep=6.8em, minimum width=2em]
  {
\mathfrak{X}(\mathbb{R} \times M) & \mathfrak{X}(\mathbb{R} \times M)  \\
\mathfrak{X}(\mathbb{R} \times M) &   \\
J\times M    &       J\times M \\
};
  \path[->]
  (m-3-1) edge node [above] {$$} (m-2-1)
  edge node [above] {$\widetilde{\theta}_s$} (m-3-2)
  (m-3-2) edge node [auto] {$$} (m-1-2)
  edge [bend left] node [auto] {$\widetilde{\theta}_{-s}$} (m-3-1)
  (m-1-2) edge node [above] {$d(\widetilde{\theta}_{-s})=(\widetilde{\theta}_{-s})_*$} (m-1-1)
;
\end{tikzpicture} \quad \quad \quad \, \begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=2em, column sep=6.8em, minimum width=2em]
  {
d(\widetilde{\theta}_{-s})_{\widetilde{\theta}_s(t,p)}(W_{\widetilde{\theta}_s(t,p)}) & W_{\widetilde{\theta}_s(t,p)}  \\
W_{(t,p)}   &    \\
(t,p)    &       \widetilde{\theta}_s(t,p) \\
};
  \path[|->]
  (m-3-1) edge node [above] {$$} (m-2-1)
  edge node [above] {$\widetilde{\theta}_s$} (m-3-2)
  (m-3-2) edge node [auto] {$$} (m-1-2)
  edge [bend left] node [auto] {$\widetilde{\theta}_{-s}$} (m-3-1)
  (m-1-2) edge node [above] {$d(\widetilde{\theta}_{-s})=(\widetilde{\theta}_{-s})_*$} (m-1-1)
;
\end{tikzpicture}

with $\widetilde{\theta}$ being the flow of $\widetilde{V}$.  Let's define the Lie derivative:

\begin{equation}
\begin{gathered}
  \mathcal{L}_{\widetilde{V}}W = (\mathcal{L}_{\widetilde{V}}W)_{(t,p)} = \left. \frac{d}{ds} \right|_{s=0}(d\widetilde{\theta}_{-s})_{\widetilde{\theta}_s(t,p)}(W_{\widetilde{\theta}_s(t,p)})   = \lim_{s\to 0} \frac{ (d\widetilde{\theta}_{-s})_{\widetilde{\theta}_s(t,p)}( W_{\widetilde{\theta}_s(t,p)}) - W_{\widetilde{\theta}_s(t,p)} }{s}
\end{gathered}
\end{equation}

Use Case 1 of the proof of Lee's Theorem 9.38, for showing $\mathcal{L}_VW = [V,W]$.  \\
Let open neighborhood $U \subseteq J \times M$, with $(t,p) \in U$.  On open $U$, choose smooth coordinates $(t,u^i)$ on $U$.  By Theorem 9.22, that at a regular point $p\in M$, $\exists \, (u^i)$ coordinates s.t. $V_p = \frac{ \partial }{ \partial u^1}$, then consider

\[
\widetilde{V} = \frac{ \partial }{ \partial t} + \frac{ \partial }{ \partial u^1} \in \mathfrak{X}(\mathbb{R} \times M)
\]
with $V(t)(p) = \frac{ \partial }{ \partial u^1} \in \mathfrak{X}(M)$.  (Remember, $V(t)$ is a vector-field that is time-dependent, but is on $M$.  I will use this as a justification for using Thm. 9.22).

Now the flow $\widetilde{\theta}_s$ takes on these forms:
\[
\begin{gathered}
  \widetilde{\theta}^{(t,p)}(s) = \widetilde{\theta}(s,(t,p)) = \widetilde{\theta}_s(t,p) = \\
  = (\alpha(s,(t,p)) , \beta(s,(t,p))) = (s+t, \beta(s,(t,p)) )
\end{gathered}
\]
Given these conditions, that \\
$\beta(0,(t,p)) = p = (u^1,u^2, \dots u^n)$ and
\[
\left. \frac{ \partial \beta}{ \partial s}(s, (t,p)) \right|_{s=0} = V(t,p) = \frac{ \partial }{ \partial u^1} = \left. \frac{d}{ds} \beta^{(t,p)}(s) \right|_{s=0}
\]
then a $\beta$ that satisfies these conditions above is
\[
\beta(s,(t,p)) = \beta_s(t,p) = (u^1 + s, u^2 \dots u^n)
\]
so that we can conclude that
\[
\widetilde{\theta}_s(t,p) = (t+s, u^1 + s, u^2 , \dots , u^n)
\]

For fixed $s$, then
\[
d(\widetilde{\theta}_{-s})_{\widetilde{\theta}_s(t,p)} =1_{T_{\widetilde{\theta}_s(t,p)}(\mathbb{R}\times M)}
\]
so that
\[
\begin{gathered}
  d(\widetilde{\theta}_{-s})_{\widetilde{\theta}_s(t,p)}(W_{\widetilde{\theta}_s(t,p)}) = d(\widetilde{\theta}_{-s})_{\widetilde{\theta}_s(t,p)} \cdot W^j(t+s,u^1 +s, u^2 \dots u^n) \left. \frac{ \partial }{ \partial u^j} \right|_{\widetilde{\theta}_s(t,p)} = W^j(t+s,u^1+s, u^2 \dots u^n) \left. \frac{ \partial }{ \partial u^j} \right|_{(t,p)} \\
\Longrightarrow \left. \frac{d}{ds} \right|_{s=0} W^j(t+s,u^1+s, u^2 \dots u^n) \left. \frac{ \partial }{ \partial u^j} \right|_{(t,p)} = \left( \frac{\partial }{ \partial t} W^j(t,u^1 \dots u^n) + \frac{ \partial }{ \partial u^1 } W^j(t,u^1 \dots u^n) \right) \left. \frac{ \partial}{ \partial u^j} \right|_{(t,p)}
\end{gathered}
\]

Thus, we can conclude that
\begin{equation}
  \boxed{ \mathcal{L}_{\widetilde{V}}W = \mathcal{L}_{ \frac{ \partial }{ \partial t} +V}W = \left( \mathcal{L}_{ \frac{ \partial}{ \partial t} V } W \right)_{(t,p)} = \left( \left( \frac{ \partial }{ \partial t} + V \right) W^j \right) \left. \frac{ \partial }{ \partial x^j} \right|_{(t,p)} }
\end{equation}

\subsection*{First-Order Partial Differential Equations }

\subsection*{ Problems }

\problemhead{9-21} Note that from wikipedia,

ambient isotopy \\
Let $N, M$ manifolds, \\
\quad $g,h$ embeddings of $N$ in $M$

cont. map $F: M \times [0,1] \to M$ s.t.  \\
$F: g\mapsto h$ \\
if $F_0 = 1$ \\
\phantom{ if } $F_t$ homeomorphism, $F_t: M \to M$ \\
\phantom{ if } $F_1 : g \mapsto h$ \\

\textbf{smooth isotopy} of $M$ is smooth $H: M \times J \to M$, \, $J \subseteq R$ interval s.t. \\
\quad \, $\forall \, t \in J$, $\begin{aligned} & \quad \\
  & H_t : M \to M \\
  & H_t(p) = H(p,t) \end{aligned}$ is a diffeomorphism.

Suppose open interval $J \subseteq \mathbb{R}$ \\
\phantom{Suppose } smooth isotopy $H:M \times J \to M$ \\

EY : 20140206

By definition \\
$\forall \, t, \, \begin{aligned} & \quad \\
  & H_t : M \to M \\
  & H_t(p) = H(p,t) \end{aligned}$

Then $DH_t = (H_t)_*$ \\
\[
DH_t : TM \to TM
\]

I tried,

for some time $t$, consider $H(x^i(p),t) = y^j(x^i,t)$
\[
\frac{ \partial H(p,t)}{ \partial t } = \frac{ \partial y^j(x^i,t) }{ \partial t }
\]

Consider integral curve $x = x(t)$ s.t. $\dot{x} = X(t)$

\[
\begin{gathered}
  \dot{y} = \frac{dy}{dt} = \frac{d}{dt} y(x(t),t) = \frac{ \partial y^j}{ \partial x^i }\dot{x}^i = (DH_t)X \\
\begin{aligned}
  & (H_t)_* : TM \to TM \\
  & DH_t : X \mapsto \dot{y} = Y
\end{aligned}
\end{gathered}
\]

$\psi(t,t_0,p) = H_t \circ H_{t_0}^{-1}(p)$ domain $J \times J \times M$ ??


\documentclass[12pt]{article}
\usepackage{amsfonts}
\usepackage{amssymb,amsmath}
\usepackage{ifthen}
\newboolean{flagoptimfirst}

\newenvironment{optim}[2]{
\setboolean{flagoptimfirst}{true}
\begin{aligned}
& \underset{#1}{\text{minimize}} & & #2 \\
& \text{subject to} & & }
{\end{aligned}}

\newcommand{\sjt}{
 \ifthenelse{\boolean{flagoptimfirst}}{
 }{
 \\ & & &
 }
\setboolean{flagoptimfirst}{false}
}
\begin{document}

\section*{Example of MHE in casadi for a mass-spring system}

In the MHE example, we consider a simple mass-spring system. Measurements of the position of the mass are available. We would like to solve the following MHE-problem:
\begin{equation*}
\begin{optim}{\textbf{x}(\cdot),\textbf{w}(\cdot)}{ \int_{\tau=t-T}^t \parallel \textbf{w}(\tau) \parallel^2_{Q_\mathrm{c}} + \parallel \textbf{y}(\tau) - h(\textbf{x}) \parallel^2_{R_\mathrm{c}}d\tau + \parallel x(t-T) - \hat{x}(t-T)  \parallel^2_{S}}
\sjt \dot{\textbf{x}} = f(\textbf{x},\textbf{u},\textbf{w},\tau), \hspace{7mm} \tau \in [t-T,t],
\end{optim}
\end{equation*}
where:
\begin{itemize}
 \item $\vec{x}$ is the system state,
 \item $\vec{y}$ are the measurements,
 \item $\vec{u}$ is the control input,
 \item $\vec{w}$ is a noise term introduced to model the model uncertainty (i.e.~the process noise),
 \item $t$ is the current time,
 \item $\hat{x}(t-T)$ is an estimate for the state at the beginning of the horizon
 \item $Q_\mathrm{c}$ and $R_\mathrm{c}$ $S$ are the weighting matrices for the model and measurement noise and for the arrival cost respectively,
 \item $T$ is the considered time horizon,
 \item $f$ is a model of the considered system, and
 \item $h$ is the measurement function that maps the system state to the measurements.
\end{itemize}

In the example, this example is discretized using multiple shooting, which results in the following problem:
\begin{equation*}
\begin{optim}{\textbf{x}_k,\textbf{w}_k}{ \sum_{k=i-N}^{i-1} \parallel \textbf{w}_k \parallel^2_{Q_{\mathrm{d}_k}} + \sum_{k=i-N}^i \parallel \textbf{y}_k - h(\textbf{x}_k) \parallel^2_{R_{\mathrm{d}_k}} +  \parallel x_{i-N} - \hat{x}_{i-N}  \parallel^2_{S}}
\sjt \textbf{x}_{k+1} = \phi(\textbf{x}_k,\textbf{u}_k,\textbf{w}_k), \; k = i-N,\ldots,i-1
\end{optim}
\end{equation*}
where
\begin{itemize}
 \item $\phi$ integrates our model $f$, given the state $\vec{x}_k$, control input $\vec{u}_k$ and process noise $\vec{w}_k$, over one sampling interval,
 \item N is the number of measurements in the considered time horizon,
 \item $i$ is the current sampling index, and
 \item $Q_\mathrm{d}$ and $R_\mathrm{d}$ are the discretized versions of covariance matrices $Q_\mathrm{c}$ and $R_\mathrm{c}$, which might vary over the time horizon.
\end{itemize}

This is the setup of the MHE that is implemented in this example. Note that in this example, Structures are used. If you are unfamiliar with this, a tutorial can be found here: http://docs.casadi.org/tutorials/tools/structure.pdf
The arrival cost is updated using the smoothed EKF update.

\end{document}


\subsection{Distributions}\label{distributions}

Let's imagine we will measure how long it takes to get from Brooklyn
College to Times square. Google maps says this takes about 54 minutes.
But, we all know that is an estimate that sometimes be off. Any given
trip could be shorter or longer. As a result, if we measured how long
several trips take for different people, we will find different times.
So, the population of travel times has variability. We can easily
describe these travel times with distributions. For example, consider
the two distributions below.

\includegraphics{Ttest_files/figure-latex/unnamed-chunk-1-1}

Both distributions have peaks around 54 minutes, which is the average
travel time between Brooklyn College and Times Square by subway. And,
both distributions have some variability. Some travel times are shorter
and some are longer than 54 minutes. The narrow distribution has less
variability than the wide distribution. For example, the narrow
distribution has a standard deviation of 2 minutes, and the wide
distribution has a standard deviation of 20 minutes.

What does the variability mean for your travel time? If there is less
variability, then more of your trips will be close to the mean of 54
minutes. And, when the trip is shorter or longer than 54 minutes, it
won't be too much shorter or longer, only a few minutes give or take.
Notice, that certain travel times pretty much never happen in the narrow
distribution. For example, it never takes 20 or a 100 minutes. When
there is more variability, then more of your trips will be slower or
faster than 54 minutes. For example, although the trips will average out
to 54 minutes, many trips will be much shorter, and much longer than 54
minutes. For example, you could expect a trip of 75 minutes to happen
fairly often. But, even when the distribution is wide, some very short
or long trips still do not happen very often. For example, a trip of 300
minutes never happens according to the wide distribution.

Randomly sampling a number from a distribution is a lot like taking your
chances on the subway. You might get to your destination in the average
time, or you could have bad luck and get on the train when there are a
lot of delays. We have a feeling for what the subway can do, it can
sometimes be fast and sometimes be slow. Similarly, by looking at a
distribution, we can get a feeling for what chance can do to the
measurement.

Whenever we take a measurement, we can think of it as taking a random
sample from a distribution. The distribution shows us that there are
different probabilities of getting smaller or larger numbers. The mean
is the most probable number, and in the distributions we are looking at,
as the numbers get smaller or larger, they also get less and less
likely. So, just by looking at the distribution, we can get a feeling
for what chance can do. For example, random sampling from the narrow
distribution will usually give numbers around 54, plus or minus 2 or
4ish. And, random sampling from the wide disribution will usually give
us numbers around 54, plus or minus 20-40ish.

\subsection{Differences can arise by chance because of
sampling}\label{differences-can-arise-by-chance-because-of-sampling}

Let's say you and your friend each take 10 subway trips between Brooklyn
College and Times Square, and each time you use your cell phone to
record how long each trip takes. This is the same as taking two samples
of 10 scores from the travel time distribution. What happens we we do
this? Will you and your friend have identical scores? Probably not. Each
time, different random factors will cause each of the trips to take
different amounts of time. We can plot the outcome of these hypothetical
trips below in a histogram.

\includegraphics{Ttest_files/figure-latex/unnamed-chunk-2-1}

The histogram shows that in each sample, different trips took different
amounts of time. These samples were created by randomly picking numbers
from a normal distribution with mean = 54, and standard deviation = 20.
So, we might expect that both of our samples with also have a mean of
54. But, as you can see this is not true. The black lines on each of the
histograms show the mean travel times, and it is clear they are not
exactly the same.
\emph{The difference between these two sample means was produced by random chance.}

\subsection{What kind of differences can chance
produce?}\label{what-kind-of-differences-can-chance-produce}

Let's first look at the kind of differences that random sampling can
produce in our subway example. Imagine, that 20 people each took 10
trips between Brooklyn College and Times Square, and all of them
recorded their travel times. The data might look like this:

\includegraphics{Ttest_files/figure-latex/unnamed-chunk-3-1}

It easy to see that each person had different sets of travel times, and
that the means (black bars) are also moving around. All of the means are
close-ish to 54 minutes (which is the true mean), but some means are
smaller and larger. These sample means are very important, and they
point to another distribution, the sampling distribution of the mean.

The sampling distribution of the mean is a hypothetical idea. Imagine if
instead of 20 people taking 10 trips, and infinite number of people each
took 10 trips, and then recorded their travel times. Each of these
samples would have it's own mean. What does this distribution look like?
We can use a computer to simulate this distribution below:

\includegraphics{Ttest_files/figure-latex/unnamed-chunk-4-1}

Remember each of the black lines in the sample histograms that represent
the sample means? The above histogram shows means from 10,000 of those
black lines (imagining we had 10,000 take trips).

We see that the distribution is centered on 54, which is the true mean
of the population. We also see that some means get as small as around
35, and as large as 75. However, sample means hardly ever get smaller
than 30, or larger than 80.

This graph is our window into the things that chance can do, and the
differences that random sampling can produce just by taking measurements
that have variability. What is most important, is that there are clearly
hard limits on what chance can do in this situation. We already said,
that chance alone hardly ever produces a mean larger than 75. We can use
this kind of information when we observe means that occur outside of our
chance window. For example, if one person had a sample mean of 5 minutes
for taking 10 trips, what can we infer? Well, we can say that chance has
an infintesimally small probability of producing this sample mean. For
this reason,we can also confidently rule-out chance as an explanation.
My guess is that person obviously DID NOT TAKE THE SUBWAY. Perhaps they
flew in a helicopter.

It easy to rule out chance when the measurement produces sample mean
that is well outside the chance window (like 5 minutes). It gets harder
to confidently rule out chance when the sample mean is inside the chance
window, but it can still be done. Researchers set their own criterions
about this issue (e.g., alpha value). For example, if you found a sample
mean of 70, what would you conclude? The histogram shows this sample
mean occurs with a very low frequency, which means it does occur by
chance. But, the chances are very low, less than 1\%. So, if you are
willing to accept those chances of being wrong, you might infer that a
sample mean of 75 was not produced by chance, but perhaps produced by
long delays on the subway.

\subsection{Chance can produce differences between conditions in an
experiment}\label{chance-can-produce-differences-between-conditions-in-an-experiment}

The reason we are spending so much time on understanding chance, is that
chance can produce differences between conditions in an experiment. This
occurs for the same reason that chance can produce different sample
means by random sampling alone. Remember in a simple experiment, we are
taking samples of the dependent variable in two conditions. We want to
know if there was a difference in the measure between conditions, so we
often look at the difference in sample means between the conditions.
And, as we have learned, those sample means can be different just
because of random chance.

Fortunately, we can use methods called inferential statistics to
estimate the kinds of differences that chance can produce. Then, we can
estimate the likelihood that the differences we observe were produced by
chance. When we find differences that are \emph{likely not} produced by
chance, we can be more confident that our observed differences are real,
and not random.

\section{2 level designs and t-tests}\label{level-designs-and-t-tests}

There are multiple ways to estimate whether chance is responsible for a
difference in an experiment. By far the most common approach is to use a
t-test. The t-test is a statitiscal method for analyzing the data in two
conditions to determine the likelihood that any observed difference
could have been produced by chance. You can refer to the inferential
statistics chapter, your old notes from statistics, discussions of
t-tests in the lab manual, and google t-tests to learn more about how
they work. For now, we will briefly describe the three different kinds
of t-tests, and give an example of how they are used to analyze data,
and how the results from a t-test are reported in journal article.

The three most common versions of the t-test are: one-sample t-test,
independent samples t-test, and the paired samples t-test. The one
sample t-test is used to test whether a sample mean could have come from
a particular population. The independent samples t-test is used in
between-subjects designs, to test whether the sample mean in one
condition is different from the sample mean in another condition. The
paired samples t-test is used in within-subjects designs, to test
whether the sample mean in one condition is different from the sample
mean in the other condition.

All t-tests give the same basic information, a t-value, and a p-value.
Simply, the p-value gives the probability that the observed difference
between means could have been produced by chance alone. If we dive into
the details, we will see that the p-value estimate depends on several
assumptions being met, and also has more nuanced meanings. But for now,
it gives us what we want, an estimate of the likelihood that chance
could have produced the difference we observed. When the p-value is very
small (e.g., less than .05, or 5\%), many researchers would conclude
that a difference ``statistically significant'', and probably not
produced by chance.

\subsection{An example}\label{an-example}

Imagine a between-subjects experiment on 20 student, asking whether
studying or not studying changes test performance on a midterm. The IV
is studying (Studying vs.~No-Studying), and the DV is test performance
(percentage on the midterm). Below are some imaginary results from the
experiment.

\begin{longtable}[]{@{}rr@{}}
\toprule
study & nostudy\tabularnewline
\midrule
\endhead
75 & 75\tabularnewline
82 & 79\tabularnewline
82 & 85\tabularnewline
86 & 75\tabularnewline
71 & 79\tabularnewline
78 & 73\tabularnewline
85 & 76\tabularnewline
77 & 75\tabularnewline
72 & 78\tabularnewline
74 & 67\tabularnewline
\bottomrule
\end{longtable}


\section{SCC}

%%%%%%%%%%%%%%%
\begin{frame}{SCC}
  \begin{exampleblock}{Kosaraju SCC algorithm, 1978 \pno{3.4.7}}
    \begin{itemize}
      \item 1st DFS $\Rightarrow^{?}$ BFS
      \item 2nd DFS $\Rightarrow^{?}$ BFS
    \end{itemize}
  \end{exampleblock}

  \begin{block}{Solution.}
    digraph = dag of SCCs
    \begin{itemize}
      \item (2nd round) Repeat: traversal from $s \in \text{\textcolor{red}{sink} scc}$; delete
      \item (1nd round) dag: toposort $\Rightarrow$ decreasing finish time $\Rightarrow$ $s \in \text{\textcolor{blue}{source} scc}$
    \end{itemize}
  \end{block}

  \begin{alertblock}{Remark.}
    \begin{itemize}
      \item DFS on $G^{T}$; DFS/BFS on $G$
      \item DFS on $G$; DFS/BFS on $G^{T}$
    \end{itemize}
  \end{alertblock}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{One-way streets}
  \begin{exampleblock}{One-way streets \pno{3.4.23}}
    \begin{itemize}
      \item $\forall u,v: u \leftrightsquigarrow v$
      \item $s: s \leadsto v \leadsto s$
    \end{itemize}
  \end{exampleblock}

  \begin{block}{Solution.}
    \begin{itemize}
      \item $G$ is an SCC
      \item $\set{v \mid s \leadsto v}$ is an SCC
	\begin{itemize}
	  \item compute $\set{v \mid s \leadsto v}$
	  \item compute SCCs
	  \item compare
	\end{itemize}
    \end{itemize}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Infinite path}
  \begin{exampleblock}{Infinite path \pno{3.4.25}}
    \begin{itemize}
      \item prove: $\text{Inf}(p) \subseteq \exists \text{SCC}$
      \item an infinite path?
      \item $\ldots \land$ visiting $\exists g \in V_{G}$ infinitely often
      \item $\ldots \land$ not visiting $\exists b \in V_{B}$ infinitely often
    \end{itemize}
  \end{exampleblock}

  \begin{block}{Solution.}
    \begin{itemize}
      \item $\text{cycle} \subseteq \exists \text{scc}$
      \item $\exists \text{scc}: s \leadsto \text{scc}$
      \item $\exists \text{scc}: s \leadsto \text{scc} \land \text{scc} \cap V_{G} \neq \emptyset$
      \item delete $V_{B}$; $\exists \text{scc}: \text{scc} \cap V_{G} \neq \emptyset$; in $G$: $s \leadsto \text{scc}$
	\begin{itemize}
	  \item wrong: $\exists \text{scc}: s \leadsto \text{scc} \land \text{scc} \cap V_{G} \neq \emptyset \land \text{scc} \cap V_{B} = \emptyset$
	  \item wrong: delete $V_{B}$; $\exists \text{scc}: s \leadsto \text{scc} \land \text{scc} \cap V_{G} \neq \emptyset$
	\end{itemize}
    \end{itemize}
  \end{block}
\end{frame}
%%%%%%%%%%%%%%%
\begin{frame}{Odd cycle in digraph}
  \begin{exampleblock}{Odd cycle in digraph \pno{3.4.15}}
    Find an odd cycle in a digraph $G$.
  \end{exampleblock}

  \begin{lemma}
    A digraph $G$ has an odd directed cycle $\iff$ $\exists \text{scc}: $ scc is non-bipartite (when treated undirected).
  \end{lemma}

  \begin{proof}
    \begin{itemize}
      \item $\Leftarrow$: undirected $C$; oriented
	\begin{itemize}
	  \item odd directed cycle
	  \item choose a direction $\forall u \to v$: $\text{Len}(v \leadsto u)$
	\end{itemize}
    \end{itemize}
  \end{proof}

  \begin{alertblock}{Remark.}
    DFS + Coloring on $G$
  \end{alertblock}
\end{frame}
%%%%%%%%%%%%%%%