\chapter{The statistics of inverse modeling}
\section{Definition of the system}

The discrete-time state-space formulation of a nonlinear dynamic system
is\footnote{Refer to Table~\ref{tab:definition-of-terms} for the meaning of the
symbols used herein.}:

\begin{equation}\label{eq:true-state}
x_{t+1}=f(x_t,u_t,\boldsymbol\theta)
\end{equation}
\begin{equation}\label{eq:true-output}
y_{t+1}=h(x_{t+1},\boldsymbol\phi)
\end{equation}
To keep notation as simple as possible, we consider a system in which the state,
the forcing and the output at any given time can be represented as scalars.
Further note that the `state' of the system at a given time can include history.
Since it is generally impossible to observe the true state, the true forcing,
and the true output of a system, we have to make do with the observed state,
observed forcing, and the observed output instead:

\begin{equation}\label{eq:observed-state}
\tilde{x}_{t+1}=x_{t+1} + \omega_{t+1}
\end{equation}
\begin{equation}\label{eq:observed-forcing}
\tilde{u}_{t+1}=u_{t+1} + \psi_{t+1}
\end{equation}
\begin{equation}\label{eq:observed-output}
\tilde{y}_{t+1}=y_{t+1} + \nu_{t+1}
\end{equation}
Note that Eqs.~\ref{eq:observed-state}--\ref{eq:observed-output} assume that the
dimensionality of $x_{t+1}$, $u_{t+1}$ and $y_{t+1}$ is the same as their
observed counterparts, and that they do indeed represent the same entities (in
other words, there is no \textit{incommensurability}). Furthermore, we do not
know the mechanism by which $x_t$ leads to $x_{t+1}$ in Eq.~\ref{eq:true-state},
so instead we propose a mechanism $\hat{f}(\cdot{})$; similarly we do not know
how $x_{t+1}$ leads to $y_{t+1}$ in Eq.~\ref{eq:true-output}, so we propose
$\hat{h}(\cdot{})$. Typically, $\hat{f}(\cdot{})$ and $\hat{h}(\cdot{})$ are
part of the same computer model structure. Because of philosophical reasons, it
is impossible to prove that $\hat{f}(\cdot{})$ and $\hat{h}(\cdot{})$ are in
fact the correct functions $f(\cdot{})$ and $h(\cdot{})$---instead, we can only
subject $\hat{f}(\cdot{})$ and $\hat{h}(\cdot{})$ to increasingly more difficult
tests, and if $\hat{f}(\cdot{})$ and $\hat{h}(\cdot{})$ are not falsified by
these tests, then the confidence in the correctness of $\hat{f}(\cdot{})$ and
$\hat{h}(\cdot{})$ increases.

\section{Bayes' law in parameter optimization}

Eq.~\ref{eq:bayes-law-general} shows Bayes' Law:
\begin{equation}\label{eq:bayes-law-general}
p(A|B) = \frac{p(B|A)\:p(A)}{p(B)}
\end{equation}
It describes how a prior belief in something can be modified or strengthened as
a result of observations. For example, within the context of parameter
estimation, it describes how a \textit{prior} belief in the value of a parameter
vector, or $p(\boldsymbol\theta)$, can be modified by something called the
\textit{likelihood} , or $p(\tilde{\mathbf{x}}|\boldsymbol\theta)$, to yield a
\textit{posterior} belief in the value of the parameter vector, or
$p(\boldsymbol\theta|\tilde{\mathbf{x}})$,  according to Eq.~\ref{eq:bayes-law}
($p(\tilde{\mathbf{x}})$ is just a normalization constant):
\begin{equation}\label{eq:bayes-law}
p(\boldsymbol\theta|\tilde{\mathbf{x}}) =
\frac{p(\tilde{\mathbf{x}}|\boldsymbol\theta)\:p(\boldsymbol\theta)}{p(\tilde{\mathbf{x}})}
\end{equation}

\section{Constructing a likelihood for a simple error model}
The probability of sampling a value $x$ from a normal distribution  is
calculated with:
\begin{equation}\label{eq:normal-distribution}
p\,(\,x\,|\,\mu,\sigma\,) =
\frac{1}{\sqrt{2\pi\sigma^2}}\:
\mathrm{exp}\left[{-\frac{1}{2}
\left(\frac{x-\mu}{\sigma}\right)^2}\right]
\end{equation}
Within the context of calibration, this is equivalent to:
\begin{equation}\label{eq:normal-distribution-calibration}
p\,(\,\hat{x}\,|\,\tilde{x},\sigma\,) =
\frac{1}{\sqrt{2\pi\sigma^2}}\:
\mathrm{exp}\left[{-\frac{1}{2}\left(\frac{\hat{x}-\tilde{x}}{\sigma}\right)^2}\right]
\end{equation}
Note that this assumes that the true mean of the distribution can be observed,
i.e.\,$\tilde{x}=\mu$.

For the case where we have not just 1 observation, but instead have a time
series of $n_o$ observations, the probability
$p\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\boldsymbol\sigma\,)$ is
calculated as the product of all individual probabilities\footnote{Note that
this can be extended to deal with non-constant variance
(\textit{heteroscedasticity}) by making $\sigma$ into a vector
$\boldsymbol\sigma$:
\begin{equation}\label{eq:heteroscedastic-normal-distribution-calibration}
p\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\boldsymbol\sigma\,) =
\prod_{t=1}^{n_o}
\frac{1}{\sqrt{2\pi\sigma_t^2}}\:
\mathrm{exp}\left[{-\frac{1}{2}
\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma_t}\right)^2}\right]\nonumber
\end{equation}}:
\begin{equation}\label{eq:normal-distribution-calibration}
p\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,) = \prod_{t=1}^{n_o}
\frac{1}{\sqrt{2\pi\sigma^2}}\:
\mathrm{exp}\left[{-\frac{1}{2}
\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma}\right)^2}\right]
\end{equation}
Note that the multiplication of individual probabilities in
Eq.~\ref{eq:normal-distribution-calibration} reflects the implicit assumption
that the errors are independent---an assumption that is often violated.

\vspace{1em}
Since $\frac{1}{\sqrt{2\pi\sigma^2}}$ is constant for homoscedastic problems,
Eq.~\ref{eq:normal-distribution-calibration} can be rearranged as follows:
\begin{equation}\label{eq:normal-distribution-calibration2}
p\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,) =
\left[\frac{1}{\sqrt{2\pi\sigma^2}}\right]^{n_o}\:\cdot{}\:
\prod_{t=1}^{n_o}\:\mathrm{exp}\left[{-\frac{1}{2}
\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma}\right)^2}\right]
\end{equation}
and since
\begin{equation}
\left[\frac{1}{\sqrt{2\pi\sigma^2}}\right]^{n_o} =
\left[\sqrt{2\pi\sigma^2}\right]^{-n_o} \nonumber
\end{equation}
Eq.~\ref{eq:normal-distribution-calibration2} can be rewritten as:
\begin{equation}\label{eq:normal-distribution-calibration3}
p\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,) =
\left[\sqrt{2\pi\sigma^2}\right]^{-n_o}\:\cdot{}\:\prod_{t=1}^{n_o}\:
\mathrm{exp}\left[{-\frac{1}{2}
\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma}\right)^2}\right]
\end{equation}
Furthermore,
\begin{equation}
\mathrm{exp}(a)\cdot{}\mathrm{exp}(b)=\mathrm{exp}(a+b)
\end{equation}
so Eq.~\ref{eq:normal-distribution-calibration3} may be written as:
\begin{equation}\label{eq:normal-distribution-calibration4}
p\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,) =
\left[\sqrt{2\pi\sigma^2}\right]^{-n_o}\:\cdot{}\:
\mathrm{exp}\left[-\frac{1}{2}\sum_{t=1}^{n_o}
\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma}\right)^2\right]
\end{equation}
The probability density in Eq.~\ref{eq:normal-distribution-calibration4} is
related to the \textit{log-likelihood} according to\footnote{Note that,
$\hat{\mathbf{x}}$ in Eq.~\ref{eq:log-likelihood1} is only dependent on the
parameter vector  $\boldsymbol\theta$, while the observations
$\tilde{\mathbf{x}}$ and $\sigma$ are given. When a probability is a function of
the parameter value, `likelihood' is preferred over `probability'.}:
\begin{align}\label{eq:log-likelihood1}
\ell\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,) &=
\mathrm{log}\left(\,p\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,)\,\right)\\
&=\mathrm{log}\left(\left[\sqrt{2\pi\sigma^2}\right]^{-n_o}\cdot{}
\mathrm{exp}\left[-\frac{1}{2}\sum_{t=1}^{n_o}
\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma}\right)^2\right]
\right)
\end{align}
and since:
\begin{equation}\label{eq:log-power}
\mathrm{log}\left(a^b\right) = b \cdot \mathrm{log}\left(a\right),
\end{equation}
\begin{equation}\label{eq:log-multiplication}
\mathrm{log}\left(a\cdot{}b\right) = \mathrm{log}\left(a\right) +
\mathrm{log}\left(b\right),
\end{equation}
\begin{equation}
\mathrm{log}\left[\mathrm{exp}\left(a\right)\right] = a,
\end{equation}
Eq.~\ref{eq:log-likelihood1} can be rewritten as:
\begin{equation}\label{eq:log-likelihood2}
\ell\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,) = -n_o \cdot{}
\mathrm{log}\left[\sqrt{2\pi\sigma^2}\right]\:+\:
\left[-\frac{1}{2}\sum_{t=1}^{n_o}
\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma}\right)^2\right]
\end{equation}
Subsequently applying Eqs.~\ref{eq:log-power} and \ref{eq:log-multiplication},
Eq.~\ref{eq:log-likelihood2} can be rewritten as:
\begin{equation}\label{eq:log-likelihood3}
\ell\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}},\sigma\,) =
-\frac{1}{2}n_o\cdot{}\mathrm{log}\left(2\pi\right)\:
-\:\frac{1}{2}n_o\cdot{}\mathrm{log}\left(\sigma^2\right)\:
-\:\frac{1}{2}\sum_{t=1}^{n_o}\left(\frac{\hat{x}_t-\tilde{x}_t}{\sigma}\right)^2
\end{equation}
to yield the Gaussian log-likelihood function with unknown variance $\sigma^2$
of the residuals $\hat{x}_t-\tilde{x}_y$. For many measuring devices, $\sigma^2$
is either known or can be determined by simple tests. If necessary, $\sigma^2$
can also be estimated from the observations themselves according to:
\begin{equation}\label{eq:variance-estimator}
s^2 = \frac{1}{n_o-1}\sum_{t=1}^{n_o}\left(\hat{x}_t-\tilde{x}_t\right)^2
\end{equation}
\begin{equation}\label{eq:log-likelihood4}
\ell\,(\,\hat{\mathbf{x}}\,|\,\tilde{\mathbf{x}}\,) =
-\frac{1}{2}n_o\cdot{}\mathrm{log}\left(2\pi\right)\:
-\:\frac{1}{2}n_o\cdot{}\mathrm{log}\left(s^2\right)\:
-\:\frac{1}{2}\sum_{t=1}^{n_o}\left(\frac{\hat{x}_t-\tilde{x}_t}{s}\right)^2
\end{equation}


\chapter{CT Fourier Series}

Recall the complex exponential $e^{st}$ for $s\in\mathbb{C}$ is the Eigenfunction of CT LTI systems. If we can decompose an input into a (possibly infinite) sum of such signals, we can easily determine the output using the superposition principle. In this section we consider the decomposition when the input is periodic, called the CT \emph{Fourier Series} (CTFS).

Recall a signal $x(t)$ is periodic, with fundamental frequency $\omega_0 = \frac{2\pi}{T_0}$ rad/sec or $f_0 = \frac{1}{T_0}$ Hertz, if $x(t) = x(t+kT_0)$ for integer multiple $k$ and fundamental period $T_0\in \mathbb{R}$. As we shall see, in this case the complex exponent of the Eigenfunction becomes $s_k = jk\omega_0$, and the decomposition is a countably infinite sum. This gives the input-output relationship for a stable LTI system as
\[
x(t) = \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t} \; \longrightarrow\; y(t) = \sum\limits_{k = -\infty}^{\infty} H(j k\omega_0)\, a_k \, e^{j k\omega_0 t}
\]
where $H(j k\omega_0)$ are the Eigenvalues or frequency response. We now turn to determining under what circumstances the decomposition exists and how to find the coefficients $a_k$.

\section{Synthesis and Analysis Equation}

Suppose we can approximate (we will revisit shortly when this approximation is exact) the periodic function $x(t)$ by the sum
\[
\boxed{x(t) \approx \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t}\;.}
\]
This is called the \emph{synthesis equation} of the CT Fourier series.

Assuming equivalence, let us multiply both sides by the function $e^{-jn\omega_0 t}$,
\[
x(t)e^{-jn\omega_0 t} = \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t}e^{-jn\omega_0 t}
\]
and integrate over one period
\[
\int\limits_{0}^{T_0} x(t)e^{-jn\omega_0 t} \; dt = \int\limits_{0}^{T_0} \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t}e^{-jn\omega_0 t} \; dt
\]
Exchanging the order of integration and summation in the right-hand expression gives
\[
\int\limits_{0}^{T_0} x(t)e^{-jn\omega_0 t} \; dt = \sum\limits_{k = -\infty}^{\infty} a_k \left[ \int\limits_{0}^{T_0} \, e^{j k\omega_0 t}e^{-jn\omega_0 t} \; dt\right]
\]
The bracketed term can be rewritten as
\[
\int\limits_{0}^{T_0} \, e^{j k\omega_0 t}e^{-jn\omega_0 t} \; dt = \int\limits_{0}^{T_0} \, e^{j (k-n)\omega_0 t} \; dt = \int\limits_{0}^{T_0} \cos((k-n)\omega_0 t) \; dt + j \int\limits_{0}^{T_0} \sin((k-n)\omega_0 t) \; dt
\]
We now note that for $k\neq n$ the integrals of the real and imaginary parts are zero
\[
\int\limits_{0}^{T_0} \cos((k-n)\omega_0 t) \; dt = \frac{1}{(k-n)\omega_0}\sin((k-n)\omega_0 t) \Big|_{0}^{T_0} = \frac{1}{(k-n)\omega_0}\sin((k-n)2\pi) - \frac{1}{(k-n)\omega_0}\sin(0) = 0
\]
\[
\int\limits_{0}^{T_0} \sin((k-n)\omega_0 t) \; dt = -\frac{1}{(k-n)\omega_0}\cos((k-n)\omega_0 t) \Big|_{0}^{T_0} = -\frac{1}{(k-n)\omega_0}\cos((k-n)2\pi) + \frac{1}{(k-n)\omega_0}\cos(0) = 0
\]
When $k=n$
\[
\int\limits_{0}^{T_0} e^{j (k-n)\omega_0 t} \; dt = \int\limits_{0}^{T_0} \; dt = T_0
\]
Thus the bracketed term above is
\[
\int\limits_{0}^{T_0} \, e^{j k\omega_0 t}e^{-jn\omega_0 t} \; dt = T_0\, \delta[k-n]
\]
and the right-hand side is
\[
\sum\limits_{k = -\infty}^{\infty} a_k \left[ \int\limits_{0}^{T_0} \, e^{j k\omega_0 t}e^{-jn\omega_0 t} \; dt\right] = \sum\limits_{k = -\infty}^{\infty} a_k  T_0\, \delta[k-n] = T_0 \,a_n
\]
Thus we obtain the \emph{analysis equation} of the CT Fourier series:
\[
\boxed{a_n = \frac{1}{T_0} \int\limits_{0}^{T_0} x(t)e^{-jn\omega_0 t} \; dt}
\]
where the integration can be over any interval of length $T_0$ and the symbol for the subscript (integer $n$) is arbitrary. The CT Fourier Series coefficients are also called the \emph{spectrum} of the signal. In general the $a_k$ are complex. The function of $k$, $|a_k|$ is called the \emph{amplitude spectrum}. The function of $k$, $\angle a_k$ is called the \emph{phase spectrum}. When plotting the coefficients it is common to plot the amplitude and phase spectrum together.

\begin{example}
  Consider the signal
  \[
  x_p(t) = \left\{ \begin{array}{lc}
    t^2 & -1 < t < 1\\
    0 & \mbox{else}
  \end{array}
\right.
\]
periodically extended with period $T_0 = 2$
\[
x(t) = \sum\limits_{i = -\infty}^{\infty} x_p(t - 2i)
\]
as shown below:
\begin{center}
  \includegraphics[scale=1]{graphics/ctfs-example1.pdf}
\end{center}
To find the Fourier Series approximation of $x(t)$,
\[
x(t) \approx \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t}\; ,
\]
we need to find the coefficients
\[
a_k = \frac{1}{T_0} \int\limits_{0}^{T_0} x(t)e^{-jk\omega_0 t} \; dt
\]
Since the integration can be over any period, we can use the limits $[-1,1]$ and note that $T_0 = 2$ so that $\omega_0 = \pi$, giving the sequence of expressions
\begin{align*}
  a_k &= \frac{1}{2} \int\limits_{-1}^{1} t^2\,e^{-jk\pi t} \; dt\\
  &= \frac{1}{2} \left[ \int\limits_{-1}^{1} t^2\,\cos(-k\pi t) \; dt + j \int\limits_{-1}^{1} t^2\,\sin(-k\pi t) \; dt \right]\\
  &= \frac{1}{2} \left[ \int\limits_{-1}^{1} t^2\,\cos(k\pi t) \; dt + j \int\limits_{-1}^{1} - t^2\,\underbrace{\sin(k\pi t)}_{\text{always = 0}} \; dt \right]\\
  &= \frac{1}{2} \int\limits_{-1}^{1} t^2\,\cos(k\pi t) \; dt\; \mbox{ using an integration table }\\
  &= \frac{1}{2} \frac{4k\pi\overbrace{\cos(k\pi)}^{(-1)^k} + 2(k^2\pi^2-2)\overbrace{\sin(k\pi)}^{\text{always = 0}}}{k^3\pi^3}\\
 a_k &= \frac{2}{k^2\pi^2}\left(-1\right)^k
\end{align*}
This result is undefined for when $k=0$. In that case note the original integral is
\[
a_0 = \frac{1}{2} \int\limits_{-1}^{1} t^2 \; dt = \frac{1}{6}t^3 \Big|_{-1}^{1} = \frac{1}{3}
\]
Thus the final approximation is
\[
x(t) \approx \sum\limits_{k = -\infty}^{\infty} \underbrace{\frac{2}{k^2\pi^2}\left(-1\right)^k}_{a_k} \, e^{j k\pi t} \;.
\]
We can plot the spectrum of this signal (using for example Matlab)
\begin{verbatim}
k = -10:10;
a = 2./(pi^2*k.^2);
a(11) = 1/3;

subplot(2,1,1);
stem(k, abs(a));
xlabel('k');
ylabel('|a(k)|');
title('Amplitude Spectrum');

subplot(2,1,2);
stem(k, angle(a));
xlabel('k');
ylabel('Angle a(k)');
title('Phase Spectrum');
\end{verbatim}
Giving the amplitude and phase spectrum plot
\begin{center}
\includegraphics[scale=0.7]{graphics/ctfs_exampleplot.png}
\end{center}
$\blacksquare$
\end{example}

\section{Variations on the Synthesis and Analysis Equations}
There are two commonly used, equivalent, expressions for computing the CTFS coefficients. They can be derived using Euler's formula and related trig identities.

\begin{itemize}
\item Exponential Form. This is the form derived above
  \[
  x(t) = \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t}
  \]
  where
  \[
  a_k = \frac{1}{T_0} \int\limits_{T_0} x(t)e^{-jk\omega_0 t} \; dt
  \]
\item Trig Form
  \[
  x(t) = b_0 + \sum\limits_{k = 1}^{\infty} b_k \,\cos(k\omega_0 t) + c_k\,\sin(k\omega_0 t)
  \]
  where
  \[
  b_0 = \frac{1}{T_0} \int\limits_{T_0} x(t) \; dt
  \]
  is the average value of the signal, and
  \[
  b_k = \frac{2}{T_0} \int\limits_{T_0} x(t)\cos(k\omega_0 t) \; dt
  \]
  \[
  c_k = \frac{2}{T_0} \int\limits_{T_0} x(t)\sin(k\omega_0 t) \; dt
  \]
\item Compact Trig Form
  \[
  x(t) = d_0 + \sum\limits_{k = 1}^{\infty} d_k \,\cos(k\omega_0 t + \theta_k)
  \]
  where
  \[
  d_0 = \frac{1}{T_0} \int\limits_{T_0} x(t) \; dt
  \]
  is the average value of the signal, and
  \[
  d_k = \sqrt{b_k^2 + c_k^2}
  \]
  \[
  \theta_k = \arctan\left( \frac{-c_k}{b_k} \right)
  \]
\end{itemize}

\section{Convergence of the CT Fourier Series}

As mentioned above the Fourier Series is strictly speaking an approximation
\[
x(t) \approx \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t} \mbox{ where } a_k = \frac{1}{T_0} \int\limits_{T_0} x(t)e^{-jk\omega_0 t} \; dt
\]
to determine when this approximation is an equivalence (and in what sense) we need to establish the existence and convergence of the integral and summation respectively.

The coefficients $a_k$ will exist when the integral converges, or equivalently when
\[
\int\limits_{T_0} \left|x(t)\right| \; dt < \infty
\]
i.e. the signal is absolutely integrable over any period. Note, such a signal is a power signal.

To determine when the summation converges, first consider the \emph{truncated} CT Fourier Series
\[
x_N(t) \approx \sum\limits_{k = -N}^{N} a_k \, e^{j k\omega_0 t}
\]
where the infinite sum has been truncated to the finite range $[-N,N]$. Define the error between the original signal $x(t)$ and the truncated approximation $x_N(t)$ at each time point as
\[
E(N,t) = x(t) - x_N(t)
\]
There are two relevant notions of convergence. If
\[
\lim_{N\rightarrow \infty} \int\limits_{T_0} \left| E(N,t] \right|\;dt = 0
\]
we say the CT Fourier Series converges \emph{exactly} to the signal. If
\[
\lim_{N\rightarrow \infty} \int\limits_{T_0} \left| E(N,t) \right|^2\;dt = 0
\]
we say the CT Fourier Series converges in the \emph{mean-square} sense to the signal.

More formally the CTFS exists if the \emph{Dirichlet Conditions} hold for the signal:

\begin{itemize}
\item The signal has a finite number of discontinuities per period.
\item The signal has a finite number of maxima and minima per period.
\item The signal is bounded, i.e.
  \[
  \int_{T_0} |x(t)| \;dt < \infty
  \]
\end{itemize}

These conditions rule out pathological functions. For most practical signals of interest, the conditions hold.

\begin{example}
  Consider the \emph{impulse train} signal defined as
  \[
  x(t) = \sum\limits_{m = -\infty}^{\infty} \delta(t-mT_0)
  \]
  which we be important later when we discuss sampling CT signals. Do the Dirichlet conditions hold? Yes. It has one discontinuity, one maximum, and one minimum per period. It is also bounded since
  \[
  \int_{T_0} |\delta(t)| \;dt = 1 \mbox{ by definition.}
  \]
  The spectrum for the impulse train is given by
  \[
  a_k = \frac{1}{T_0} \int\limits_{T_0} x(t)e^{-jk\omega_0 t} \; dt =  \frac{1}{T_0} \int\limits_{-\frac{T_0}{2}}^{\frac{T_0}{2}} \delta(t)e^{-jk\omega_0 t} \; dt = \frac{1}{T_0}
  \]
  $\blacksquare$
\end{example}

\begin{example}
  Consider the signal $x(t) = \cos(\omega t)$. We can write this as the sum of two complex exponentials using Euler's formula
  \[
  x(t) = \frac{1}{2}e^{j\omega t} + \frac{1}{2}e^{-j\omega t}
  \]
  Comparing this to the synthesis equation
  \[
  x(t) = \sum\limits_{k = -\infty}^{\infty} a_k \, e^{j k\omega_0 t} = \cdots + a_{-2} \, e^{j (-2)\omega_0 t} + a_{-1} \, e^{j (-1)\omega_0 t} + a_0 + a_{1} \, e^{j (1)\omega_0 t} + a_{2} \, e^{j (2)\omega_0 t} + \cdots
  \]
  we note that if $\omega_0 = \omega$ and
  \[
  a_k = \left\{ \begin{array}{lc}
    \tfrac{1}{2} & k = -1\\[0.5em]
    \tfrac{1}{2} & k = 1\\[0.5em]
    0 & \text{else}
  \end{array}
  \right.
  \]
  then the two expressions are identical and the CT Fourier Series is an exact representation.\\
  $\blacksquare$
\end{example}

\begin{example}
  Consider the square wave signal of amplitude $A > 0$
  \[
  x(t) = \sum\limits_{m= -\infty}^{\infty} \left\{ \begin{array}{lc}
    -A & \tfrac{T_0}{2} < t-mT_0 < 0\\[0.5em]
    A & 0 < t - mT_0 < \tfrac{T_0}{2}
  \end{array}
  \right.
  \]
  shown below
  \begin{center}
  \includegraphics[scale=1]{graphics/squarewave.pdf}
  \end{center}
  The coefficients are given by
  \begin{align*}
    a_k &= \frac{1}{T_0} \int\limits_{T_0} x(t)e^{-jk\omega_0 t} \; dt\\
    &= \frac{1}{T_0} \left[ \int\limits_{0}^{\frac{T_0}{2}} Ae^{-jk\omega_0 t} \; dt + \int\limits_{\frac{T_0}{2}}^{T_0} -Ae^{-jk\omega_0 t} \; dt\right]\\
    &= \frac{1}{T_0} \left[ \frac{A}{-jk\omega_0}e^{-jk\omega_0 t} \Big|_{0}^{\frac{T_0}{2}} + \frac{-A}{-jk\omega_0}e^{-jk\omega_0 t} \Big|_{\frac{T_0}{2}}^{T_0}\right]\\
    &= \frac{1}{T_0} \frac{A}{jk\omega_0} \left[ -\left(e^{-jk\omega_0 \frac{T_0}{2}} - e^{0}\right) + \left(e^{-jk\omega_0 T_0} - e^{-jk\omega_0 \frac{T_0}{2}}\right)\right]
  \end{align*}
  Note that $\omega_0\frac{T_0}{2} = \frac{2\pi}{T_0}\frac{T_0}{2}= \pi$ and $\omega_0 T_0 = \frac{2\pi}{T_0}T_0 = 2\pi$ . Thus
  \begin{align*}
    a_k &= \frac{1}{T_0} \frac{A}{jk\frac{2\pi}{T_0}} \left[ -\left(e^{-jk\pi} - e^{0}\right) + \left(e^{-jk2\pi} - e^{-jk\pi}\right)\right]\\
    &= \frac{A}{jk\pi}\left( 1-e^{-jk\pi}\right) \\
    &= \left\{ \begin{array}{lc}
      0 & k \mbox{ even}\\
      \frac{2A}{jk\pi} & k \mbox{ odd}
    \end{array}
\right.
  \end{align*}
  The amplitude spectrum is given by
  \[
  |a_k| = \left\{ \begin{array}{lc}
    0 & k \mbox{ even}\\
    \left|\frac{2A}{k\pi}\right| & k \mbox{ odd}\end{array}\right.
  \]

  The phase spectrum is given by
  \[
  \angle a_k = \left\{ \begin{array}{lc}
    \pi & k < 0 \mbox{ and even}\\
    -\pi & k > 0 \mbox{ and even}\\
    \frac{\pi}{2} & k < 0 \mbox{ and odd}\\
    -\frac{\pi}{2} & k > 0 \mbox{ and odd}\end{array}\right.
  \]
  This is plotted below for $A = 1$.
  \begin{center}
    \includegraphics[scale=0.7]{graphics/ctfs_exampleplot2.png}
  \end{center}
  We can plot the truncated approximation for increasing number of terms N, the squared error, and the total error.
  \begin{center}
    \includegraphics[scale=0.5]{graphics/squarewaveapprox1.png}
  \end{center}
  \begin{center}
    \includegraphics[scale=0.5]{graphics/squarewaveapprox2.png}
  \end{center}
  \begin{center}
    \includegraphics[scale=0.5]{graphics/squarewaveapprox3.png}
  \end{center}
  Note as $N$ increases the approximation gets closer to the square wave, except at the discontinuities. This is called \emph{Gibbs Ringing}. As $N \rightarrow \infty$ the mean-square error goes to zero, so the CTFS approximation to the square wave converges in the mean-square sense.
  $\blacksquare$
\end{example}

\section{Properties of the CT Fourier Series}

Let $a_k$ and $b_k$ be the CTFS coefficients for the periodic signals $x(t)$ and $y(t)$ respectively.

\begin{itemize}
\item Linearity. The coefficients of the signal
  \[
  z(t) = Ax(t) + By(t) \mbox{ for constants } A,B
  \]
  are $Aa_k + Bb_k$
\item Time Shifting. The coefficients of
  \[
  z(t) = x(t-t_0) \mbox{ are } e^{-jk\omega_0 t_0}a_k
  \]
  that is it adds a phase shift.
\item Time reversal. The coefficients of
  \[
  z(t) = x(-t) \mbox{ are } a_{-k}
  \]
  that is the sequence reverses.
\item Time Scaling. Let $T_0$ and $\omega_0$ be the fundamental period and frequency of a periodic $x(t)$. The signal
  \[
  z(t) = x(\alpha t) \mbox{ for } \alpha > 0
  \]
  is periodic with period $\frac{T_0}{\alpha}$ and fundamental frequency $\alpha\omega_0$.
  The coefficients of $z(t)$ are the same as $x(t)$.
\item Multiplication. The coefficients of
  \[
  z(t) = x(t) \cdot y(t) \mbox{ are } \sum\limits_{m = -\infty}^{\infty} a_m\cdot b_{k-m}
  \]
  the discrete convolution of the individual signals' coefficients.
\item Conjugate Symmetry. The coefficients of
  \[
  z(t) = x^*(t) = \Re{x(t)} - j\Im{x(t)} \mbox{ are } a_{-k}^*
  \]
  A consequence of this property is that real, even signals have real, even $a_k$; and real, odd signals have purely imaginary, odd $a_k$ (check the examples above).
\item Parseval's Relation. The power of the signal with Fourier series coefficients
  \[
  \frac{1}{T_0} \int_{T_0} |x(t)|^2\;dt = \sum\limits_{k = -\infty}^{\infty} |a_k|^2
  \]
\end{itemize}


\newpage
\section{Relationship between SVM and Logistic Regression}
In this section, we will briefly discuss SVM and the relation with logistic regression for binary case.
We start it with the induction of SVM, we consider the following practical problem: Given a collection of labelled data, determine whether the
classes are linearly separable. If so, we would like to obtain a hyperplane or matrix which separates them, and, ideally
we would want to find the separation which has the largest possible margin. The support vector machine (SVM) model solves this
problem via convex optimization.

Support vector machines are linear models for classifying data,
similar to the logistic regression. In particular, the support vector
machine model is essentially just a regularized logistic regression.

\subsection{2-class case}

We will now show that if the sets $A_1$ and $A_2$ are two compact and
linearly separable sets, then we can obtain a `margin' for this linear
separation.

\begin{definition}\label{margin_two_class}
	Suppose two sets $A_1, A_2$ are separated by a hyperplane
	$H=\{x:wx+b=0\}$. The margin of separation with respect to $d$ is
	given by
	\begin{equation}
	m(w,b; A_1, A_2) = \sup \{\epsilon:\text{$wx+b>0$ if $x\in A^{\epsilon}_1$ and $wx+b<0$ if $x\in A^\epsilon_2$}\}
	\end{equation}
	where the $\epsilon$-enlargement of $A_i$ is given by
	\begin{equation}
	A^\epsilon_i = \{y:\text{there is an $x\in A_i$ such that $\|x-y\| < \epsilon$}\}
	\end{equation}
\end{definition}

What this definition is saying is that the margin is the largest amount that we can perturb an element of $A_i$
such that the plane $H$ still classifies it correctly.
We have the following technical result, showing that the margin is always positive if the sets $A_1$ and $A_2$ are
compact (this result can safely be skipped by most readers).

\begin{lemma}
	Suppose that two sets $A_1, A_2$ are separated by a hyperplane
	$H=\{x:wx+b=0\}$ and that $A_1$ and $A_2$ are compact.
	\begin{equation}
	m(w,b; A_1, A_2) > 0
	\end{equation}

\end{lemma}

\subsection{2-class Hard-margin Case}
We first consider the simplest case where there are only two classes. Let $A_1$ denote the set of data points belonging to the
first class and $A_2$ the set of data points belonging to the second class.

Since we have a finite amount of data for each class, the sets $A_1$ and $A_2$ are compact. This means that if the sets are
separable, say they are separated by $H=\{x:Wx+b=0\}$, then there exists a finite margin, i.e. there exists an $\epsilon > 0$
such that $(Wx+b)_1\cdot(Wx+b)_2\leq -\epsilon^2/4$ and
\begin{equation}
(Wx+b)_1 - (Wx+b)_2  \begin{cases}
\geq \epsilon & x\in A_1 \\
\leq -\epsilon & x\in A_2 \\
\end{cases}
\end{equation}
Rescaling $w$ and $b$ by $2\epsilon^{-1}$, we may thus assume that $(Wx+b)_1\cdot(Wx+b)_2\leq -1$ and
\begin{equation}
(Wx+b)_1 - (Wx+b)_2 \begin{cases}
\geq 2 & x\in A_1 \\
\leq -2 & x\in A_2 \\
\end{cases}
\end{equation}
Indexing our data points $x_1,...,x_N$ and introducing labels $y_1,...,y_N$, where
\begin{equation}
y_i = \begin{cases}
e_1 & x\in A_1 \\
e_2 & x\in A_2 \\
\end{cases}
\end{equation}
this can be more succinctly written as
\begin{equation}\label{separation_condition_2}
(y_i - e_j)\cdot (Wx_i+b) \geq \|y_i - e_j\|_1
\end{equation}
for all $i = 1,...,N$.

One important thing to note is that the above equation represents a convex constraint on $W\in \mathbb{R}^{2\times n}$ and
$b\in \mathbb{R}^2$. In particular, for each data point $x_i$, this condition is a linear constraint on $w$ and $b$, thus
condition (\ref{separation_condition_2}) is a finite intersection of linear constraints on $w$ and $b$. This means that
we can determine whether the sets are linearly separable by checking whether a linear program is feasible.

Of course, if the sets are separable, we would like to find the hyperplane which maximizes the margin, as defined in
Definition \ref{margin_two_class}. To this end, we have the following lemma.
\begin{lemma}
	Assume that $A_1$ and $A_2$ are linearly separated by the matrix $W=
	\begin{pmatrix}
	w_1\\
	w_2
	\end{pmatrix}
	\in \mathbb{R}^{2\times d},
	b\in
	\mathbb{R}^2 $, i.e $A_1$ and $A_2$ can be separated by the hyperplane $H=\{x:(w_1-w_2)x+(b_1-b_2)=0\}$, such that (\ref{separation_condition_2})
	holds.
	Then the margin satifies
	\begin{equation}
	m(W,b;A_1,A_2)\geq \frac{1}{\|w_1-w_2\|}
	\end{equation}
	Moreover, we have equality iff there exists an $x_1\in A_1$ and
	an $x_2\in A_2$ such that $|(w_1-w_2)x_1+(b_1-b_2)| = 1$ and $|(w_1-w_2)x_2+(b_1-b_2)| = 1$.

\end{lemma}

\begin{proof}
	For $\forall x_i \in A_i, i=1,2$,
	\begin{align}
	d(A_i, H)\ge d(x_i, H)=\frac{|(w_1-w_2)x+(b_1-b_2)|}{\|w_1-w_2\|}\ge \frac{1}{\|w_1-w_2\|}.
	\end{align}
	So by the definition,
	\begin{equation}
	m(H,A_1,A_2)\geq \frac{1}{\|w_1-w_2\|}
	\end{equation}
	The equality holds iff $d(A_1, H)= d(A_2, H)=\frac{1}{\|w_1-w_2\|}.$ The equation holds iff there exists an $x_1\in A_1$ and
	an $x_2\in A_2$ such that $|(w_1-w_2)x_1+(b_1-b_2)| = 1$ and $|(w_1-w_2)x_2+(b_1-b_2)| = 1$.
\end{proof}

Since maximizing the margin $\|w_1-w_2\|^{-1}$ is the same as minimizing $\|w_1-w_2\|$. Denoting $w_1-w_2$ as $w$, $b_1-b_2$ as $b$, we can obtain the following  convex optimization problem
\begin{align}\label{2class_hard_op}
\min_{w,~b~}~~&\|w\|,\\
s.t.~~&wx+b \geq 2, \forall x\in A_1,\\
&wx+b \leq -2, \forall x \in A_2.
\end{align}

\begin{figure}
	\centering
	\includegraphics[width=3.0in]{./figures/margin.png}
	\caption{margin}
	\label{margin}
\end{figure}

\blankpage
\newbreak
\subsection{Relation between SVM and LR}
The SVM presented above can also be formulated as
\begin{equation}\label{key}
\bm \theta^*_{\rm SVM} = \mathop{\arg\max}_{\bm \theta \in \Theta} \min_{1\le i\le 2} {\rm dist}(H_{\bm \theta}, A_i),
\end{equation}
with $H_{\bm \theta} = \{ wx + b = 0 \}$.

Then ,for logistic regression, we first generalize the regularization term $R(\|\bm \theta\|)$ just as $R(\bm \theta)$ and specifically
\begin{equation}\label{key}
R(\bm \theta) = \|w\| := \sqrt{\sum_{ij} w_{ij}},
\end{equation}
for $\bm \theta = (w,b)$.
Then, let us denote
\begin{equation}\label{key}
\bm\theta_{\rm LR}(\lambda) = (w_{\rm LR}(\lambda),b_{\rm LR}(\lambda)) = \mathop{\arg\min}_{\theta} L_\lambda(\bm \theta),
\end{equation}
as one of the solution of LR when we choose $\lambda R(\bm \theta) = \lambda \|w\|$ as regularization term.
Here, we only care the direction of the parameter because the direction has already determined the separating hyperplane and the value of hard margin.
The following theorem tell us that the LR solution will converge to a SVM solution in direction as $\lambda$ tends to 0 when data ia linearly separable.
\begin{theorem}
	Suppose that $A_1$ and $A_2$ are linearly separable, given $\theta_\lambda = (w_\lambda,b_\lambda)\in \theta_{LR}(\lambda)$  for any $\lambda>0$, if $\frac{\bm\theta_\lambda}{\|w_\lambda\|}$ converges, it must convergers to normalized SVM solition, i.e.
	\begin{equation}\label{key}
	\frac{\theta^*_{\rm SVM}}{\|w^*_{SVM}\|}  = \lim_{\lambda \to 0} \frac{\bm\theta_\lambda}{\|w_\lambda\|}.
	\end{equation}
\end{theorem}

\endinput

\begin{comment}
A very common choice of metric $d$ is the Euclidean metric,
corresponding the $2$-norm $\|\cdot\|_2$. In this case the dual norm
$\|\cdot\|$ is the same. Another reasonable choice could be the
$p$-norm $\|\cdot\|_p$, for $1\leq p\leq \infty$, on $\mathbb{R}^n$.
In this case the dual norm becomes $\|\cdot\|_{p^*}$ where $p^{-1} +
(p^*)^{-1} = 1$.
\end{comment}

\subsection{2-class soft-margin case}

Of course, the following question arises: What should we do if the data is not linearly separable? A possible approach here is to
replace the hard constraint (\ref{separation_condition_2}) by a penalty term. This is often called a soft-margin SVM,
as opposed to the hard constraint, which is called a hard-margin SVM.

A common choice of penalty is the hinge, or ReLU penalty, which only penalizes when each of the constraints
in (\ref{separation_condition_2}) is violated. The resulting optimization problem takes the following form:
\begin{equation}
\min_{W,~b} \|w_1-w_2\| + C\displaystyle\sum_{i=1}^N \text{RuLU}\Big(\|y_i - e_j\|_1- (y_i - e_j)\cdot (Wx_i+b) \Big)
\end{equation}
where $C$ is a parameter controlling how much the penalty term is weighted.


\section{The Lorentz Group}
\begin{frame}{The Lorentz Transformations}
	\begin{align*}
		x^\mu =
		\begin{pmatrix}
			t \\
			\vec x
		\end{pmatrix}
		\qquad
		x_{\mu} =
		g_{\mu\nu} x^{\nu}
		=
		\begin{pmatrix}
			t \\
			-\vec x
		\end{pmatrix}
		\qquad
		g_{\mu\nu}
		= \symup{diag}(1, -1, -1, -1)
		\qquad
		\symup{c} = 1
	\end{align*}
	Lorentz-Transformations are \emph{all} transformations $x_\mu\rightarrow x'_\mu$, which leave the spacetime distance
	\begin{align}
		\label{eqn:s2}
		s^2 = \l(x_2-x_1\r)_\mu\l(x_2-x_2\r)^\mu=(t_2-t_1)^2-(\vec x_2 - \vec x_1)^2
	\end{align}
	invariant.
	It is easy to see, that these transformations must be affine tranformations:
	\begin{align}
		\label{eqn:trans}
		x'^\mu = L(\Lambda, a; x)^\mu = \Lambda^\mu_{\ \nu}x^\nu + a^\mu
	\end{align}
	\eqref{eqn:s2} into \eqref{eqn:trans}:
	\begin{align*}
		a^\mu \in \symbb{R} \qquad g_{\alpha \beta} = g_{\mu\nu} \Lambda^\mu_{\ \alpha}\Lambda^\nu_{\ \beta}
	\end{align*}
\end{frame}
\begin{frame}{The Group Axioms}
	Lorentz Transformations fulfill the group axioms $\rightarrow$ Poincaré  or inhomogeneous Lorentz Group (LG)

	\centering
	\begin{tabular}{l l l}
		1. & $L(\Lambda, a)\circ L(\Lambda', a') \in \mathcal L$ & $L\l(\Lambda, a; L(\Lambda', a'; x)\r) = L(\Lambda\Lambda', \Lambda a'+a; x)$                                                      \\
		2. & Associativity:                                      & $\l(L(\Lambda, a)\circ L(\Lambda', a')\r)\circ L(\Lambda'', a'')= L(\Lambda, a)\circ \l(L(\Lambda', a')\circ L(\Lambda'', a'')\r)$ \\
		3. & Identity:                                           & $L(\symbb{1}_4, \vec 0; x) = x$                                                                                \\
		4. & Inverse:                                            & $L(\Lambda, a)^{-1}=L(\Lambda^{-1}, -\Lambda^{-1}a)$
	\end{tabular}

\end{frame}
\begin{frame}
	\frametitle{The Group Structure}

	\begin{tabular}{l l l}
		Inhomogeneous LG             & $L(\Lambda, a)$                                                                             & Unconnected          \\
		$\rightarrow$Space Inversion & $L(P, 0) = L(\symup{diag}(1, -1, -1, -1), 0)$                                               &                      \\
		$\rightarrow$Time Reversal   & $L(T, 0) = L(\symup{diag}(-1, 1, 1, 1), 0)$                                                 &                      \\
		Homogeneous LG               & $L(\Lambda, 0)$                                                                             & Unconnected subgroup \\
		Translations                 & $L(0, a)$                                                                                & Connected subgroup   \\
		Rotations                    & $L(\symbf R_4, 0) =  L\l(\begin{pmatrix}
					1      & \vec 0^{\symup{T}}     \\
					\vec 0 & \symbf{R(\vec \alpha)}
		\end{pmatrix} , 0\r)\quad \symbf{R} \in \symup{SO(3)}$ & \vspace{1em}Connected subgroup   \\
		Boosts                       & $L(\symbf B, 0) = L\l(
			\begin{pmatrix}
					\gamma         & -\gamma \vec v^{\symup{T}}                                      \\
					-\gamma \vec v & \symbb{1} + \vec v \vec v^{\symup{T}} \frac{\gamma-1}{\vec v^2}
				\end{pmatrix}
		, 0\r)$                      & Connected subgroup                                                                                \\
		Restricted LG                & $L(\symbf R_4, 0) \cup L(\symbf B, 0)$                                                      & Connected subgroup
	\end{tabular}
\end{frame}
\begin{frame}
	\frametitle{The Lie-Algebra of the restricted LG}
	Transformations close to unity:
	\begin{align*}
		\Lambda^{\mu}_{\ \nu} = \delta^{\mu}_{\ \nu} + \omega^{\mu}_{\ \nu}
	\end{align*}
	$\omega^{\mu}_{\ \nu}$ is infinitesimal.
	\begin{align*}
		\Rightarrow g_{\alpha \beta} = g_{\mu\nu} \l(\delta^{\mu}_{\ \alpha} + \omega^{\mu}_{\ \alpha}\r)\l(\delta^{\nu}_{\ \beta} + \omega^{\nu}_{\ \beta}\r)
		= g_{\alpha\beta}+\omega_{\alpha\beta}+\omega_{\beta\alpha}+\symcal O (\omega^2) \Rightarrow  \omega_{\alpha\beta}= -\omega_{\beta\alpha}
	\end{align*}
	\pause
	Let $\symbf M(\Lambda)$ be a representation of the restricted LG: $\symbf M(\Lambda)\symbf M(\Lambda')=\symbf M(\Lambda\Lambda')$
	\begin{align*}
		\symbf M (1+\omega) = \symbf 1 + \frac{1}{2} i\omega_{\mu\nu} \symbf J^{\mu\nu} + \symcal O (\omega^2)
	\end{align*}
	Choose $\symbf J^{\mu\nu}=-\symbf J^{\nu\mu}$
	\begin{align*}
		\symup M(\Lambda)\symup M(1+\omega)\symup M(\Lambda)^{-1}
		= \symup M(\Lambda (1+\omega)\Lambda^{-1}) \\
		\dots \Rightarrow i[\symbf J^{\mu\nu}, \symbf J^{\rho\sigma}] = g^{\nu\rho}\symbf J^{\mu\sigma} - g^{\mu\rho} \symbf J^{\nu\sigma} - g^{\sigma\mu} \symbf J^{\rho\nu} + g^{\sigma\nu} \symbf J^{\rho\mu}
	\end{align*}
\end{frame}
\begin{frame}
	\frametitle{Representation of the restricted LG}
	Since $\symbf J^{\mu\nu}= -\symbf J^{\nu\mu}$, it has 6 independent components. We choose:
	\begin{align*}
		\symbf{\vec J} = (\symbf J^{23},\symbf J^{31},\symbf J^{12}) & \qquad \symbf{\vec K} = (\symbf J^{01},\symbf J^{02},\symbf J^{03}) \\
		\Rightarrow [\symbf J_i,\symbf J_j]                          & = i \epsilon_{ijk} \symbf J_k                                       \\
		\Rightarrow [\symbf J_i,\symbf K_j]                          & = i \epsilon_{ijk} \symbf K_k                                       \\
		\Rightarrow [\symbf K_i,\symbf K_j]                          & = -i \epsilon_{ijk} \symbf K_k
	\end{align*}
	\pause
	\begin{align*}
		\symbf{\vec A}^\pm              & = \frac{1}{2}\l(\symbf{\vec J} \pm i\symbf{\vec K}\r) \\
		[\symbf A^\pm_i,\symbf A^\pm_j] & = i \epsilon_{ijk} \symbf A^\pm_k                     \\
		[\symbf A^\pm_i,\symbf A^\mp_j] & = 0
	\end{align*}
\end{frame}
\begin{frame}
	\frametitle{$(A, B)$ representation of the restricted LG}
	The restricted Lorentz group can be written as  $L = \symup{SO}(3)_l \oplus \symup{SO}(3)_r$.
	\\We find matrices satisfying the $\symbf{\vec A}^\pm$ algebra with the standard spin matrices:
	\begin{align*}
		\l(\symbf{A_3}^+\r)_{aa'}                   & = a \delta_{aa'}                               \\
		\l(\symbf{A_1}^+\pm i\symbf{A_2}^+\r)_{aa'} & = \delta_{a',a\pm1} \sqrt{(A\mp a)(A\pm a +1)} \\
		a                                           & = -A, -A+1, \dots, +A
	\end{align*}
	Likewise for $\symbf{\vec A}^-$ only with $B$ and $b$ $\Rightarrow\ (A, B)$ representation of the restricted Lorentz group
	\pause
	Since $\symbf{\vec J}=\symbf{\vec A}^++\symbf{\vec A}^-$, Fields transforming under the $(A, B)$ representation have components with spin
	\begin{align*}
		j = A+B, A+B-1, \dots, \abs{A-B}
	\end{align*}
\end{frame}
\begin{frame}
	\frametitle{Examples of representations}
	\begin{tabular}{l l l}
		$(0, 0)$                                         & Scalar                        & Boson                              \\
		$(\sfrac{1}{2}, 0)\text{ and }(0, \sfrac{1}{2})$ & Lefthanded and RH Weyl Spinor & Massless fermion                   \\
		$(\sfrac{1}{2}, \sfrac{1}{2})$                   & Vector                        & Boson                              \\
		$\bigotimes_{i=1}^N(\sfrac{1}{2}, \sfrac{1}{2})$ & $N$-Rank Tensor               &                                    \\
		$(\sfrac{1}{2}, 0)\oplus(0, \sfrac{1}{2})$       & Dirac Bispinor                & Fermions                           \\
		$(\sfrac{1}{2}, 1)\oplus(1, \sfrac{1}{2})$       & Rarita Schwinger Field        & Gravitino                          \\
		$(2, 0)\oplus (0, 2)$                            & Spin 2 Spinor                 & Graviton / Rieman Curvature Tensor \\
	\end{tabular}
\end{frame}


\lab{Optimal Reentry of a Spacecraft}{Optimal Reentry of a Spacecraft}
\label{lab:reentry}
\objective{ We consider the problem of minimizing the heating experienced by a spacecraft during reentry.
The boundary value problem (BVP) associated with the reentry of a spacecraft is inherently challenging: the craft must descend quickly enough to enter the atmosphere, but pull out soon enough to prevent overheating or crashing.
Problems involving variational calculus and optimal control often include the numerical solution of a challenging BVP. }

\begin{figure}
\centering
\includegraphics[width=6cm]{Apollo8_during_Launch.jpg}
\caption{Apollo 8 during launch}
\label{fig:reentry:apollo8}
\end{figure}

A fundamental topic considered in aerospace engineering is the process of landing a spacecraft.
Landing a spacecraft requires a massive reduction in the kinetic energy of the craft.
That reduction can be accomplished either through the use of massive quantities of fuel (very expensive), or by  transforming kinetic energy into heat.
That heat must then be absorbed by the atmosphere and the spacecraft.
The question then is how to choose the optimal path for reentry into the atmosphere, where the total heating experienced by the craft is minimized.

We begin with a control system\footnote{This control problem and its numerical solution are thoroughly described in `Introduction to Numerical Analysis' by J. Stoer, R. Bulirsch (pg 524).
We will mirror their presentation throughout this lab.}
that describes the path of a spacecraft through the atmosphere
(we assume the spacecraft is similar to the Apollo craft).
The dependent variables are the velocity $v$ of the spacecraft,
the angle $\gamma$ of the flight path,
and the normalized altitude $\xi=h/R$ above the Earth's surface, where $R$ is the radius of the Earth and $h$ is the altitude of the spacecraft above the Earth.
The control variable  $u$ represents the angle of attack of the spacecraft.
The flight path is given by
\begin{align}
\begin{split}
\dot{v} &= -s\rho v^2C_D(u) - \frac{g\sin(\gamma)}{(1+\xi)^2},\\
\dot{\gamma} &= s \rho v C_L(u) + \frac{v \cos(\gamma)}{R(1+\xi)} - \frac{g \cos \gamma}{v(1+\xi)^2},\\
\dot{\xi} &= \frac{v \sin \gamma}{R}.
\end{split} \label{eqn:reentry:control_system}
\end{align}
Coefficients $C_D$ and $C_L$ represent drag and lift coefficients, and depend on the angle of attack:
\begin{align*}
 C_D(u) &= 1.174 - .9\cos u, \\
 C_L(u) &= 0.6\sin u.
\end{align*}

The atmospheric density $\rho$ is a function of height,
\[\rho(\xi) = \rho_0e^{-R\beta\xi},
\] where  $\rho_0$ is the atmospheric density at the surface of the earth.
Other parameters include the force of gravity $g$, and $s = \frac{1}{2}S/m$, where $S$ is the frontal area of the craft and $m$ is its mass.
The numerical values we will use are coded below, along with the drag and lift functions.
\begin{lstlisting}
from __future__ import division
from math import pi, sqrt, sin, cos, exp
from numpy import linspace, array, tanh, cosh, ones, arctan
import numpy as np
from scipy.special import erf
from scipy.optimize import root

from bvp6c import bvp6c, bvpinit, deval
from structure_variable import struct

R = 209
beta = 4.26
rho0 = 2.704e-3
g = 3.2172e-4
s = 26600

def C_d(u):
	return 1.174 - 0.9*cos(u)

def C_l(u):
	return 0.6*sin(u)
\end{lstlisting}

Realistic boundary conditions for the trajectory of the spacecraft are
\begin{equation}
  \begin{split}
    v(0) &= 0.36 \quad (36000 \text{ ft/sec})\\
    \gamma(0) &= -8.1^\circ \frac{\pi}{180^\circ}\\
    \xi(0)&= \frac{4}{R}\quad (h = 400000 \text{ ft})
  \end{split}
\quad \quad \quad \quad \quad
  \begin{split}
    v(T) &= 0.27\\
    \gamma(T) &= 0 \\
	\xi(T)&= \frac{2.5}{R}
  \end{split} \label{eqn:reentry:BCs}
\end{equation}
where $T$ represents the time at the end of the (first) reentry maneuver.
These boundary conditions are similar to those encountered at the end of each Apollo mission to the moon.

% To simpify notation, we will also write \eqref{eqn:reentry:control_system} in the form $y' = G(y)$, where $y = [y_0, y_1, y_2]^T=[v,\gamma, \xi]^T$ and $G$ has component functions $G = [G_0, G_1, G_2]^T$.
The total heating is
\[
J[u] = \int_0^T 10 v^3 \sqrt{\rho}.
\]
The Hamiltonian corresponding to this control system\footnote{Here we are using the Pontryagin Minimum Principle, rather than the Maximum Principle. Due to this slight variation, the Hamiltonian is defined as  $\lambda  \cdot f + L$, where $\lambda$ is the costate vector, the state equation is $\dot{x} = f,$ and the functional $J = \int_0^T L$.} is
\begin{align}
	\begin{split}
H &=  10v^3 \sqrt{\rho} + \lambda_1 \left ( -s\rho v^2C_D(u) - \frac{g\sin(\gamma)}{(1+\xi)^2} \right) + \\
&{ }\quad \quad\lambda_2 \left( s \rho v C_L(u) + \frac{v \cos(\gamma)}{R(1+\xi)} - \frac{g \cos \gamma}{v(1+\xi)^2} \right) + \\
&{ }\quad \quad \lambda_3 \left( \frac{v \sin \gamma}{R} \right),
	\end{split}
\end{align}
% \begin{align}
% H &=  10y_0^3 \sqrt{\rho} + \lambda_0G_0 + \lambda_1G_1 + \lambda_2G_2,
% \end{align}
where $\lambda = [\lambda_1,\lambda_2,\lambda_3]^T$ is the adjoint variable.
The state and adjoint equations are thus given by
\begin{align}
\begin{split}
	\dot{y} &= H_{\lambda},\quad \dot{} = \frac{d}{dt},\\
	\dot{\lambda} &= -H_{y}, \label{eqn:reentry:full_system}
\end{split}
\end{align}
where $y = [y_1,y_2,y_3]^T = [v,\gamma, \xi]^T$.
To our boundary conditions we add the terminal condition that $H = 0$ at $t = T$.
Finally, from the condition $\frac{\partial H}{\partial u} = 0$ we find that the optimal control satisfies
\begin{align}
\tan u &= \frac{6\lambda_2}{9v\lambda_1}.
\end{align}

Most BVP solvers require an equal number of differential equations and boundary conditions.
Currently we have a free boundary value problem; there are 6 ODEs and 7 boundary conditions, and the length of the reentry maneuver, $T$, is still unknown.
By making the transformation $x = t/T$, and treating $T$ as a dependent variable, the BVP is now defined on the interval $(0,1)$ and is augmented with an additional ODE:
\begin{align}
\begin{split}
	y' &= TH_{\lambda},\quad ' = \frac{d}{dx},\\
	\lambda' &= -TH_{y},\\
	T' &= 0. \label{eqn:reentry:full_system}
\end{split}
\end{align}
This BVP has 7 ODEs, and with the 7 boundary conditions introduced earlier it has the required form.
% \footnote{BNDSCO - A program for the numerical solution of optimal control problems, H.J. Oberle and W. Grimm, 1989}

\begin{figure}
\centering
\includegraphics[width=7cm]{The_Lunar_Farside.jpg}
\caption{ The Apollo 8 mission was the first to orbit the moon and return to earth.
After a flight of three days from earth, they orbited the moon ten times in 20 hours before making the return trip.
This photograph  shows a portion of the far side of the moon, as seen by the Apollo 8.
}
\label{fig:reentry:Lunar_Farside}
\end{figure}

\begin{problem}
Complete the function \li{ode} below that implements the right hand side of \eqref{eqn:reentry:full_system}.
Notice that the adjoint variables and the final time are coordinates of $y:$ $y_4 = \lambda_1$, $y_5 = \lambda_2$, $y_6=\lambda_3$, and $y_7 = T$. Finally, note that we use Python zero based indexing below.
\begin{lstlisting}
def ode(x,y):
	# Parameters:
	# x: independent variable (unused in our ODEs)
	# y: vector-valued dependent variable; it is an ndarray
	# 	 with shape (7,)

	# Returns:
	# ndarray of length (7,) that evalutes the RHS of the ODES
	u =	 arctan((6*y[4])/(9*y[0]*y[3] ))
	rho = rho0*exp(-beta*R*y[2])
	out = y[6]*array([
				 # G_0
				 -s*rho*y[0]**2*C_d(u) - g*sin(y[1])/(1+y[2])**2,
				 # G_1
				( s*rho*y[0]*C_l(u) + y[0]*cos(y[1])/(R*(1 + y[2])) -
				  g*cos(y[1])/(y[0]*(1+y[2])**2) ),
				 # G_2
				y[0]*sin(y[1])/R,
				 # G_3
				-( 30*y[0]**2.*sqrt(rho)+ y[3]*(-2*s*rho*y[0]*C_d(u)) +
				   y[4]*( s*rho*C_l(u) +cos(y[1])/(R*(1 + y[2])) +
						  g*cos(y[1])/( y[0]**2*(1+y[2])**2 )
							) +
				   y[5]*(sin(y[1])/R)	   ),
				  # G_4
				-( y[3]*( -g*cos(y[1])/(1+y[2])**2	) +
				   y[4]*( -y[0]*sin(y[1])/(R*(1+y[2])) +
						  g*sin(y[1])/(y[0]*(1+y[2])**2 )
							) +
				   y[5]*(y[0]*cos(y[1])/R )	   ),
				  # G_5 -- This line needs to be completed.
				  ,
				  # G_6
					0
			   ])
	return out
\end{lstlisting}
\end{problem}

\begin{figure}
\centering
\includegraphics[width=\textwidth]{solutions.pdf}
\caption{The optimal path for the reentry maneuver of a spacecraft.
This path minimizes the heating of the spacecraft, and satisfies  \eqref{eqn:reentry:full_system},\eqref{eqn:reentry:BCs}, and the terminal condition $H(T) = 0$.
}
\label{fig:reentry:solutions}
\end{figure}

\section*{Constructing an Initial Guess}
We will use the BVP solver \li{scikits.bvp_solver}.
Like any solver capable of handling nonlinear problems, \li{bvp_solver} requires an initial guess to jump-start its Newton-like iteration process.
% We will use the BVP solver \li{bvp6c}.
% Like any solver capable of handling nonlinear problems, \li{bvp6c} requires an initial guess to jump-start its Newton-like iteration process.
Our nonlinear BVP is very sensitive, and requires an initial guess that is quite close to the solution.
This sensitivity is physically meaningful.
The spacecraft is traveling at a speed far greater than a typical aircraft.
If the control is not aggressive, the spacecraft will fall/`bounce' back into space as it encounters the atmosphere at a high velocity.
However, if the control lasts too long, the craft will overheat or crash.

Since this is a sensitive problem, we will use a heuristic method to construct good initial guesses for $v, \gamma, \xi, \lambda_1, \lambda_2,\lambda_2$, and $u$.
From aerospace engineers we know that the control $u$ should empirically look like Figure \ref{fig:reentry:estimate_u};
we can create a smooth approximation of the form $u = p_1\erf(p_2(p_3-t/T))$, where $p_1, p_2,$ and $p_3$ are unknown constants.
To help us determine these constants, and to find good initial guesses for $v, \gamma$, and $\xi$, we define an auxiliary BVP
\begin{align}
\begin{split}
\dot{y_0} &= -s\rho y_0^2C_D(u) - \frac{g\sin(y_1)}{(1+y_2)^2},\\
\dot{y_1} &= s \rho y_0 C_L(u) + \frac{y_0 \cos(y_1)}{R(1+y_2)} - \frac{g \cos y_1}{y_0(1+y_2)^2},\\
\dot{y_2} &= \frac{y_0 \sin y_1}{R} ,\\
\dot{p_1} &= 0, \\
\dot{p_2} &= 0, \\
\dot{p_3} &= 0.
\end{split} \label{eqn:reentry:control_system_auxiliary}
\end{align}

This auxiliary BVP is defined on the interval $[0,T]$, where $T$ is unknown.
We guess at $T$: the maneuver will occur quickly, so how about 230 seconds?  After this boundary value problem has been solved, we will have good initial guesses for the correct $v,\gamma,\xi$, and $u.$ We will still need to construct initial guesses for $\lambda_1, \lambda_2$, and $\lambda_3$.
Below we code  functions for \eqref{eqn:reentry:control_system_auxiliary} and for the boundary conditions.
\begin{lstlisting}
T0 = 230

def ode_auxiliary(t,y):
	u = y[3]*erf( y[4]*(y[5]-(1.*t)/T0) )
	rho = rho0*exp(-beta*R*y[2])
	out = array([-s*rho*y[0]**2*C_d(u) - g*sin(y[1])/(1+y[2])**2,
				  ( s*rho*y[0]*C_l(u) + y[0]*cos(y[1])/(R*(1 + y[2])) -
				  g*cos(y[1])/(y[0]*(1+y[2])**2) ),
				  y[0]*sin(y[1])/R,
				  0,
				  0,
				  0		])
	return out

def bcs_auxiliary(ya,yb):
	out1 = array([ ya[0]-.36,
				  ya[1]+8.1*pi/180,
				  ya[2]-4/R
				  ])
	out2 = array([ yb[0]-.27,
				  yb[1],
				  yb[2]-2.5/R
				  ])
	return out1, out2
\end{lstlisting}

% The two main functions used by \li{bvp6c} are \li{bvpinit} and \li{deval}.
The two main functions used are \li{ProblemDefinition} and \li{solve}.
% You will want to look at their docstrings to learn more about their functionality.
The function \li{solve} requires an initial guess, which you will create in Problem \ref{prob:reentry:guess}.

% \begin{lstlisting}
%
% options = struct()
% # options include abstol, reltol, singularterm, stats, vectorized, maxnewpts,slopeout,xint
% options.abstol, options.reltol = 1e-8, 1e-7
% options.fjacobian = ode_auxiliary_jacobian
% options.bcjacobian = bcs_auxiliary_jacobian
% options.nmax = 2000
%
% solinit = bvpinit(np.linspace(0,1,100),initial_guess)
% sol = bvp6c(ode,bcs,solinit,options)
%
% N = 240
% xint = linspace(0,T0,N+1)
% num_sol_auxiliary, _ = deval(sol,xint)
%
%
% \end{lstlisting}

\begin{lstlisting}
problem_auxiliary = bvp_solver.ProblemDefinition(num_ODE = 6,
										  num_parameters = 0,
										  num_left_boundary_conditions = 3,
										  boundary_points = (0, T0),
										  function = ode_auxiliary,
										  boundary_conditions = bcs_auxiliary)

solution_auxiliary = bvp_solver.solve(problem_auxiliary,
								solution_guess = guess_auxiliary)

N = 240
t_guess = linspace(0,T0,N+1)
guess = solution_auxiliary(t_guess)
\end{lstlisting}

\begin{figure}
\begin{minipage}[b]{.47\linewidth}
\centering
\includegraphics[width=\textwidth]{u_heuristic.pdf}
\caption*{Heuristic for the control $u$, provided by engineers. }
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.47\linewidth}
\centering
\includegraphics[width=\textwidth]{u_heuristic_smooth.pdf}
\caption*{A smooth initial approximation of the control.}
\end{minipage}
\caption{We construct a smooth estimate for the control $u$, by supposing the control has the form
$u = p_1\erf(p_2(p_3-t/T))$ and estimating parameters $p_1, p_2, p_3$.}
\label{fig:reentry:estimate_u}
\end{figure}

\begin{problem}
	Complete the function \li{guess_auxiliary} given below. Then run the code above to check that your initial guess is adequate.
	This function provides an initial guess to \li{bvp_solver} for the auxiliary BVP described by  \eqref{eqn:reentry:control_system_auxiliary} and \eqref{eqn:reentry:BCs}.
	Use the heuristic data provided in Figure \ref{fig:reentry:estimate_u} to find good estimates of $p_1, p_2,$ and $p_3$.
	Use Figure \ref{fig:reentry:solutions} to estimate the trajectories of $y_1, y_2,$ and $y_3$. Hint: Try using the $\tanh$ function.

\begin{lstlisting}
def guess_auxiliary(t):
	out = array([ .5*(.36+.27)-.5*(.36-.27)*tanh(.025*(t-.45*T_init)),
			# Finish this line,
			# And this one,
			p1*ones(t.shape),
			p2*ones(t.shape),
			p3*ones(t.shape)   ])
	return out
\end{lstlisting}
	\label{prob:reentry:guess}
\end{problem}

At this point we have constructed good initial guesses for the dependent variables $y_1,y_2, y_3,$ and $y_7$ (representing the total time of the manuever) in the original BVP \eqref{eqn:reentry:full_system}.
We now need to construct initial guesses for the adjoint variables $y_4, y_5,$ and $y_6$.

By reexamining the condition $H_u = 0$, we find that the optimal control $u$ satisfies
\[
\sin u = \frac{-0.6 y_5}{\alpha} \qquad \cos u  = \frac{-0.9 y_1y_4}{\alpha}
\]
where $\alpha = \sqrt{(0.6y_5)^2 + (0.9y_1y_4)^2}$.
From this we know that $y_4 <0$, since $\cos u >0$. A simple guess would be $y_4 = -1$.
(Recall that the adjoint variables are unique up to some scaling.)
We can then approximate $y_5$ from the relationship
\begin{align*}
\tan u &= \frac{6y_5}{9y_1y_4}.
\end{align*}
To approximate $y_6$, we use the identity $H = 0$.

\begin{problem}
	Adapt your previous code to solve the original, dimension seven BVP.
	Use the solution of the auxiliary BVP to construct a good initial guess.
	Plot the control $u$. How long does the reentry maneuver take?
\end{problem}


\section{Confidence intervals}

Confidence Intervals follow the form:\\

(statistic) $\pm$ (critical value)(estimated standard deviation of statistic)\\

Let $\displaystyle ( E,(\mathbb{P}_{\theta })_{\theta \in \Theta })$ be a statistical  model based on observations $X_{1} , \ldots X_{n}$  and assume $\displaystyle \Theta \subseteq \mathbb{R}$. Let $\displaystyle \alpha \in ( 0,1)$.\\
\textbf{Non asymptotic} confidence interval of level $\displaystyle 1-\alpha $ for $\displaystyle \theta $:\\
Any random interval $\displaystyle \mathcal{I}$, depending on the sample $X_{1} , \ldots X_{n}$ but not at $\displaystyle \theta $ and such that:\\
$\mathbb{P}_{\theta }[\mathcal{I} \ni \theta ] \geq 1-\alpha ,\ \ \forall \theta \in \Theta$\\
Confidence interval of \textbf{asymptotic level} $\displaystyle 1-\alpha $  for $\displaystyle \theta $:\\
Any random interval $\displaystyle \mathcal{I}$ whose boundaries do not depend on $\displaystyle \theta $ and such that: $\lim _{n\rightarrow \infty }\mathbb{P}_{\theta } [\mathcal{I} \ni \theta ]\geq 1-\alpha ,\ \ \forall \theta \in \Theta $
\subsection{Two-sided asymptotic CI}
Let $X_1, \ldots, X_n = \tilde{X}$ and $\tilde{X}\stackrel{iid} {\sim} P_{\theta}$. A two-sided CI is a function depending on $\tilde{X}$ giving an upper and lower bound in which the estimated parameter lies $\mathcal{I} = [l(\tilde{X},u(\tilde{X})]$ with a certain probability $\mathbb{P}(\theta \in  \mathcal{I}) \geq 1 -q_{\alpha}$ and conversely $\mathbb{P}(\theta \not\in  \mathcal{I}) \leq \alpha$\\
Since the estimator is a r.v. depending on $\tilde{X}$ it has a variance $Var(\hat{\theta}_n$ and a mean $\mathbb{E}[\hat{\theta}_n]$.
Since the CLT is valid for every distribution standardizing the distributions and massaging the expression yields an an asymptotic CI:
\begin{align*}
\mathcal{I} =  [&\hat{\theta}_n - \frac{q_{\alpha /2} \sqrt{Var(X_i)} }{\sqrt{n}},\\
&\hat{\theta}_n + \frac{q_{\alpha /2} \sqrt{Var(X_i)} }{\sqrt{n}}]
\end{align*}
This expression depends on the real variance $Var(X_i)$ of the r.vs, the variance has to be estimated.\\
Three possible methods: plugin (use sample mean or empirical variance), solve (solve quadratic inequality), conservative (use the theoretical maximum of the variance).
\subsection{Sample Mean and Sample Variance}
Let $X_1, ..., X_n \stackrel{iid}{\sim} P_{\mu}$, where $E(X_i)=\mu$ and $Var(X_i)=\sigma^2$ for all $i=1,2,...,n$\\
\textbf{Sample Mean:}
\begin{align*}
\bar{X}_n= \frac{1}{n} \sum_{i=1}^{n} X_i
\end{align*}
\textbf{Sample Variance:}
\begin{align*}
S_n &= \frac{1}{n} \sum_{i=1}^{n} (X_i - \bar{X}_n)^2\\
&= \frac{1}{n} (\sum_{i=1}^{n} X_i^2) - \bar{X}_n^2
\end{align*}
\textbf{Unbiased estimator of sample variance:}
\begin{align*}
\tilde{S}_n &= \displaystyle  \frac{1}{n-1} \sum _{i=1}^ n \left(X_ i - \overline{X}_ n\right)^2\\
&= \frac{n}{n-1} S_n
\end{align*}
\subsection{Delta Method}

To find the asymptotic CI if the estimator is a function of the mean. Goal is to find an expression that converges a function of the mean using the CLT. Let $Z_n$ be a sequence of r.v. $\sqrt(n) (Z_n-\theta) \xrightarrow[n \rightarrow \infty]{(d)} N(0,\sigma^2)$ and let $g: R\longrightarrow R$ be continuously differentiable at $\theta$, then:
\begin{align*}
&\sqrt{n}(g(Z_n) - g(\theta)) \xrightarrow [n \to \infty ]{(d)}\\
&\mathcal{N}(0, g'(\theta )^2 \sigma ^2)
\end{align*}
\textbf{Example:} let  $X_1,... ,X_n ~ exp(\lambda)$  where  $\lambda>0$ . Let  $\overline{X}_ n= \frac{1}{n} \sum _{i = 1}^ n X_ i$ denote the sample mean. By the CLT, we know that $\sqrt{n}\left(\overline{X}_ n - \frac{1}{\lambda }\right) \xrightarrow [n \to \infty ]{(d)} N(0, \sigma ^2)$ for some value of  $\sigma^2$  that depends on  $\lambda$.

If we set $g: \displaystyle \mathbb {R} \to \mathbb {R}$ and $\displaystyle x \mapsto 1/x,$ then by the Delta method:

\begin{align*}
&\sqrt{n}\left( g(\overline{X}_ n) - g\left(\frac{1}{\lambda }\right) \right)\\
&\xrightarrow [n \to \infty ]{(d)} N(0, g'(E[X])^2\textsf{Var}{X})\\
&\xrightarrow [n \to \infty ]{(d)} N(0, g'\left(\frac{1}{\lambda }\right)^2\frac{1}{\lambda ^2})\\
&\xrightarrow [n \to \infty ]{(d)} N(0, \lambda^2)
\end{align*}