\chapter{Data Restoration on the Sphere}
\label{ch_restore}
\index{Denoising}
\index{Filtering}

\label{sect_exp}
\section{Introduction}
\index{wavelet!denoising}
\index{curvelet!denoising}

Wavelets and Curvelets have been used successfully for image denoising \emph{via} non-linear filtering or
thresholding methods \cite{starck:book02,starck:sta01_3}. Hard thresholding, for instance, consists in
setting all insignificant coefficients (\emph{i.e.} coefficients with an absolute value below a given
threshold) to zero. In practice, we need to estimate the noise standard deviation $\sigma_j$ in each band
$j$ and a wavelet (or curvelet) coefficient $w_j$ is significant if $\mid w_j \mid > k \sigma_j$, where $k$
is a user-defined parameter, typically chosen between 3 and 5. The $\sigma_j$ estimation in band $j$ can be
derived from simulations \cite{starck:book02}. Denoting $D$ the noisy data and $\delta$ the thresholding
operator, the filtered data $\tilde D$ are obtained by :
\begin{eqnarray}
 {\tilde D} =    {\cal R} \delta( {\cal T} D)
\end{eqnarray}
where ${\cal T}$ is the wavelet (resp. curvelet) transform operator and ${\cal R}$ is the wavelet (resp. curvelet) reconstruction operator.

\section{Significant Wavelet Coefficients}
\label{ch_noise}
\subsection{Definition}
\index{noise}
\index{wavelet!significant coefficient}

In most applications, it is necessary to know if a wavelet coefficient is due to signal (i.e.\ it is significant) or to noise.

The wavelet (resp. curvelet) transform yields a set of resolution-related views of the input image.
A wavelet (resp. curvelet) band at level $j$ has coefficients given by $w_{j,k}$. If we obtain the
distribution of the coefficient $w_{j,k}$ for each band of the decomposition, based on the noise,
we can introduce a statistical significance test for this coefficient. This procedure is the classical
significance-testing one. Let ${\cal H}_0$ be the hypothesis that the image is locally constant at scale $j$.
Rejection of hypothesis ${\cal H}_0$ depends (for positive coefficient values) on:
\begin{eqnarray}
P = Prob(\mid w_{j,k} \mid \ < \ \tau \mid {\cal H}_0)
\end{eqnarray}
The detection threshold, $\tau$, is defined for each scale. Given an estimation threshold, $\epsilon$,
if $P = P(\tau) > \epsilon$ the null hypothesis is not excluded. Although non-null, the value of the
coefficient could be due to noise. On the other hand, if $P < \epsilon$, the coefficient value cannot be due to
the noise alone, and so the null hypothesis is rejected. In this case, a significant coefficient has been detected.

\subsection{Noise Modeling}
\index{noise}
\index{noise!Gaussian}
If the distribution of $w_{j,l}$ is Gaussian, with zero mean and standard deviation $\sigma_j$, we have the probability density
\begin{eqnarray}
p(w_{j,l}) = \frac{1}{\sqrt{2\pi} \sigma_j} e^{{- w_{j,l}^2}/2\sigma^2_j}
\end{eqnarray}
Rejection of hypothesis ${\cal H}_0$ depends (for a positive coefficient value) on:
\begin{eqnarray}
P = Prob( w_{j,l} > W) = \frac{1}{\sqrt{2\pi} \sigma_j} \int^{+\infty}_{w_{j,l}} e^{-W^2/2\sigma^2_j} dW
\end{eqnarray}
and if the coefficient value is negative, it depends on
\begin{eqnarray}
P = Prob( w_{j,l} < W) = \frac{1}{\sqrt{2\pi} \sigma_j} \int^{w_{j,l}}_{-\infty} e^{-W^2/2\sigma^2_j} dW
\end{eqnarray}

Given stationary Gaussian noise, it suffices to compare $w_{j,l}$ to
\index{stationary signal}
$k \sigma_j$.  Often $k $ is chosen as 3, which corresponds approximately to $\epsilon = 0.002$.
If $w_{j,l}$ is small, it is not significant and could be due to noise. If $w_{j,l}$ is large, it is significant:
\begin{eqnarray}
\begin{array}{l}
\mbox{ if }  \mid  w_{j,l} \mid \ \geq \ k \sigma_j \ \ \mbox{ then } w_{j,l}   \mbox{ is significant } \\
\mbox{ if }  \mid  w_{j,l} \mid \ < \ k \sigma_j \ \ \mbox{ then }  w_{j,l} \mbox{ is not significant }
\end{array}
\end{eqnarray}

So we need to estimate, in the case of Gaussian noise models, the noise standard deviation at each scale.
These standard deviations can be determined analytically, but the calculations can become complicated.

The appropriate value of $\sigma_j$ in the succession of wavelet planes is assessed from the standard deviation
of the noise $\sigma_N$ in the original data $D$, and from study of the noise in the wavelet space. This study
consists of simulating a data set containing Gaussian noise with a standard deviation equal to 1, and taking the
wavelet transform of this data set. Then we compute the standard deviation $\sigma^e_j$ at each scale. We get a curve
$\sigma^e_j$ as a function of $j$, giving the behavior of the noise in the wavelet space (Note that if we had used
an orthogonal wavelet transform, this curve would be linear). Due to the properties of the wavelet (resp. curvelet)
transform, we have $ \sigma_j = \sigma_N \sigma^e_j $. The noise standard deviation at scale $j$ of the data is equal
to the noise standard deviation $\sigma_N$ multiplied by the noise standard deviation at scale $j$ of the simulated data.

\subsection{Automatic Estimation of Gaussian Noise}
\subsubsection{$k$-sigma clipping}
\index{sigma clipping}
\index{noise!sigma clipping}
\index{noise}
The Gaussian noise $\sigma_N$ can be estimated automatically in a data set $D$. This estimation is particularly important,
because all the noise standard deviations $\sigma_j$ in the scales $j$ are derived from $\sigma_N$. Thus an error associated
with $\sigma_N$ will introduce an error on all $\sigma_j$. Noise is therefore more usefully estimated in the high frequencies,
where it dominates the signal. The resulting method consists first of filtering the data $D$ with an average filter or the
median filter and subtracting from $D$ the filtered signal $F$: $S = D - F $. In our case, we replace $S$ by the first scale
of the wavelet transform ($S = w_1$), which is more convenient from the computation time point of view. The histogram of $S$
shows a Gaussian peak around 0. A k-sigma clipping is then used to reject pixels where the signal is significantly large.
We denote $S^{(1)}$ the subset of $S$ which contains only the pixels such that $\mid S_l \mid \ < k \sigma_S$, where $\sigma_S$
is the standard deviation of $S$, and $k$ is a constant generally chosen equal to 3. By iterating, we obtain the subset $S^{(n+1)}$
verifying $\mid S^{(n)}_l \mid \ < k \sigma_{S^{(n)}}$, where $\sigma_{S^{(n)}}$ is the noise standard deviation of $S^{(n)}$.
Robust estimation of the noise $\sigma_1$ in $w_1$ (as $S = w_1$) is now obtained by calculation of the standard deviation of
$S^{(n)}$ ($\sigma_1 = \sigma_{S^{(n)}}$). In practice, three iterations are enough, and accuracy is generally better than $5$\%.
$\sigma_N$ is finally calculated by:
\be
\sigma_N = \frac{\sigma_1}{\sigma^e_1} = \frac{\sigma_{S^{(n)}} }{\sigma^e_1}
\ee

\subsection{Correlated Noise}
\index{median!median absolute deviation}
\index{MAD}
\index{noise!median absolute deviation}
\index{noise}
In this case, the data can be treated as for the Gaussian case, but the noise standard deviation $\sigma_j$ at scale $j$
is calculated independently at each scale. Two methods can be used:
\begin{enumerate}
\item $\sigma_j$ can be derived from a k-sigma clipping method applied at scale $j$.
\item The median absolute deviation, MAD, can be used as an estimator of the noise standard deviation:
\begin{eqnarray}
\sigma_j = \mbox{median}( \mid w_j \mid ) / 0.6745
\end{eqnarray}
\end{enumerate}

\section{Thresholding}
Many filtering methods have been proposed in the last ten years. {\em Hard thresholding} consists of setting to 0 all
wavelet coefficients which have an absolute value lower than a threshold $T_j$ (non-significant wavelet coefficient):
\begin{eqnarray}  \tilde w_{j,k} =
\left\{ \begin{array}{ll} w_{j,k} &  \mbox{ if } \mid w_{j,k} \mid \geq T_j  \nonumber  \\

0 &  \mbox{ otherwise}  \end{array} \right.
\end{eqnarray}
where $w_{j,k}$ is a wavelet coefficient at scale $j$ and at spatial position $k$.

{\em Soft thresholding} consists of replacing each wavelet coefficient by the value $\tilde w$ where
\begin{eqnarray}  \tilde w_{j,k} =
\left\{ \begin{array}{ll} sgn(w_{j,k}) ( \mid w_{j,k} \mid - T_j)    &  \mbox{ if } \mid w_{j,k} \mid \geq T_j \nonumber  \\
0 &  \mbox{ otherwise}  \end{array} \right.
\end{eqnarray}
This operation is generally written as:
\begin{eqnarray}
 \tilde w_{j,k} = \mathrm{soft}( w_{j,k})  = sgn(w_{j,k}) ( \mid w_{j,k} \mid - T_j)_{+}
\end{eqnarray}
where $(x)_{+} = MAX(0,x)$.

When the discrete orthogonal wavelet transform is used instead of the \`a trous algorithm, it is interesting to note
that the hard and soft thresholded estimators are solutions of the following minimization problems:
\begin{eqnarray*}
  \tilde w  =   \mathrm{arg}_w \min {1 \over 2} \parallel D - {\cal W}^{-1} w \parallel^2_{l^2} +
 \lambda \parallel w \parallel^2_{l^0} & & \mbox{\bf   hard threshold} \nonumber \\
  \tilde w   =   \mathrm{arg}_w \min {1 \over 2} \parallel D - {\cal W}^{-1} w \parallel^2_{l^2} +
 \lambda \parallel w \parallel^2_{l^1} & & \mbox{\bf   soft threshold}
\end{eqnarray*}
where $D$ is the input data, ${\cal W}$ the wavelet transform operator, and $l^0$ indicates the limit of $l^\delta$
when $\delta \rightarrow 0$. This counts in fact the number of non-zero elements in the sequence.
\index{thresholding!hard}
\index{thresholding!soft}
\index{wavelet!hard threshold}
\index{wavelet!soft threshold}

As described before, in the case of Gaussian noise, $T_j = K \sigma_j$, where $j$ is the scale of the wavelet coefficient,
$\sigma_j$ is the noise standard deviation at the scale $j$, and $K$ is a constant generally chosen equal to 3.

Other threshold methods have been proposed, like the {\em universal threshold}
\index{universal threshold}
\index{SURE}
\index{thresholding!universal threshold}
\index{thresholding!SURE}
\cite{rest:donoho93_1,rest:donoho93_2}, or the SURE (Stein Unbiased Risk Estimate) method \cite{rest:donoho95},
but they generally do not yield as good results as the hard thresholding method based on the significant coefficients.
For astronomical data, soft thresholding should never be used because it leads to a photometry loss associated with all
objects, which can easily be verified by looking at the residual map (i.e.\ data $-$ filtered data). Concerning the
threshold level, the universal threshold  corresponds to a minimum risk. The larger the number of pixels, the larger
is the risk, and it is normal that the threshold $T$ depends on the number of pixels ($T = \sqrt{2\log n} \sigma_j$,
$n$ being the number of pixels). The $K\sigma$ threshold corresponds to a false detection probability, the probability
to detect a coefficient as significant when it is due to the noise. The $3\sigma$ value corresponds to 0.27 \% false detection.

\begin{figure*}
% \includegraphics[height=8truecm,width=6truecm]{fig_uwt_sphere.pdf}
% \includegraphics[height = 5 in]{fig_back_cur_sphere.pdf}
\vbox{
\centerline{
\hbox{
\psfig{figure=fig_synchrotron_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
\psfig{figure=fig_synchrotron_noise5_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
}}
\centerline{
\hbox{
\psfig{figure=fig_pwt5_synchrotron_noise5_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
\psfig{figure=fig_resi_pwt5_synchrotron_noise5_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
}}
\centerline{
\hbox{
\psfig{figure=fig_pcur5_synchrotron_noise5_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
\psfig{figure=fig_resi_pcur5_synchrotron_noise5_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
}}
}
\caption{\textbf{Denoising.} Upper left and right : simulated synchrotron image and same image with an additive
Gaussian noise (\emph{i.e.} simulated data). Middle: pyramidal wavelet filtering and residual. Bottom: pyramidal
curvelet filtering and residual.{ On such data, presenting very anisotropic features, the residual with a curvelet
denoising is cleaner than with the wavelet denoising.}}
\label{Figure:sync_filter}
\end{figure*}

Figure~\ref{Figure:sync_filter} describes the setting and the results of a simulated denoising experiment :
upper left, the original simulated map of the synchrotron emission (renormalized between 0 and 255); upper right,
the same image plus additive Gaussian noise ($\sigma=5$); middle, the pyramidal wavelet filtered image and the
residual (i.e. noisy data minus filtered data); bottom, the pyramidal curvelet transform filtered image and the
residual. A $5 \sigma_j$ detection threshold was used in both cases. On such data, presenting very anisotropic
features, the curvelets produces better results than the wavelets.

\section{The Combined Filtering Method on the Sphere}
\index{wavelet!combined filtering}
\index{curvelet!combined filtering}
\index{combined filtering method}

%\voffset -1truecm
{\small
\begin{table*}[htb]
\baselineskip=0.4cm
\begin{center}
\begin{tabular}{lccccc} \hline \hline
Method                          &  Error Standard Deviation     &  SNR (dB)    \\ \hline \hline
Noisy map                       & 5.  &      13.65  \\
Wavelet                         & 1.30  &    25.29  \\
Curvelet                        & 1.01  &    27.60  \\
CFM                             & 0.86  &    28.99  \\ \hline
\hline
\end{tabular}
\caption{Table of error standard deviations and SNR values after filtering the synchrotron noisy map (Gaussian white noise - sigma = 5 )
by the wavelet, the curvelet and the combined filtering method. Images are available at "http://jstarck.free.fr/mrs.html".}
% \vspace{0.5cm}aa_sphere05
\label{comptab_sync}
\end{center}
\end{table*}
}

\begin{figure}
% \includegraphics[height=8truecm,width=6truecm]{fig_uwt_sphere.pdf}
% \includegraphics[height = 5 in]{fig_back_cur_sphere.pdf}
\centerline{
\hbox{
\psfig{figure=fig_cbf5_synchrotron_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
\psfig{figure=fig_resi_cbf5_synchrotron_bw.pdf,bbllx=0.5cm,bblly=9.5cm,bburx=20cm,bbury=20cm,width=8cm,height=4.5cm,clip=}
}}
\caption{Denoising. Combined Filtering Method (pyramidal wavelet and pyramidal curvelet) and residual.}
\label{Figure:sync_cbf_filter}
\end{figure}

\begin{figure}
\centerline{
\hbox{
% \psfig{figure=fig_result_cbf_face5_bw.ps,bbllx=1.5cm,bblly=4.5cm,bburx=20cm,bbury=23cm,height=10cm,width=10cm,clip=}
\psfig{figure=fig_cmp_fil_synchrotron_face6_bw.pdf,bbllx=1.5cm,bblly=12.5cm,bburx=10.5cm,bbury=25.5cm,height=19.5cm,width=13.5cm,clip=}
}}
\caption{{ Combined Filtering Method, face 6 in the Healpix representation of the image shown in figure~\ref{Figure:sync_cbf_filter}.
From top to bottom and left to right, respectively the a) original image face, b) the noisy image, c) the combined filtered image,
d) the combined filtering residual, e) the wavelet filtering residual and f) the curvelet filtering residual.}}
\label{Figure:sync_face_cbf_filter}
\end{figure}

Although the results obtained by simply thresholding the curvelet expansion are encouraging, there is of course ample room for further
improvement. A quick inspection of the residual images for both the wavelet and curvelet transforms shown in Figure~\ref{Figure:sync_filter}
reveals the existence of very different features. For instance, wavelets do not restore long features with high fidelity while curvelets
are seriously challenged by isotropic or small features. Each transform has its own area of expertise and this complementarity is of great
potential. The Combined Filtering Method (CFM) \cite{starck:spie01a} allows us to benefit from the advantages of both transforms. This iterative
method detects the significant coefficients in both the wavelet domain and the curvelet domain and guarantees that the reconstructed map will
take into account any pattern which is detected as significant by either of the transforms. A full description of the algorithm is given in Appendix B.
Figure~\ref{Figure:sync_cbf_filter} shows the CFM denoised image and its residual. { Figure~\ref{Figure:sync_face_cbf_filter} shows one face
(face 6) of the following Healpix images: upper left, original image; upper right, noisy image; middle left, restored image after denoising
by the combined transform; middle right, the residual; bottom left and right, the residual using respectively the curvelet and the wavelet
denoising method. } The results are reported in Table~\ref{comptab_sync}. The residual is much better when the combined filtering is applied,
and no feature can be detected any more by eye in the residual. This was not the case for either the wavelet and the curvelet filtering.

% \section{Deconvolution ?}


\documentclass{ximera}
\input{../preamble}
\title{Applications of ODEs}
%%%%%\author{Philip T. Gressman}

\begin{document}
\begin{abstract}
We study some sample applications of ODEs.
\end{abstract}
\maketitle

\section*{(Videos) Calculus: Single Variable}
\youtube{54HrJmeON24}
\youtube{xZ3CxLxljLA}

\section*{Examples}

\begin{example}
Newton's law of cooling states that the rate of change of the temperature of an object is proportional to the \textit{difference} between the object's temperature and the ambient temperature.
For example, if the ambient temperature is $20$ degrees Celsius, then
\[ \frac{dT}{dt} = -k \left( T(t) - \answer{20} \right). \]
(Here $k$ is a positive number is called the \textit{heat transfer coefficient}; it depends on the physical properties of the object and the surrounding environment).
\begin{itemize}
\item The equation is linear:
\[ \frac{dT}{dt} + k T = \answer{20} k. \]
\item In this case, $P(t) = \answer{k}$ and the integrating factor is $\answer{e^{k t}}$ (since $k$ is a constant with respect to $t$).  The general solution is
\[ T(t) = \answer{20} + C \answer{e^{-k t}}. \]
\item If we subtract ambient temperature from both sides, this tells us that the temperature difference decays exponentially at some rate determined by the unknown constant $k$.
\item We can generally solve for $k$ if we have enough information.  For example, if $T(0) = 100$, then $C = \answer{80}$.  If we also know that $T(10) = 60$, then $C e^{-10 k} = 40$ (because $40$ is the difference of $60$ and $20$), which means $k = \answer{(\ln 2)/10}$. Another way of understanding this exponential decay is to observe that the temperature difference for this particular object will be cut in half every ten minutes.
\item Now that we know $k$, we can compute $T(t)$ for all time. For example, $T(20) = \answer{40}$, which we could see by plugging in directly to the solution or by merely observing that the temperature difference will be cut in half $\answer{2}$ times in the course of 20 minutes.
\end{itemize}
\end{example}

\begin{example}
For the family of curves in the plane given by
\[ x^4 + y^2 = C \]
(illustrated by the purple oval-shaped curves in the image below),
find a formula for the orthogonal trajectories (shown in red).
\begin{center}
\begin{image}
\includegraphics[width=4in]{images/orthoX01.png}
\end{image}
\end{center}
\begin{itemize}
\item The first step is to find a first-order ODE that is satisfied by the family. This involves differentiating with respect to $x$. We get
\[ 4 x^3 + 2y y' = 0, \ \text{ meaning } y' = \answer{-\frac{2x^3}{y}}. \]
\item If $m$ and $m'$ are slopes of orthogonal lines, then $m m' = -1$. So the orthogonal trajectories satisfy an ODE similar to the one above except that the formula for $y'$ is replaced by its negative reciprocal, i.e.,
\[ y' = \answer{\frac{y}{2x^3}}. \]
\item This is a separable ODE. It separates to
\[ \frac{dy}{\answer{y}} = \frac{1}{2} \frac{dx}{\answer{x^3}}. \]
Integrating both sides gives
\[ \ln |y| = - \frac{1}{4} x^{-2} + C. \]
If we exponentiate both sides and reexpress the arbitrary constant, we get
\[ y = C \answer{e^{-\frac{1}{4x^2}}} \]
\end{itemize}
\end{example}

\begin{example}
For the family of curves in the plane given by
\[ y = \frac{1}{C + x^2} \]
(shown in purple)
find a formula for the orthogonal trajectories (shown in red).
\begin{center}
\begin{image}
\includegraphics[width=4in]{images/orthoX02.png}
\end{image}
\end{center}
\begin{itemize}
\item We first differentiate with respect to $x$:
\[ y' = \answer{ - \frac{2x}{(x^2+C)^2}}. \]
\item Next we must eliminate $C$ from the equation for $y'$ by using the formula $y = 1/ (x^2+C)$. (For example, solve for $C$ in terms of $x$ and $y$ and then substitute this in to your expression for $y'$.)
\[ y' = \answer{ - 2 x y^2} \]
(your answer here will depend on the variables $x$ and $y$ but should not explicitly depend on $C$).
\item Then we write a new ODE whose slope is the negative reciprocal of the expression we just found:
\[ y' = \answer{\frac{1}{2xy^2}}. \]
This is a separable ODE:
\[ \answer{y^2} dy = \frac{1}{2} \frac{dx}{\answer{x}}. \]
\item Integrate both sides:
\[ \answer{\frac{y^3}{3}} = \frac{1}{2} \answer{\ln |x|} + C. \]
(Don't forget absolute values on logarithms.)
\end{itemize}
\end{example}

\begin{example}
A large 100 liter tank is initially filled with fresh water. At time $t=0$, a technician begins pouring in $2$ liters per minute of sugar water which is at a concentration of 4 grams per liter. At the same time, another technician opens a valve at the bottom of the tank and begins to drain the tank at a rate of $1$ liter per minute. Assuming the whole tank is kept well-mixed at all times, what is the concentration of the liquid in the tank after 100 minutes?
\begin{itemize}
\item It is always easiest to write an ODE for the total amount $A$ of sugar in the tank (in grams). The concentration can be deduced later by dividing amount by volume.
\item The first step is to find the function $V(t)$ for the total volume of solution in the tank.  The rate of fresh solution coming in is $\answer{2}$ liters per minute and the rate going out is $\answer{1}$ liter(s) per minute. So the net flow in of all liquid is $\answer{1}$ liter(s) per minute. This means that at time $t$, $V(t) = \answer{100 + t}$.
\item Fill in the blanks: $R_{\mathrm{in}}$ is the rate of sugar coming in (measured in grams per minute), $F_{\mathrm{out}}$ is the \textit{volume} rate of flow out from the bottom of the tank. Then
\[ \frac{dA}{dt} = R_{\mathrm{in}} - F_{\mathrm{out}} \frac{A(t)}{V(t)} = \answer{8} - \answer{1} \frac{A(t)}{\answer{t+100}}.\]
\item The equation is linear:
\[ \frac{dA}{dt} + \answer{ \frac{1}{100 + t}} A(t) = \answer{8}. \]
\item We compute the integrating factor:
\[ I(t) = e^{\int P(t) dt} = e^{\int \answer{(t+100)^{-1}} dt} = \answer{t+100}. \]
(Note: logarithms don't need absolute values here because $t  > 0$.)
\item After multiplying both sides by $I(t)$, we have
\[ \left( \answer{(t+100)} A(t) \right)' = \answer{8 (t+100)}. \]
\item Integrating both sides gives
\[ (t+100) A(t) = 4 (t+100)^2 + C. \]
At $t = 0$, $A(0)$ is given to be zero, so $C = \answer{-40000}$. The full solution of the initial value problem is then
\[ A(t) = \answer{4 (t + 100) - \frac{40000}{t+100}}. \]
\item $A(100) = \answer{600}$ grams. Furthermore $V(t) = \answer{200}$ liters, so the concentration at time $t = 100$ minutes is $\answer{3}$ grams per liter.
\end{itemize}
\end{example}

\end{document}


\documentclass[]{AVSSimReportMemo}
\usepackage{AVS}

\newcommand{\ModuleName}{attTrackingError}
\newcommand{\subject}{Module to Evaluate the Attitude Tracking Error Relative to a Time Varying Reference Frame}
\newcommand{\status}{Initial Version}
\newcommand{\preparer}{H. Schaub}
\newcommand{\summary}{This module is intended to be the last module in the guidance module chain.  It's input is the reference motion message generated by a prior module.  It's output is at the guidance attitude tracking errors relative to a moving reference frame.  This module applies the body to corrected body attitude correction.     }

\begin{document}

\makeCover

%
%	enter the revision documentation here
%	to add more lines, copy the table entry and the \hline, and paste after the current entry.
%
\pagestyle{empty}
{\renewcommand{\arraystretch}{1.1}
\noindent
\begin{longtable}{|p{0.5in}|p{4.5in}|p{1.14in}|}
\hline
{\bfseries Rev}: & {\bfseries Change Description} & {\bfseries By} \\
\hline
Draft & initial copy & H. Schaub \\
\hline

\end{longtable}
}

\newpage
\setcounter{page}{1}
\pagestyle{fancy}

\tableofcontents
~\\ \hrule ~\\

\section{Introduction}
This technical note outlines how the attitude tracking errors are evaluated relative to a given reference frame. The reference frame from the chain of guidance modules is called $\mathcal{R}_{0}$, while the body corrected reference frame orientation is $\mathcal{R}$.

\section{Reference Frame Definitions}
Let the primary body-fixed coordinate frame be \frameDefinition{B}. However, instead of aligning this frame with a reference, a corrected body frame $\mathcal{B}_{c}$ is to be aligned with a reference frame.   Let the uncorrected reference orientation be given by $\mathcal{R}_{0}$.  Thus, the guidance goal is to drive $\mathcal{B}_{c} \rightarrow \mathcal{R}_{0}$, which yields
\begin{equation}
	[R_{0} N] = [B_{c} B] [BN]
\end{equation}
where $\mathcal{N}$ is an inertial reference frame.  Rearranging this relationship, with perfect attitude tracking the inertial body frame orientation should be
\begin{equation}
	 [BN] = [B_{c} B]^{T} [R_{0}N]  = [RN]
\end{equation}
where $\mathcal{R}$ is a corrected reference frame.  Note that $[B_{c} B] = [R_{0}R]$.  Thus, the corrected reference orientation is computed using
\begin{equation}
	 [RN] = [R_{0} R]^{T} [R_{0}N]
\end{equation}
where the body-frame correction is subtracted from the original reference orientation.

The benefit of of driving $\mathcal{B} \rightarrow \mathcal{R}$ instead of $\mathcal{B}_{c} \rightarrow \mathcal{R}_{0}$ is that the body frame, along with the many device position and orientation vectors expressed in  body-frame components, don't have to be rotated for each control evaluation.  In simple terms, if the corrected body frame is a 60\dg rotation from the body frame, then the 60\dg is subtracted from the original reference orientation.  This allows all body inertia tensor and reaction wheel heading vector descriptions to remain in the primary body frame $\mathcal{B}$.

Assume the initial uncorrected reference frame $\mathcal{R}_{0}$ is given through the MRP set $\bm\sigma_{R_{0}/N}$
\begin{equation}
	[R_{0}N(	\bm\sigma_{R_{0}/N})]
\end{equation}
The relative orientation of the corrected body frame relative to the primary body frame is a constant MRP set
\begin{equation}
	[B_{c}B(\bm\sigma_{B_{c}/B})] = [R_{0}R(\bm\sigma_{R_{0}/R})]
\end{equation}
To apply this correction to the original reference frame, using the Direction Cosine Matrix (DCM) description, this is determined through
\begin{equation}
	[RN(\bm\sigma_{R/N})] = [R_{0}R(\bm\sigma_{R_{0}/R})]^{T} [R_{0}N(\bm\sigma_{R_{0}/N})] =
	[R_{0}R(-\bm\sigma_{R_{0}/R})] [R_{0}N(\bm\sigma_{R_{0}/N})]
\end{equation}
where the convenient MRP identity
\begin{equation}
	 [R_{0}R(\bm\sigma_{R_{0}/R})]^{T} = [R_{0}R(-\bm\sigma_{R_{0}/R})]
\end{equation}

Note the following MRP addition property developed in Reference~\citenum{schaub}.  If
\begin{equation}
	[BN(\bm\sigma)] = [FB(\bm\sigma '')] [ BN(\bm\sigma ')]
\end{equation}
then
\begin{equation}
	\bm\sigma = \frac{
		(1-|\bm\sigma'|^{2})\bm\sigma '' + (1-|\bm\sigma ''|^{2}) \bm\sigma ' - 2 \bm\sigma '' \times \bm\sigma '
	}{
		1 + |\bm\sigma '|^{2} |\bm\sigma''|^{2} - 2 \bm\sigma' \cdot \bm\sigma''
	}
\end{equation}
In the RigidBodyKinematics software library of Reference~\citenum{schaub}, this MRP evaluation is achieved with
$$
	\bm\sigma = {\tt addMRP}(\bm\sigma ', \bm\sigma'')
$$
Thus, to properly apply the body frame orientation correction to the original reference frame, this function should be used with
$$
	\bm\sigma_{R/N} = {\tt addMRP}(\bm\sigma_{R_{0}/N}, -\bm\sigma_{R_{0}/R})
$$

The attitude tracking error of $\mathcal{B}$ relative to $\mathcal{R}$ is
$$
	\bm\sigma_{B/R} = {\tt subMRP}(\bm\sigma_{B/N}, -\bm\sigma_{R/N})
$$

\section{Reference Frame Angular Velocity Vector}
The angular velocity of the original reference frame $\mathcal{R}_{0}$ is
\begin{equation}
	\bm\omega_{R_{0}/N}
\end{equation}
The angular velocity tracking error is defined as
\begin{equation}
	\delta\bm\omega = \bm\omega_{B/N} - \bm\omega_{R/N}
\end{equation}
The correct reference frame angular velocity is
\begin{equation}
	\bm\omega_{R/N} = \bm\omega_{R/R_{0}} + \bm\omega_{R_{0}/N} =  \bm\omega_{R_{0}/N}
\end{equation}
because the body frame correction $[B_{c} B] = [R_{0}R]$ is a constant angular offset.

The required inertial reference frame rate vector, in body frame components, is then given by
\begin{equation}
	\leftexp{B}{\bm\omega}_{R/N} = [BN] \leftexp{N}{\bm\omega}_{R/N}
\end{equation}

\section{Reference Frame Angular Acceleration Vector}
With $\dot{\bm \omega}_{R/N}$ given in the inertial frame, in the body frame this vector is expressed as
\begin{equation}
	\leftexp{B}{\dot{\bm\omega}}_{R/N} = [BN] \leftexp{N}{\dot{\bm\omega}}_{R/N}
\end{equation}

\section{Angular Velocity Tracking Error}
Finally, the angular velocity tracking error is expressed in body frame components as
\begin{equation}
	\leftexp{B}{\delta\bm\omega} = \leftexp{B}{\bm\omega_{B/R}} = \leftexp{B}{\bm\omega}_{B/N} - \leftexp{B}{\bm\omega}_{R/N}
\end{equation}

\bibliographystyle{unsrt}
\bibliography{references}

\end{document}


\documentclass{article}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{float}

\title{Assignment for CS 696-04 \\ (Deep Learning)}
\author{Diwas Sharma}
\date{\today}
\begin{document}

\maketitle
\newpage

\section{Design}
The implementation of convolution and max pooling layer is generalized enough
so it can be used with other programs as well. Furthermore, the code for the
CNN layers have been merge with the implementation of the Dense layers.
Together the dense layers and the CNN layers can be stacked to any depth required
and can be used to describe any valid neural network with dense and CNN layers.

An example of convolution neural network that can be construct is given below.

\begin{lstlisting}[language=python]
from depth.models import Sequential
from depth.layers import Convolution2D, Flatten, DenseLayer, MaxPooling
from depth.optimizers import ADAM

optimizer = ADAM(lr=0.01)
nn = Sequential()

self.nn = Sequential()
self.nn.add_layer(Convolution2D(5, (3, 3), input_shape=(3, 32, 32)))
self.nn.add_layer(MaxPooling(pool_size=(2, 2)))
self.nn.add_layer(Convolution2D(10, (3, 3)))
self.nn.add_layer(MaxPooling(pool_size=(2, 2)))
self.nn.add_layer(Flatten())
self.nn.add_layer(DenseLayer(units=32))
self.nn.add_layer(DenseLayer(units=10, activation="softmax"))
self.nn.compile(loss="cross_entropy", error_threshold=0.01,
                optimizer=optimizer)

\end{lstlisting}

\section{CIFAR 10}
\subsection{Network}
The network that is used to classify the CIFAR 10 dataset is follows:

\begin{enumerate}
    \item{Convolution layer}
        \begin{itemize}
            \item{Input: $N * 3 * 32 * 32$ tensor}
            \item{Filters: 4 filters with size $3*3$}
            \item{Padding: 0 padded with pad width of 1}
            \item{Stride: 1 on each dimension}
            \item{Regularizer: $L_2$ Regularizer}
        \end{itemize}
    \item{Max pooling layer}
        \begin{itemize}
            \item{Input: $N * 4 * 32 * 32$ tensor}
            \item{Pool size: $2*2$}
            \item{Stride: 2 on each dimension}
        \end{itemize}
    \item{Convolution layer}
        \begin{itemize}
            \item{Input: $N * 4 * 16 * 16$ tensor}
            \item{Filters: 8 filters with size $3*3$}
            \item{Padding: 0 padded with pad width of 1}
            \item{Stride: 1 on each dimension}
            \item{Regularizer: $L_2$ Regularizer}
        \end{itemize}
    \item{Max pooling layer}
        \begin{itemize}
            \item{Input: $N * 8 * 16 * 16$ tensor}
            \item{Pool size: $2*2$}
            \item{Stride: 2 on each dimension}
        \end{itemize}
    \item{Convolution layer}
        \begin{itemize}
            \item{Input: $N * 8 * 8 * 8$ tensor}
            \item{Filters: 16 filters with size $3*3$}
            \item{Padding: 0 padded with pad width of 1}
            \item{Stride: 1 on each dimension}
            \item{Regularizer: $L_2$ Regularizer}
        \end{itemize}
    \item{Softmax layer}
        \begin{itemize}
            \item{Input: $512 * N$ tensor}
            \item{Units: 10}
        \end{itemize}
\end{enumerate}

\subsubsection{Source Code}
\begin{lstlisting}[language=python]
optimizer = ADAM(lr=0.001)
regularizer = L2Regularizer(0.01)

self.nn = Sequential()
self.nn.add_layer(Convolution2D(
    4, (3, 3), input_shape=(3, 32, 32), regularizer=regularizer))
self.nn.add_layer(MaxPooling(pool_size=(2, 2)))
self.nn.add_layer(Convolution2D(8, (3, 3), regularizer=regularizer))
self.nn.add_layer(MaxPooling(pool_size=(2, 2)))
self.nn.add_layer(Convolution2D(16, (3, 3), regularizer=regularizer))
self.nn.add_layer(Flatten())
self.nn.add_layer(DenseLayer(units=10, activation="softmax"))
self.nn.compile(loss="cross_entropy", error_threshold=0.01,
                optimizer=optimizer, mini_batch_size=1024)
\end{lstlisting}

\subsection{Training}
The network was trained using ADAM optimizer with mini batch size of 1024. The parameters
used for the optimizer were $\eta$ = 0.001, $\beta_1$ = 0.9 and
$\beta_2$ = 0.999.

The plot for training loss per mini batch is shown in figure {\ref{fig:training_loss}}
and the plot of training accuracy per mini batch is shown in figure {\ref{fig:training_accuracy}}.

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.35\textheight,keepaspectratio]{cifar10_training_loss.png}
  \caption{Training Loss}
  \label{fig:training_loss}
\end{figure}

\begin{figure}[!ht]
  \includegraphics[width=\textwidth,height=0.35\textheight,keepaspectratio]{cifar10_training_accuracy.png}
  \caption{Training accuracy}
  \label{fig:training_accuracy}
\end{figure}

\subsection{Testing}
The accuracy obtained on the test data is 0.536.

\end{document}


\subsection{Clause Learning}

\begin{frame}
  \frametitle{From DPLL to CDCL}

  \scriptsize

  Consider the following scenario before and after BCP
  \vfill
  \begin{tabular}{ccc}
  \begin{minipage}{.4\textwidth}
  $$
  \begin{array}{l}
    \ldots \\
    (\colone{\neg a_{10}} \vee \colone{\neg a_1} \vee a_4) \\
    (\colone{a_3} \vee \colone{\neg a_1} \vee a_5) \\
    (\neg a_4 \vee a_6) \\
    (\neg a_5 \vee \neg a_6) \\
    \ldots \\
    \\
    \{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{a_7}{2}, \dec{\neg a_2}{3}, \dec{a_1}{4} \}
  \end{array}
  $$
  \end{minipage}
  & ~~~~ &
  \begin{minipage}{.5\textwidth}
  $$
  \begin{array}{l}
    \ldots \\
    (\colone{\neg a_{10}} \vee \colone{\neg a_1} \vee \coltwo{a_4}) \\
    (\colone{a_3} \vee \colone{\neg a_1} \vee \coltwo{a_5}) \\
    (\colone{\neg a_4} \vee \coltwo{a_6}) \\
    (\colone{\neg a_5} \vee \colone{\neg a_6}) \\
    \ldots \\
    \\
    \{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{a_7}{2}, \dec{\neg a_2}{3}, \dec{a_1}{4}, \dec{a_4}{4}, \dec{a_5}{4}, \dec{a_6}{4}\}
  \end{array}
  $$
  \end{minipage}
  \end{tabular}
  \vfill
  \pause
  BCP leads to a conflict, but, what is the {\bf reason} for it ?
  Do $a_7$ and $a_2$ play any role ?
  \vfill
  \pause
  Does it make sense to consider the assignments (which backtracking would produce) ?\\
  $\{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{\neg a_7}{2}, \dec{\neg a_2}{3}, \dec{a_1}{4} \}$ ---
  $\{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{a_7}{2}, \dec{\neg a_2}{3}, \dec{a_1}{4} \}$ ---
  $\{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{a_7}{2}, \dec{a_2}{3}, \dec{a_1}{4} \}$ \\
  \vfill
  \pause
  No, because {\em whenever $a_{10}$, $\neg a_3$ is assigned, then $a_1$ must not be set to $\top$}. \pause
  This translates to an additional clause, which can be {\em learnt}, i.e., it can be added to the formula
  $$(\neg a_{10} \vee a_3 \vee \neg a_1)$$

\end{frame}

\begin{frame}
  \frametitle{From DPLL to CDCL}

  Search
  \vfill

  \begin{tabular}{ccc}
    Without learnt clause & & With learnt clause \\ \\
    \begin{minipage}{.4\textwidth}
      \scalebox{.3}{\input{search_5.pdf_t}}
    \end{minipage}
    & ~~~~ &
    \begin{minipage}{.4\textwidth}
      \scalebox{.3}{\input{search_6.pdf_t}}
    \end{minipage}
  \end{tabular}

\end{frame}

\subsection{Conflict Analysis}

\begin{frame}
  \frametitle{Deriving the clause to be learnt}

  \scriptsize

  The clause to be learnt is derived from the conflict ``caused'' by BCP
  (conflict is never caused by a Decision)
  \vfill
  \pause
  To better {\bf analyze} a conflict we need to look at the {\bf implication graph}
  \vfill
  \begin{tabular}{ccc}
  \begin{minipage}{.4\textwidth}
  $$
  \begin{array}{l}
    \ldots \\
    (\colone{\neg a_{10}} \vee \colone{\neg a_1} \vee \coltwo{a_4}) \\
    (\colone{a_3} \vee \colone{\neg a_1} \vee \coltwo{a_5}) \\
    (\colone{\neg a_4} \vee \coltwo{a_6}) \\
    (\colone{\neg a_5} \vee \colone{\neg a_6}) \\
    \ldots \\  \\
    \{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{a_7}{2}, \dec{\neg a_2}{3}, \dec{a_1}{4}, \dec{a_4}{4}, \dec{a_5}{4}, \dec{a_6}{4}\}
  \end{array}
  $$
  \end{minipage}
  & ~~~ &
  \begin{minipage}{.4\textwidth}
  \begin{overlayarea}{.4\textwidth}{4cm}
    \only<2|handout:0>{\scalebox{.4}{\input{impl_graph_1.pdf_t}}}
    \only<3|handout:0>{\scalebox{.4}{\input{impl_graph_2.pdf_t}}}
    \only<4|handout:0>{\scalebox{.4}{\input{impl_graph_3.pdf_t}}}
    \only<5->{\scalebox{.4}{\input{impl_graph_4.pdf_t}}}
  \end{overlayarea}
  \end{minipage}
  \end{tabular}
  \vfill
  \pause\pause
  Any cut of the graph that separates the conflict from the decision variables
  represents a possible learnt clause
  \vfill
  \pause
  In this course we take the clause that contains
  {\bf only one variable of the current decision level}

\end{frame}

\begin{frame}
  \frametitle{Deriving the clause to be learnt}

  \scriptsize

  In practice, we use {\bf resolution} steps to compute the learnt clause:
  \begin{itemize}
    \item we start from the clause with all literals to $\bot$ (conflicting clause)
    \item iteratively, we take the clause that propagated the last literal on the trail
	  and we apply resolution
    \item we stop when only one literal from the current decision level is left in the clause
  \end{itemize}
  \vfill
  \pause
  \begin{tabular}{ccc}
    \begin{minipage}{.4\textwidth}
      \begin{overlayarea}{.4\textwidth}{3cm}
      \only<2|handout:0>{\scalebox{.4}{\input{ca_1.pdf_t}}}
      \only<3|handout:0>{\scalebox{.4}{\input{ca_2.pdf_t}}}
      \only<4|handout:0>{\scalebox{.4}{\input{ca_3.pdf_t}}}
      \only<5|handout:0>{\scalebox{.4}{\input{ca_4.pdf_t}}}
      \only<6|handout:0>{\scalebox{.4}{\input{ca_5.pdf_t}}}
      \only<7|handout:0>{\scalebox{.4}{\input{ca_6.pdf_t}}}
      \only<8->{\scalebox{.4}{\input{ca_7.pdf_t}}}
      \end{overlayarea}
    \end{minipage}
    & ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &
    \begin{minipage}{.4\textwidth}
      \begin{tabular}{ccl}
	\hline
	Trail & dl & Reason \\
	\hline
	$a_{10}$   & 0 & $( a_{10} )$ \\
	$\neg a_3$ & 1 & Decision \\
	$a_7$      & 2 & Decision \\
	$\neg a_2$ & 3 & Decision \\
	$a_1$      & 4 & Decision \\
	$a_4$      & 4 & $(\neg a_{10} \vee \neg a_1 \vee a_4)$ \\
	$a_5$      & 4 & $(a_3 \vee \neg a_1 \vee a_5)$ \\
	$a_6$      & 4 & $(\neg a_4 \vee a_6)$ \\
	\hline
      \end{tabular}
      \medskip \\
      $\{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{a_7}{2}, \dec{\neg a_2}{3}, \dec{a_1}{4}, \dec{a_4}{4}, \dec{a_5}{4}, \dec{a_6}{4}\}$
    \end{minipage}
  \end{tabular}
  \vfill
  \onslide<9>{We say that $(\neg a_{10} \vee a_3 \vee \neg a_1)$ is the {\bf conflict clause} and it is the one we learn}

\end{frame}

\subsection{Non-Chronological Bactracking}

\begin{frame}
  \frametitle{Non-chronological backtracking}

  So far we have been backtracking {\bf chronologically}, but
  \vfill
  given our (wrong) assignment $\{ \dec{a_{10}}{0}, \dec{\neg a_3}{1}, \dec{a_7}{2}, \dec{\neg a_2}{3}, \dec{a_1}{4}, \dec{a_4}{4}, \dec{a_5}{4}, \dec{a_6}{4}\}$
  and the computed conflict clause $(\neg a_{10} \vee a_3 \vee \neg a_1)$, is it really clever to backtrack to level 3 ?
  \vfill
  \pause
  The correct level to backtrack to is:
  \begin{center}
  ``the level that would have propagated $\neg a_1$ if we had the clause
  $(\neg a_{10} \vee a_3 \vee \neg a_1)$ as part of the original formula''
  \end{center}
  \vfill
  \pause
  In our case, it is level 1, because assignment $\{ \dec{a_{10}}{0}, \dec{\neg a_3}{1} \}$ is
  sufficient to propagate $\neg a_1$ in $(\colone{\neg a_{10}} \vee \colone{a_3} \vee \neg a_1)$
  \vfill
  \pause
  We say that $\neg a_1$ is the {\bf asserting literal} as it becomes true by BCP once
  we have backtracked to the correct decision level
\end{frame}

\begin{frame}
  \frametitle{CDCL: Conflict Driven Clause Learning}

  Search
  \vfill

  \begin{tabular}{ccc}
    DPLL                        & & CDCL  \\
    no learning                 & & conflict-driven learning \\
    chronological backtracking  & & non-chronological backtracking \\ \\
    \begin{minipage}{.4\textwidth}
      \scalebox{.3}{\input{search_7.pdf_t}}
    \end{minipage}
    & ~~~~ &
    \begin{minipage}{.4\textwidth}
      \scalebox{.3}{\input{search_8.pdf_t}}
    \end{minipage}
  \end{tabular}

\end{frame}

\begin{frame}
  \frametitle{The CDCL Procedure}

  \scriptsize

  \vfill

  \begin{tabbing}
  as \= a \= a \= a \= as \= asdfsdfasdfasdfasdfasdfasdfasdfasdfasdf \= \kill
  \> $dl = 0$; $trail = \{\ \}$;                              \> \> \> \> \> // Decision level, assignment\\ \\
  \> while ( $true$ ) \\ \\
  \> \> if ( BCP( ) == conflict )                                \> \> \> \> // Do BCP until possible \\
  \> \> \> if ( $dl == 0$ ) return $unsat$;                         \> \> \> // Unresolvable conflict \\
  \> \> \> $C,dl =$ {\sc AnalyzeConflict}( );                           \> \> \> // Compute conf. clause, and dec. level \\
  \> \> \> {\sc AddClause}( $C$ );                                      \> \> \> // Add $C$ to clause database \\
  \> \> \> {\sc BacktrackTo}( $dl$ );                                   \> \> \> // Backtracking (shrinks $trail$) \\
  \> \> else \\
  \> \> \> if ( ``all variables assigned'' ) return $sat$;          \> \> \> // $trail$ holds satisfying assignment \\
  \> \> \> $l = $ {\sc Decision}( );                                      \> \> \> // Do another decision \\
  \> \> \> $trail = trail \cup \{ l \}$ \\
  \> \> \> $dl = dl + 1$;                                           \> \> \> // Increase decision level \\
  \end{tabbing}

  \vfill

\end{frame}

\begin{frame}
  \frametitle{The CDCL Procedure}

  \begin{center}
  \scalebox{.45}{\input{cdcl.pdf_t}}
  \end{center}

\end{frame}

\begin{frame}
  \frametitle{Other things which we did not see}

  {\bf Watched Literals}: technique to efficiently discover which clauses
                          become unsat
  \vfill
  {\bf Decision heuristics}: how do we choose the right variable ?
  And which polarity ? ($\top, \bot$). Landmark strategy is VSIDS heuristic
  \vfill
  {\bf Clause removal}: adding too many clauses negatively impacts
			performance, need mechanisms to remove learnts
  \vfill
  {\bf Restarts}: start the search from scratch, but retaining learnts
  \vfill
  many many other heuristics discovered every year

\end{frame}

\begin{frame}
  \frametitle{Exercise}

  \scriptsize

  Consider the following clause set and assignment
  $$
  \begin{array}{l}
  (\neg a_1 \vee a_2) \\
  (\neg a_1 \vee a_3 \vee a_9) \\
  (\neg a_2 \vee \neg a_3 \vee a_4) \\
  (\neg a_4 \vee a_5 \vee a_{10}) \\
  (\neg a_4 \vee a_6 \vee a_{11}) \\
  (\neg a_5 \vee \neg a_6) \\
  (a_1 \vee a_7 \vee \neg a_{12}) \\
  (a_1 \vee a_8) \\
  (\neg a_7 \vee \neg a_8 \vee \neg a_{13}) \\
  \ldots \\ \\
  \{ \dec{\neg a_9}{1}, \dec{a_{12}}{2}, \dec{a_{13}}{2}, \dec{\neg a_{10}}{3}, \dec{\neg a_{11}}{3}, \ldots, \dec{a_1}{6}\}
  \end{array}
  $$
  \vfill
  \begin{itemize}
    \item Find the correct conflict clause
    \item Find the correct decision level to backtrack
  \end{itemize}

\end{frame}


\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\newtheorem{defi}{Definition}
\newcommand{\bsp}{\paragraph{Example}}
\author{moi}
\title{Function spaces}
\begin{document}
\section{Introduction}
Given two sets $X, Y \neq \emptyset$, we want to discuss the relation
$$\mathrm{map}(X, Y) \simeq Y^X$$
We are going to apply a categorical and set-theoretic approach in order to explain this equivalence.
\subsection{Category theory}
This theory dates back to the 40ies of the last century.\\
/*\\
 ~* Proper historic review (morphs, objects and compos; co/contravar. funct, ~* special categories: grp, abel, rng, ...)\\
 */
\subsection{Set theory}
//sets blabla
\newpage
\section{Function spaces}
The term \textit{space} is to be understood as follows
\begin{defi}
Let $\mathrm{Set}$ denote the category of sets, with maps as morphisms. There exists a subcategory called the category of pointed spaces, denoted by $\mathrm{PSpc}$, with:
\begin{enumerate}
\item $\mathrm{Obj}(\mathrm{PSpc})$ all sets/classes $X$ with a designated element $x \in X$, called the basepoint.
\item $\mathrm{Mor}(\mathrm{PSpc})$ all basepoint preserving maps in $\mathrm{Set}(A,B)$ for all $A, B \in \mathrm{Obj}(\mathrm{PSps})$.
\end{enumerate}
If $A \in \mathrm{Obj}(\mathrm{PSpc})$ then we simply denote it by $(A, a)$ with basepoint $a \in A$.
\end{defi}
\begin{description}
\item[Counter] A prominent counterexample is the empty set $\emptyset$. Since it has no element we cannot choose a designated element $x$. Hence, $\mathrm{Set}$ is a proper supercategory (borrowing from set theory).
\item[Example] Any non-empty set $X$ with a fixed element $x_0 \in X$ is a pointed space $(X,x_0)$. Furthermore, due to non-emptyness of any monoid $G \in \mathrm{Obj}(\mathrm{Grp})$, with neutral element $e \in G$, we have that
$$(G, e)$$ is a pointed space. In turn, if $(G, e)$ and $(G', e')$ are two monoids and $\varphi : G \longrightarrow G'$ is a monoid homomorphism (a morphism in $\mathrm{Mon}$) then
$$\varphi(e) = e' \Leftarrow \varphi \in \mathrm{PSpc}(G,G'),$$
i.e. each monoid homomorphism is also a morphism of pointed spaces.
\end{description}
\begin{defi}
A pointed $(X,x_0)$ is called a \textit{singleton} if $X\backslash\{x_0\} = \emptyset$.
\index{singleton}
\end{defi}
We claim
\begin{prop}
The singleton is terminal object in the category of pointed spaces.
\end{prop}
\end{document}


\addtocontents{toc}{\protect\newpage}
\chapter{Differential Equations}
Any equation involving derivatives of a function can be called a differential equation.  For example, $ \dydx=2x$ says ``the derivative equals 2$x$.'' As the derivative of $x^2$, this simple equation also represents a rate-of-change as a function of $x$, or, a differential equation. In this chapter we explore this idea further and look at some mathematical models that take the form of differential equations.

\begin{multicols}{2}
The trajectory of a projectile launched from a cannon follows a curve determined by an ordinary differential equation that is derived from Newton's second law. The relationship between the displacement $x$ and the time $t$ of an object under the force $F$, is given by the differential equation: \[ m\ddxdt=F(x(t)) \]
	 \includegraphics[width=8cm]{DE1}
\end{multicols}
Change is a familiar concept from the slope of the tangent line that we are familiar with. If we have the function, then we can calculate the slope of the tangent at any point on the axis. Now, if the $x$-axis represents time, $t$, this calculation has the possibility of predicting the future! Differential equations can arise when we formulate mathematical models.  We can develop our understanding of this process by considering the mathematical models of some physical phenomena.

%---------------------------------------------------
% Population Growth
%---------------------------------------------------
\section{Basic Differential Equations}
One model of population growth arises from the assumption that the rate at which the population grows is proportional to the size of the population.
Let $N$ be the size of the population at time $t$ then the rate of change of population with respect to time is $\frac{\mathrm{d} N}{\mathrm{d} t}\text{.}$  So the model can be expressed as a differential equation
\begin{equation*}\frac{\mathrm{d} N}{\mathrm{d} t} =k N
\end{equation*}
where $k$ is the constant of proportionality.

To make any sense of this model we need to explore the range of values of $N$ and $k$.  $N$ cannot be zero (otherwise there would be nothing to change).  We assume that $N$ is a function of $t$ and that $N (t) >0$.  Similarly for us to have population ``growth''\  $k >0$
\begin{equation*} \therefore \frac{\mathrm{d} N (t)}{\mathrm{d} t} >0
\end{equation*}

We have already shown the properties of the exponential function.  The general exponential function is
\begin{equation*}N (t) =N_{0} e^{k t}
\end{equation*}

Let $N (t)$ be $N_{0}$ when $t =0$.  i.e. $N (0) =N_{0}\text{.}$  $N_{0}$ is called the \emph{initial value} of $N (t)$.

Now
\begin{align*}\frac{\mathrm{d} N (t)}{\mathrm{d} t} &    = N_{0} e^{k t} \times k \\
 &    = k N (t)\end{align*}

Thus we have shown that $N (t) =N_{0} e^{k t}$ is a solution of the differential equation $\frac{\mathrm{d} N (t)}{\mathrm{d} t} =k N (t)$

This solution arises because we are familiar with the behaviour of the exponential function.  Our ability to ``guess''\ the answer is limited so the subject of differential equations involves developing techniques to handle physical situations that are more and more realistic and more and more complex.  The answer to this problem came so simply to us we have to wonder if there are other equations for $N (t)$ that give the same answer.

%---------------------------------------------------
% The Order of a Differential Equation
%---------------------------------------------------
\section*{The Order of a Differential Equation}
The differential equation $\frac{\mathrm{d} N (t)}{\mathrm{d} t} =k N (t)$ is referred to as a first order differential equation because the order of the highest derivative is \emph{one}.

Here is an example of a second order differential equation
\begin{equation*}m \ddxdt= -k x\end{equation*}

This is the differential equation that arises from Hooke's Law. The second derivative is written $\ddxdt$. Another application from mechanics is found in construction.
\begin{multicols}{2} The elastic curve of a beam under a uniform distributed load will be deflected according to:
	\[M=EI\ddydx\]
Where $M$ is the bending moment acting at $O$. $E$ is Young’s modulus of elasticity of the material of the beam, and $I$ is the moment of inertia of the beam section.\\
\includegraphics[width=8cm]{DE2}
\end{multicols}

%---------------------------------------------------
% The Solution of a Differential Equation
%---------------------------------------------------
\section*{The Solution of a Differential Equation}
When you are asked to ``solve''\ a differential equation you are expected to find all possible solutions of the differential equation. Thus, the solution is another function.

\example Find all possible solutions of the differential equation $\dydx =2 x$.  This differential equation could also be expressed as $y^{ \prime } =2 x\text{.}$\medskip\\
\solution By integrating we obtain
\begin{equation*}y =x^{2} +C
\end{equation*}
Where $C$ is the constant of integration.  This is an arbitrary constant and gives us a family of functions all of which are solutions of the differential equation $y^{ \prime } =2 x$.  This family of solutions is often referred to as the \emph{general solution}.

In a physical situation we are often provided with additional information and this will allow us to find a \emph{particular solution}.  This is easy to visualise when considering $y^{ \prime } =2 x\text{.}$  The general solution is $y =x^{2} +C$ and if you are also told that the curve passes through $\left (2 ,6\right )$ you can use this information to evaluate $C\text{.}$
\begin{align*}6 &    = 2^{2} +C \\
C &    = 2\end{align*}

So the particular solution is $y =x^{2} +2$.  To appreciate the concept of this particular solution you only need to use \desmos to
draw $y =x^{2} +C$ for various values of $C$.

\subsection*{Initial-Value Problems}
In a physical problem when you are given the conditions for the particular solution in the form $y (t_{0}) =y_{0}$ where $t_{0}$ is the initial value of $t$ and $y_{0}$ is the initial value of $y (t)$, the point $\left (t_{0} ,y_{0}\right )$ is called an \emph{initial condition} and the
problem of finding the particular solution given the differential equation is referred to as an \emph{initial-value problem}.

\example For the differential equation $y^{ \prime } = -y^{2}$ \medskip\\
(a) Verify that $y =\frac{1}{t +C}$ is the general solution \\
(b) Find the solution of the initial-value problem $y^{ \prime } = -y^{2}$ and $y \left (0\right ) =0.5$ \\
%\clearpage
\solution
\begin{tasks}(2)
\task Given $y =\frac{1}{t +C} =\left (t +C\right )^{ -1}$
\begin{align*}y^{ \prime } &    =  -\left (t +C\right )^{ -2} \\
 &    = \frac{ -1}{\left (t +C\right )^{2}} \\
 &    =  -\left(\frac{1}{t +C}\right)^{2} = -y^{2}\end{align*}

So $y =\frac{1}{t +C}$ is the general solution of $y^{ \prime } = -y^{2}$

\task Substitute $\left (0 ,0.5\right )$ in $y =\frac{1}{t +C}$
\begin{align*}0.5 &    = \frac{1}{0 +C} \\
\frac{1}{2} &    = \frac{1}{C} \\
C &    = 2\end{align*}
The particular solution is $y =\frac{1}{t +2}$
\end{tasks}
\rule{6.8cm}{0.5pt}\\
\examq\\ Find the particular solution to the differential equation $1+x^2\dydx=x^3$ given that $y(1)=\frac{5}{2}$.\\
\solution Isolate the derivative, $\dydx$, and integrate to find the function $y$:\\
\begin{align*}
\dydx&=\frac{x^3-1}{x^2}\\
\int\dydx&=\int xdx-\int\frac{1}{x^2}dx\\
y&=\frac{x^2}{2}+\frac{1}{x}+C
\end{align*}
Use the initial condition $y(1)=\frac{5}{2}$ to solve for the unknown constant:\\
	\begin{align*}\frac{5}{2}&=\frac{1^2}{2}+\frac{1}{1}+C\\
	C&=1
	\end{align*}
Therefore the particular solution is $\qquad\displaystyle y=\frac{x^2}{2}+\frac{1}{x}+1$

%---------------------------------------------------
% Separable Equations
%---------------------------------------------------
\section{Separable Equations}
In some special cases we can find explicit solutions of differential equations. One type of equation can be written in the form
\begin{equation*}\dydx =\frac{f (x)}{g (y)}
\end{equation*}

Expressed in this form we simply have to recognise that $f (x)$ is a function without any $y$'s in it and $g (y)$ is a function without any $x$'s in it. The variables can be \textit{separated} by cross-multiplying such that:

\begin{align*}
g (y)\, d y &=f (x)\, d x
\end{align*}
Then we integrate both sides
\begin{equation*}\int g (y) \mathrm{d} y =\int f (x) \mathrm{d} x
\end{equation*}This procedure can be verified by differentiating both sides with respect to $x$
\begin{equation*}\frac{\mathrm{d}}{\mathrm{d} x} \int g (y) \mathrm{d} y =\frac{\mathrm{d}}{\mathrm{d} x} \int f (x) \mathrm{d} x
\end{equation*}By the chain rule the left hand side becomes
\begin{equation*}\frac{\mathrm{d}}{\mathrm{d} y} \int g (y) \,\mathrm{d} y \times \dydx
\end{equation*}So
\begin{align*}\frac{\mathrm{d}}{\mathrm{d} y} \int g (y) \mathrm{d} y \times \dydx &    = \frac{\mathrm{d}}{\mathrm{d} x} \int f (x) \mathrm{d} x \\
g (y) \times \dydx &    = f (x) \\
\text{or\  \  \ }\dydx &    = \frac{f (x)}{g (y)}\end{align*}
\rule{6.8cm}{0.5pt}\\
\example Solve the differential equation by the method of separating variables \[ \dydx =\frac{x^{2}}{y^{2}}\]
\solution The solution to a differential equation is another function. Separate the variables and integrate both sides.
\begin{align*}y^{2} \mathrm{d} y &    = x^{2} \mathrm{d} x \\
\int y^{2} \mathrm{d} y &    = \int x^{2} \mathrm{d} x \\
\frac{y^{3}}{3} &    = \frac{x^{3}}{3} +C \\
y^{3} &    = x^{3} +3 C \\
 &    = x^{3} +C_{1}\end{align*}Where $C_{1}$ is a new arbitrary constant. Isolate $y$ to find a function of the form $y=f(x)$:
\begin{equation*}y =\sqrt[{3}]{x^{3} +C_{1}}
\end{equation*}Find $C_{1}$ given $y (0) =2$
\begin{align*}2 &    = \sqrt[{3}]{0^{3} +C_{1}} \\
C_{1} &    = 8 \\
\text{therefore }y &    = \sqrt[{3}]{x^{3} +8}\end{align*}

\rule{6.8cm}{0.5pt}\\
%\clearpage
\example Solve the differential equation: \[y'=3x^2 y\]
\solution First write $y^{ \prime } =\dydx$
\begin{equation*}\dydx =3 x^{2} y
\end{equation*}Separate the variables
\begin{equation*}\frac{1}{y} \mathrm{d} y =3 x^{2} \mathrm{d} x
\end{equation*}Integrate
\begin{align}\int \frac{1}{y} \mathrm{d} y &    = \int 3 x^{2} \mathrm{d} x \nonumber  \\
\ln  \left \vert y\right \vert  &    = x^{3} +C \tag{1}\end{align}We usually write this by writing in exponential form
\begin{align*}\left \vert y\right \vert  &    = e^{x^{3} +C} \\
 &    = e^{x^{3}} e^{C} \\
y &    =  \pm e^{C} e^{x^{3}}\end{align*}And write $A = \pm e^{C}$ where the value of $A$ is used that satisfies the particular problem
\begin{equation}y =A e^{x^{3}}\tag{2}
\end{equation}

In practice we usually jump from line (1) to line (2) and leave out the intermediate steps.

%---------------------------------------------------
% Chapter Exercises in a separate file
%---------------------------------------------------
\section{Chapter Exercises}
\subimport{}{6DiffEqnExercises}


\section{Proofs for Chapter 2}
\label{sec:a11chapter2}

\disableornamentsfornextheadingtrue
\subsection{Proof of the Size of the Regular Sparse Grid with Coarse Boundaries}
\label{sec:a111proofGridSizeCoarseBoundary}

\propGridSizeCoarseBoundary*

\begin{proof}
  Note that the outer union in the definition of $\coarselevelset{n}{d}{b}$ in
  \eqref{eq:coarseBoundary2} is indeed disjoint.
  Therefore,
  \begin{equation}
    \setsize{\coarseregsgset{n}{d}{b}}
    = \sum_{\substack{\*l \in \nat^d\\\normone{\*l} \le n}}
    \setsize{\hiset{\*l}} +
    \hspace*{-5mm}\sum_{
      \substack{
        \*l \in \natz^d \setminus \nat^d\\
        (\normone{\vecmax(\*l, \*1)} \le n - b + 1) \lor
        (\*l = \*0)
      }
    }\hspace*{-10mm} \setsize{\hiset{\*l}}.
  \end{equation}
  The first sum is the number $\setsize{\interiorregsgset{n}{d}}$
  of interior grid points in $\regsgset{n}{d}$.
  The second sum can be split into summands
  with the same number $q$ of zero entries,
  which we count with
  $N_\*l \ceq \setsize{\{t \mid l_t = 0\}}
  = \normone{\vecmax(\*l, \*1)} - \normone{\*l}$,
  and the same level sum $m = \normone{\*l}$:
  \begin{equation}
    \setsize{\coarseregsgset{n}{d}{b}}
    = \setsize{\interiorregsgset{n}{d}} + 2^d +
    \sum_{q=1}^{d-1} \sum_{m=d-q}^{n-b-q+1}
    \sum_{
      \substack{
        \*l \in \natz^d\\
        N_\*l = q,\,\normone{\*l} = m}
    }\hspace*{-4mm} \setsize{\hiset{\*l}},
  \end{equation}
  where $2^d$ is the summand for $\*l = \*0$
  (number $\setsize{\hiset{\*0}}$ of corners of $\clint{\*0, \*1}$).
  The limits of the sum over $m$ are $d-q$,
  since there are $d-q$ entries $\ge 1$ in a level vector
  with $q$ zero entries, and $n-b-q+1$,
  since $m = \normone{\*l}
  = \normone{\vecmax(\*l, \*1)} - N_\*l
  \le n-b+1 - N_\*l
  = n-b-q+1$.

  \vspace*{2em}

  In general, the innermost summand $\setsize{\hiset{\*l}}$ equals
  $\setsize{\hiset{\*l}}
  = \prod_{\{t \mid l_t \ge 1\}} 2^{l_t-1} \cdot \prod_{\{t \mid l_t = 0\}} 2
  = 2^{\normone{\*l} - d + 2N_\*l}$.
  The number of innermost summands is given by
  \begin{equation}
    \setsize{\{\*l \in \natz^d \mid N_\*l = q,\; \normone{\*l} = m\}}
    = \binom{d}{q} \setsize{\{\*l \in \nat^{d-q} \mid \normone{\*l} = m\}}
    = \binom{d}{q} \binom{m-1}{d-q-1}.
  \end{equation}
  This can be seen by first putting $q$ zeros in $d$ places,
  for which there are $\binom{d}{q}$ possibilities, and then
  counting all positive vectors of length $d - q$ with level sum $m$,
  which can be done in $\binom{m-1}{d-q-1}$ ways.
  Thus,
  \begin{subequations}
    \begin{align}
      \setsize{\coarseregsgset{n}{d}{b}}
      &= \setsize{\interiorregsgset{n}{d}} + 2^d +
      \sum_{q=1}^{d-1} \binom{d}{q} \sum_{m=d-q}^{n-b-q+1}
      2^{m - d + 2q} \binom{m-1}{d-q-1}.\\[1em]
      \intertext{%
        After shifting the index $m \to (m + d - q)$ and slightly
        rearranging the terms, we obtain%
      }
      \cdots
      &= \setsize{\interiorregsgset{n}{d}} + 2^d +
      \sum_{q=1}^{d-1} 2^q \binom{d}{q} \sum_{m=0}^{n-d-b+1}
      2^m \binom{(d-q)-1+m}{(d-q)-1}.\\[1em]
      \intertext{%
        We can now use \thmref{lemma:numberOfGridPointsInterior} to
        conclude that%
      }
      \cdots
      &= \setsize{\interiorregsgset{n}{d}} +
      \sum_{q=1}^d 2^q \binom{d}{q}
      \setsize{\interiorregsgset{n-q-b+1}{d-q}}
    \end{align}
  \end{subequations}
  as desired.
\end{proof}

\vspace*{2em}

\breakpagebeforenextheadingtrue
\subsection{%
  Correctness Proof of the Construction of the Regular Sparse Grid
  with Coarse Boundaries%
}
\label{sec:a112proofInvariantCoarseBoundary}

\propInvariantCoarseBoundary*

\begin{proof}
  First, we show that every inserted level $\*l' \in \natz^t$ in the inner loop
  can be found on the right-hand side of \eqref{eq:coarseInvariant}.
  If $\*l' \ceq (\*l, 0)$
  is inserted for some $\*l \in \levelset^{(t-1)}$,
  then we have $\normone{\vecmax(\*l, \*1)} \le n-d+t-b$ or
  $\*l = \*0$ by \cref{line:algCoarseBoundary1} of
  \cref{alg:coarseBoundary}.
  In the first case, we have
  \begin{equation}
    \normone{\vecmax(\*l', \*1)}
    = \normone{\vecmax(\*l, \*1)} + 1
    \le n - d + t - b + 1,
  \end{equation}
  and in the second case $\*l' = \vec{0}$.
  In either case, $\*l'$ is contained in the \rhs of
  \eqref{eq:coarseInvariant}.

  If $\*l' \ceq (\*l, l_t)$ is inserted
  for some $\*l \in \levelset^{(t-1)}$ and
  $l_t \in \{1, \dotsc, l^\ast\}$, then there are,
  depending on whether $\*l \in \nat^{t-1}$, two cases:
  \begin{itemize}
    \item
    \mbox{If $\*l \in \nat^{t-1}$, then $\*l' \in \nat^t$ and}
    $\normone{\*l'} \le \normone{\*l} + l^\ast = n - d + t$
    due to \cref{line:algCoarseBoundary2},
    i.e., $\*l'$ is contained in the first set of the \rhs of
    \eqref{eq:coarseInvariant}.

    \item
    \mbox{If $\*l \notin \nat^{t-1}$, then $\*l' \notin \nat^t$ and}
    $\normone{\vecmax(\*l', \*1)}
    \le \normone{\vecmax(\*l, \*1)} + l^\ast
    = n - d + t - b + 1$
    due to \cref{line:algCoarseBoundary3},
    i.e., $\*l$ is contained in the second set of the \rhs of
    \eqref{eq:coarseInvariant}.
  \end{itemize}
  Thus, all levels that the algorithm inserts into $\levelset^{(t)}$
  can be found on the \rhs of \eqref{eq:coarseInvariant}.

  It remains to prove that all levels on the \rhs of
  \eqref{eq:coarseInvariant}
  are eventually inserted by the algorithm into $\levelset^{(t)}$.
  We prove this by induction over $t = 1, \dotsc, d$.
  For $t = 1$, the \rhs of \eqref{eq:coarseInvariant} equals
  $\{l \in \natz \mid l \le n-d+1\}$, which is just $\levelset^{(1)}$
  (see \cref{line:algCoarseBoundary6} of \cref{alg:coarseBoundary}).
  For the induction step $(t - 1) \to t$, we assume
  the validity of the induction hypothesis
  \begin{equation}
    \label{eq:proofCoarseInductionHypothesis}
    \begin{aligned}
      \levelset^{(t-1)}
      &= \{\*l \in \nat^{t-1} \mid
      \normone{\*l} \le n-d+t-1\} \dotcup {}\\
      &\hphantom{{}={}}
      \paren*{
        \{\*l \in \natz^{t-1} \setminus \nat^{t-1} \mid
        \normone{\vecmax(\*l, \*1)} \le n-d+t-b\} \cup
        \{\vec{0}\}
      }.
    \end{aligned}
  \end{equation}
  The \rhs of \eqref{eq:coarseInvariant} has three parts,
  so we check for elements $\*l' \in \natz^t$
  of each of the three sets that they are appended to $\levelset^{(t)}$
  eventually.

  First, let $\*l' = (\*l, l_t)$ be in the first set of the \rhs,
  i.e., $\*l' \in \nat^t$ (in particular $l_t \ge 1$) and
  $\normone{\*l'} \le n - d + t$.
  Note that $\*l$ will be encountered in the inner loop, as
  $\*l \in \nat^{t-1}$ and
  $\normone{\*l} = \normone{\*l'} - l_t \le n - d + t - 1$,
  which implies $\*l \in \levelset^{(t-1)}$ by the induction
  hypothesis \eqref{eq:proofCoarseInductionHypothesis}.
  Since $1 \le l_t \le l^\ast$
  (due to
  $l_t = \normone{\*l'} - \normone{\*l} \le n-d+t - \normone{\*l} = l^\ast$),
  the level $\*l'$ is inserted into $\levelset^{(t)}$ during the innermost loop
  in \cref{line:algCoarseBoundary4} of \cref{alg:coarseBoundary}.

  Second, let $\*l' = (\*l, l_t)$
  be in the second set of the \rhs, i.e., we have
  $\*l' \notin \nat^t$ and
  $\normone{\vecmax(\*l', \*1)} \le n-d+t-b+1$.
  Here, there are three cases:
  \begin{enumerate}
    \item
    $l_t \ge 1$:
    This implies $\*l \notin \nat^{t-1}$ and
    $\normone{\vecmax(\*l, \*1)}
    = \normone{\vecmax(\*l', \*1)} - l_t
    \le n-d+t-b$.
    Consequently, $\*l \in \levelset^{(t-1)}$ by the induction hypothesis
    \eqref{eq:proofCoarseInductionHypothesis}.
    As $1 \le l_t \le l^\ast$
    (due to $l_t \le n-d+t-b+1 -
    \normone{\vecmax(\*l, \*1)} = l^\ast$),
    $\*l$ is added to $\levelset^{(t)}$ in \cref{line:algCoarseBoundary4}.

    \item
    $l_t = 0$ and $\*l \in \nat^{t-1}$:
    This implies $\normone{\*l} = \normone{\*l'}
    = \normone{\vecmax(\*l', \*1)} - 1
    \le n - d + t - b
    \le n - d + t - 1$ since $b \ge 1$.
    Again, by the induction hypothesis
    \eqref{eq:proofCoarseInductionHypothesis},
    $\*l$ is added to $\levelset^{(t)}$ in \cref{line:algCoarseBoundary5}
    due to
    $\normone{\vecmax(\*l, \*1)}
    = \normone{\*l} \le n - d + t - b$.

    \item
    $l_t = 0$ and $\*l \notin \nat^{t-1}$:
    This implies $\normone{\vecmax(\*l, \*1)}
    = \normone{\vecmax(\*l', \*1)} - 1
    \le n - d + t - b$.
    Again, by the induction hypothesis
    \eqref{eq:proofCoarseInductionHypothesis},
    $\*l$ is added to $\levelset^{(t)}$ in \cref{line:algCoarseBoundary5}.
  \end{enumerate}

  \noindent
  Third, let $\*l = (\vec{0}, 0) \in \natz^t$
  be in the third set of the \rhs.
  This level is appended in \cref{line:algCoarseBoundary5}
  to $\levelset^{(t)}$, since $\*l' = \vec{0} \in \natz^{t-1}$
  is in $\levelset^{(t-1)}$ by the
  induction hypothesis~\eqref{eq:proofCoarseInductionHypothesis}.
\end{proof}


\section{Networks of Queues}
\label{sec:Networks-Of-Queues}

A network of queues is an architecture where multiple queue nodes are connected with probabilistic routing. Such a network can be
(i) open, if it receives external arrivals and departures exit the system, or
(ii) closed, if the number of jobs is fixed to a multiprogramming level and it does not have external arrival neither departures exits the system.

Jackson Networks are the simplest network of queues, and they are very useful in modeling packet-routing computer networks.

We define Open Jackson Networks, Closed Jackson Networks and their respective closed-form limiting probabilities.

Furthermore, we present the Local Balance Approach to solve Open Jackson Network, and the Mean Value Analysis to solve Closed Jackson Networks.


\documentclass[12pt]{article}

\usepackage{amsthm}
\usepackage{amsmath}    % need for subequations
\usepackage{amsfonts}
\usepackage[ocgcolorlinks]{hyperref}

\setlength{\baselineskip}{16.0pt}    % 16 pt usual spacing between lines

\setlength{\parskip}{3pt plus 2pt}
\setlength{\parindent}{20pt}
\setlength{\oddsidemargin}{0.5cm}
\setlength{\evensidemargin}{0.5cm}
\setlength{\marginparsep}{0.75cm}
\setlength{\marginparwidth}{2.0cm}
\setlength{\marginparpush}{1.0cm}
\setlength{\textwidth}{150mm}

\DeclareMathOperator{\sinc}{sinc}
\DeclareMathOperator{\sgn}{sgn}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{example}[1][Example]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{remark}[1][Remark]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

\begin{document}

\section{Example: Counting change}

\begin{lemma}
    $\forall n, d, k \in \mathbb{N} : d, k \ge 1 \implies n^{k-1} + (n-d)^k \le n^k$
\end{lemma}

\begin{proof}
    $$d \ge 1 \implies n - d \le n - 1 < n.$$
    $$k \ge 1 \implies (n-d)^{k-1} < n^{k-1}.$$
    $$(n-d)^k = (n-d)(n-d)^{k-1} \le (n-1)n^{k-1} = n^k - n^{k-1}.$$
\end{proof}

\begin{definition}
    $T(n,k)$ is the number of ways to change amount $n$ using $k$ kinds of coins. $n, k \in \mathbb{N}, n, k \ge 1$.
\end{definition}

\begin{theorem}
    $T(n,k) = O(n^k).$
\end{theorem}

\begin{proof}
    To prove the theorem we have to show that $\exists c>0$ such that $T(n,k) \le cn^k$ for sufficiently large $n$.
    Let's prove it using substitution method (CLRS, p.83).

    Assume that the inequality is true.
    The recurrence formula for $T(n,k)$ is
    $$T(n,k) = T(n,k-1) + T(n-d,k),$$
    where $d$ is denomination of the first coin. $d \ge 1$. Therefore by Lemma
    $$T(n,k) \le cn^{k-1} + c(n-d)^k = c\left[n^{k-1} + (n-d)^k\right] \le cn^k.$$

    To finish the proof, we just need to find $c$. Since the boundary condition $T(1,1) = 1$, it's sufficient to put $c \ge 1$.
\end{proof}

\end{document}