\subsection{Tranformations}
\dfont{Transformations} are operations we can apply to a function in order to obtain a \ifont{new} function.
The most common transformations include translations, stretches and reflections.
We summarize these below.

\begin{center}
\framebox{
$\begin{array}{ccccl}
\mbox{\underline{Function}}&\qquad&\mbox{\underline{Conditions}}&\qquad&\mbox{\underline{How to graph $F(x)$ given the graph of $f(x)$}}\\
F(x)=f(x)+c&\qquad&c>0&\qquad&\mbox{Shift $f(x)$ upwards by $c$ units}\\
F(x)=f(x)-c&\qquad&c>0&\qquad&\mbox{Shift $f(x)$ downwards by $c$ units}\\
F(x)=f(x+c)&\qquad&c>0&\qquad&\mbox{Shift $f(x)$ to the left by $c$ units}\\
F(x)=f(x-c)&\qquad&c>0&\qquad&\mbox{Shift $f(x)$ to the right by $c$ units}\\
\hline
F(x)=-f(x)&\qquad&~&\qquad&\mbox{Reflect $f(x)$ about the $x$-axis}\\
F(x)=f(-x)&\qquad&~&\qquad&\mbox{Reflect $f(x)$ about the $y$-axis}\\
\hline
F(x)=|f(x)|&\qquad&~&\qquad&\mbox{Take the part of the graph of $f(x)$ that lies}\\
~&\qquad&~&\qquad&\mbox{below the $x$-axis and reflect it about the $x$-axis}\\
\end{array}$}
\end{center}

For horizontal and vertical stretches, different resources use different terminology and notation.
Use the one you are most comfortable with!
Below, both $a,b$ are positive numbers. Note that we only use the term \ifont{stretch} in this case:

\begin{center}
\framebox{
$\begin{array}{ccccl}
\mbox{\underline{Function}}&\qquad&\mbox{\underline{Conditions}}&\qquad&\mbox{\underline{How to graph $F(x)$ given the graph of $f(x)$}}\\
F(x)=af(x)&\qquad&a>0&\qquad&\mbox{Stretch $f(x)$ vertically by a factor of $a$}\\
F(x)=f(bx)&\qquad&b>0&\qquad&\mbox{Stretch $f(x)$ horizontally by a factor of $1/b$}\\
\end{array}$}
\end{center}

In the next case, we use both the terms \ifont{stretch} and \ifont{shrink}.
We also split up vertical stretches into two cases ($0<a<1$ and $a>1$), and split up horizontal stretches into two cases ($0<b<1$ and $b>1$).
Note that having $0<a<1$ is the same as having $1/c$ with $c>1$.
Also note that \ifont{stretching by a factor of $1/c$} is the same as \ifont{shrinking by a factor $c$}.

\begin{center}
\framebox{
$\begin{array}{ccccl}
\mbox{\underline{Function}}&\qquad&\mbox{\underline{Conditions}}&\qquad&\mbox{\underline{How to graph $F(x)$ given the graph of $f(x)$}}\\
F(x)=cf(x)&\qquad&c>1&\qquad&\mbox{Stretch $f(x)$ vertically by a factor of $c$}\\
F(x)=(1/c)f(x)&\qquad&c>1&\qquad&\mbox{Shrink $f(x)$ vertically by a factor of $c$}\\
F(x)=f(cx)&\qquad&c>1&\qquad&\mbox{Shrink $f(x)$ horizontally by a factor of $c$}\\
F(x)=f(x/c)&\qquad&c>1&\qquad&\mbox{Stretch $f(x)$ horizontally by a factor of $c$}\\
\end{array}$}
\end{center}

Some resources keep the condition $0<c<1$ rather than using $1/c$.
This is illustrated in the next table.

\begin{center}
\framebox{
$\begin{array}{ccccl}
\mbox{\underline{Function}}&\qquad&\mbox{\underline{Conditions}}&\qquad&\mbox{\underline{How to graph $F(x)$ given the graph of $f(x)$}}\\
F(x)=df(x)&\qquad&d>1&\qquad&\mbox{Stretch $f(x)$ vertically by a factor of $d$}\\
F(x)=df(x)&\qquad&0<d<1&\qquad&\mbox{Shrink $f(x)$ vertically by a factor of $1/d$}\\
F(x)=f(dx)&\qquad&d>1&\qquad&\mbox{Shrink $f(x)$ horizontally by a factor of $d$}\\
F(x)=f(dx)&\qquad&0<d<1&\qquad&\mbox{Stretch $f(x)$ horizontally by a factor of $1/d$}\\
\end{array}$}
\end{center}

\begin{example}{Transformations and Graph Sketching}{TransformationsGraphSketching}
In this example we will use appropriate transformations to sketch the graph of the function $y=|\sqrt{x+2}-1|-1$.
\end{example}
\begin{solution}
We start with the graph of a function we know how to sketch, in particular, $y=\sqrt{x}$:
To obtain the graph of the function $y=\sqrt{x+2}$ from the graph $y=\sqrt{x}$, we must shift $y=\sqrt{x}$ to the left by $2$ units.
To obtain the graph of the function $y=\sqrt{x+2}-1$ from the graph $y=\sqrt{x+2}$, we must shift $y=\sqrt{x+2}$ downwards by $1$ unit.
$$\includegraphics[width=6in]{images/transf1}$$
To obtain the graph of the function $y=|\sqrt{x+2}-1|$ from the graph $y=\sqrt{x+2}-1$, we must take the part of the graph of $y=\sqrt{x+2}-1$ that lies below the $x$-axis and reflect it (upwards) about the $x$-axis.
Finally, to obtain the graph of the function $y=|\sqrt{x+2}-1|-1$ from the graph $y=|\sqrt{x+2}-1|$, we must shift $y=|\sqrt{x+2}-1|$ downwards by $1$ unit:
$$\includegraphics[width=6in]{images/transf2}$$
\end{solution}


\paragraph{Question 2.}

Given the binary alphabet \(\Sigma = \{a, b\}\) and the order on
letters \(a < b\), write regular definitions for the following
languages.
\begin{enumerate*}

  \item All words starting and ending with \(a\).

  \item All non-empty words.

  \item All words in which the third last letter is \(a\).

  \item All words containing exactly three \(a\).

  \item All words containing at least one \(a\) before a \(b\).

  \item All words in which the letters are in increasing order.

  \item All words with no letter following the same one.

\end{enumerate*}


\include{config/config}

\begin{document}
% ========== Edit your name here
\title{MATH 2901 Basic Probability Lecture Notes 4}
\author{Instructor: Richard Kleeman}
\date{}
\maketitle

%\medskip

% ========== Contents begin here ==============
\section{Expectation of discrete random variables}
The intuition of expectation is the \emph{average value} of an experiment. Suppose we do an experiment for $N$ repeated times. The probability of each possible outcome $x$ can be approximately defined by
\begin{equation*}
    \Prob(x) \approx f(x) = \frac{freq(x)}{N}.
\end{equation*}
Then the average outcome is
\begin{equation*}
    m \approx \frac{1}{N}\sum_{x} freq(x)x = \sum_x f(x)x
\end{equation*}

\begin{definition}
The \textbf{mean value}, or \textbf{expectation}, or \textbf{expected value} of the random variable $X$ with mass function $f$ is defined to be
\begin{equation*}
    \Exp(X) = \sum_{x:f(x)>0} xf(x)
\end{equation*}
whenever this sum is absolutely convergent.
\end{definition}

\begin{remark}
\begin{enumerate}[(a)]
    \item For notation convenience, we also write $\Exp(X) = \sum_x xf(x)$.
    \item We require \textbf{absolute convergence} in order that $\Exp(X)$ be unchanged by reordering the $x_i$.
\end{enumerate}
\end{remark}

\begin{theorem}[Riemann Rearrangement Theorem] \href{https://en.wikipedia.org/wiki/Riemann_series_theorem}{See this: Riemann series theorem}.
\end{theorem}

\begin{lemma}
If $X$ has mass function $f$ and $g:\R\to\R$, then
\begin{equation*}
    \Exp(g(x)) = \sum_x g(x) f(x)
\end{equation*}
whenever this sum is absolutely convergent.
\end{lemma}

\begin{example}
If $X$ is a random variable with mass function f, and $g(x) = x^2$, then
\begin{equation*}
    \Exp(X^2) = \sum_x g(x)f(x) = x^2 f(x).
\end{equation*}
\end{example}

\begin{definition}
If $k$ is a positive integer, the $k$th \text{moment} $m_k$ of $X$ is defined to be
\begin{equation*}
    m_k = \Exp(X^k).
\end{equation*}
The $k$th \textbf{central moment} $\sigma_k$ is defined as
\begin{equation*}
    \sigma_k = \Exp\left( (X-m_1)^k \right) = \Exp\left( (X-E(X))^k \right).
\end{equation*}
\end{definition}

The two moments of most use are $m_1 = \Exp(X)$ and $\sigma_2 = \Exp( (X - \Exp(X))^2$, called the \textbf{mean} (or \textbf{expectation)} and \textbf{variance} of $X$. These two quantities are measures of the mean and dispersion of $X$; that is, $m_1$ is the average value of $X$, and $\sigma_2$ measures the amount by which $X$ tends to deviate from this average. The mean $m_1$ is often denoted $\mu$, and the variance of $X$ is often denoted $\Var(X)$. The positive square root $\sigma = \Var(X)$ is called the \textbf{standard deviation}, and in this notation $\sigma_2 = \sigma^2$.

The central moments $\{\sigma_i\}$ can be expressed in terms of the ordinary moments $\{m_i\}$. For example, $\sigma_1 = 0$, and
\begin{equation*}
    \begin{aligned}
        \sigma_{2} &=\sum_{x}\left(x-m_{1}\right)^{2} f(x) \\
        &=\sum_{x} x^{2} f(x)-2 m_{1} \sum_{x} x f(x)+m_{1}^{2} \sum_{x} f(x) \\
        &=m_{2}-m_{1}^{2} ,
    \end{aligned}
\end{equation*}
which may be written as
\begin{equation}
    \label{eq:4-1}
    \tag{4-1}
    \Var(X) = \Exp\left( (X-E(X))^2 \right) = \Exp(X^2) - \Exp(X)^2.
\end{equation}

\begin{example}[Binomial variables]
Let $X$ be a random variable with binomial distribution. The p.m.f. is
\begin{equation*}
    f(k) = \binom{n}{k} p^k q^{n-k} \quad k = 0,\dots, n,
\end{equation*}
where $q = 1-p$. The expectation of $X$ is
\begin{equation*}
    \Exp(X) = \sum_{k=0}^n k f(k) = \sum_{k=0}^n k\binom{n}{k} p^k q^{n-k}.
\end{equation*}
We use the following algebraic identity to compute $\Exp(X)$.
\begin{equation}
    \label{eq:4.2}
    \tag{4-2}
    \sum_{k=0}^n \binom{n}{k} x^k = (1+x)^n,
\end{equation}
Differentiate it and multiply by $x$, we obtain
\begin{equation}
    \label{eq:4.3}
    \tag{4-3}
    \sum_{k=0}^n k \binom{n}{k} x^k = nx(1+x)^{n-1}.
\end{equation}
We substitute $x = p / q$ to obtain $\Exp(X) = np$. A similar argument shows that the variance of $X$ is given by $\Var(X) = npq$.
\end{example}

We can think of the process of calculating expectations as a \textbf{linear operator} on the space of random variables.

\begin{theorem}
The expectation operator $\Exp$ has the following properties:
\begin{enumerate}[(a)]
    \item if $X\geq 0$, then $\Exp(X) \geq 0$,
    \item if $a, b \in \R$, then $\Exp(aX+bY) = a\Exp(X) + b\Exp(Y)$,
    \item the random variable 1, taking the value 1 always, has expectation $\Exp(1) = 1$.
\end{enumerate}
\end{theorem}

\begin{proof}
We only prove the second property, which is also called the linear property.

We must use the joint p.m.f. of $X$ and $Y$ to compute the expectation.
\begin{equation*}
    \begin{split}
        \Exp(aX+bY) &= \sum_{i, j} (ax_i + by_j) f(x_i, y_j) \\
        &= a \sum_{i,j} x_i f(x_i, y_j) + b\sum_{i,j} y_j f(x_i, y_j) \\
        &= a\sum_{i} x_i f_X(x_i) + b\sum_{j}y_j f_Y(y_j) \\
        &= a\Exp(X) + b\Exp(Y),
    \end{split}
\end{equation*}
where $f_X(x)$ and $f_Y(y)$ are marginal p.m.f. of $X$ and $Y$ respectively.
\end{proof}

\begin{caution}
It is \textbf{NOT} in general true that $\Exp(XY)$ is the same as $\Exp(X)\Exp(Y)$.
\end{caution}

\begin{lemma}
If $X$ and $Y$ are independent, then $\Exp(XY) = \Exp(X)\Exp(Y)$.
\end{lemma}
\begin{proof}
If $X, Y$ are independent, $f(x,y) = f_X(x) f_Y(y)$. Then
\begin{equation*}
    \Exp(XY) = \sum_{ij} x_i y_j f(x,y) = \sum_{i} \left( x_i f_X(x_i) \right) \sum_{j} \left( y_j f_Y(y_j) \right) = \Exp(X) \Exp(Y).
\end{equation*}
\end{proof}

\begin{definition}
$X$ and $Y$ are called \textbf{uncorrelated} if $\Exp(XY) = \Exp(X)\Exp(Y)$.
\end{definition}

\begin{caution}
Independent variables are uncorrelated. But the converse is \textbf{NOT} true.
\end{caution}

\begin{theorem}
For random variables $X$ and $Y$,
\begin{enumerate}[(a)]
    \item $\Var(aX) = a^2 \Var(X)$ for $a \in \R$,
    \item $\Var(X+Y) = \Var(X) + \Var(Y)$ is $X$ and $Y$ are uncorrelated.
\end{enumerate}
\end{theorem}

\begin{remark}
The above theorem shows that the variance operator $\Var$ is \textbf{NOT} a linear operator, even when it
is applied only to uncorrelated variables.
\end{remark}

%==============================================
Sometimes the sum $S = \sum xf(x)$ does not converge absolutely, which means the mean of the distribution does not exist. Here is an example.
\begin{example}
\textbf{A distribution without a mean.} Let $X$ have mass function
\begin{equation*}
    f(k) = Ak^{-1} \quad k = \pm 1, \pm 2, \dots,
\end{equation*}
where $A$ is chosen so that $\sum_k f(k) = 1$. The sum $\sum_k kf(k) = A\sum_{k\neq 0} k^{-1}$ doesn't converge absolutely, because both the positive and the negative parts diverge.
\end{example}
This example is suitable to point out that we can base probability theory upon the expectation operator $\Exp$ rather than upon the probability measure $\Prob$. Roughly speaking, the way we proceed is to postulate axioms, such as (a)-(c) of the above Theorem, for a so-called ``expectation operator" $\Exp$ acting on a space of ``random variables". The probability of an event can then be recaptured by defining $\Prob(A) = \Exp(I_A)$.

Recall the indicator function of a set $A$ is defined as
\begin{equation*}
    I_A(\omega) = \begin{cases} 1 & \omega \in A, \\
    0 & \omega \not\in A. \end{cases}
\end{equation*}
In addition, we have $\Exp(I_A) = \Prob(A)$.

%==============================================

\section{Dependence of discrete random variables}
\begin{definition}
The \textbf{joint distribution function} $F:\R^2 \to [0,1]$ of $X$ and $Y$, where $X$ and $Y$ are discrete variables, is given by
\begin{equation*}
    F(x, y) = \Prob(X\leq x \text{ and } Y \leq y).
\end{equation*}
Their \textbf{joint mass function} $f:\R^2 \to [0,1]$ is given by
\begin{equation*}
    f(x,y) = \Prob(X = x \text{ and } Y = y).
\end{equation*}
\end{definition}

We write $F_{X,Y}$ and $f_{X,Y}$ when we need to stress the role of $X$ and $Y$. We may think of the joint mass function in the following way. If $A_x = \{X = x\}$ and $B_y = \{Y = y\}$, then
\begin{equation*}
    f(x,y) = \Prob(A_x \cap B_y).
\end{equation*}

\begin{lemma}
The discrete random variables $X$ and $Y$ are \textbf{independent} if and only if
\begin{equation}
    \label{eq:4.4}
    \tag{4-4}
    f_{X,Y}(x,y) = f_X(x)f_Y(y) \quad \forall x,y \in \R.
\end{equation}
More generally, $X$ and $Y$ are independent if and only if $f_{X,Y}(x, y)$ can be \textbf{factorized as the product} $g(x)h (y)$ of a function of $x$ alone and a function of $y$ alone.
\end{lemma}
\begin{remark}
We stress that the factorization \eqref{eq:4.4} must hold for all $x$ and $y$ in order that $X$ and $Y$ be independent.
\end{remark}

\begin{lemma}
\begin{equation*}
    \Exp(g(X, Y))=\sum_{x, y} g(x, y) f_{X, Y}(x, y).
\end{equation*}
\end{lemma}

\begin{definition}
The \textbf{covariance} of $X$ and $Y$ is
\begin{equation*}
    \cov(X,Y) = \Exp\left( (X-\Exp(X))(Y-\Exp(Y)) \right).
\end{equation*}
The \textbf{correlation (coefficient)} of $X$ and $Y$ is
\begin{equation*}
\corr(X, Y) = \rho(X,Y) = \frac{\cov(X,Y)}{\sqrt{\Var(X)\Var(Y)}}
\end{equation*}
as long as the variances are non-zero.
\end{definition}

\begin{remark}
Notice the following two equations.
\begin{enumerate}
    \item $\cov(X,X) = \Var(X)$,
    \item $\cov(X,Y) = \Exp(XY) - \Exp(X)\Exp(Y)$.
\end{enumerate}
\end{remark}

Covariance itself is not a satisfactory measure of dependence because the scale of values which $\cov(X, Y)$ may take contains no points which are clearly interpretable in terms of the relationship between $X$ and $Y$.

\begin{theorem}[Cauchy-Schwarz inequality] For random variables $X$ and $Y$,
\begin{equation*}
    \Exp(XY)^2 \leq \Exp(X^2) \Exp(Y^2)
\end{equation*}
with equality if and only if $\Prob(aX = bY) = 1$ for some real $a$ and $b$, at least one of which is non-zero.
\end{theorem}

\begin{proof}
For $a, b \in \R$, let $Z = aX - bY$. Then
\begin{equation*}
    0 \leq \Exp(Z^2) = a^2 \Exp(X^2) - 2ab\Exp(XY) + b^2\Exp(Y^2).
\end{equation*}
Thus the right-hand side is a quadratic in the variable $a$ with at most one real root. Its discriminant must be non-positive. That is to say, if $b \neq 0$,
\begin{equation*}
    \Exp(XY)^2 - \Exp(X^2) \Exp(Y^2) \leq 0.
\end{equation*}
The discriminant is zero if and only if the quadratic has a real root. This occurs if and only if
\begin{equation*}
    \Exp\left( (aX-bY)^2 \right) = 0
\end{equation*}
for some $a$ and $b$.
\end{proof}

We define $X' = X-\Exp(X), Y' = Y - \Exp(Y)$. Since all $X, Y$ satisfy the Cauchy-Schwarz inequality, so do $X'$ and $Y'$. Therefore,
\begin{equation*}
    \Exp(X'Y')^2 \leq \Exp(X'^2) \Exp(Y'^2) \quad \Leftrightarrow \quad \cov(X, Y)^2 \leq \Var(X)\Var(Y).
\end{equation*}
Therefore,
\begin{equation*}
    \rho(X,Y)^2 \leq 1 \quad \Rightarrow \quad \rho(X,Y) \in [-1, 1].
\end{equation*}
which gives the following lemma.

\begin{lemma}
The correlation coefficient $\rho$ satisfies $\abs{\rho (X, Y) } \leq 1$ with equality if and only if $\Prob(aX + bY = c) = 1$ for some $a, b, c \in \R$.
\end{lemma}

\section{Expectation of continuous random variables}
\subsection{Idea of translating expectation from discrete to continuous}
Suppose we have a continuous random variable $X$ with $f$ being the probability density function. We split $X$ into small intervals $\Delta x$. Then $p_i = f(x_i)\Delta x$. $\frac{p_i}{\Delta x}$ is an approximation of probability density function. Therefore,
\begin{equation*}
    \Exp(X) \approx \sum_{i} x_i p_i = \sum_{i} x_i f(x_i) \Delta x,
\end{equation*}
which is the Remann sum. We take the limit and get
\begin{equation*}
    \Exp(x) = \int_{-\infty}^\infty x f(x)dx.
\end{equation*}

\subsection{Expectation}
\begin{definition}
The \textbf{expectation} of a continuous random variable $X$ with density function $f$ is given by
\begin{equation*}
    \Exp(X) = \int_{-\infty}^\infty xf(x) dx
\end{equation*}
whenever this integral exists.
\end{definition}

\begin{theorem}
If $X$ and $g(X)$ are continuous random variables, then \begin{equation*}
    \Exp\left( g(X) \right) = \int_{-\infty}^\infty g(x)f(x) dx.
\end{equation*}
\end{theorem}

\begin{definition}
The $k$th \textbf{moment} of a continuous variable $X$ is defined as
\begin{equation*}
    \Exp(X^k) = \int_{-\infty}^\infty x^k f(x) dx
\end{equation*}
whenever the integral converges.
\end{definition}

\begin{example}[Cauchy distribution] The random variable $X$ has the Cauchy distribution t if it has density
function
\begin{equation*}
    f(x) = \frac{1}{\pi (1+x^2)}, \quad x \in \R.
\end{equation*}
This distribution is notable for having \textbf{no moments}.
\end{example}

\section{Dependence of continuous random variables}
\begin{definition}
The \textbf{joint distribution function} of $X$ and $Y$ is the function $F: \R^2 \to [0, 1]$ given by
\begin{equation*}
    F(x,y) = \Prob(X\leq x, Y \leq y).
\end{equation*}
\end{definition}

\begin{definition}
The random variables $X$ and $Y$ are \textbf{(jointly) continuous} with \textbf{joint (probability) density function} $f : \R^2 \to [0, \infty)$ if
\begin{equation*}
    F(x, y)=\int_{v=-\infty}^{y} \int_{u=-\infty}^{x} f(u, v) d u d v \quad \text{for each } x, y\in\R.
\end{equation*}
If $F$ is sufficiently differentiable at the point $(x , y)$, then we usually specify
\begin{equation*}
    f(x, y)=\frac{\partial^{2}}{\partial x \partial y} F(x, y).
\end{equation*}
\end{definition}

\begin{newnotion}{Probabilities}
\begin{equation*}
    \begin{aligned}
        \Prob(a \leq X \leq b, c \leq Y \leq d) &=F(b, d)-F(a, d)-F(b, c)+F(a, c) \\
        &=\int_{y=c}^{d} \int_{x=a}^{b} f(x, y) d x d y. \end{aligned}
\end{equation*}
If $B$ is a sufficiently nice subset of $\R^2$, then
\begin{equation*}
    \Prob \left( (X, Y) \in B \right)=\iint_{B} f(x, y) d x d y.
\end{equation*}
\end{newnotion}
\begin{newnotion}{Marginal distributions}
The marginal distribution functions of $X$ and $Y$ are
\begin{equation*}
    F_{X}(x)=\Prob(X \leq x)=F(x, \infty), \quad F_{Y}(y)=\Prob(Y \leq y)=F(\infty, y).
\end{equation*}
\begin{equation*}
    F_{X}(x)=\int_{-\infty}^{x}\left(\int_{-\infty}^{\infty} f(u, y) d y\right) d u.
\end{equation*}
Marginal density function of $X$ and $Y$:
\begin{equation*}
    f_{X}(x)=\int_{-\infty}^{\infty} f(x, y) d y, \quad f_{Y}(y)=\int_{-\infty}^{\infty} f(x, y) d x.
\end{equation*}
\end{newnotion}

\begin{newnotion}{Expectation}
If $g: \R^2 \to \R$ is a sufficiently nice function, then
\begin{equation*}
    \Exp(g(X, Y))=\int_{-\infty}^{\infty} \int_{-\infty}^{\infty} g(x, y) f(x, y) d x d y;
\end{equation*}
in particular, setting $g(x, y) = ax + by$,
\begin{equation*}
    \Exp(aX+bY) = a\Exp(X) + b\Exp(Y).
\end{equation*}
\end{newnotion}

\begin{newnotion}{Independence}
The random variables $X$ and $Y$ are independent if and only if
\begin{equation*}
    F(x,y) = F_X(x) F_Y(y) \quad \forall x, y \in \R,
\end{equation*}
which, for \textbf{continuous random variables}, is equivalent to requiring that
\begin{equation*}
    f(x,y) = f_X(x) f_Y(y).
\end{equation*}
\end{newnotion}

\begin{theorem}[Cauchy-Schwarz inequality] For any pair $X, Y$ of jointly continuous variables, we have that
\begin{equation*}
    \Exp(XY)^2 \leq \Exp(X^2) \Exp(Y^2),
\end{equation*}
with equality if and only if $\Prob(aX = bY) = 1$ for some real $a$ and $b$, at least one of which is non-zero.
\end{theorem}

\end{document}


\SecDef{properties}{Properties of the Decomposition}

\subsection{Cryptographic Properties}
The decomposition uncovers an interesting property of the 6-bit APN permutation $S_0$: it is affine-equivalent to a 6-bit APN involution $S_{\inv}$. The DDT and the LAT of the involution $S_{\inv}$ are illustrated in \FigRef{ddt-lat} (the DDT of $\Swap \circ S_{\inv} \circ \Swap$ is illustrated, because it has clearer structure). $S_{\inv}$ has differential uniformity 2 and its linearity is 16. The left and right halves of the output of $S_{\inv}$ have algebraic degree 4 and 3 respectively.

\FigTex{ddt-lat}

We used the algorithm from~\cite{LinAffEQ} to find all pairs of affine self-equivalence mappings, i.e. maps $A,B\in\affbij{6}$ such that $S_{\inv} = B \circ S_{\inv} \circ A$. In~\cite{LinAffEQ} it was suggested as a measure of symmetry of the permutation. The number of such pairs is invariant under affine-equivalence. Therefore, the decomposition is not necessary to count them. On the other hand, the decomposition shows that these maps have a simple expression. Let $(a,b)\otimes(c,d) \eqdef (ac, bd)$ denote the component-wise $\fielde{3}$-multiplication. Then, for each $\lambda \in \fielde{3},\lambda \ne 0$ the following holds for all $x,y\in\fielde{3}$:
$$
S_{\inv}(\lambda x, \lambda^{-1}y) = (\lambda, \lambda^{-1}) \otimes S_{\inv}(x,y).
$$
That is, multiplying the input halves by $\lambda$ and $\lambda^{-1}$ is equivalent to multiplying the output halves by $\lambda$ and $\lambda^{-1}$. In~\SecRef{relations} it is shown that this property is similar to a property that the Kim mapping has.

\subsection{Univariate Representations}

In this section I show that there exist 6-bit APN permutations with simpler univariate polynomials, than a random permutation or the Dillon's APN permutation has. These results are based on interpolating the involution $S_{\inv}$ in $\fielde{6} \simeq \fielde{3} \times \fielde{3}$ using different field basis. This is done by composing $S_{\inv}$ with linear maps corresponding to the basis change. All polynomial presented in this section are defined over $\fielde{6} \simeq \field{}[v]/(v^6 + v^4 + v^3 + v + 1)$, where $v$ is primitive.

\textbf{Single polynomial.}
In~\cite{DillonAPN}, the APN permutation was given as a univariate polynomial over $\fielde{6}$ with 52 nonzero coefficients. Our decomposition allows to obtain an APN permutation from 25 monomials. The permutation $s$ of $\fielde{6}$ given by
\begin{align*}
    s(x) &= x^{58} + x^{51} + x^{44} + x^{37} + \VV^{27}x^{36} + \VV^{38}x^{32} + x^{30} \\
         &+ \VV^{53}x^{28} + \VV^{7}x^{25} + \VV^{51}x^{24} + x^{23} + \VV^{53}x^{21} + \VV^{7}x^{18} + \VV^{24}x^{17}\\
         &+ \VV^{7}x^{16} + \VV^{46}x^{14} + \VV^{7}x^{11} + \VV^{4}x^{10} + x^{9} + \VV^{22}x^{8} + \VV^{46}x^{7}\\
         &+ \VV^{3}x^{4} + \VV^{50}x^{3} + \VV^{56}x^{2} + \VV^{52}x
\end{align*}
is APN.

\textbf{Composition of 2 polynomials.}
Dillon~\etal{} also represented $S_0$ as the composition $S_0 = f_2 \circ f_1^{-1}$, where polynomials $f_1$ and $f_2$ contain 18 monomials each. Using our decomposition, we found more compact polynomials. Let $f_1', f_2'$ be permutations of $\fielde{6}$ given by
\begin{align*}
f_1'(x) &= \VV^{11}x^{34} + \VV^{53}x^{20} + x^{8} + x,\\
f_2'(x) &= \VV^{28}x^{48} + \VV^{61}x^{34} + \VV^{12}x^{20} + \VV^{16}x^{8} + x^{6} + \VV^{2}x.
\end{align*}
Then $f_2' \circ f_1'^{-1}$ is an APN permutation.

\textbf{Composition of 3 polynomials.}
Finally, the representation becomes even simpler if 3 functions are used in the composition. Let $i,m$ be permutations of $\fielde{6}$ given by
$$
i(x) = \VV^{21}x^{34} + x^{20} + x^8 + x, \quad
m(x) = \VV^{52}x^8 + \VV^{36}x.
$$
Then $i \circ m \circ i^{-1}$ is an APN permutation. Similarly, let $i',m'$ be permutations of $\fielde{6}$ given by
$$
i'(x) = \VV^{37}x^{48} + x^{34} + \VV^{49}x^{20} + \VV^{21}x^{8} + \VV^{30}x^{6} + x, \quad
m'(x) = x^8.
$$
Then $i' \circ m' \circ i'^{-1}$ is also an APN permutation.
These decompositions are obtained by interpolating parts of the decomposition separately. $i$ and $i'$ correspond to the part with the inverses and $m,m'$ correspond to the central linear layer.


\documentclass[11pt]{article}
\usepackage{cctbx_preamble}
\usepackage{amscd}
\usepackage{latexsym}
\usepackage{listings}
\lstset{language=Python,tabsize=2,columns=spaceflexible}

\title{Change of Basis\\of\\Electron Density and Structure Factors}
\author{\lucjbourhis}
\date{\today}

\begin{document}
\maketitle

\section{Change of basis}

\subsection{Transformations}

Let us consider two frames of the real space, $\mathcal{R}=(\omega, e_1, e_2, e_3)$ and $\mathcal{R}'=(\omega', e'_1, e'_2, e'_3)$, where $\omega$ and $\omega'$ are the origins and $\{e_i\}$ and $\{e'_j\}$ are the basis vectors. The 3-vector of coordinates $x$ and $x'$ of a site in respectively $\mathcal{R}$ and $\mathcal{R}'$ are related by
\begin{equation}
x' = \sym{R}{t}x.
\label{eqn:change::of::basis::position}
\end{equation}
where $\sym{R}{t}$ is the change-of-basis operator from $\mathcal{R}$ to $\mathcal{R}'$. We will only consider the case where $\sym{R}{t}$ is orthogonal and the unit cell $U$ is invariant under $R$.

A corollary is the corresponding law for the miller indices,
\begin{equation}
h' = hR^{-1}.
\label{eqn:change::of::basis::miller::index}
\end{equation}
and therefore
\begin{equation}
h'x' = hx + h't
\label{eqn:change::of::basis::hx}
\end{equation}
Indeed, since scalar product should be independent of the basis, $h'$ must statisfy\footnote{It is most natural in crystallography to represent any position $x$ by a column vector and any miller index $h$ by a row vector (mathematically speaking $h$ is in the reciprocal space of $x$ and therefore $h$ is really a linear form). Therefore the scalar product $h.x$ reads like the mere matrix product $hx$ and the operator relation $h.Rx = R^Th.x$ is the trivial matrix product $hRx$ interpreted in two ways using associativity.} $h'\Delta x' = h\Delta x$ for any vector $\Delta x'$ (as opposed to the point\footnote{Let's not forget the positions make an affine space whereas the miller indices are only the reciprocal of the associated vector space and of course \eqnref{change::of::basis::position} results in $\Delta x' = R \Delta x$} $x$).

The transformation law for the electron density $\rho(x)$ and $\rho'(x')$ in the respective frames
$\mathcal{R}$ and $\mathcal{R}'$ reads
\begin{equation}
\rho'(x') = \rho(x).
\label{eqn:change::of::basis::rho}
\end{equation}
The transformation for the structure factors can then be deduced from it,
\begin{align}
F'(h') &= \int_U \rho'(x') e^{i2\pi h'x'}d^3x', \nonumber\\
&= e^{i2\pi h' t}  \int_{\sym{R}{t}^{-1}U} \rho(x) e^{i2\pi h x} d^3x, \nonumber\\
\intertext{by using \eqnref{change::of::basis::rho,change::of::basis::hx} and the Jacobian of $x \mapsto \sym{R}{t}x$ being 1 since $R$ is orthogonal. Thus the invariance of $U$ and the periodicity of $\rho$ results in}
F'(h') &= e^{i2\pi h't} F(h).
\label{eqn:change::of::basis::F}\\
\intertext{or equivalently with \eqnref{change::of::basis::miller::index}}
F'(h) &= e^{i2\pi ht} F(hR)
\label{eqn:change::of::basis::F::bis}
\end{align}

\subsection{Implementation}

\Eqnref{change::of::basis::F} is the formula implemented in the \cctbx\ in \code{sym\_equiv.h}, c.f. \code{sym\_equiv\_index::phase\_eq} and its use in \code{change\_basis.h}. It is particularly convenient since a \code{miller.array} stores $h$ and $F(h)$ in two parallel arrays. By looping over the both of them at the same time, one can compute and immediately store the new miller index $h'$ and the value $F'(h')$ for that new miller index. However it means that the ordering of the original and new data are related as follow
\begin{equation}
\begin{CD}
\ldots @. \ldots\\
F(h_{i-1}) @= F'(h'_{i-1})\\
F(h_i) @= F'(h'_i)\\
F(h_{i+1}) @= F'(h'_{i+1})\\
\ldots @. \ldots
\end{CD}
\label{eqn:miller::array::change::basis}
\end{equation}

Once the array $\{F'(h')\}$ is computed, one can move back to the more natural memory layout
\begin{equation}
\begin{CD}
\ldots @. \ldots\\
F(h_{i-1}) @= F'(h_{i-1})\\
F(h_i) @= F'(h_i)\\
F(h_{i+1}) @= F'(h_{i+1})\\
\ldots @. \ldots
\end{CD}
\label{eqn:miller::array::transform}
\end{equation}
with the following one-liner
\begin{lstlisting}
# op is (R|t) and f is a miller.array
original, transform = f.common_set(
	f.change_basis(sgtbx.change_of_basis_op(op))
\end{lstlisting}
if need be.

\section{Invariance and symmetry cross-correlation: an application}

The following questions are recurrent after any method processing a structure in P1: is the structure invariant under an operator $\sym{R}{t}$ in some ``new'' basis which is not necessarily the ``old'' one we have done that processing in? That is true of the dual space solution method (Phenix.hyss, ShelXD) and also of charge flipping. In practice, the change of basis to consider from the old to the new basis is just a change of origin. The goal is to assess how well this symmetry holds and to find the origin shift.

The key change of variable to consider is
\begin{equation}
x' - \omega = \sym{R}{t}(x - \omega),
\end{equation}
where $\omega$ is the sought origin. So the change-of-basis operator is $\sym{R}{t + (I-R)\omega}$.
The sought symmetry is realised if the following invariance holds\footnote{i.e. $\rho = \rho'$, as functions.}
\begin{equation}
\rho(x) = \rho(x').
\end{equation}
How well this is realised can be quantified by considering the overlap of those two functions
\begin{align}
c(\omega) &= \int_U \rho(x) \rho(x') d^3x.\\
\intertext{The bigger $c(\omega)$, the better the symmetry and therefore one should find the value of $\omega$ maximising $c(\omega)$. Parseval theorem gives its equivalent in Fourier space,}
c(\omega) &= \sum_h F(h) \overline{F'(h)}. \nonumber\\
\intertext{Then, with \eqnref{change::of::basis::F::bis}, }
c(\omega) = c(d) &= \sum_h F(h) \overline{F(hR)} e^{-i 2\pi h d},
\end{align}
by denoting $d=t + (I-R)\omega$. This formula is a Fourier transform, which provides an efficient way to compute $c(d)$ on a grid over the entire unit cell to search for a maximum. It also features $F(hR)$ which is the result of applying the change-of-basis operator $\sym{R}{0}$ to $F$. Thus, the \code{cctbx} lets us compute $c(d)$ very easily:
\begin{lstlisting}
# The rotation part r is a sgtbx.rot_mx and f is a miller.array
original, transform = f.common_set(
	f.change_basis(sgtbx.change_of_basis_op(sgtbx.rt_mx(r)))
cc = original * transform.conjugate().data() / original.sum_sq()
cc_map = cc.fft_map(
	symmetry_flags=maptbx.use_space_group_symmetry,
	resolution_factor=cc.d_min()) # e.g.
\end{lstlisting}

As a side note, in real space, that Fourier transform of the product $F(h) \overline{F(hR)}$ is the convolution,
\begin{align}
c(d) &= \int_U \rho(d-x) \rho(-R^{-1}x) d^3x \nonumber\\
\intertext{which can be recast as a cross-correlation,}
&= \int_U \rho(x+d) \rho(R^{-1}x) d^3x. \nonumber
\end{align}

\end{document}


\section{Motion along a curve}\label{sec:MotionAlongCurve}

We have already seen that if $t$ is time and an object's location is
given by ${\bf r}(t)$, then the derivative ${\bf r}'(t)$ is the
velocity vector ${\bf v}(t)$.
Just as ${\bf v}(t)$ is a vector describing how ${\bf r}(t)$ changes,
so is ${\bf v}'(t)$ a vector describing how ${\bf v}(t)$ changes,
namely, ${\bf a}(t)={\bf v}'(t)={\bf r}''(t)$ is the
\dfont{acceleration vector}.

\begin{example}{}{}
Suppose ${\bf r}(t)=\langle \cos t,\sin t,1\rangle$. Then
${\bf v}(t)=\langle -\sin t,\cos t,0\rangle$ and
${\bf a}(t)=\langle -\cos t,-\sin t,0\rangle$. This describes the
motion of an object traveling on a circle of radius 1, with constant
$z$ coordinate 1. The velocity vector is of course tangent to the
curve; note that ${\bf a}\cdot{\bf v}=0$, so ${\bf v}$ and ${\bf a}$
are perpendicular. In fact, it is not hard to see that ${\bf a}$
points from the location of the object to the center of the circular
path at $(0,0,1)$.
\end{example}

Recall that the unit tangent vector is given by ${\bf T}(t)=
{\bf v}(t)/|{\bf v}(t)|$, so ${\bf v}=|{\bf v}|{\bf T}$. If we take
the derivative of both sides of this equation we get

\begin{equation}\label{eq:acceleration decomposition initial}
{\bf a}=|{\bf v}|'{\bf T}+|{\bf v}|{\bf T}'.
\end{equation}

Also recall the definition of the curvature,
$\kappa=|{\bf T}'|/|{\bf v}|$, or $|{\bf T}'|=\kappa|{\bf v}|$. Finally,
    recall that we defined the unit normal vector as
${\bf N}={\bf T}'/|{\bf T}'|$, so ${\bf T}'=|{\bf T}'|{\bf N}=
\kappa|{\bf v}|{\bf N}$.
Substituting into Equation~\ref{eq:acceleration decomposition initial} we get

\begin{equation}\label{eq:acceleration decomposition final}
{\bf a}=|{\bf v}|'{\bf T}+\kappa|{\bf v}|^2{\bf N}.
\end{equation}

The quantity $|{\bf v}(t)|$ is the speed of the object, often written as
$v(t)$; $|{\bf v}(t)|'$ is the rate at which the speed is changing, or
the scalar acceleration of the object, $a(t)$. Rewriting
Equation~\ref{eq:acceleration decomposition final} with these gives
us
$${\bf a}=a{\bf T}+\kappa v^2{\bf N}=
a_{T}{\bf T}+a_{N}{\bf N};$$
$a_T$ is the \dfont{tangential component of acceleration} and
$a_N$ is the \dfont{normal component of acceleration}.
We have already seen that $a_T$ measures how the speed is changing; if
you are riding in a vehicle with large $a_T$ you will feel a force
pulling you into your seat. The other component, $a_N$, measures how
sharply your direction is changing \emph{with respect to time}. So it
naturally is related to how sharply the path is curved, measured by
$\kappa$, and also to how fast you are going. Because $a_N$ includes
$v^2$, note that the effect of speed is magnified; doubling your speed
around a curve quadruples the value of $a_N$. You feel the effect of
this as a force pushing you toward the outside of the curve, the
``centrifugal force.''

In practice, if want $a_N$ we would use the formula for $\kappa$:
$$a_N=\kappa |{\bf v}|^2= {|{\bf r}'\times{\bf r}''|\over
|{\bf r}'|^3}|{\bf r}'|^2={|{\bf r}'\times{\bf r}''|\over|{\bf r}'|}.$$
To compute $a_T$ we can project ${\bf a}$ onto ${\bf v}$:
$$a_T={{\bf v}\cdot{\bf a}\over|{\bf v}|}={{\bf r}'\cdot{\bf r}''\over
|{\bf r}'|}.$$

\begin{example}{}{}
Suppose ${\bf r}=\langle t,t^2,t^3\rangle$.
Compute ${\bf v}$, ${\bf a}$,
$a_T$, and $a_N$.
\end{example}
\begin{solution}
Taking derivatives we get
${\bf v}=\langle 1,2t,3t^2\rangle$
and ${\bf a}=\langle 0,2,6t\rangle$. Then
$$a_T={4t+18t^3\over \sqrt{1+4t^2+9t^4}}
\quad\hbox{and}\quad
a_N={\sqrt{4+36t^2+36t^4}\over\sqrt{1+4t^2+9t^4}}.$$
\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Opensolutionfile{solutions}[ex]
\section*{Exercises for \ref{sec:MotionAlongCurve}}

\begin{enumialphparenastyle}

\begin{ex}
Let ${\bf r}=\langle \cos t,\sin t,t\rangle$.
Compute ${\bf v}$, ${\bf a}$,
$a_T$, and $a_N$.
\begin{sol}
	$\langle -\sin t,\cos t,1\rangle$,
	$\langle -\cos t, -\sin t,0\rangle$,
	$0$, $1$
\end{sol}
\end{ex}

\begin{ex}
Let ${\bf r}=\langle \cos t,\sin t,t^2\rangle$.
Compute ${\bf v}$, ${\bf a}$,
$a_T$, and $a_N$.
\begin{sol}
	$\langle -\sin t,\cos t,2t\rangle$,
	$\langle -\cos t, -\sin t,2\rangle$,
	$4t/\sqrt{4t^2+1}$, $\sqrt{4t^2+5}/\sqrt{4t^2+1}$
\end{sol}
\end{ex}

\begin{ex}
Let ${\bf r}=\langle \cos t,\sin t,e^t\rangle$.
Compute ${\bf v}$, ${\bf a}$,
$a_T$, and $a_N$.
\begin{sol}
	$\langle -\sin t,\cos t,e^t\rangle$,
	$\langle -\cos t, -\sin t,e^t\rangle$,
	$e^{2t}/\sqrt{e^{2t}+1}$, $\sqrt{2e^{2t}+1}/\sqrt{e^{2t}+1}$
\end{sol}
\end{ex}

\begin{ex}
Let ${\bf r}=\langle e^t,\sin t,e^t\rangle$.
Compute ${\bf v}$, ${\bf a}$,
$a_T$, and $a_N$.
\begin{sol}
	$\langle e^t,\cos t,e^t\rangle$,
	$\langle e^t, -\sin t,e^t\rangle$,
	$(2e^{2t}-\cos t\sin t)/\sqrt{2e^{2t}+\cos^2 t}$,
	$\sqrt{2}e^t|\cos t+\sin t|/\sqrt{2e^{2t}+\cos^2 t}$
\end{sol}
\end{ex}

\begin{ex}
Suppose an object moves so that its acceleration is given by
${\bf a}=\langle -3\cos t,-2\sin t,0\rangle$. At time $t=0$ the object
is at $(3,0,0)$ and its velocity vector is $\langle
0,2,0\rangle$. Find ${\bf v}(t)$ and ${\bf r}(t)$ for the object.
\begin{sol}
	$\langle -3\sin t,2\cos t,0\rangle$,
	$\langle 3\cos t, 2\sin t,0\rangle$
\end{sol}
\end{ex}

\begin{ex}
Suppose an object moves so that its acceleration is given by
${\bf a}=\langle -3\cos t,-2\sin t,0\rangle$. At time $t=0$ the object
is at $(3,0,0)$ and its velocity vector is $\langle
0,2.1,0\rangle$. Find ${\bf v}(t)$ and ${\bf r}(t)$ for the object.
\begin{sol}
	$\langle -3\sin t,2\cos t+0.1,0\rangle$,
	$\langle 3\cos t, 2\sin t+t/10,0\rangle$
\end{sol}
\end{ex}

\begin{ex}
Suppose an object moves so that its acceleration is given by
${\bf a}=\langle -3\cos t,-2\sin t,0\rangle$. At time $t=0$ the object
is at $(3,0,0)$ and its velocity vector is $\langle
0,2,1\rangle$. Find ${\bf v}(t)$ and ${\bf r}(t)$ for the object.
\begin{sol}
	$\langle -3\sin t,2\cos t,1\rangle$,
	$\langle 3\cos t, 2\sin t,t\rangle$
\end{sol}
\end{ex}

\begin{ex}
Suppose an object moves so that its acceleration is given by
${\bf a}=\langle -3\cos t,-2\sin t,0\rangle$. At time $t=0$ the object
is at $(3,0,0)$ and its velocity vector is $\langle
0,2.1,1\rangle$. Find ${\bf v}(t)$ and ${\bf r}(t)$ for the object.
\begin{sol}
	$\langle -3\sin t,2\cos t+1/10,1\rangle$,
	$\langle 3\cos t, 2\sin t+t/10,t\rangle$
\end{sol}
\end{ex}

\begin{ex}
Describe a situation in which the normal component of
acceleration is 0 and the tangential component of acceleration is
non-zero. Is it possible for the tangential component of acceleration
to be 0 while the normal component of acceleration is non-zero? Explain.
Finally, is it possible for an object to move (not be stationary)
so that both the tangential and normal components of acceleration are 0?
Explain.
\end{ex}

\end{enumialphparenastyle}


\chapter{Sampling CT Signals}

Up until now in the course we have focused on either CT or DT signals and systems. Practical systems though often are hybrid and require conversion between DT and CT signals. For example a CT audio signal might be converted to a DT audio signal for storage and/or transmission, and at a later time or location converted back to a CT signal for playback through a speaker.

It is also common to design a CT system and then implement it as a DT system. Advantages of this approach are e.g. such implementations are less susceptible to component variations, require no tuning a build time, are easier to change (firmware or software update), easier to prototype, and more easily use encryption.

In this lecture we focus on \emph{sampling} of CT signals to produce a DT signal $x[n] = x(nT)$ with sample index $n$ and sample time $T$. In the next lecture we consider the case of converting from a DT to CT signal.

\section{Sampling Theory}

The process of sampling is to produce a DT signal $x[n]$ from a CT signal $x(t)$ by sampling time at regular intervals $T\in \mathbb{R}^+$ called the \emph{sample-time}, or equivalently sampling at a frequency of $\tfrac{1}{T}$ Hz or $\tfrac{2\pi}{T}$ rad/s. Mathematically this is simple to express in the time domain as $x[n] = x(nT)$, however we seek a system that can perform this task.

Recall the impulse train is the periodic signal
\[
x_1(t) = \sum\limits_{n=-\infty}^{\infty} \delta(t-nT_0)
\]
with period $T_0$ and frequency $\omega_0 = \tfrac{2\pi}{T_0}$. The exponential CT Fourier series of the impulse train is given by
\[
x_1(t) = \sum\limits_{n=-\infty}^{\infty} a_n e^{j\tfrac{2\pi}{T_0}nt}
\]
where the Fourier series coefficients are
\[
a_n = \frac{1}{T_0} \int\limits_{-\frac{T_0}{2}}^{\frac{T_0}{2}} \delta(t) e^{-jn\omega_0 t} \; dt = \frac{1}{T_0}
\]
Now, lets take the Fourier Transform of the Fourier series representation
\begin{align*}
X_1(j\omega) &= \int\limits_{-\infty}^{\infty} \sum\limits_{n=-\infty}^{\infty} \frac{1}{T_0} e^{j\tfrac{2\pi}{T_0}nt}e^{j\omega t}\; dt\\
&= \frac{1}{T_0} \sum\limits_{n=-\infty}^{\infty} \int\limits_{-\infty}^{\infty} e^{j\tfrac{2\pi}{T_0}nt}e^{j\omega t}\; dt\\
&= \frac{1}{T_0} \sum\limits_{n=-\infty}^{\infty} \delta(\omega - \omega_0 n)
\end{align*}
also an impulse train in the frequency domain. Now suppose we have another signal $x_2(t)$ and we multiply $x_1(t)$ and $x_2(t)$ to get a signal $y(t)$.
\[
y(t) = x_1(t) \cdot x_2(t) = \sum\limits_{n=-\infty}^{\infty} x_2(t) \delta(t-nT_0) = \sum\limits_{n=-\infty}^{\infty} x_2(nT_0) \delta(t-nT_0)
\]
Since $y(t)$ is non-zero only at the locations of the delta functions, we can treat $y(nT_0) = x_2(nT_0)$ as the DT signal $x_2[n]$. This is illustrated below

\begin{center}
  \includegraphics[scale=1]{graphics/samplinf_timedomain.pdf}
\end{center}

Equivalently in the frequency domain the modulation theorem gives
\[
y(t) = x_1(t) \cdot x_2(t) \stackrel{\mathcal{F}}{\longleftrightarrow} \frac{1}{2\pi} X_1(j\omega) * X_2(j\omega) = Y(j\omega)
\]
Lets do the convolution
\begin{align*}
  Y(j\omega) &= \frac{1}{2\pi} X_1(j\omega) * X_2(j\omega)\\
  &=  \frac{1}{2\pi} \left[  \frac{1}{T_0} \sum\limits_{n=-\infty}^{\infty} \delta(\omega - \omega_0 n) \right] * X_2(j\omega)\\
  &= \frac{1}{2\pi} \int\limits_{-\infty}^{\infty}  \frac{1}{T_0} \sum\limits_{n=-\infty}^{\infty} \delta(\omega - \omega^\prime - \omega_0 n) X_2(j\omega^\prime) \; d\omega^\prime\\
  &= \frac{1}{2\pi T_0} \sum\limits_{n=-\infty}^{\infty} X_2(j(\omega - n\omega_0))
\end{align*}
Thus the sampling process in the frequency domain causes periodic replication of the Fourier transform of the signal being sampled, $x_2(t)$, which are sometimes called \emph{images}. This signal $Y(j\omega)$ is periodic in $\omega_0 = \tfrac{2\pi}{T_0}$ \emph{radians per second} and corresponds to the DT Fourier Transform of $x_2[n]  \stackrel{\mathcal{F}}{\longleftrightarrow} X_2\left(e^{j\omega}\right)$, which is periodic in $2\pi$ \emph{radians per sample time}.

To help us visualize this, suppose that the signal $x_2(t)  \stackrel{\mathcal{F}}{\longleftrightarrow} X_2(j\omega)$ is \emph{band-limited} to $B$ Hz, that is $X_2(j\omega) = 0$ for all $-2\pi B < \omega < 2\pi B$. This is shown schematically as the magnitude spectrum below:

\begin{center}
  \includegraphics[scale=1]{graphics/bandlimited.pdf}
\end{center}
After sampling ($y(t) = x_1(t)*x_2(t)$) and assuming $\omega_0 > 4\pi B$ the spectrum of the sampled signal is:
\begin{center}
  \includegraphics[scale=1]{graphics/bandlimitedsampled1.pdf}
\end{center}
If instead $\omega_0 < 4\pi B$ the images overlap and we get \emph{aliasing}, where high frequency content gets added to the lower frequency content. This is shown below with the lighter lines showing the images and the heavier line showing their sum.
\begin{center}
  \includegraphics[scale=1]{graphics/bandlimitedsampled2.pdf}
\end{center}
As we will see next time, to reconstruct the signal $x_2[n]$ back to $x_2(t)$ we need to ensure that $\omega_0 > 4\pi B$ rad/s or equivalently $f_0 > 2 B$ Hz, which requires the sample time $T_0 < \tfrac{1}{2B}$ seconds. This is called the \emph{Nyquist} sample rate/frequency.

\begin{example} Consider a signal representing a musical chord (an additive mixture of three notes)
  \[
  x(t) = \sin(2\pi\cdot (261) t) + \sin(2\pi\cdot (329) t) + \sin(2\pi\cdot (392) t)
  \]
  Suppose it is sampled at a frequency of $f_0 = 1$ kHz. Then there is no aliasing into the frequency range $(0, 500)$ Hz. After reconstruction $x(t)$ would be unmodified. Suppose instead it is sampled at $f_0 = 500$ Hz. Then the signal component at $261$ Hz aliases to $239 = 500-261$ Hz, the signal component at $329$ Hz aliases to $171 = 500-329$ Hz, and the signal component at $392$ Hz aliases to $108 = 500-392$ Hz. When reconstructed, the signal now has an additional 3 tones mixed in at audible frequencies, but do not correspond to (Western) musical notes, i.e.
  \[
  x(t) = \sin(2\pi\cdot (108) t) + \sin(2\pi\cdot (171) t) + \sin(2\pi\cdot (239) t) + \sin(2\pi\cdot (261) t) + \sin(2\pi\cdot (329) t) + \sin(2\pi\cdot (392) t)
  \]
\end{example}

\section{Practical Sampling}

Sampling in practice requires addressing three issues. First, we cannot generate the impulse train, but can only approximate it. Second, digital signals must have a fixed bit width so we have to convert the real signal value to a \emph{quantized} one. Lastly, since in general we have no control over the input signal means we need to ensure the signal is approximately band-limited before sampling.

\subsection{Sample and Hold}
Sampling is typically accomplished using a circuit called a \emph{sample-and-hold}, schematically illustrated below.

\begin{center}
  \includegraphics[scale=0.8]{graphics/smaple_hold.pdf}
\end{center}

The CT signal is applied to the input of the first op-amp buffer. The output of this first buffer is switched into a charging capacitor for the \emph{sample time}, then disconnected (high impedance) at regular intervals for the \emph{hold time}, typically using a MOSFET switch. The effect is the capacitor is charged to the current value of $x(t)$ during the sample-time, which it maintains during the hold-time, the value of which is bufered by the second op-amp. This can be mathematically modeled as a pulse train with a width equal to the sample time rather than as an impulse train.

\subsection{Quantization}

To quantize the signal after the sample-and-hold into $N$ bits, several strategies can be used. One popular approach is called \emph{successive approximation}, illustrated below

\begin{center}
  \includegraphics[scale=1]{graphics/sar.pdf}
\end{center}

The current quantized digital value is held in a counter connected to a clock signal. The direction of the counter (up or down) is controlled by a comparator connected to the output of the sample and hold and the current counter output and a digital-to-analog converter (DAC, usually a resistor ladder) that converts it back to an analog value. If the DAC value is less than the held value, the counter counts up, if the DAC value is greater than the held value the counter counts down. In this fashion the counter output tracks the held value after a settling time required for convergence, at which point the counter value is clocked into a register for storage.

\subsection{Anti-aliasing}

Before the sample and hold we need to include a filter to limit the bandwidth. This can be accomplished by a CT low-pass filter called an \emph{anti-aliasing} filter whose cutoff frequency in the ideal case is $\omega_c = 2\pi B$. As we saw in lecture 24 ideal filters cannot be implemented, thus we specify the anti-aliasing filter as a pass-band gain/frequency and a stop-band gain/frequency. Since the transition band is non-zero for a practical filter, this means we have to either lower the pass-band relative to the ideal or increase the sample rate. In the best case, the filter should have a stop-band frequency at half the sampling frequency with the order of the filter and pass-band frequency adjusted as needed. Alternatively the gain that defines the stop-band can be relaxed. This gives a desired frequency response magnitude that looks like the following.

\begin{center}
  \includegraphics[scale=1]{graphics/antialias.pdf}
\end{center}
The bold dotted line shows the maximum frequency response of the first image.


\chapter{Initial Value Problems and their Properties}
\label{cha:IVP}
\input{models}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction to initial value problems}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{Definition*}{ode}{Ordinary differential equations} \label{Definition:IVP}
  \defindex{differential equation!ordinary|see{ordinary differential equation}} \index{ODE|see{ordinary
      differential equation}} An \define{ordinary differential
    equation} (ODE) is an equation for a function $u(t)$, defined on
  an interval $I \subset \R$ and with values in the real or complex
  numbers or in the space $\R^d$ ($\C^d$), of the form
  \begin{gather}
    F\bigl(t, u(t), u'(t), u''(t), \dots, u^{(n)}(t)\bigr) = 0.
  \end{gather}
  Here $F(\ldots)$ denotes an arbitrary function of its arguments.
  The \textbf{order}\defindex{order!of a differential equation} $n$ of
  a differential equation is the highest derivative which occurs.  If
  the dimension $d$ of the value range of $u$ is higher than one, we
  talk about systems of differential equations.
\end{Definition*}

\begin{remark}
  A differential equation, which is not ordinary, is called partial.
  These are equations or systems of equations, which involve partial
  derivatives with respect to several independent variables.  While
  the functions in an ordinary differential equation may be dependent
  on additional parameters, derivatives are only taken with respect to
  one variable, typically, but not exclusively, this variable is
  time. Due to the fact that this manuscript just deals with ordinary
  differential equations, the adjective will be omitted in the
  following.
\end{remark}

\begin{Definition}{explicit-ode}{Explicit differential equation}
  \defindex{ordinary differential equation!explicit} An \define{explicit
    differential equation} of first order is a equation of the form
  \begin{align}
    \label{eq:IVP:ode}
    u'(t) &= f(t,u(t))\\
    \text{or shorter:}\qquad u'&=f(t,u). \notag
  \end{align}
  A differential equation of order $n$ is called explicit, if it is of
  the form
  \begin{gather*}
    u^{(n)}(t) = F\left(t, u(t), u'(t), \ldots, u^{(n-1)}(t)\right)
  \end{gather*}
\end{Definition}

\begin{Lemma}{first-order}
  Every differential equation of higher order can be written as a
  system of first-order differential equations. If the equation is
  explicit, then the system is explicit.
\end{Lemma}

\begin{proof}
  By the introduction of additional variables $u_0(t) = u(t)$, $u_1(t)
  = u'(t)$ to $u_{n-1}(t) = u^{(n-1)}(t)$, each differential equation of
  order $n$ can be transformed into a system of $n$ differential equations
  of first order. This system has the form
  \begin{gather}
    \label{eq:IVP:13}
    \begin{pmatrix}
      u_0'(t) - u_1(t) \\
      u_1'(t) - u_2(t) \\
      \vdots\\
      u_{n-2}'(t) - u_{n-1}(t) \\
      F\bigl(t, u_0(t),u_1(t),\dots,u_{n-1}(t), u_{n-1}'(t)\bigr)
    \end{pmatrix}
    =
    \begin{pmatrix}
      0\\0\\\vdots\\0\\0
    \end{pmatrix}.
  \end{gather}
  In the case of an explicit equation, the system has the form
  \begin{gather}
    \label{eq:IVP:13a}
    \begin{pmatrix}
      u_0'(t) \\
      u_1'(t) \\
      \vdots\\
      u_{n-2}'(t) \\
      u_{n-1}' (t)
    \end{pmatrix}
    =
    \begin{pmatrix}
      u_1(t)\\u_2(t)\\\vdots\\u_{n-1}(t)\\F\bigl(t, u_0(t),u_1(t),\dots,u_{n-1}(t)\bigr)
    \end{pmatrix}.
  \end{gather}
\end{proof}

\begin{example}
  \label{ex:IVP:sine-1}
  The differential equation
  \begin{gather}
    \label{eq:IVP:17}
    u'' + \omega^2 u = f(t)
  \end{gather}
  can be transformed into the system
  \begin{gather}
    \label{eq:IVP:18}
    \begin{split}
      u_1' - u_2 &= 0, \\
      u_2' + \omega^2 u_1 &= f(t).
    \end{split}
  \end{gather}
  The transformation is not uniquely determined. In this example, a
  more symmetric system can be obtained:
  \begin{gather}
    \label{eq:IVP:18a}
    \begin{split}
      u_1' - \omega u_2 &= 0, \\
      u_2' + \omega u_1 &= f(t).
    \end{split}
  \end{gather}
  From a numerical perspective, system ~\ref{eq:IVP:18a} should be
  chosen over ~\ref{eq:IVP:18} to avoid loss of significance or overflow,
  i.e. if $|\omega| \ll 1$ or $|\omega| \gg 1$.
\end{example}

\begin{Definition}{autonomization}
  A differential equation of the form~\eqref{eq:IVP:ode} is called
  \textbf{autonomous}, \defindex{autonomous differential equation} if
  the right hand side $f$ is not explicitly dependent on $t$, i.e.
  \begin{gather}
    u'=F(u).
  \end{gather}

  Each differential equation can be transformed into an autonomous
  differential equation.  This is called
  \textbf{autonomization}. \defindex{autonomization}
  \begin{equation*}
    U = \begin{pmatrix} u \\ t \end{pmatrix},
    \qquad
    F(U) = \begin{pmatrix} f(t,u) \\ 1 \end{pmatrix},
    \qquad
    U' = F(U)
  \end{equation*}

  A method which provides the same solution for the autonomous
  differential equation as for the original IVP, is called
  \textbf{invariant under autonomization}.
\end{Definition}

Differential equations usually provide sets of solutions from which we
have to choose a solution. An important selection criteria is setting
an initial value which leads to a well-posed problem (see below).

\begin{Definition}{IVP}
  \index{IVP|see{initial value problem}} Given a point
  $(t_0,u_0)\in \R \times \R^d$.  Furthermore, let the function
  $f(t,u)$ with values in $\R^d$ be defined in a neighborhood
  $I\times U \subset \R\times \R^d$ of the initial value.  Then an
  \define{initial value problem} (IVP) is defined as follows: find a
  function $u(t)$, such that
  \begin{subequations}
    \label{eq:IVP}
    \begin{align}
      \label{eq:IVP:2}
      u'(t)&=f\bigl(t,u(t)\bigr)
      \\
      \label{eq:IVP:3}
      u(t_0)&=u_0
  \end{align}
  \end{subequations}
\end{Definition}

\begin{Definition}{local-solution}
    \label{def:IVP:local solution}
  \defindex{solution!local} We call a continuously differentiable
  function $u(t)$ with $u(t_0) = 0$ a \define{local solution} of the
  IVP~\eqref{eq:IVP}, if there exists a neighborhood $J$ of the point
  in time $t_0$ in which $u$ and $f(t,u(t))$ are defined and if the
  equation~\eqref{eq:IVP:2} holds for all $t\in J$.
\end{Definition}

\begin{remark}
  We introduced the IVP deliberately in a ``local'' form because the
  local solution term is the most useful one for our purpose. Due to
  the fact that the neighborhood $J$ in the definition above can be
  arbitrarily small, we will have to deal with the extension to larger
  intervals below.
\end{remark}

\begin{remark}
  Through the substitution of $t\mapsto \tau$ with $\tau = t-t_0$ it
  is possible to transform every IVP at the point $t_0$ to a IVP in
  point $0$. We will make use of this fact and soon always assume
  $t_0 = 0$.
\end{remark}

\begin{Lemma}{volterra}
  Under the assumption that the right hand side $f$ is continuous in
  both arguments, the function $u(t)$ is a solution of the initial
  value problem~\eqref{eq:IVP} if and only if it is a solution of the
  \define{Volterra integral equation} (VIE) \index{VIE!see{Volterra
      integral equation}}
  \begin{gather}
    \label{eq:volterra}
    u(t) = u_0 + \int_{t_0}^t f\bigl(s,u(s)\bigr)\ds.
  \end{gather}
  The formulation as integral equation allows on the other hand a more
  general solution term, because the problem is already well-posed for
  functions $f(t,u)$, which are just integrable with respect to $t$.
  In that case the solution $u$ would be just absolutely continuous
  and not continuously differentiable.
\end{Lemma}

\begin{remark} \label{remark:volterra}
  Both the theoretical analysis of the IVP and the numerical methods
  (with exception of the BDF methods) in this lecture notes, solve
  actually never the IVP~\eqref{eq:IVP} but always the associated
  integral equation ~\eqref{eq:volterra}.
\end{remark}

\begin{Theorem*}{peano}{Peano's existence theorem}
  \defindex{Peano's theorem}
  \label{satz:peano}
  Let the function $f(t,u)$ be continuous on the closed set
  \begin{gather*}
    \overline D =\bigl\{
    (t,u) \in \R\times\R^d \;\big|
    \;|t-t_0| \le \alpha,\;
    |u-u_0|\le\beta
    \bigr\},
  \end{gather*}
  where $\alpha,\beta>0$. Then there exists a solution
    $u(t) \in C^1(I)$
  on the interval
    $I=[t_0-T,t_0+T]$
  with
  \begin{gather*}
    T=\min\left(\alpha ,\frac{\beta}{M}\right),\;
    M=\max_{(t,u)\in \overline D} \ |f(t,u)|.
  \end{gather*}
\end{Theorem*}

The proof of this theorem is of little consequence for the remainder
of these notes.  For its verification, we refer to textbooks on the
theory of ordinary differential equations.

\begin{remark}
  The Peano existence theorem does not make any statements about the
  uniqueness of a solution and also just guarantees local existence.
  The second limitation is addressed by the following theorem. The
  first will be postponed to section~\ref{sec:IVP:well-posedness}.
\end{remark}

\begin{Theorem*}{peano-continuation}{Peano's continuation theorem}
  Let the assumptions of Theorem~\ref{satz:peano} hold. Then, the
  solution can be extended to an interval $I_m = [t_-, t_+]$ such that
  the points $\bigl(t_-,u(t_-)\bigr)$ and $\bigl(t_+,u(t_+)\bigr)$ are
  on the boundary of $\overline D$. Neither the values of $t$, nor of
  $u(t)$ need to be bounded as long as $f$ remains bounded.
\end{Theorem*}

\begin{example}
  The IVP
  \begin{gather*}
    u' = 2 \sqrt{\lvert u \rvert}, \qquad u(0) = 0,
  \end{gather*}
  has solutions $u(t) = t^2$ and $u(t) = 0$.
\end{example}

\begin{example}
  The functions $1/(t-t_0)$ are solutions to the IVP
  \begin{gather*}
    u'=-u^2, \qquad u(t_0) = 1.
  \end{gather*}
\end{example}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Linear differential equations
  and Grönwall's inequality}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{intro}
  The examination of linear differential equation turns out to be
  particularly simple. On the other hand, results obtained here will
  provide us with important statements for general non-linear
  IVP. Therefore we pay particular attention to the linear case.
\end{intro}

\begin{Definition}{linear-ode}
    \defindex{ordinary differential equation!linear} An IVP according to
  definition ~\ref{Definition:IVP} is called \textbf{linear} \defindex{linear
    differential equation} if the right hand side $f$ is an affine
  function of $u$. Thus, we can write it in the form
  \begin{subequations}
    \label{eq:IVP:4}
    \begin{xalignat}{2}
      \label{eq:IVP:5}
      u'(t) &= A(t)u(t) + b(t)
      & \forall t &\in \R \\
      \label{eq:IVP:6}
      u(t_0) &= u_0
    \end{xalignat}
  \end{subequations}
  with a continuous matrix function $A:\R\to \C^{d \times d}$. If in
  addition $b(t) \equiv 0$, we call it \define{homogeneous}.
\end{Definition}

\begin{Definition}{integrating-factor}
    Let the matrix function $A:I\to \C^{d\times d}$ be continuous.  Then
  the function defined by
  \begin{gather}
    \label{eq:IVP:7}
    M(t) = \exp\left(-\int_{t_0}^t A(s) \ds\right)
  \end{gather}
  is called \define{integrating factor} of the
  equation~\eqref{eq:IVP:5}.
\end{Definition}

\begin{corollary}
  The integrating factor $M(t)$ has the properties
  \begin{align}
    \label{eq:IVP:14}
    M(t_0) &= \identity\\
    \label{eq:IVP:15}
    M'(t) &= -M(t)A(t).
  \end{align}
\end{corollary}

\begin{Lemma}{linear-representation}
  % Voraussetzungen an A und b
  A solution of the IVP~\eqref{eq:IVP:4} is given through the
  representation
  \begin{gather}
    \label{eq:IVP:8}
    u(t) =  M(t)^{-1}\left(u_0 + \int_{t_0}^t M(s) b(s) \ds\right)
  \end{gather}
  with the integrating factor $M(t)$ of the equation~\eqref{eq:IVP:7}.
  This solution exists for all $t\in \R$.
\end{Lemma}

\begin{proof}
  We consider the auxiliary function $w(t) = M(t) u(t)$ with the
  integrating factor $M(t)$ of the equation~\eqref{eq:IVP:7}. Using the
  product rule, there holds
  \begin{gather}
    \label{eq:IVP:19}
    w'(t) =  M(t) u'(t) + M'(t) u(t)
    =  M(t) u'(t) - M(t)A(t)u(t).
  \end{gather}
  Comparing this to the differential equation~\eqref{eq:IVP:5}, we see
  that $w$ solves
  \begin{gather*}
    w'(t) = M(t) b(t).
  \end{gather*}
	This can be integrated directly to obtain
  \begin{gather*}
    w(t) = u_0 + \int_{t_0}^t M(s) b(s) \ds,
  \end{gather*}
  where we use that $w(t_0) = u_0$.  According to
  lemma~\ref{Lemma:appendix:exp-1} about the \putindex{matrix
    exponential}, $M(t)$ is invertible for all $t$.  With the
  definition of $w(t)$ we are therefore able to solve for $u(t)$,
  which results in the equation~\eqref{eq:IVP:8}. The global
  solvability follows from the fact that the solution is defined for
  arbitrary $t\in \R$.
\end{proof}

\begin{example}
  \label{ex:IVP:sine-2}
  The equation in example~\ref{ex:IVP:sine-1} is linear and can be
  written in the form of~\eqref{eq:IVP:4} with
  \begin{align*}
    A(t) = A &=
    \begin{pmatrix}
      0 & \omega \\ -\omega & 0
    \end{pmatrix}
    \\
    b(t) &= f(t).
  \end{align*}
  Let now $f(t) \equiv 0$. The Jordan canonical form of $A$ is
  \begin{gather*}
    A = C^{-1}
    \begin{pmatrix}
      \omega i \\ & -\omega i
    \end{pmatrix}
    C
  \end{gather*}
  with a suitable transformation matrix $C$. The integrating factor is
  \begin{gather*}
    M(t) = e^{At} = C^{-1}
    \begin{pmatrix}
      e^{\omega i} \\ & e^{-\omega i}
    \end{pmatrix} C
    =
    \begin{pmatrix}
      \cos \omega t & \sin \omega t \\
      -\sin \omega t & \cos \omega t
    \end{pmatrix}.
  \end{gather*}
  Thus, given an initial value $(u_0, v_0)^T$, the solution is
  \begin{gather*}
    u(t) =  \begin{pmatrix}
      \cos \omega t & \sin \omega t \\
      -\sin \omega t & \cos \omega t
    \end{pmatrix}
    \begin{pmatrix}
      u_0\\v_0
    \end{pmatrix}.
  \end{gather*}
  The missing details in this argument and the case for an
  inhomogenety $f(t) = \cos \alpha t$ are left as an exercise.
\end{example}

\begin{remark}
  If the function $b(t)$ in~\eqref{eq:IVP:5} is only integrable, the
  function $u(t)$ defined in~\eqref{eq:IVP:8} is absolutely continuous
  and thus differentiable almost everywhere. The chain
  rule~\eqref{eq:IVP:19} is applicable in all points of
  differentiability and $w(t)$ solves the Volterra integral equation
  corresponding to~\eqref{eq:IVP:4}. Thus, the representation
  formula~\eqref{eq:IVP:8} holds generally for solutions of linear
  Volterra integral equations.
\end{remark}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{Lemma*}{gronwall}{Grönwall}
  Let be $w(t)$, $a(t)$ and $b(t)$ be nonnegative, integrable
  functions, such that $a(t)w(t)$ is integrable. Furthermore, let
  $b(t)$ be monotonically nondecreasing and let $w(t)$ satisfy the
  integral inequality
  \begin{gather}
    \label{eq:IVP:10}
    w(t) \le b(t) + \int_{t_0}^t a(s)w(s)\ds,\qquad t\ge t_0.
  \end{gather}
  Then, for almost all $t \ge t_0$ there holds:
  \begin{gather}
    \label{eq:IVP:11}
    w(t) \le b(t) \exp\left( \int_{t_0}^t  a(s) \ds\right).
  \end{gather}
\end{Lemma*}

\begin{proof}
  Using the integrating factor
  \begin{gather*}
    m(t) = \exp\left(-\int_{t_0}^t a(s) \ds\right),
    \quad
    \frac1{m(t)} = \exp\left(\int_{t_0}^t a(s) \ds\right),
  \end{gather*}
  we introduce the auxiliary function
  \begin{gather*}
    v(t) = m(t) % \exp\left(-\int_{t_0}^t a(s) \ds\right)
    \int_{t_0}^t a(s)w(s)\ds,
  \end{gather*}
  This function is absolutely continuous and almost everywhere
  \begin{gather*}
    v'(t) = m(t) a(t) %\exp\left(-\int_{t_0}^t a(s) \ds\right)
    \left[
      w(t) - \int_{t_0}^t a(s) w(s) \ds
    \right].
  \end{gather*}
  By assumption~\eqref{eq:IVP:10}, the bracket on the right is bounded
  by $b(t)$. Thus,
  \begin{gather*}
    v'(t) \le m(t) a(t) b(t) %\exp\left(-\int_{t_0}^t a(s) \ds\right),
  \end{gather*}
  and since $v(t_0) = 0$ by its definition,
  \begin{gather*}
    v(t) \le \int_{t_0}^t m(s) a(s) b(s) % \exp\left(-\int_{t_0}^s a(r)
    \ds.
  \end{gather*}
  From the definition of $v(t)$, we obtain
  \begin{gather*}
    \int_{t_0}^t a(s)w(s)\ds = \frac1{m(t)} % \exp\left(\int_{t_0}^t a(s) \ds\right)
    v(t)
    \le \frac1{m(t)} \int_{t_0}^t m(s)a(s)b(s) \ds
    % \exp\left( %\int_{t_0}^t a(r) \dr
    %   - \int_{t_0}^s a(r) \dr\right)\ds
  \end{gather*}
  Finally, since $b(t)$ is nondecreasing we obtain almost everywhere
  \begin{align*}
    \int_{t_0}^t a(s)w(s)\ds
    &\le  \frac{b(t)}{m(t)} \int_{t_0}^t a(s)
    \exp\left(-\int_{t_0}^s a(r) \dr\right)\ds
    \\
    &= \frac{b(t)}{m(t)} \left[-
    \exp\left(-\int_{t_0}^s a(r) \dr\right)
      \right]_{t_0}^t
    \\
    &= \frac{b(t)}{m(t)} \bigl(m(t_0)-m(t)\bigr)
      = \frac{b(t)}{m(t)} - b(t)
  \end{align*}
  Now, entering into the integral inequality~\eqref{eq:IVP:10}, we
  obtain
  \begin{gather*}
    w(t) \le b(t) + \int_{t_0}^t a(s)w(s)\ds = \frac{b(t)}{m(t)},
  \end{gather*}
  which proves the lemma.
\end{proof}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{remark}
	On the form of the requirements~\eqref{eq:IVP:10} as well as the
  estimation~\eqref{eq:IVP:11}, we can see that Grönwall's
  inequality is basically based on the construction of a majorant for
	$w(t)$, which satisfies a linear IVP.
\end{remark}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{Corollary}{IVP:unique-linear}
  Let the functions $u(t)$ and $v(t)$ be two solutions of the linear
  differential equation~\eqref{eq:IVP:5}. If both functions
  coincide in a point $t_0$ then they are identical.
\end{Corollary}

\begin{proof}
	The difference $w(t) = v(t) - u(t)$ solves the integral equation
  \begin{gather*}
    w(t) = \int_{t_0}^t A(s) w(s) \ds.
  \end{gather*}
  Hence $|w(t)|$ satisfies the integral inequality
  \begin{gather*}
    |w(t)| \le \int_{t_0}^t |A(s)| |w(s)| \ds,
  \end{gather*}
	from which we conclude with Grönwall's inequality~\eqref{eq:IVP:11}
	for $b(t) = 0$, that $|w(t)|=0$ for all $t$ and therefore
  $u(t) = v(t)$.
\end{proof}

\begin{corollary}
  The representation formula~\eqref{eq:IVP:8} in
  Lemma~\ref{Lemma:linear-representation} defines the unique solution to the
  IVP~\eqref{eq:IVP:4}. In particular, solutions of linear IVP are
  always defined on the whole real axis.
\end{corollary}

\begin{example}
  Let $A \in \C^{d\times d}$ be diagonalizable with possibly repeated
  eigenvalues $\lambda_1,\dots,\lambda_d$ and corresponding
  eigenvectors $\psi^{(i)}$. Let $\Psi$ be the matrix of column
  vectors $\psi^{(i)}$. Then, the solution of the IVP
  \begin{gather*}
    \begin{split}
      u' &= A u,\\
      u(0) &= u_0,
    \end{split}
  \end{gather*}
  is given by the formula
  \begin{gather*}
    u(t) = e^{At} u_0 = \Psi \exp
    \begin{pmatrix}
      \lambda_1\\&\ddots\\&&\lambda_d
    \end{pmatrix}
    \Psi^{-1} u_0.
  \end{gather*}
  This is due to the fact, that $M(t) = e^{-At}$ and $e^{-\Psi A
    \psi^{-1}t} = \Psi e^{-At} \Psi^{-1}$.
\end{example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{Lemma}{solution-space}
  \index{homogeneous}
  \index{ordinary differential equation!linear!homogeneous}
  The solutions of the homogeneous, linear differential equation
  \begin{gather}
    \label{eq:IVP:9}
    u'(t) = A(t) u(t)
  \end{gather}
  with $u:\R\to\R^d$, define a vector space of dimension $d$. Let
  $\{\psi^{(i)}\}_{i=1,\dots,d}$ be a basis of $\R^d$.
	Then the solutions $\phi^{(i)}(t)$ of the equation~\eqref{eq:IVP:9} with
  initial values $\phi^{(i)}(0) = \psi^{(i)}$ form a basis of the solution
  space. The vectors $\{\phi^{(i)}(t)\}$ are linear independent
  for all $t\in \R$.
\end{Lemma}

\begin{proof}
  At first we observe that for two solutions $u(t)$ and $v(t)$ of the
  equation~\eqref{eq:IVP:9}, their sum and their scalar multiples are
  solutions too, due to linearity \index{linear} of the derivative
  and the right hand side.  Therefore the vector space structure is
  proven.

  Let now $\phi^{(i)}(t)$ be solutions of the IVP with linear
  independent initial values $\{\psi^{(i)}\}$.  As a consequence the
  functions are linear independent as well.

  Assume that $w(t)$ is a solution of the equation~\eqref{eq:IVP:9},
  which cannot be written as a linear combination of $\psi^{(i)}$.
  Then $w(0)$ is not a linear combination of the vectors $\psi^{(i)}$:
  else let's say $w(0) = \sum \alpha_i \psi^{(i)}$, then
  $w(t) = \sum \alpha_i \phi^{(i)}(t)$ would be a linear combination
  because of uniqueness proven in
  corollary~\ref{Corollary:IVP:unique-linear}.  Since $\{\psi^{(i)}\}$
  according to the assumtions is a basis of $\R^d$, such a $w(0)$
  cannot exist.  Hence it is shown that $\phi^{(i)}(t)$ is a basis of
  the solution space of dimension $d$.

  It remains to show that the $\phi^{(i)}(t)$ are linearly independent
  for all $t\in \R$. To this end, assume that the set $\phi^{(i)}(t)$
  is linearly dependent for a value $t_1$.  Then the following holds
  true without loss of generality
  \begin{gather*}
    \phi^{(d)}(t_1) = \sum_{i=1}^{d-1}\alpha_i\phi^{(i)}(t_1) =: w(t).
  \end{gather*}
  Again according to corollary~\ref{Corollary:IVP:unique-linear} we
  have $\phi^{(d)} \equiv w$, moreover $\phi^{(d)}(0) = w(0)$ which
  again is a contradiction to the assumption $\psi^{(d)}$ is a linear
  combination of the other initial values.
\end{proof}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{Definition}{fundamental-system}
  A basis $\{\phi^{(1)},\dots,\phi^{(d)}\}$ of the solution space of
  the linear differential equation~\eqref{eq:IVP:9}, in particular the
  basis with initial values $\phi^{(i)}(0) = e_i$, is called
  \define{fundamental system} of solutions.  The
  matrix function
  \begin{gather}
    \label{eq:IVP:12}
    \fundam(t) =
    \begin{pmatrix}
      \phi^{(1)}(t)\dots\phi^{(d)}(t)
    \end{pmatrix}
  \end{gather}
  with column vectors $\phi^{(i)}(t)$ is called
  \define{fundamental matrix}.
\end{Definition}

\begin{Corollary}{fundamental-regular}
  The fundamental matrix is regular for all $t\in \R$ and solves the
  IVP
  \begin{align*}
    \fundam'(t) &= A(t)\fundam(t)\\
    \fundam (0) &= \identity.
  \end{align*}
\end{Corollary}

\begin{proof}
  The initial value is part of the definition. On the other hand,
  splitting the the matrix valued IVP into its column vectors, we
  obtain the original IVP defining the solution space. Regularity
  follows from linear independence of solutions for any $t$.
\end{proof}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Well-posedness of the IVP}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\label{sec:IVP:well-posedness}

\begin{Definition}{hadamard}
  A mathematical problem is called \define{well-posed} if the
  following \textbf{Hadamard conditions} are satisfied:
  \index{Hadamard conditions}
  \begin{enumerate}
  \item A solution exists.
  \item The solution is unique.
  \item The solution is continuously dependent on the data.
  \end{enumerate}
  The third condition in this form is purely qualitative. Typically,
  in order to characterize problems with good approximation
  properties, we will require \putindex{Lipschitz continuity}, which
  has a more quantitative character.
\end{Definition}

\begin{example}
  The IVP
  \begin{gather*}
    u'= \sqrt[3]{u}, \qquad u(0) = 0,
  \end{gather*}
  has solutions of the form
  \begin{gather*}
    u(t) =
    \begin{cases}
      0 \\
      c \left(\tfrac23t\right)^{3/2}.
    \end{cases}
  \end{gather*}
  Thus, the solution is not unique and therefore, the IVP is not
  well-posed.
  Let now the initial value be nonzero, but slightly positive. Then, a small
  perturbation, which changes its sign, will have dramatic effect on
  the solution.
\end{example}

\begin{Definition}{Lipschitz-condition}
  The function $f(t,y)$ satisfies on its domain $D = I\times\Omega \subset
  \R \times \R^d$ an uniformly continuous \define{Lipschitz condition} if
	it is Lipschitz continuous with regard to $y$, i.e., it exists a
	positive constant $L$, such that
  \begin{gather}
    \label{eq:IVP:1}
    \forall t\in I;\,x,y\in\Omega \;:\;
    \abs{f(t,x)-f(t,y)} \le L \abs{x-y}
  \end{gather}
  It satisfies a local Lipschitz condition if the same holds true for all
  compact subsets of $D$.
\end{Definition}

\begin{example}
  Let $f(t,u)\in C^1(\R \times\R^d )$ and let all partial derivatives
  with respect to components of $u$ be bounded by
  \begin{gather*}
    \max_{\substack{t\in \R\\u\in \R^d\\1\le i,j \le d}}
   \abs{
     \frac{\partial}{\partial u_i} f_j(t,u)
   } \le K.
  \end{gather*}
  Then, $f$ satisfies the Lipschitz condition~\eqref{eq:IVP:1} with
  $L=K$. Indeed, by using Taylor expansion, we see that
  \begin{multline*}
    f_j(t, u) - f_j(t,v)
    = \int_0^1 \frac{d}{ds}f_j\bigl(t,u+s(v-u)\bigr)\ds\\
    = \int_0^1 \sum_{i=1}^d(u_i-v_i)\partial_if_j\bigl(t,u+s(v-u)\bigr)\ds.
  \end{multline*}
  It is an easy conclusion that
  \begin{gather*}
    \abs{f(t,u)-f(t,v)}
    \le K \abs{u-v}.
  \end{gather*}
\end{example}

\begin{Theorem*}{IVP-stability}{Stability}
  Let $f(t,u)$ and $g(t,u)$ be two continuous functions on a
  cylinder $D = I \times \Omega$ where the interval $I$ contains
  $t_0$ and $\Omega$ is a convex set in $\R^d$.  Furthermore, let
  $f$ admit a Lipschitz condition with constant $L$ on $D$. Let $u$
  and $v$ be solutions to the IVP
  \begin{xalignat}{2}
    \label{eq:IVP:20}
    u'&=f(t,u) \quad\forall t\in I,& u(t_0)&= u_0,\\
    \label{eq:IVP:21}
    v'&=g(t,v) \quad\forall t\in I,& v(t_0)&= v_0.
  \end{xalignat}
  Then, there holds
  \begin{gather}
    \label{eq:IVP:22}
    \abs{u(t)-v(t)} \le e^{L|t-t_0|}
    \left[ \abs{u_0-v_0}
      + \int_{t_0}^{t} \max_{x\in\Omega}
      \abs{f(s,x)-g(s,x)}\ds
    \right].
  \end{gather}
\end{Theorem*}

\begin{proof}
  Both $u(t)$ and $v(t)$ solve their respective Volterra integral
  equations. Taking the difference, we obtain
  \begin{align*}
    u(t)-v(t) &= u_0-v_0
           + \int_{t_0}^t \bigl[ f(s,u(s)) - g(s,v(s)) \bigr]\ds
    \\
         &= u_0-v_0
           + \int_{t_0}^t \bigl[ f(s,u(t)) - f(s,v(s)) \bigr]\ds
           + \int_{t_0}^t \bigl[ f(s,v(t)) - g(s,v(s)) \bigr]\ds.
  \end{align*}
  Thus, its norm admits the integral inequality
  \begin{align*}
    \abs{u(t)-v(t)}
    &\le \abs{u_0-v_0} + \int_{t_0}^t\abs{f(s,u(t)) - f(s,v(s))} \ds
    + \int_{t_0}^t \abs{f(s,v(t)) - g(s,v(s))} \ds
    \\
    &\le \underbrace{\abs{u_0-v_0}
      + \int_{t_0}^t \max_{x\in\Omega} \abs{f(s,x)-g(s,x)}\ds}_{b(t)}
      + \int_{t_0}^t L \abs{u(s)-v(s)} \ds.
  \end{align*}
  This inequality is in the form of the assumption in Grönwall's
  lemma, and its application yields the stability result.
\end{proof}

\begin{Theorem*}{picardlindelof}{Picard-Lindelöf}
  \defindex{Picard-Lindelöf theorem}
  Let $f(t,y)$ be continuous on a cylinder
  \begin{gather*}
    D = \{ (t,y) \in \R \times
    \R^d | \ |t-t_0| \le a, |y-u_0| \le b \}.
  \end{gather*}
  Let $f$ be bounded such that there is a constant $M = \max_D
  \abs{f}$ and satisfy the Lipschitz condition~\eqref{eq:IVP:1} with
  constant $L$ on $D$.  Then the IVP
  \begin{gather*}
    \begin{split}
      u' &= f(t,u) \\ u(t_0) &= u_0
    \end{split}
  \end{gather*}
  is uniquely solvable on the interval
  $I = [t_0-T,t_0+T]$ where
  $T = \min \{ a, \frac{b}{M} \}$.
\end{Theorem*}

\begin{proof}
  First, we assume for simplicity $t_0=0$ or we transform the problem
  accordingly. Abbreviate $I = [-T,T]$ and
  \begin{gather*}
    \Omega = \bigl\{x\in \R^d\big| \abs{x-u_0} \le b \bigr\}.
  \end{gather*}

  We introduce the operator $F(u)$ which is defined
  through the \putindex{Volterra integral
    equation}~\eqref{eq:volterra} as
  \begin{gather}
    \label{eq:IVP:16}
   F(u)(t) = u_0 + \int\limits_{0}^t f(s,u(s)) \ds.
  \end{gather}
  Obviously $u$ is a solution of the Volterra integral
  equation~\eqref{eq:volterra} if and only if $u$ is a \putindex{fixed
    point} of $F$ i.e., $u=Fu$. We can obtain such a fixed-point by
  the iteration $u^{(k+1)} = F(u^{(k)})$ with some initial guess
  $u^{(0)}:I\to\Omega$. From the boundedness of $f$, we obtain for
  $t-t_0 \le T$
  \begin{align*}
    \abs{u^{(k+1)}(t)-u_0} = \abs[big]{\int_{t_0}^t f(s,u^{(k)}(s))\ds } \le \int_{t_0}^t
    \abs{f(s,u^{(k)}(s))}\ds \le TM \le b.
  \end{align*}
  Thus, from $u^{(0)}:I\to\Omega$ follows $u^{(k)}:I\to\Omega$ for all
  $k$ and the iteration is well-defined.

  We now show that $F$ is a contraction under the assumtions of the
  theorem. We follow the technique
  in~\cite[\S117]{Heuser86} and choose on the space $\mathcal C(I)$,
  which is the space of the continuous functions on $I$, the norm
  \begin{gather*}
    \norm{u}_e := \underset{t \in I}{max} ~e^{-2 L t} |u(t)|.
  \end{gather*}

  With estimating the difference of operator $F$ applied to two functions:
  \begin{align*}
    |F(u)(t) - F(v)(t)|
    & = \left| u_0 - u_0 + \int\limits_{0}^t (f(s,u(s)) - f(s,v(s))) \ds \right| \\
    & \le \int\limits_{0}^t \left| f\bigl(s,u(s)\bigr) - f\bigl((s,v(s)\bigr) \right| \ds \\
    & \le \int\limits_{0}^t L |u(s) - v(s)| \underbrace{e^{-2 L s} e^{2 L s}}_{= 1} \ds \\
    & \le L \norm{u-v}_e \int\limits_{0}^t e^{2 L s} \ds \\
    & = L \norm{u-v}_e \frac{e^{2 L t} - 1}{2 L} \\
    & \le \frac12 e^{2 L t} \norm{u-v}_e.
  \end{align*}

  It follows
  \begin{gather*}
    e^{-2 L t}|F(u)(t) - F(v)(t)| \le \frac12 \norm{u-v}_e,
  \end{gather*}
  for all $t$ and we observe:
  \begin{gather*}
    |F(u)(t) - F(v)(t)|_e \le \frac12 \norm{u-v}_e.
  \end{gather*}
  Thus, we have shown that $F$ is a contraction on the space of the
  continuous functions with the norm $\norm{.}_e$.  Therefore, we can apply
  the \putindex{Banach fixed-point theorem}, concluding that $F$ has
  exactly one fixed-point. This proves the theorem.
\end{proof}

\begin{remark}
  The norm $\norm{u}_e$ had been chosen with regard to Grönwall's
  inequality, which was not used in the proof explicitly.  It is
  equivalent to the norm $\norm{u}_\infty$ because $e^{-2 L t}$ is strictly
  positiv and bounded. On the other hand one could have performed the
  proof with some more calculations with respect to the ordinary
  Tchebychev distance (maximum norm) $\norm{u}_\infty$.
\end{remark}

\begin{remark}
  Currently our solution is restricted to $I = [t_0 - T, t_0 + T]$.
  Since $T$ is chosen in such a way in
  equation~\ref{Theorem:picardlindelof} that the graph of $u$ does not
  leave the domain, this extension always ends on the boundary of
  $D$. One can now extend the solution by solving the next IVP
  $\left\{\begin{array}{l}
            u' = f(t,u)\\
            u(t_1) = u_1\\
  \end{array}\right\}$
	on the interval $I_1$. This way one obtains a solution on
 $I \cup I_1 \cup I_2 \cup ...$.
\end{remark}

\begin{corollary}
  Let the function $f(t,u)$ admit the Lipschitz condition on $\R\times
  \C^d$. Then, the IVP has a unique solution on the whole real axis.
\end{corollary}

\begin{proof}
  The boundedness was used in order to guarantee that $u(t)\in \Omega$
  for any $t$. This is not necessary anymore, if $\Omega =
  \C^d$. Thus, the limitation of the interval $I$ becomes unnecessary
  as well. Finally, the fixed point argument does not depend on
  boundedness of the set.
\end{proof}
% \begin{theorem}[Differential stability]
%   In addition to the assumptions of the Picard-Lindelöf theorem, let
%   the gradient of $f$ with respect to its second argument, $\nabla_u
%   f(t,u)$ exist and be continuous in $D$. Then, the solution of the
%   IVP depends continuously on the initial value $u_0$ and the gradient
%   of the solution $u$ with respect to $u_0$ solves the IVP
%   \begin{gather}
%     \label{eq:IVP:23}
%     \begin{split}
%     (\nabla_{u_0} u)' &= \nabla_u f(t,u) \nabla_{u_0} u,
%     \\
%     \nabla_{u_0} u(t_0) &= \mathbb I.
%     \end{split}
%   \end{gather}
% \end{theorem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Examples}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \begin{example}
% 	It exists a solution of the IVP
%     $\left\{\begin{array}{l}
%       u'=\sin(u)\\
%       u(0)=7\\
%     \end{array}\right\}$?

%   \begin{enumerate}
%     \item The IVP is autonomous.
%     \item $|\sin(u)| \le 1$
%     \item $\sin(u)$ satisfies the Lipschitz condition with $L=1$.
%     \item $D = \R \times \R$
%   \end{enumerate}

%   $\Rightarrow$ Due to the theorems of Peano~\eqref{satz:peano} and Picard-Lindelöf~\eqref{Theorem:picardlindelof} it follows:
%   $\exists! u : \R \to \R$
% \end{example}

% \begin{example}
%   $\left\{\begin{array}{l}
%     u'(t) = -u^2\\
%     u(-1) = 1\\
%   \end{array}\right\}$

%   \begin{enumerate}
%     \item $u^2$ is continuous in $\R$.
%     \item However we just have a local Lipschitz condition.
%   \end{enumerate}
%   \noindent $\Rightarrow$ $u(t) = \frac1t$ auf $(-\infty,0)$
% \end{example}

% \begin{example}
%   $\left\{\begin{array}{l}
%     u' = \lambda u\\
%     u(0) = u_0\\
%   \end{array}\right\}$

% 	\begin{enumerate}
%   \item $\lambda u$ is Lipschitz continuous on $\R$
% 	\end{enumerate}

%   \noindent $\Rightarrow e^{\lambda t} u_0$ is the unique solution in $\R$.
% \end{example}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main"
%%% End:


\chapter{Finding the Closest Pair of Dots}
The objective of this challenge is to find the distance between the two closest
dots on a two-dimensional plane. No two dots occupy the same coordinate.

\section{Naive Solution}
% \imb[<++>][<++>]{\alg/closestpair.cpp}

\section{Application of the Merge Sort Algorithm}
% \imb[<++>][<++>]{\alg/closestpair.cpp}


\documentclass{article}
%\usepackage{fullpage}
%\usepackage{nopageno}
\usepackage[margin=1.5in]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[normalem]{ulem}
\usepackage{fancyhdr}
\usepackage{cancel}
%\renewcommand\headheight{12pt}
\pagestyle{fancy}
\lhead{April 9, 2014}
\rhead{Jon Allen}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\begin{enumerate}
\item
Let $f_0,f_1,f_2,\dots,f_n,\dots$ denote the Fibonacci sequence. By evaluating each of the following expressions for small values of $n$, conjecture a general formula and then prove it, using mathematical induction and the Fibonacci recurrence:
\begin{enumerate}
\item
$f_1+f_3+\dots+f_{2n-1}$
\begin{align*}
  &\cancel{0},1,\cancel{1},2,\cancel{3},5,\cancel{8},13,\cancel{21},34,\dots\\
  1&=1,\quad 1+2=3,\quad 1+2+5=8,\quad 1+2+5+13=21\\
  f_{2n}&=f_1+f_3+\dots+f_{2n-1}
\end{align*}
\subsubsection*{proof}
We already know the sum for $n=1$. Lets look at $n>1$
\begin{align*}
  f_1+f_3+f_5+\dots+f_{2n-1}&=f_1+\sum\limits_{k=2}^{n}{f_{2k-1}}\\
  f_n&=f_{n-1}+f_{n-2}\\
  f_1+f_3+f_5+\dots+f_{2n-1}&=1+\sum\limits_{k=2}^{n}{f_{2k-3}+f_{2k-2}}\\
  &=1+0+\sum\limits_{k=1}^{2n-2}{f_{k}}=1+f_0+\sum\limits_{k=1}^{2n-2}{f_{k}}\\
  s_n&=f_0+f_1+f_2+\dots+f_n=f_{n+2}-1\\
  f_1+f_3+f_5+\dots+f_{2n-1}&=1+s_{2n-2}=1+f_{2n-2+2}-1\\
  &=f_{2n}
\end{align*}
And we have our result. $\Box$
\item
$f_0+f_2+\dots+f_{2n}$
\begin{align*}
  &0,\cancel{1},1,\cancel{2},3,\cancel{5},8,\cancel{13},21,\cancel{34},55,\dots\\
  0&=0,\quad0+1=1\quad0+1+3=4\quad0+1+3+8=12,\quad0+1+3+8+21=33\\
  f_{2n+1}-1&=f_0+f_2+\dots+f_{2n}
\end{align*}
\subsubsection*{proof}
When looking for the pattern so we established that the formula is true for $n=0,1,2,3,4$ which is more than sufficient for a basis.
\begin{align*}
  f_0+f_2+\dots+f_{2n}&=\sum\limits_{k=0}^n{f_{2k}}\\
  f_n&=f_{n-1}+f_{n-2}\\
  f_0+f_2+\dots+f_{2n}&=f_0+\sum\limits_{k=1}^n{f_{2k-2}+f_{2k-1}}\\
  &=0+\sum\limits_{k=0}^{2n-1}{f_{k}}\\
  s_n&=f_0+f_1+f_2+\dots+f_n=f_{n+2}-1\\
  f_0+f_2+\dots+f_{2n}&=s_{2n-1}=f_{(2n-1)+2}-1\\
  &=f_{2n+1}-1
\end{align*}
And our result is proved. $\Box$
\item
$f_0-f_1+f_2-\dots+(-1)^nf_{n}$
\begin{align*}
  n&=1:0-1=-1,\quad n=2:0-1+1=0,\quad n=3:0-1+1-2=-2\\
  n&=4:0-1+1-2+3=1,\quad n=5:0-1+1-2+3-5=-4\\
  &f_0-f_1+(f_0+f_1)-(f_1+f_2)+(f_2+f_3)-\dots\\
  &f_0-f_1+f_0+f_1-f_1-f_2+f_2+f_3-\dots\\
  &-f_1+(-1)^nf_{n-1}
\end{align*}
So our general formula is $-1+(-1)^nf_{n-1}$
\subsubsection*{proof}
We know that the sum is 0 when $n=0$ and the sum is -1 when $n=1$. Let us look at when $n>1$
\begin{align*}
  f_0-f_1+f_2-\dots+(-1)^nf_{n}&=\sum\limits_{k=0}^n{(-1)^kf_k}\\
  &=f_0-f_1+\sum\limits_{k=2}^n{(-1)^kf_k}\\
  &=-1+\sum\limits_{k=2}^n{(-1)^k(f_{k-2}+f_{k-1})}\\
  &=-1+\sum\limits_{k=0}^{n-2}{(-1)^k(f_{k}+f_{k+1})}\\
  &=-1+\sum\limits_{k=0}^{n-2}{(-1)^kf_{k}}+\sum\limits_{k=0}^{n-2}{(-1)^kf_{k+1}}\\
  &=-1+\sum\limits_{k=0}^{n-2}{(-1)^kf_{k}}-\sum\limits_{k=1}^{n-1}{(-1)^kf_{k}}\\
  &=-1+(-1)^0f_0+\sum\limits_{k=1}^{n-2}{(-1)^kf_{k}}-\sum\limits_{k=1}^{n-2}{(-1)^kf_{k}}-(-1)^{n-1}f_{n-1}\\
  &=-1+(-1)^nf_{n-1}
\end{align*}
And we have our proof. $\Box$
%\item
%${f_0}^2+{f_1}^2+\dots+{f_n}^2$
%\begin{align*}
%  0^2&=0\\
%  0+1^2&=1\\
%  0+1^2+1^2&=2\\
%  0+1^2+1^2+2^2&=6\\
%  0+1^2+1^2+2^2+3^2&=15\\
%  0+1^2+1^2+2^2+3^2+5^2&=40\\
%  0+1^2+1^2+2^2+3^2+5^2+6^2&=76\\
%  0+1^2+1^2+2^2+3^2+5^2+6^2+7^2&=125\\
%\end{align*}
%\begin{align*}
%  {f_0}^2+{f_1}^2+\dots+{f_n}^2&=\sum\limits_{k=0}^n{{f_{k}}^2}\\
%  &={f_0}^2+{f_1}^2+\sum\limits_{k=2}^n{(f_{k-1}+f_{k-2})^2}\\
%  &={f_0}^2+{f_1}^2+\sum\limits_{k=2}^n{{f_{k-1}}^2+2f_{k-2}f_{k-1}+{f_{k-2}}^2}\\
%  &={f_0}^2+{f_1}^2+{f_{1}}^2+2f_{0}f_{1}+{f_{0}}^2+\sum\limits_{k=3}^n{{f_{k-1}}^2+2f_{k-2}f_{k-1}+{f_{k-2}}^2}\\
%  &={f_0}^2+{f_1}^2+{f_{1}}^2+2f_{0}f_{1}+{f_{0}}^2+\sum\limits_{k=3}^n{(f_{k-2}+f_{k-3})^2+2f_{k-2}f_{k-1}+{f_{k-2}}^2}\\
%  %{f_0}^2+{f_1}^2+\sum\limits_{k=2}^n{{f_{k}}^2}&={f_0}^2+{f_1}^2+\sum\limits_{k=2}^n{{f_{k-1}}^2+2f_{k-2}f_{k-1}+{f_{k-2}}^2}\\
%  %\sum\limits_{k=2}^n{{f_{k}}^2}-\sum\limits_{k=2}^n{{f_{k-1}}^2}&=\sum\limits_{k=2}^n{2f_{k-2}f_{k-1}+{f_{k-2}}^2}\\
%  %\sum\limits_{k=2}^n{{f_{k}}^2}-\sum\limits_{k=1}^{n-1}{{f_{k}}^2}&={f_n}^2+\sum\limits_{k=2}^{n-1}{{f_{k}}^2}-{f_1}^2-\sum\limits_{k=2}^{n-1}{{f_{k}}^2}
%\end{align*}
\end{enumerate}
\setcounter{enumi}{2}
\item
Prove th following about the Fibonacci numbers:
\begin{enumerate}
\setcounter{enumii}{1}
\item
$f_n$ is divisible by 3 if and only if $n$ is divisible by 4.
\subsubsection*{proof}
Let $f_n=3a_n+b_n$ where $a_n\in\mathbb{N}$ and $b_n\in\{0,1,2\}$.
Lets assume that $b_{n-1}=b_{n-2}=0$.
Then $f_n=3a_{n-1}+3a_{n-2}$ which means that for all $n$, $3\mid f_n$.
Three seconds of scratchwork shows this is clearly not true at least for low values of $n$.
Now lets assume that $3\nmid f_n$ for all $n$.
But $3\mid f_0$ and $3\mid f_4$ so clearly this isn't true.
We know now that 3 sometimes divides Fibonacci numbers, but not always.
So lets assume that $3\mid f_{n}$.
Then for $f_{n-1}=3a_{n-1}+2$ or $f_{n-1}=3a_{n-1}+1$.
Note that these cases can be seen at $f_4$ and $f_8$ respectively.
Also note that $4\mid4$ and $4\mid8$.
Finally notice that these two (four?) facts conveniently provide a basis for the following inductive proof in two cases where $3\mid f_n$ and $4\mid n$.

First we look at the case where $f_{n-1}=3a_{n-1}+2$.
Let the algebra walk the walk.
\begin{align*}
  f_{n+1}&=3a_n+3a_{n-1}+2=3(a_n+a_{n-1})+2=3a_{n+1}+2\\
  f_{n+2}&=3a_{n+1}+2+3a_n=3a_{n+2}+2\\
  f_{n+3}&=3a_{n+2}+2+3a_{n+1}+2=3a_{n+2}+3a_{n+1}+3+1=3a_{n+3}+1\\
  f_{n+4}&=3a_{n+3}+1+3a_{n+2}+2=3(a_{n+3}+a_{n+2}+1)
\end{align*}
And because $4\mid n$ then $4\mid n+4$.
Further, $3\mid f_{n+4}$ in this case.
Also notice that we have shown the other half of the if and only if.
Three does not divide any of $f_{n+1},f_{n+2},$ or $f_{n+3}$.

Now lets examine the case where $f_{n-1}=3a_{n-1}+1$. We proceed as above, with maths.
\begin{align*}
  f_{n+1}&=3a_n+3a_{n-1}+1=3a_{n+1}+1\\
  f_{n+2}&=3a_{n+1}+1+3a_{n}=3a_{n+2}+1\\
  f_{n+3}&=3a_{n+1}+1+3a_{n+2}+1=3a_{n+3}+2\\
  f_{n+4}&=3a_{n+3}+2+3a_{n+2}+1=3(a_{n+3}+a_{n+2}+1)
\end{align*}
So we see that this case meets all the conditions of the last case.

We have shown that a Fibanocci style recurrence relation is either always divisible by three or is divisible by three only every fourth number. In our case the numbers are not always divisible by three. The index of every fourth number that divides three is itself divided by four. Thus we have proven the assertion. $\Box$
\end{enumerate}
\item
Prove that the Fibonacci sequence is the solution of the recurrence relation
\[a_n=5a_{n-4}+3a_{n-5},\quad(n\ge5),\]
where $a_0=0,a_1=1,a_2=1,a_3=2,$ and $a_4=3$. Then use this formula to show that the Fibonacci numbers satisfy the condition that $f_n$ is divisible by 5 if and only if $n$ is divisible by 5.
\subsubsection*{proof}
Lets just try to wrangle the Fibanocci sequence into the relation shown.
\begin{align*}
  f_n&=f_{n-1}+f_{n-2}\\
  f_n&=(f_{n-2}+f_{n-3})+(f_{n-3}+f_{n-4})\\
  f_n&=(f_{n-3}+f_{n-4})+(f_{n-4}+f_{n-5})+(f_{n-4}+f_{n-5})+f_{n-4}\\
  f_n&=(f_{n-4}+f_{n-5})+f_{n-4}+f_{n-4}+f_{n-5}+f_{n-4}+f_{n-5}+f_{n-4}\\
  f_n&=5f_{n-4}+3f_{n-5}
\end{align*}
Since the relation is the same and the first five numbers are the same, the sequence is the same. $\Box$

The case where $5\mid f_{n-4}$ and $5\mid f_{n-5}$ is the trivial case and would mean that five divides all $f_n$ which is clearly not true, so we will just write off that case.

Let $f_n=5a_n+b_n$ where $a_n\in\mathbb{N}$ and $b_n\in\{0,1,2,3,4\}$.

Now lets assume that $5\mid f_{n-5}$ and $5\nmid f_{n-4}$. In other words $b_{n-5}=0$ and $b_{n-4}\ne0$
\begin{align*}
  f_n&=5(5a_{n-4}+b_{n-4})+3(5a_{n-5})\\
  f_n&=5(5a_{n-4}+b_{n-4}+3a_{n-5})
\end{align*}
So $b_n=0$ and therefore $5\mid f_n$ if $5\mid f_{n-5}$ and $5\nmid f_{n-4}$.

Now lets check on $5\mid f_{n-4}$ and $5\nmid f_{n-5}$
\begin{align*}
  f_n&=5(5a_{n-4})+3(5a_{n-5}+b_{n-5})\\
  f_n&=5(5a_{n-4}+3a_{n-5})+3b_{n-5}
\end{align*}
Since $3b_{n-5}\in\{3,6,9,12\}$ we can say that $5\nmid 3b_{n-5}$ and therefore $5\nmid f_n$
And for our last case lets find out what happens if five divides neither $f_{n-4}$ nor $f_{n-5}$.
\begin{align*}
  f_n&=5(a_{n-4}+b_{n-4})+3(5a_{n-5}+b_{n-5)}\\
  f_n&=5(a_{n-4}+b_{n-4}+3a_{n-5})+3b_{n-5}
\end{align*}
As above $5\nmid 3b_{n-5}$ so $5\nmid f_n$.

So we see 5 divides $f_n$ only every 5th $f_n$. Since $f_5=5$ we can say that $5\mid f_n$ if and only if $5\mid n$.
\setcounter{enumi}{6}
%\item
%* Let $m$ and $n$ be positive integers whose greatest common divisor is $d$. Prove that the greatest common divisor of the Fibonacci numbers $f_m$ and $f_n$ is the Fibonacci number $f_d$.
\setcounter{enumi}{10}
\item
The \emph{Lucas numbers} $l_0,l_1,l_2,\dots,l_n,\dots$ are defined using the same recurrence relation defining the Fibonacci numbers, but with differenct initial conditions:
\[l_n=l_{n-1}+l_{n-2}, (n\ge2),l_0=2,l_1=1.\]
Prove that
\begin{enumerate}
\item
$l_n=f_{n-1}+f_{n+1}$ for $n\ge1$
\subsubsection*{proof}
We can see that $l_1=1=0+1=f_0+f_2=f_{1-1}+f_{1+1}$. Also note that $l_2=l_1+l_0=1+2=f_{1}+f_{3}=f_{2-1}+f_{2+1}$. So our assumption holds for $n=1,2$. Lets assume it holds for any $n-1, n-2$ and verify that it holds for $n$.
\begin{align*}
  l_n&=l_{n-1}+l_{n-2}&\text{by definition of Lucas number}\\
  &=(f_{n-2}+f_{n})+(f_{n-3}+f_{n-1})&\text{by assumption}\\
  &=(f_{n}+f_{n-1})+(f_{n-2}+f_{n-3})\\
  &=f_{n+1}+f_{n-1}&\text{by definition of Fibanocci number}
\end{align*}
So the assumption holds for $n\ge3$ and we have proved our result by induction. $\Box$
\item
${l_0}^2+{l_1}^2+\dots+{l_n}^2=l_nl_{n+1}+2$ for $n\ge0$
\subsubsection*{proof}
So we see that ${l_0}^2=2^2=4=2+2=(2)(1)+2=l_0l_1$ and ${l_0}^2+{l_1}^2=2^2+1^2=5=3+2=(1)(3)+2=l_1l_2+2$. Now we know that our idea holds for $n=0,1$. Let us assume that our idea holds for all $n$. Lets see if it holds for $n+1$.
\begin{align*}
  {l_0}^2+{l_1}^2+\dots+{l_n}^2+{l_{n+1}}^2&=l_nl_{n+1}+2+{l_{n+1}}^2\\
  &=l_nl_{n+1}+2+l_{n+1}(l_{n}+l_{n-1})\\
  &=l_nl_{n+1}+2+l_{n+1}l_{n}+l_{n+1}l_{n-1}\\
  &=l_{n+1}(l_n+l_{n}+l_{n-1})+2\\
  &=l_{n+1}(l_n+l_{n+1})+2\\
  &=l_{n+1}l_{n+2}+2\\
\end{align*}
Well, it looks like it holds for $n+1$ and therefore by induction it holds for all $n$. $\Box$
\end{enumerate}
\item
Let $h_0,h_1,h_2,\dots,h_n,\dots$ be the sequence defined by
\[h_n=n^3,(n\ge0).\]
Show that $h_n=h_{n-1}+3n^2-3n+1$ is the recurrence relation for the sequence.
\begin{align*}
  h_n&=n^3\\
  &=(n-1+1)^3\\
  &=(n-1)^3+3(n-1)^2+3(n-1)+1\\
  &=h_{n-1}+3(n^2-2n+1)+3n-3+1\\
  &=h_{n-1}+3n^2-6n+3+3n-3+1\\
  &=h_{n-1}+3n^2-3n+1\\
\end{align*}
\item
Determine the generating function for each of the following sequences:
\begin{enumerate}
\setcounter{enumii}{2}
\item
$\binom{\alpha}{0},-\binom{\alpha}{1},\binom{\alpha}{2},\dots,(-1)^n\binom{\alpha}{n},\dots,$ ($\alpha$ is a real number)
\begin{align*}
  \binom{\alpha}{0}-\binom{\alpha}{1}x+\binom{\alpha}{2}x^2-\dots+(-1)^n\binom{\alpha}{n}x^n+\dots&=\sum\limits_{n=0}^\infty{(-1)^n\binom{\alpha}{n}x^n}\\
  \sum\limits_{n=0}^\infty{(-1)^n\binom{\alpha}{n}x^n}&=\sum\limits_{n=0}^\infty{\binom{\alpha}{n}(-x)^n}\\
  \intertext{By newton's generalised binomial theorem}
  &=(1-x)^\alpha\\
\end{align*}
\setcounter{enumii}{4}
\item
$1,-\frac{1}{1!},\frac{1}{2!},\dots,(-1)^n\frac{1}{n!},\dots$
\end{enumerate}
\begin{align*}
  1-\frac{1}{1!}x+\frac{1}{2!}x^2-\dots+(-1)^n\frac{1}{n!}x^n+\dots&=\sum\limits_{n=0}^\infty{(-1)^n\frac{1}{n!}x^n}\\
  &=\sum\limits_{n=0}^\infty{\frac{(-x)^n}{n!}}\\
  &=e^{-x}
\end{align*}
\item
Let $S$ be the multiset $\{\infty\cdot e_1,\infty\cdot e_2,\infty\cdot e_3,\infty\cdot e_4\}$. Determine the generating function for the sequence $h_0,h_1,h_2,\dots,h_n,\dots,$ where $h_n$ is the number of $n$-combinations of $S$ with the following added restrictions:
\begin{enumerate}
\setcounter{enumii}{2}
\item
The element $e_1$ does not occur, and $e_2$ occurs at most once.
\begin{align*}
  1&=(1+x^2+x^3+\dots)-(x+x^2+x^3\dots)\\
  &=\frac{1}{1-x}-\frac{x}{1-x}=\frac{1-x}{1-x}\\
  1+x&=(1+x^2+x^3+\dots)-(x^2+x^3+x^4\dots)\\
  &=\frac{1}{1-x}-\frac{x^2}{1-x}=\frac{1-x^2}{1-x}\\
  (1+x+x^2+x^3+\dots)^2&=\frac{1}{(1-x)^2}\\
  g(x)&=\frac{1-x^2}{(1-x)^3}
\end{align*}
\item
The element $e_1$ occurs 1,3,or 11 times, and the element $e_2$ occurs 2,4, or 5 times.
\begin{align*}
  x^n&=1+x^2+x^3+\dots-1-x-x^2-\dots-x^{n-1}-x^{n+1}-x^{n+2}\dots\\
  &=\frac{1}{1-x}-\frac{1-x^{n-1}}{1-x}-\frac{x^{n+1}}{1-x}=\frac{x^{n-1}-x^{n+1}}{1-x}\\
  x^1+x^3+x^{11}&=\frac{x^0-x^2}{1-x}+\frac{x^2-x^4}{1-x}+\frac{x^{10}-x^{12}}{1-x}\\
  &=\frac{1-x^4+x^{10}-x^{12}}{1-x}\\
  x^2+x^4+x^5&=\frac{x^1-x^3}{1-x}+\frac{x^3-x^5}{1-x}+\frac{x^4-x^6}{1-x}\\
  &=\frac{x+x^4-x^5-x^6}{1-x}\\
  g(x)&=\frac{(1-x^4+x^{10}-x^{12})(x+x^4-x^5-x^6)}{(1-x)^2}
\end{align*}
\item
Each $e_i$ occurs at least 10 times.
\begin{align*}
  (x^{10}+x^{11}+x^{12}+\dots)^4&=x^{40}(1+x+x^2+\dots)^4\\
  &=\frac{x^{40}}{(1-x)^4}
\end{align*}
\end{enumerate}
\item
Determine the generating function for the sequence of cubes
\[0,1,8,\dots,n^3,\dots\]
\begin{align*}
  0x^0+1x^1+8x^2+\dots&=\sum\limits_{n=0}^{\infty}{n^3x^n}\\
  \frac{1}{1-x}&=\sum\limits_{n=0}^\infty{x^n}\\
  \frac{\mathrm{d}}{\mathrm{d}x}\left(\frac{1}{1-x}\right)&=\frac{\mathrm{d}}{\mathrm{d}x}\left(\sum\limits_{n=0}^\infty{x^n}\right)\\
  \frac{1}{(1-x)^2}&=\sum\limits_{n=0}^\infty{nx^{n-1}}\\
  \frac{x}{(1-x)^2}&=\sum\limits_{n=0}^\infty{nx^n}\\
  \frac{\mathrm{d}}{\mathrm{d}x}\left(\frac{x}{(1-x)^2}\right)&=\frac{\mathrm{d}}{\mathrm{d}x}\left(\sum\limits_{n=0}^\infty{nx^n}\right)\\
  \frac{1}{(1-x)^2}+\frac{2x}{(1-x)^3}&=\sum\limits_{n=0}^\infty{n^2x^{n-1}}\\
  \frac{x}{(1-x)^2}+\frac{2x^2}{(1-x)^3}=\frac{x-x^2+2x^2}{(1-x)^3}=\frac{x+x^2}{(1-x)^3}&=\sum\limits_{n=0}^\infty{n^2x^n}\\
  \frac{\mathrm{d}}{\mathrm{d}x}\left(\frac{x+x^2}{(1-x)^3}\right)&=\frac{\mathrm{d}}{\mathrm{d}x}\left(\sum\limits_{n=0}^\infty{n^2x^n}\right)\\
  \frac{1+2x}{(1-x)^3}+\frac{3x+3x^2}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^{n+1}}\\
  \frac{1-x+2x-2x^2+3x+3x^2}{(1-x)^4}=\frac{1+4x+x^2}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^{n+1}}\\
  \frac{x+4x^2+x^3}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
  g(x)&=\frac{x+4x^2+x^3}{(1-x)^4}\\
%  \frac{\mathrm{d}}{\mathrm{d}x}\left(\frac{x}{(1-x)^2}\left(1+\frac{2x}{1-x}\right)\right)&=\frac{\mathrm{d}}{\mathrm{d}x}\left(\sum\limits_{n=0}^\infty{n^2x^n}\right)\\
%  \left(\frac{1}{(1-x)^2}+\frac{2x}{(1-x)^3}\right)\left(1+\frac{2x}{1-x}\right)+\frac{x}{(1-x)^2}\left(\frac{2}{1-x}+\frac{2x}{(1-x)^2}\right)&=\sum\limits_{n=0}^\infty{n^3x^{n-1}}\\
%  x\left(\frac{1}{(1-x)^2}+\frac{2x}{(1-x)^3}\right)\left(1+\frac{2x}{1-x}\right)+x\frac{x}{(1-x)^2}\left(\frac{2}{1-x}+\frac{2x}{(1-x)^2}\right)&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  x\left(\frac{1}{(1-x)^2}+\frac{2x}{(1-x)^3}+\frac{2x}{(1-x)^3}+\frac{4x^2}{(1-x)^4}\right)+x\left(\frac{2x}{(1-x)^2}+\frac{2x^2}{(1-x)^4}\right)&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  \frac{x}{(1-x)^2}+\frac{4x^2}{(1-x)^3}+\frac{4x^3}{(1-x)^4}+\frac{2x^2}{(1-x)^2}+\frac{2x^3}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  \frac{x+2x^2}{(1-x)^2}+\frac{4x^2}{(1-x)^3}+\frac{6x^3}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  \frac{(x+2x^2)(1-x)^2}{(1-x)^4}+\frac{4x^2(1-x)}{(1-x)^4}+\frac{6x^3}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  \frac{(x+2x^2)(1-2x+x^2)+4x^2-4x^3+6x^3}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  \frac{x-2x^2+x^3+2x^2-4x^3+2x^4+4x^2+2x^3}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  \frac{x-x^3+2x^4+4x^2}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
%  \frac{x+4x^2-x^3+2x^4}{(1-x)^4}&=\sum\limits_{n=0}^\infty{n^3x^n}\\
\end{align*}
\end{enumerate}
\end{document}


% !TEX root=../presentation_1.tex
\section{Introduction}

\subsection{Minimum-Weight Spanning Tree (MST)}

\begin{frame}
\frametitle{Minimum-Weight Spanning Tree (MST)}

\begin{itemize}
  \item A \textbf{weighted} graph $G = (V,E,W)$.
  \item A \textbf{spanning tree} is a tree that covers all vertices.
  \item A spanning tree is \textbf{minimum} if the sum of all weights in the tree is the minimum among all spanning trees.
\end{itemize}
\begin{figure}
    \centering
    \includegraphics[width=0.4\textwidth]{figures/mst.pdf}
    \caption{An example of MST}
\end{figure}
\end{frame}

\subsection{Greedy Sequential Algorithms}

\begin{frame}
\frametitle{Greedy Sequential Algorithms}

\begin{itemize}
% \item \textcolor{red}{\textbf{Red}} rule. Heaviest edge in a cycle is not in the MST.
% \item \textcolor{blue}{\textbf{Blue}} rule.
\item Lightest edge across a cut is in the MST.
\end{itemize}
\begin{itemize}
  \item Kruskal's algorithm
    \begin{itemize}
      \item Adding the minimum weighted edge without forming a cycle.
    \end{itemize}
  \item Prim's algorithm
    \begin{itemize}
      \item Expanding by selecting the minimum weighted outgoing edge.
    \end{itemize}
  \item Boruvka's algorithm
    \begin{itemize}
      \item Locally merging components by picking the minimum weighted edge connecting both components.
    \end{itemize}
\end{itemize}
\end{frame}

% \begin{frame}
% \begin{figure}
%     \resizebox{.48\textwidth}{!}{
% \animategraphics{12}{figures/KruskalDemo-}{0}{92}
% }
%     \resizebox{.48\textwidth}{!}{
% \animategraphics{12}{figures/PrimAlgDemo-}{0}{57}
% }
% \caption{Left: Kruskal's Algorithm; Right: Prim's Algorithm}
% \end{figure}
% \end{frame}