\documentclass[a4paper]{article}

\title{Efficient numerical methods to solve ballistic equations}
\author{Javier Burguete}
\date{\today}

\newcommand{\ABS}[1]{\left|#1\right|}
\newcommand{\C}[1]{\left[#1\right]}
\newcommand{\COMB}[2]{\left(\begin{array}{c}#1\\#2\end{array}\right)}
\newcommand{\D}[3]{\DD{^{#3}#1}{#2^{#3}}}
\newcommand{\DD}[2]{\frac{d#1}{d#2}}
\newcommand{\EQ}[2]{\begin{equation}#1\label{#2}\end{equation}}
\newcommand{\PA}[1]{\left(#1\right)}
\newcommand{\PARTIAL}[2]{\frac{\partial #1}{\partial #2}}

\begin{document}

\maketitle

\tableofcontents

\section{Introduction}

We are interested in solving ordinary differential equations (ODE) as:
\EQ{\DD{u}{t}=f\PA{t,\,u(t)}.}{EqODE}

The following notation has been used in this work:
\[u_0=u\PA{t_0},\quad f_0=f\PA{t_0,\,u\PA{t_0}},\]
\[
	f_{n\,t}=\PARTIAL{^nf}{t^n},\quad
	f_{n\,t,m\,u}=\PARTIAL{^{n+m}f}{t^n\,\partial u^m},
\]
\[F_{0,0}=f_0,\quad F_{1,0}=\PA{f_t+f\,f_u}_0,\quad F_{1,1}=\PA{f_u}_0,\]
\[
	F_{2,0}=\PA{f_{2t}+2\,f\,f_{t,u}+f^2\,f_{2u}}_0,\quad
	F_{2,1}=\PA{f_{t,u}+f\,f_{2u}}_0,\quad
	F_{2,2}=\PA{f_{2u}}_0,
\]
\[\cdots\]
\[
	F_{i,j}=\C{\sum_{k=0}^{i-j}\COMB{i-j}{k}\,f^k\,f_{(i-j-k)\,t,(j+k)\,u}}_0,
	\quad j\leq i.
\]

The following recurrence rule is hold:
\EQ{\DD{F_{i,j}}{t}=F_{i+1,j}+(i-j)\,F_{i,j+1}\,F_{1,0}.}{EqdF}

Then,
\[\left.\DD{u}{t}\right|_0=F_{0,0},\]
\[\left.\D{u}{t}{2}\right|_0=F_{1,0},\]
\[\left.\D{u}{t}{3}\right|_0=F_{2,0}+F_{1,1}\,F_{1,0},\]
\[
	\left.\D{u}{t}{4}\right|_0=F_{3,0}+3\,F_{2,1}\,F_{1,0}+F_{2,0}\,F_{1,1}
	+F_{1,1}^2\,F_{1,0},
\]
\[
	\left.\D{u}{t}{5}\right|_0=F_{4,0}+6\,F_{3,1}\,F_{1,0}+F_{3,0}\,F_{1,1}
	+3\,F_{2,2}\,F_{1,0}^2+4\,F_{2,1}\,F_{2,0}+7\,F_{2,1}\,F_{1,1}\,F_{1,0}
\]
\[
	+F_{2,0}\,F_{1,1}^2+F_{1,1}^3\,F_{1,0},
\]

When $f=f(t)$ is a function depending only in time, the above relatons are
considerably simplified:
\[
	\left.\D{u}{t}{n}\right|_0=F_{n,0};\quad
	F_{i,j}=0,\;\forall j>0.
\]

Numerical methods to solve ODE (\ref{EqODE}) are based in approximations of the
Taylor's serie. For instance, in 5-th order:
\[
	u\PA{t_0+h}=u_0+h\,\left.\DD{u}{t}\right|_0
	+\frac{h^2}{2}\,\left.\D{u}{t}{2}\right|_0
	+\frac{h^3}{6}\,\left.\D{u}{t}{3}\right|_0
	+\frac{h^4}{24}\,\left.\D{u}{t}{4}\right|_0
	+\frac{h^5}{120}\,\left.\D{u}{t}{5}\right|_0
\]
\[+O\PA{h^6}\]
\[
	=u_0+h\,F_{0,0}+\frac{h^2}{2}\,F_{1,0}
	+\frac{h^3}{6}\,\PA{F_{2,0}+F_{1,1}\,F_{1,0}}
\]
\[
	+\frac{h^4}{24}\,\PA{F_{3,0}+3\,F_{2,1}\,F_{1,0}+F_{2,0}\,F_{1,1}
	+F_{1,1}^2\,F_{1,0}}
\]
\[
	+\frac{h^5}{120}\,\left(F_{4,0}+6\,F_{3,1}\,F_{1,0}+F_{3,0}\,F_{1,1}
	+3\,F_{2,2}\,F_{1,0}^2+4\,F_{2,1}\,F_{2,0}+7\,F_{2,1}\,F_{1,1}\,F_{1,0}
	\right.
\]
\EQ{\left.+F_{2,0}\,F_{1,1}^2+F_{1,1}^3\,F_{1,0}\right)+O\PA{h^6}.}{EqTaylor}

\subsection{Decay ODE}

A common particular case of ODE are the ''decay equations'' defined as:
\EQ{\DD{u}{t}=-|g(u)|\,u,\quad g_u\geq0.}{EqDODE}
with $g$ an increasing function on $u$. In these equations the variable module
decreases always in time:
\[\frac{du}{u}=-|g|\,dt\Rightarrow\]
\[u(t)=u_0\,\exp\PA{-\int_0^t|g|\,dt}\Rightarrow\]
\EQ{|u(t)|=\ABS{u_0}\,\exp\PA{-\int_0^t|g|\,dt.}}{EqDecay}
As $|g|$ is positive the integral is an increasing function. Then, $|u|$ is a
decreasing function. Another interesting property of these equations is that $u$
cannot change the sign:
\EQ{\frac{u(t)}{u_0}=\exp\PA{-\int_0^t|g|\,dt}\geq 0.}{EqDODEP}
Solving DODE (\ref{EqDODE}) numerically in first order using the Euler's rule:
\[u\PA{t_0+h}=u\PA{t_0}-h\,\ABS{g\PA{u\PA{t_0}}}\,u\PA{t_0}\Rightarrow\]
\EQ{\frac{u\PA{t_0+h}}{u\PA{t_0}}=1-h\,\ABS{g\PA{u\PA{t_0}}}.}{EqDODEI}
Then, to prevent numerical variable sign changes the time step size has to be
limited by:
\EQ
{
	\frac{u\PA{t_0+h}}{u\PA{t_0}}\geq0\Rightarrow\;
	1-h\,\ABS{g\PA{u\PA{t_0}}}\geq0\Rightarrow\;
	h\leq\frac{1}{|g|}.
}{EqDODELimit}
In these equations, we use the time step size as:
\EQ{h=\frac{k_t}{|g|},}{EqDODE dt}
with $k_t\leq1$ the dimensionless stability factor.

\subsection{Ballistic ODE}

Ballistic equations are a particular form of ODE follow a form:
\EQ{\ddot{\vec{r}}(t)=\ddot{\vec{r}}\PA{\dot{\vec{r}}(t)},}{EqBODE}
where $\vec{r}$, $\dot{\vec{r}}$, $\ddot{\vec{r}}$ are the vectors of position,
velocity and acceleration respectively.

\section{Runge-Kutta methods}

We use a variation of the Einstein's notation, where repeated indeces are
summed, in order to simplify the notation:
\EQ{f_{i,j}\,g_j\equiv\sum_{j=0}^{i-1}f_{i,j}\,g_j.}{EqNotation}
Runge-Kutta methods are methods in the form:
\EQ
{
	u_i=u_0+h\,b_{i,j}\,f_j,\quad
	f_i=f\PA{t+d_i\,h,u_i},\quad
	d_0=0,\quad
	d_i=\sum_{j=0}^{i-1}b_{i,j}.
}{EqRK}
Every $i$-th step introduces $i$ new freedom degrees.

Developing the steps in Taylor's series to 5-th order:
\[u_1=u_0+h\,d_1\,F_{0,0},\]
\[
	f_1=F_{0,0}+h\,d_1\,F_{1,0}+\frac{h^2\,d_1^2}{2}\,F_{2,0}
	+\frac{h^3\,d_1^3}{6}\,F_{3,0}+\frac{h^4\,d_1^4}{24}\,F_{4,0}+O\PA{h^5},
\]
\[
	u_2=u_0+h\,d_2\,F_{0,0}+h^2\,b_{2,j}\,d_j\,F_{1,0}
	+\frac{h^3\,b_{2,j}\,d_j^2}{2}\,F_{2,0}
	+\frac{h^4\,b_{2,j}\,d_j^3}{6}\,F_{3,0}
\]
\[	+\frac{h^5\,b_{2,j}\,d_j^4}{24}\,F_{4,0}+O\PA{h^6},\]
\[
	f_2=F_{0,0}+h\,d_2\,F_{1,0}+\frac{h^2\,d_2^2}{2}\,F_{2,0}
	+h^2\,b_{2,j}\,d_j\,F_{1,1}\,F_{1,0}+\frac{h^3\,d_2^3}{6}\,F_{3,0}
\]
\[
	+\frac{h^3\,b_{2,j}\,d_j^2}{2}\,F_{2,0}\,F_{1,1}
	+\frac{h^4\,d_2^4}{24}\,F_{4,0}
	+\frac{h^4\,d_2^2\,b_{2,j}\,d_j}{2}\,F_{3,1}\,F_{1,0}
\]
\[
	+\frac{h^4\,b_{2,j}\,d_j^3}{6}\,F_{3,0}\,F_{1,1}
	+\frac{h^4\,\PA{b_{2,j}\,d_j}^2}{2}\,F_{2,2}\,F_{1,0}^2
	+\frac{h^4\,d_2\,b_{2,j}\,d_j^2}{2}\,F_{2,1}\,F_{2,0}
	+O\PA{h^5},
\]
\[
	u_3=u_0+h\,d_3\,F_{0,0}+h^2\,b_{3,j}\,d_j\,F_{1,0}
	+\frac{h^3\,b_{3,j}\,d_j^2}{2}\,F_{2,0}
	+h^3\,b_{3,j}\,b_{j,k}\,d_k\,F_{1,1}\,F_{1,0}
\]
\[
	+\frac{h^4\,b_{3,j}\,d_j^3}{6}\,F_{3,0}
	+\frac{h^4\,b_{3,j}\,b_{j,k}\,d_k^2}{2}\,F_{2,0}\,F_{1,1}
	+\frac{h^5\,b_{3,j}\,d_j^4}{24}\,F_{4,0}
\]
\[
	+\frac{h^5\,b_{3,j}\,d_j^2\,b_{j,k}\,d_k}{2}\,F_{3,1}\,F_{1,0}
	+\frac{h^5\,b_{3,j}\,b_{j,k}\,d_k^3}{6}\,F_{3,0}\,F_{1,1}
	+\frac{h^5\,b_{3,j}\,\PA{b_{j,k}\,d_k}^2}{2}\,F_{2,2}\,F_{1,0}^2
\]
\[
	+\frac{h^5\,b_{3,j}\,d_j\,b_{j,k}\,d_k^2}{2}\,F_{2,1}\,F_{2,0}
	+O\PA{h^6}
\]
\[
	f_3=F_{0,0}+h\,d_3\,F_{1,0}+\frac{h^2\,d_3^2}{2}\,F_{2,0}
	+h^2\,b_{3,j}\,d_j\,F_{1,1}\,F_{1,0}+\frac{h^3\,d_3^3}{6}\,F_{3,0}
\]
\[
	+h^3\,d_3\,b_{3,j}\,d_j\,F_{2,1}\,F_{1,0}
	+\frac{h^3\,b_{3,j}\,d_j^2}{2}\,F_{2,0}\,F_{1,1}
	+h^3\,b_{3,j}\,b_{j,k}\,d_k\,F_{1,1}^2\,F_{1,0}
	+\frac{h^4\,d_3^4}{24}\,F_{4,0}
\]
\[
	+\frac{h^4\,d_3^2\,b_{3,j}\,d_j}{2}\,F_{3,1}\,F_{1,0}
	+\frac{h^4\,b_{3,j}\,d_j^3}{6}\,F_{3,0}\,F_{1,1}
	+\frac{h^4\,\PA{b_{3,j}\,d_j}^2}{2}\,F_{2,2}\,F_{1,0}^2
\]
\[
	+\frac{h^4\,d_3\,b_{3,j}\,d_j^2}{2}\,F_{2,1}\,F_{2,0}
	+h^4\,d_3\,b_{3,j}\,b_{j,k}\,d_k\,F_{2,1}\,F_{1,1}\,F_{1,0}
	+\frac{h^4\,b_{3,j}\,b_{j,k}\,d_k^2}{2}\,F_{2,0}\,F_{1,1}^2
\]
\[+O\PA{h^5},\]
\[
	u_4=u_0+h\,d_4\,F_{0,0}+h^2\,b_{4,j}\,d_j\,F_{1,0}
	+\frac{h^3\,b_{4,j}\,d_j^2}{2}\,F_{2,0}
	+h^3\,b_{4,j}\,b_{j,k}\,d_k\,F_{1,1}\,F_{1,0}
\]
\[
	+\frac{h^4\,b_{4,j}\,d_j^3}{6}\,F_{3,0}
	+h^4\,b_{4,j}\,d_j\,b_{j,k}\,d_k\,F_{2,1}\,F_{1,0}
	+\frac{h^4\,b_{4,j}\,b_{j,k}\,d_k^2}{2}\,F_{2,0}\,F_{1,1}
\]
\[
	+h^4\,b_{4,j}\,b_{j,k}\,b_{k,l}\,d_l\,F_{1,1}^2\,F_{1,0}
	+\frac{h^5\,b_{4,j}\,d_j^4}{24}\,F_{4,0}
	+\frac{h^5\,b_{4,j}\,d_j^2\,b_{j,k}\,d_k}{2}\,F_{3,1}\,F_{1,0}
\]
\[
	+\frac{h^5\,b_{4,j}\,b_{j,k}\,d_k^3}{6}\,F_{3,0}\,F_{1,1}
	+\frac{h^5\,b_{4,j}\,\PA{b_{j,k}\,d_k}^2}{2}\,F_{2,2}\,F_{1,0}^2
	+\frac{h^5\,b_{4,j}\,d_j\,b_{j,k}\,d_k^2}{2}\,F_{2,1}\,F_{2,0}
\]
\[
	+h^5\,b_{4,j}\,d_j\,b_{j,k}\,b_{k,l}\,d_l\,F_{2,1}\,F_{1,1}\,F_{1,0}
	+\frac{h^5\,b_{4,j}\,b_{j,k}\,b_{k,l}\,d_k^2}{2}\,F_{2,0}\,F_{1,1}^2
	+O\PA{h^6}
\]

Comparing with the Taylor's series (\ref{EqTaylor}) a $i$-steps Runge-Kutta
method has to hold the following conditions to get different approximation
orders:
\begin{itemize}
\item First order:
	\EQ{d_i=1.}{EqRKI}
\item Second order:
	\EQ{b_{i,j}\,d_j=\frac12.}{EqRKII}
\item Third order:
	\EQ
	{
		b_{i,j}\,d_j^2=\frac13,\quad
		b_{i,j}\,b_{j,k}\,d_k=\frac16.
	}{EqRKIII}
\item Fourth order:
	\EQ
	{
		b_{i,j}\,d_j^3=\frac14,\quad
		b_{i,j}\,d_j\,b_{j,k}\,d_k=\frac18,\quad
		b_{i,j}\,b_{j,k}\,d_k^2=\frac1{12},\quad
		b_{i,j}\,b_{j,k}\,b_{k,l}\,d_l=\frac1{24}.
	}{EqRKIV}
\item Fifth order:
	\[
		b_{i,j}\,d_j^4=\frac15,\quad
		b_{i,j}\,d_j^2\,b_{j,k}\,d_k=\frac1{10},\quad
		b_{i,j}\,b_{j,k}\,d_k^3=\frac1{20},
	\]
	\[
		b_{i,j}\,\PA{b_{j,k}\,d_k}^2=\frac1{20},\quad
		b_{i,j}\,d_j\,b_{j,k}\,d_k^2=\frac1{15},\quad
		b_{i,j}\,d_j\,b_{j,k}\,b_{k,l}\,d_l=\frac7{120},
	\]
	\EQ
	{
		b_{i,j}\,b_{j,k}\,b_{k,l}\,d_l^2=\frac1{60},\quad
		b_{i,j}\,b_{j,k}\,b_{k,l}\,b_{l,m}\,d_m=\frac1{120}.
	}{EqRKV}
\end{itemize}

On equations depending only in time, first of the above equations are
sufficient:
\begin{itemize}
\item $n$-th order:
	\EQ{b_{i,j}\,d_j^{n-1}=\frac1n.}{EqRKt}
\end{itemize}

\subsection{Strong stability}

General Runge-Kutta methods (\ref{EqRK}) can also be expressed as:
\EQ
{
	u_i=\sum_{j=0}^{i-1}a_{i,j}\,\PA{u_j+h\,c_{i,j}\,f_j},\quad
	\sum_{j=0}^{i-1}a_{i,j}=1.
}{EqRKac}
The following relation is hold:
\EQ{b_{i,j}=(a\,c)_{i,j}+\sum_{k=j+1}^{i-1}a_{i,k}\,b_{k,j}.}{EqRKacb}
This form introduces new $i-1$ freedom degrees for each $i$-th step.

In the context of propagation equations it has been demonstrated that a
Runge-Kutta method preserves monotonicity, and therefore absence of numerical
spurious oscillations, if:
\EQ{a_{i,j},\,c_{i,j}\geq0,\quad k_t\leq\frac1{\max\PA{c_{i,j}}}}{EqRKTVD}

\subsection{Simple stability}

On decay ODE a more simple stability condition can be obtained. In these
equations we define a Runge-Kutta method as ''simple stable'' when it preserves
the variable sign for each time step. Assuming positive $u$:
\[
	b_{i,j}\geq0\Rightarrow\;
	u_i=u_0-h\,b_{i,j}\,\ABS{g_j}\,u_j\leq u_0\Rightarrow\;
	f_i\leq f_0\Rightarrow
\]
\EQ
{
	u_i\geq u_0-h\,\sum_jb_{i,j}\,\ABS{g_0}\,u_0
	=u_0\,\PA{1-h\,d_i\,\ABS{g_0}}
}{EqRKSimpleCondition}
wherefrom preserving sign in $u$ is ensured by:
\EQ{b_{i,j}\geq0,\quad k_t\leq\frac{1}{\max\PA{d_i}}}{EqRKSimple}
These conditions are sufficient but not necessary.

A strong stable method is always simple stable, (\ref{EqRKTVD}) conditions
ensures:
\[\frac{u_j+h\,c_{i,j}\,f_j}{u_j}\geq0\Rightarrow\]
\EQ{\frac{u_i}{u_0}=\sum_ja_{i,j}\,\frac{u_j+h\,c_{i,j}\,f_j}{u_j}\geq0.}
{EqRKSimpleStrong}

\subsection{Ballistic ODE}

For ballistic ODE, Runge-Kutta methods are adapted by doing:
\EQ
{
	\vec{r}_i=\vec{r}_0+h\,b_{i,j}\,\dot{\vec{r}}_j,\quad
	\dot{\vec{r}}_i=\dot{\vec{r}}_0+h\,b_{i,j}\,\ddot{\vec{r}}_j,\quad
	\ddot{\vec{r}}_i=\ddot{\vec{r}}\PA{\dot{\vec{r}}_i}.
}{EqRKBODE}

\subsection{One step first order (Euler's method)}

The one step first order method, proposed by Euler, is defined by the
coefficient matrices of table~\ref{TableRKiI}.
\begin{table}[ht]
	\centering
	\begin{tabular}{c|c}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		1 & 1
	\end{tabular},~
	\begin{tabular}{c}
		$a_{i,j}$ \\ \hline
		1
	\end{tabular},~
	\begin{tabular}{c}
		$c_{i,j}$ \\ \hline
		1
	\end{tabular}
	\caption{Coefficients of the one step first order Runge-Kutta method (RK1-1).
		\label{TableRKiI}}
\end{table}
This a first order method with strong and simple stability for $k_t\leq1$.

\subsection{Two steps second order}

We consider two interesting two steps second order methods defined by the
coefficients matrices of tables~\ref{TableRKiiIIa} and~\ref{TableRKiiIIb}.
First method is second order, third order in equations depending only in time,
simple stable for $k_t\leq1$ and strong stable for $k_t\leq1/2$. Second method
is second order and simple and strong stable for $k_t\leq1$.
\begin{table}[ht]
	\centering
	\begin{tabular}{c|cc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		2/3 & 2/3 \\
		1 & 1/4 & 3/4
	\end{tabular},~
	\begin{tabular}{cc}
		$a_{i,j}$ \\ \hline
		1 \\
		5/8 & 3/8
	\end{tabular},~
	\begin{tabular}{cc}
		$c_{i,j}$ \\ \hline
		2/3 \\
		0 & 2
	\end{tabular}
	\caption{Coefficients of the two steps second order Runge-Kutta method optime
		in accuracy (RK2-2(3)).\label{TableRKiiIIa}}
\end{table}
\begin{table}[ht]
	\centering
	\begin{tabular}{c|cc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		1 & 1 \\
		1 & 1/2 & 1/2
	\end{tabular},~
	\begin{tabular}{cc}
		$a_{i,j}$ \\ \hline
		1 \\
		1/2 & 1/2
	\end{tabular},~
	\begin{tabular}{cc}
		$c_{i,j}$ \\ \hline
		1 \\
		0 & 1
	\end{tabular}
	\caption{Coefficients of the two steps second order Runge-Kutta method optime
		in strong stability (RK2-2).\label{TableRKiiIIb}}
\end{table}

\subsection{Three steps third order}

The most interesting three steps Runge-Kutta is the defined by the coefficients
of the table~\ref{TableRKiiiIII}.
This method is third order, fourth order in equations depending only in time and
simple and strong stable for $k_t\leq1$.
\begin{table}[ht]
	\centering
	\begin{tabular}{c|ccc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		1 & 1 \\
		1/2 & 1/4 & 1/4 \\
		1 & 1/6 & 1/6 & 2/3
	\end{tabular},~
	\begin{tabular}{ccc}
		$a_{i,j}$ \\ \hline
		1 \\
		3/4 & 1/4 \\
		1/3 & 0 & 2/3
	\end{tabular},~
	\begin{tabular}{ccc}
		$c_{i,j}$ \\ \hline
		1 \\
		0 & 1 \\
		0 & 0 & 1
	\end{tabular}
	\caption{Coefficients of the three steps third order Runge-Kutta method
		(RK3-3(4)).\label{TableRKiiiIII}}
\end{table}

\subsection{Four steps fourth order}

The only four steps fourth order simple stable for $k_t\leq1$ is the defined by
the coefficients of the table~\ref{TableRKivIV}.
They are not fourth order strong stable Runge-Kutta methods of four steps.
\begin{table}[ht]
	\centering
	\begin{tabular}{c|cccc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		1/2 & 1/2 \\
		1/2 & 0 & 1/2 \\
		1 & 0 & 0 & 1 \\
		1 & 1/6 & 1/3 & 1/3 & 1/6
	\end{tabular}
	\caption{Coefficients of the four steps fourth order Runge-Kutta method
		(RK4-4).\label{TableRKivIV}}
\end{table}

\subsection{Five steps fourth order}

It is not possible to build a fifth order Runge-Kutta method with five steps.
The method defined in table~\ref{TableRKvIV} is simple stable for $k_t\leq1$,
fourth order and fifth order in equations depending only on time.
\begin{table}[ht]
	\renewcommand*{\arraystretch}{1.3}
	\centering
	\begin{tabular}{c|ccccc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		$\frac{11}{40}$ & $\frac{11}{40}$ \\
		1 & $\frac{223}{803}$ & $\frac{580}{803}$ \\
		$\frac12$ & $\frac{1.41}{146}$ & $\frac25$ & $\frac{13.19}{146}$ \\
		$\frac{17}{20}$ & $\frac{661.15057}{19272}$ &
			$\frac{11289.7731}{46574}$ & $\frac{156.50557}{50808}$
			& $\frac{2737}{4800}$ \\
		1 & $\frac{107}{1122}$ & $\frac{64000}{198099}$ & $\frac7{522}$ &
			$\frac{46}{189}$ & $\frac{8000}{24633}$
	\end{tabular}
	\caption{Coefficients of the five steps fourth order, fifth order in
		equations depending only in time, Runge-Kutta method (RK5-4(5)).
		\label{TableRKvIV}}
\end{table}

\section{Runge-Kutta pairs}

\EQ{\hat{u}_i=u_0+h\,\hat{b}_{i,j}\,f_j.}{EqRKpair}

\EQ{E_i=\hat{u}_i-u_i=h\,\PA{\hat{b}-b}_{i,j}\,f_j.}{EqRKpairE}

\subsection{Two steps first-second order pairs}

The two second order methods defined by the coefficients matrices of
tables~\ref{TableRKiiIIa} and~\ref{TableRKiiIIb} can be combined con the
Euler's method defined in table~\ref{TableRKiI} to build the two steps second
order Runge-Kutta pairs defined in tables~\ref{TableRKIiiIIa}
and~\ref{TableRKIiiIIb}.
\begin{table}[ht]
	\centering
	\begin{tabular}{c|cc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		2/3 & 2/3 \\
		1 & 1/4 & 3/4 \\ \hline
		$\hat{b}_{2,j}$ & 1 & 0 \\ \hline
		$e_{2,j}$ & 3/4 & -3/4
	\end{tabular}
	\caption{Coefficients of the two steps first-second order, first-third order
		in equations depending only in time, Runge-Kutta pair (RK2-1-2(3)).
		\label{TableRKIiiIIa}}
\end{table}
\begin{table}[ht]
	\centering
	\begin{tabular}{c|cc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		1 & 1 \\
		1 & 1/2 & 1/2 \\ \hline
		$\hat{b}_{2,j}$ & 1 & 0 \\ \hline
		$e_{2,j}$ & 1/2 & -1/2
	\end{tabular}
	\caption{Coefficients of the two steps first-second order Runge-Kutta pair
		optime in strong stability (RK2-1-2).\label{TableRKIiiIIb}}
\end{table}

\subsection{Three steps second-third order pair}

The three steps third order Runge-Kutta defined in table~\ref{TableRKiiiIII}
can be combined with the second order defined in table~\ref{TableRKiiIIb} to
produce the three steps second-third order pair defined in
table~\ref{TableRKIIiiiIII}.
\begin{table}[ht]
	\centering
	\begin{tabular}{c|ccc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		1 & 1 \\
		1/2 & 1/4 & 1/4 \\
		1 & 1/6 & 1/6 & 2/3 \\ \hline
		$\hat{b}_{3,j}$ & 1/2 & 1/2 & 0 \\ \hline
		$e_{3,j}$ & 1/3 & 1/3 & -2/3
	\end{tabular}
	\caption{Coefficients of the three steps second-third order, second-fourth
		order in equations depending only in time, Runge-Kutta pair (RK3-2-3(4)).
		\label{TableRKIIiiiIII}}
\end{table}

\subsection{Four steps second-third order pair}

It is not possible to build a four steps third-fourth order pair but they are
infinity two-three order pairs of four steps. The defined in
table~\ref{TableRKIIivIII} is moreover simple stable for $k_t\leq1$ and
third-fourth order in equations depending only on time.
\begin{table}[ht]
	\renewcommand*{\arraystretch}{1.3}
	\centering
	\begin{tabular}{c|cccc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		$\frac13$ & $\frac13$ \\
		1 & 0 & 1 \\
		$\frac23$ & $\frac16$ & $\frac14$ & $\frac14$ \\
		1 & $\frac18$ & $\frac38$ & $\frac18$ & $\frac38$ \\ \hline
		$\hat{b}_{4,j}$ & 0 & $\frac34$ & $\frac14$ & 0 \\ \hline
		$e_{4,j}$ & $-\frac18$ & $\frac38$ & $\frac18$ & $-\frac38$
	\end{tabular}
	\caption{Coefficients of the four steps second-third order, third-fourth order
		in equations depending only in time, Runge-Kutta pair (RK4-2(3)-3(4)).
		\label{TableRKIIivIII}}
\end{table}

\subsection{Five steps third-fourth order pair}

They are infinity third-fourth order pairs of five steps. The defined in
table~\ref{TableRKIIIvIV} is moreover simple stable for $k_t\leq1$ and
fourth-fifth order in equations depending only on time.
\begin{table}[ht]
	\renewcommand*{\arraystretch}{1.3}
	\centering
	\begin{tabular}{c|ccccc}
		$d_{i}$ & $b_{i,j}$ \\ \hline
		$\frac{11}{40}$ & $\frac{11}{40}$ \\
		1 & $\frac{223}{803}$ & $\frac{580}{803}$ \\
		$\frac12$ & $\frac{141}{14600}$ & $\frac25$ & $\frac{1319}{14600}$ \\
		$\frac{17}{20}$ & $\frac{66115057}{1927200000}$ &
			$\frac{112897731}{465740000}$ & $\frac{15650557}{5080800000}$
			& $\frac{2737}{4800}$ \\
		1 & $\frac{107}{1122}$ & $\frac{64000}{198099}$ & $\frac7{522}$ &
			$\frac{46}{189}$ & $\frac{8000}{24633}$ \\ \hline
		$\hat{b}_{5,j}$ & $\frac16$ & 0 & $\frac16$ & $\frac23$ & 0 \\ \hline
		$e_{5,j}$ & $\frac{40}{561}$ & $-\frac{64000}{198099}$ & $\frac{40}{261}$
			& $\frac{80}{189}$ & $-\frac{8000}{24633}$
	\end{tabular}
	\caption{Coefficients of the five steps third-fourth order, fourth-fifth order
		in equations depending only in time, Runge-Kutta pair (RK-3(4)-4(5)).
		\label{TableRKIIIvIV}}
\end{table}

\section{Multi-steps methods}

\section{Multi-steps pairs}

\section{Tests}

\section{Conclusions}

\end{document}


\subsection{Support Vector Machine}

\begin{figure}[h]
\center\includegraphics[width = .8\textwidth]{svm.png}
\caption{Parameter Tuning of SVM}
\label{svm}
\end{figure}

Kernel support vector machines (SVMs) are supervised learning models with associated learning algorithms commonly used in classification.\cite{cristianini2000introduction}

The effectiveness of SVM depends on the selection of kernel, the kernel's parameters, and soft margin parameter C. A common choice is a Gaussian kernel, which has a single parameter $\gamma$. The best combination of C and $\gamma$ is often selected by a grid search with exponentially growing sequences of C and $\gamma$. Each combination of parameter choices is checked using cross validation, and the parameters with best cross-validation accuracy are picked. We can do this with function \emph{tune} given a list of C. In Figure \ref{svm} we can see the CV error and test error of SVM using different cost and gamma. The best C is 0.05 and the best $\gamma$ is 0.135.

With the parameters tunned we can conduct classfication. The test error are shown in Table \ref{tblsvm}. The Type \uppercase\expandafter{\romannumeral1} error is slightly larger than random forest, but Type \uppercase\expandafter{\romannumeral2} error is significantly lower than random forest. So SVM made less mistake in predicting raining days compared to random forest. This could partly be explained by the fact that this isn't a linearly separable case.

\begin{table}[h]
\setlength{\belowcaptionskip}{5pt}
\caption{Confusion Matrix and Error Rates of SVM}
\label{tblsvm}
\centering
\renewcommand\arraystretch{1.5}
\begin{tabular}{rrrrr}
\hline
\hline
 & & \multicolumn{2}{c}{True Condition} & \\
\hline
 & & Non-Precipitation & Precipitation & \\
\cline{1-4}
\multirow{2}{*}{Prediction} & {Non-Precipitation} & 326 & 47 & \\
\cline{2-4}
&Precipitation&54&231&\\
\hline
&Error Rate & 0.142 & 0.169 & 0.1535\\
\cline{2-5}
& & Type \uppercase\expandafter{\romannumeral1} & Type \uppercase\expandafter{\romannumeral2} & Overall\\
\hline
\end{tabular}
\end{table}


\section*{Exercise 7.1}
The estimator of p is
\spl{
    \hat{p}=\frac{E}{n}=\frac{\overline{X}}{n}=\frac{0\cdot39+1\cdot23+2\cdot12+3\cdot1}{75\cdot24}=\frac{1}{36}.
}

The expected frequency can be calculated by $E_i=nP[X=i]=n\binom{n}{i}\hat{p}^i(1-\hat{p})^{n-i}$.
\begin{table}[H]
    \centering
    \begin{tabular}{ccccc}\hline
        Values & 0 & 1 & 2 & 3\\\hline
        Expected Frequency & 38.145 & 26.156 & 8.594 & 2.105\\\hline
    \end{tabular}
\end{table}

We notice that $E_i\geq5$ less than 80\% categories. Thus we merge the last two categories.
\begin{table}[H]
    \centering
    \begin{tabular}{ccccc}\hline
        Values & 0 & 1 & 2\\\hline
        Expected Frequency & 38.145 & 26.156 & 10.699\\\hline
    \end{tabular}
\end{table}

Then,we calculate the Pearson's Statistic
\spl{
    X^2=\sum_{i=1}^N\frac{(O_i-E_i)^2}{E_i}=\frac{(39-38.145)^2}{38.145}+\frac{(23-26.156)^2}{26.156}+\frac{(13-10.699)^2}{10.699}=0.876.
}

The degree of freedom is $3-1-1=1$. Hence, $X^2=0.876<\chi^2_{0.05,1}=3.84$. Hence, we conclude that follows binomial distribution at 5\% level of significance.

\section*{Exercise 7.2}
\begin{table}[h]
    \centering
    \begin{tabular}{c|cccc|c}
        Mounting Position & A & B & C & D & \\\hline
        1 & 22 & 46 & 18 & 9 & 95\\
        2 & 4 & 17 & 6 & 12 & 39\\\hline
        & 26 & 63 & 24 & 21 & 134\\
    \end{tabular}
\end{table}

\spl{
    H_0:\ p_{ij}=p_{i\cdot}p_{\cdot j}
}

Since $E_{ij}=\frac{n_{i\cdot}n_{\cdot j}}{n}$, then
\spl{
    E_{11}&=18.43,\quad E_{12}=44.66,\quad E_{13}=17.01,\quad E_{14}=14.88\\
    E_{21}&=7.57,\quad E_{22}=18.34,\quad E_{23}=6.99,\quad E_{24}=6.11\\
}

\spl{
    X_{(2-1)(4-1)}^2=\sum_{i=1}^r\sum_{j=1}^c\frac{(O_{ij}-E_{ij})^2}{E_{ij}}=10.71.
}

Since the statistic follows 3 degrees of freedom chi-squared distribution, we compare the value with $\chi_{0.05,3}^2=7.8147$. We find that $X_3^2>\chi_{0.05,3}^2$. Thus, we reject the hypothesis at 5\% level of significance. We claim that the type of failure depends on the mounting position.

\section*{Exercise 7.3}
\begin{table}[h]
    \centering
    \begin{tabular}{c|ccccc|c}
        & 1 & 2 & 3 & 4 & 5 &\\\hline
        Male & 50 &47 & 103 & 76 & 24 & 300\\
        Female & 21 & 27 & 50 & 35 & 17 & 150\\\hline
        & 71 & 74 & 153 & 111 & 41 & 450\\
    \end{tabular}
\end{table}
We assume that the increase in the salary is independent od the workers' gender, saying that
\spl{
    H_0:\ p_{ij}=p_{i\cdot}p_{\cdot j}
}

Since $E_{ij}=\frac{n_{i\cdot}n_{\cdot j}}{n}$, then
\spl{
    E_{11}&=47.33,\quad E_{12}=49.33,\quad E_{13}=102,\quad E_{14}=74,\quad E_{15}=27.33\\
    E_{21}&=23.67,\quad E_{22}=24.67,\quad E_{23}=51,\quad E_{24}=37,\quad E_{25}=13.67\\
}

\spl{
    X_{(2-1)(5-1)}^2=\sum_{i=1}^r\sum_{j=1}^c\frac{(O_{ij}-E_{ij})^2}{E_{ij}}=2.19.
}

Since the statistic follows 4 degrees of freedom chi-squared distribution, we compare the value with $\chi_{0.05,4}^2=9.4877$. We find that $X_4^2<\chi_{0.05,3}^2$. Thus, we support the hypothesis at 5\% level of significance. We claim that increase in salary is independent of the gender.

\section*{Exercise 7.4}
Using the Helmert transformation $\textbf{Y}\rightarrow\textbf{D}$, we rewrite $SSE_{pe}$
\spl{
    SSE_{pe}&=\frac{1}{\sigma^2}\sum_{i=1}^k\sum_{j=1}^{n_i}(Y_{ij}-\overline{Y_{ij}})^2\\
    &=\frac{1}{\sigma^2}\sum_{i=1}^k\bigg[\sum_{j=1}^{n_i}Y_{ij}^2-n_i\overline{Y_{ij}}^2\bigg]\\
    &=\frac{1}{\sigma^2}\sum_{i=1}^k\bigg[\sum_{j=1}^{n_i}D_{ij}^2-D_{i1}^2\bigg]\\
    &=\frac{1}{\sigma^2}\sum_{i=1}^k\bigg[\sum_{j=2}^{n_i}D_{ij}^2\bigg]\\
    &=\frac{1}{\sigma^2}\bigg[\sum_{i=1}^nD_i^2-\sum_{i=1}^kD_{i1}^2\bigg]\\
    &=\sum_{i=1}^n\frac{D_i^2}{\sigma^2}-\sum_{i=1}^k\frac{D_{i1}^2}{\sigma^2},
}
which is the sum of square of $(n-k)$ normally distributed variables. Hence, it follows $(n-k)$ degrees of freedom chi-squared distribution.

\section*{Exercise 7.5}
Consider $\cov(\overline{Y},\hat{\beta}_1)$, we obtain
\spl{
    \hat{\beta}_1&=B_1=\frac{S_{xy}}{S_{xx}}\\
    \cov(\overline{Y},\hat{\beta}_1)&=E[\overline{Y}\hat{\beta}_1]-E[\overline{Y}]E[B_1]\\
    &=E\bigg[\frac{\sum_{i=1}^n(x_i-\bar{x})Y_i\overline{Y}}{\sum_{i=1}^n(x_i-\bar{x})^2}\bigg]-(\beta_0+\beta_1\bar{x})\beta_1\\
    &=\frac{\sum_{i=1}^n(x_i-\bar{x})E[Y_i\overline{Y}]}{\sum_{i=1}^n(x_i-\bar{x})^2}-(\beta_0+\beta_1\bar{x})\beta_1\\
    &=\frac{\sum_{i=1}^n(x_i-\bar{x})(\beta_0+\beta_1 x_i)(\beta_0+\beta_1\bar{x})}{\sum_{i=1}^n(x_i-\bar{x})^2}-(\beta_0+\beta_1\bar{x})\beta_1\\
    &=0
}

Consider $\cov(\hat{\beta_0},\hat{\beta_1})$, we obtain
\spl{
    \cov(\hat{\beta_0},\hat{\beta_1})&=E[B_0B_1]-E[B_0]E[B_1]\\
    &=E[(\overline{Y}-B_1\bar{x})B_1]-\beta_0\beta_1\\
    &=E[B_1\overline{Y}-B_1^2\bar{x}]-\beta_0\beta_1\\
    &=E[B_1\overline{Y}]-E[B_1^2\bar{x}]-\beta_0\beta_1\\
    &=(\beta_0+\beta_1\bar{x})\beta_1-\bar{x}E[B_1^2]-\beta_0\beta_1\\
    &=\bar{x}(\beta_1^2-E[B_1^2])\\
    &=-\bar{x}(E\bigg[(\frac{S_{xy}}{S_{xx}})^2\bigg]-E\bigg[\frac{S_{xy}}{S_{xx}}\bigg]^2)\\
    &=-\bar{x}\var(B_1)\\
    &=-\bar{x}\frac{\sigma^2}{S_{xx}}\\
    &=-\frac{\bar{x}}{S_{xx}}\sigma^2.
}

\section*{Exercise 7.6}
\enum{
\item
\spl{
    B_1&=\frac{S_{xy}}{S_{xx}}=184.6\\
    B_0&=\overline{Y}-B_1\bar{x}=-2150
}
\item
\spl{
    S^2=\hat{\sigma}^2=\frac{S_{yy}-B_1S_{xy}}{n-2}=1.15\e{5}.
}
\item
For a 100(1-0.1)\% confidence interval,
\spl{
    B_1\pm t_{0.1/2,n-2}\frac{S}{\sqrt{S_{xx}}}&=184.6\pm1.68\cdot\frac{339.2185}{\sqrt{828.2412}}=184.6\pm19.8.\\
    B_0\pm t_{0.1/2,n-2}\frac{S\sqrt{\sum x_i^2}}{\sqrt{nS_{xx}}}&=-2150\pm1.68\cdot\frac{339.2185\cdot182.8296}{\sqrt{42\cdot828.2412}}=-2150\pm560.\\
}
\item
\spl{
    &H_0:\ \text{the linear regression is appropriate}\\
    &H_1:\ \text{the linear regression is not appropriate}
}
\spl{
    SSE_{pe}&=\sum_{i=1}^k\sum_{j=1}^{n_i}(Y_{ij}-\overline{Y}_i)^2=109500.\\
    SSE_{lf}&=SSE-SSE_{pe}=4.49\e{6}.
}
Hence,
\spl{
    F_{37-2,42-37}=\frac{4.49\e{6}/(37-2)}{109500/(42-37)}=5.8621
}

Since $f_{0.05,35,5}=4.4775<F_{35,5}$, then we claim that the linear regression model is not appropriate at 5\% level of significance.

\item
\spl{
    R^2=\frac{S_{yy}-SSE}{S_{yy}}=0.8597.
}
The coefficient of determination is the proportion in $S_{yy}$ that is determined by $X$. The larger $R^2$ is, the more $Y$ are determined by $X$.

\item
\begin{figure}[H]
    \centering
    \includegraphics[height=9cm]{images/1}
    \caption{Residuals vs. Density}
\end{figure}
The assumption of constant variance is unreliable because the is irregular.
}

\section*{Exercise 7.7}
\enum{
\item
\begin{figure}[H]
    \centering
    \includegraphics[height=9cm]{images/2}
    \caption{Linear regression model}
\end{figure}

\item
\spl{
    R^2=\frac{S_{yy}-SSE}{S_{yy}}=0.9998.
}
Hence,
\spl{
    \frac{R\sqrt{n-2}}{\sqrt{1-R^2}}=191.994>t_{0.025,12}=2.18.
}
It implies that our linear regression model is appropriate.

\item
\spl{
    &H_0:\ \text{the linear regression is appropriate}\\
    &H_1:\ \text{the linear regression is not appropriate}
}
\spl{
    SSE_{pe}&=\sum_{i=1}^k\sum_{j=1}^{n_i}(L_{ij}-\overline{L}_i)^2=0.0322.\\
    SSE_{lf}&=SSE-SSE_{pe}=0.0398547-0.0322=0.00765.
}
Hence,
\spl{
    F_{8-2,14-8}=\frac{0.00765/(8-2)}{0.0322/(14-8)}=0.2376.
}

Since $f_{0.05,6,6}=4.2839>F_{6,6}$, then we claim that the linear regression model is appropriate at 5\% level of significance.
}

\section*{Exercise 7.8}
\spl{
    \textbf{LHS}-\textbf{RHS}&=\frac{S_{xy}}{S\sqrt{S_{xx}}}-\frac{\sqrt{n-2}S_{xy}/\sqrt{S_{xx}S_{yy}}}{\sqrt{1-S_{xy}^2/S_{xx}S_{yy}}}\\
    &=\frac{S_{xy}}{S\sqrt{S_{xx}}}-\frac{\sqrt{n-2}S_{xy}}{\sqrt{S_{xx}S_{yy}-S_{xy}^2}}\\
    &=\frac{S_{xy}}{\sqrt{(S_{xx}S_{yy}-S_{xy}^2)/(n-2)}}-\frac{\sqrt{n-2}S_{xy}}{\sqrt{S_{xx}S_{yy}-S_{xy}^2}}\\
    &=\frac{\sqrt{n-2}S_{xy}}{\sqrt{S_{xx}S_{yy}-S_{xy}^2}}-\frac{\sqrt{n-2}S_{xy}}{\sqrt{S_{xx}S_{yy}-S_{xy}^2}}\\
    &=0.\\
}


\section*{Appendix: Curve fitting}
In order to plot the evolution of both Lift and Drag for each phase, the computated velocity - solved from each respective ODE system - has been fitted from the resultant set of data points into a curve.\\
For this, the native \texttt{polyfit} and \texttt{poly2sym} \textsc{matlab} functions have ben employed.

To correctly fit a set of points into a curve and avoid overfitting the polynomial (thus dealing with excessive oscillations and Runge's phenomemenon among others), the lienar Least Squares Method (LLS) has been used. The following plots show the square root sum and the norm of the squared regression value for each phase's velocity fit.

\begin{center}
	\includegraphics[width=0.45\linewidth]{../matlab/1/1reg.jpg}
	\includegraphics[width=0.45\linewidth]{../matlab/1/1fit.jpg}
	\vspace{0.5cm}
	\captionof{figure}{Lift and drag on the cruise phase. Own elaboration.}
	\label{fig:1reg}
	\captionof{figure}{Lift and drag on the cruise phase. Own elaboration.}\vspace{0.25cm}
	\label{fig:1fit}
\end{center}

\begin{center}
	\includegraphics[width=0.45\linewidth]{../matlab/2reg.jpg}
	\includegraphics[width=0.45\linewidth]{../matlab/2fit.jpg}
	\vspace{0.5cm}
	\captionof{figure}{Lift and drag on the half loop. Own elaboration.}
	\label{fig:2reg}
	\captionof{figure}{Lift and drag on the half loop. Own elaboration.}\vspace{0.25cm}
	\label{fig:2fit}
\end{center}

\begin{center}
	\includegraphics[width=0.45\linewidth]{../matlab/3reg.jpg}
	\includegraphics[width=0.45\linewidth]{../matlab/3fit.jpg}
	\vspace{0.5cm}
	\captionof{figure}{Lift and drag on the half loop. Own elaboration.}
	\label{fig:3reg}
	\captionof{figure}{Lift and drag on the half loop. Own elaboration.}\vspace{0.25cm}
	\label{fig:3fit}
\end{center}


Implements the SMT compliant \emph{Simplex} method presented in \cite{DM06}.
Hence, this module can decide the consistency of any conjunction
consisting only of linear real arithmetic constraints. Furthermore,
it might also find the consistency of a conjunction of constraints
even if they are not all linear and calls a backend after removing
some redundant linear constraints, if the linear constraints are satisfiable
and the found solution does not satisfy the non-linear constraints. Note that the
\lraModuleClass might need to communicate a lemma/tautology to a preceding
\satModuleClass, if it receives a constraint with the relation symbol $\neq$
 and the strategy needs for this reason to define a \satModuleClass at any
 position before an \lraModuleClass.

\paragraph{Integer arithmetic} In order to find integer solutions, this
module applies, depending on which settings are used, branch-and-bound,
the construction of Gomory cuts and the generation of cuts from
proofs~\cite{DilligDA11}. It is also supported to combine these approaches. Note that
for all of them the \lraModuleClass needs to communicate a lemma/tautology to a
preceding \satModuleClass and the strategy needs for this reason to define a
\satModuleClass at any position before an \lraModuleClass.

\paragraph{Efficiency} The worst case complexity of the implemented
approach is exponential in the number of variables occurring in the
problem to solve. However, in practice, it performs much faster, and
the worst case applies only on very artificial examples. This module
outperforms any module implementing a method that is designed for
solving formulas with non-linear constraints. If the received formula
contains integer valued variables, the aforementioned methods might not
terminate.


%!TEX root = ../main.tex

\chapter{Notation}
\label{appendix:notation}
\vspace{-7mm}

This appendix contains a summary of the notation used in this book.

\softsection{Math notation}

{ \small
\noindent
\begin{tabularx}{\textwidth}{@{}rlp{5.9cm}@{}}
\toprule
Expression  	&	Read as  	& Used to denote			\\
\midrule
$a,b,x,y$
	&
	& variables \\
$=$
	& is equal to
	& expressions that have the same value \\ % have the same value	\\
$\eqdef$
	& is defined as
	& a new variable definition  \\
$a+b$
	& $a$ plus $b$
	& the combined lengths of $a$ and $b$ \\
$a-b$
	& $a$ minus $b$
	& the difference in lengths between $a$ and $b$ \\
$a\times b = ab$
	& $a$ times $b$
	& the area of a rectangle   \\
$a^2= aa$
	& $a$ squared
	& the area of a square of side length $a$ \\
$a^3= aaa$
	& $a$ cubed
	& the volume of a cube of side length $a$ \\
$a^n$
	& $a$ to the $n$
	%raised to the $n$\textsuperscript{th} power
	& $a$ multiplied by itself $n$ times 		\\
$\sqrt{a} = a^{\frac{1}{2}}$
	& square root of $a$
	& the side length of a square of area $a$ \\
$\sqrt[3]{a}= a^{\frac{1}{3}}$
	& cube root of $a$
	& the side length of a cube with volume $a$  \\
$a/b = \frac{a}{b}$
	& $a$ divided by $b$
	& $a$ parts of a whole split into $b$ parts \\[0.8mm]
$a^{-1}= \frac{1}{a}$
	& one over $a$
	& division by $a$ 					\\[2mm]
$f(x)$
	& $f$ of $x$
	& the function $f$ applied to input $x$ 	\\
$f^{-1}$
	& $f$ inverse
	& the inverse function of $f(x)$   \\
$f \circ g$
	& $f$ compose $g$
	& function composition; $f \circ g(x) = f(g(x))$   \\[2mm]
$e^x$
	& $e$ to the $x$
	& the exponential function base $e$ \\
$\ln(x)$
	& natural log of $x$
	& the logarithm base $e$ 				\\
$a^x$
	& $a$ to the $x$
	& the exponential function base $a$ \\
$\log_a(x)$
	& log base $a$ of $x$
	& the logarithm base $a$ 				\\[2mm]
$\theta,\phi$
	& \emph{theta}, \emph{phi}
	& angles 					\\
$\sin,\cos,\tan$
	& sin, cos, tan
	& trigonometric ratios 			\\
%\; \\
$\%$
	& percent
	& proportions of a total; $a\%=\frac{a}{100}$ 		\\
\bottomrule
\end{tabularx}
}%


%begin-include

\section{Propositional logic. General definitions}

\begin{para}[A note on circularity]
From now on, we will be working with propositional logic and predicate logic as object theories.
This unavoidably leads one to wonder what kind of reasoning they should be able to use in their metatheory.
I mean, it does not seem legit to use propositional logic in order to study propositional logic, right?

Turns out we can safely do it.
What we will be studying is not propositional logic itself, but a formalisation of propositional logic.
It should be out of question to any rational being that propositional logic is perfectly valid (and, thus, that there is no harm in using it).
What will not be obvious, however, is that the formalisation of propositional logic that we are about to present is correct and faithfully represents it.
\end{para}

\begin{definition}
The formal system $\mathsf{P}$ of propositional logic is defined by the tuple $(L_P,\Xi_P,R_P)$ where $L_P$ is the language defined in \ref{lp}, the set of axioms $\Xi_P$ consists of all the formulas of the form
\begin{axioms}[P]
\item \label{axp1} $A\limplies (B \limplies A)$,
\item \label{axp2} $(A\limplies(B\limplies C))\limplies ((A\limplies B)\limplies (A\limplies C))$,
\item \label{axp3} $(\lnot A \limplies \lnot B) \limplies (B\limplies A)$,
\end{axioms}
for $A,B,C\in F_P$, and $R_P$ has a single rule of inference:
\[ \{A,(A\limplies B)\} \vdash_{\mathsf{P}} B\]
for all $A,B\in F_P$. This rule is known as \emph{modus ponens}, MP for short.
\end{definition}

\begin{para}
As you may have already noticed, axioms such as \ref{axp1}, \ref{axp2} and \ref{axp3} are not axioms per se. Instead, they are ``rules'' for constructing the axioms; that is why they are called \emph{axiom schemata} instead of axioms. The axioms that are constructed using a particular axiom schema are said to be \emph{instances} of the schema. For example, the axiom $(p_1\limplies p_2)\limplies p_1$ is an instance of the axiom schema \ref{axp1}.
\end{para}

\begin{definition}
An interpretation of $L_P$ based on the semantics of propositional logic is a function $i : T_P \longrightarrow \{0,1\}$. Each interpretation $i$ induces a \emph{valuation} function $v_i: F_P \longrightarrow \{0,1\}$  verifying the following semantic rules:
\begin{enumerate}
\item The function $v_i$ takes the same values as $i$ on the set of propositional variables $T_P \subseteq F_P$.
\item If $A\in F_P$, then $v_i(A) \neq v_i(\lnot A)$.
\item If $A,B\in F_P$, then $v_i(A\limplies B) = 0$ if and only if $v_i(A) = 1$ and $v_i(B) = 0$.
\end{enumerate}
Given any propositional form $A$, we say that $A$ is true in $i$ if $v_i(A) = 1$. If, instead, $v_i(A) = 0$, we say that $A$ is false.

Valid propositional forms --- that is, valid formulas in the context of propositional logic --- are referred to as \emph{tautologies}.
Propositional forms that are false under any interpretation of propositional logic are said to be \emph{contradictions}.
\end{definition}

\begin{para}
It should be obvious that an interpretation is nothing more than an assignment of truth values. The interpretation function $i$ defined for the propositional symbols represents the assignment and then the ``truth value'' of the remaining formulas, given by their image under $v_i$, is obtained inductively by applying the semantic rules that define the connectives $\lnot$ and $\limplies$.

It should be obvious, according to the semantic rules that we have used, that getting the value of $v_i(A)$ for a propositional form $A$ and an interpretation $i$ is the same as getting the truth value of $A$ under the assignment of truth values induced by $i$. Thus, all the informal methods that can used to decide the truth or falsity of a propositional forms can be safely used to compute valuations.

Notice, by the way, how we have redefined tautologies. The underlying meaning, however, is the same.
\end{para}

\begin{definition}
Let $L = (\Sigma,T,F, \Lambda)$ be a language and $\mathsf{FS} = (L,\Xi,R)$ be a formal system containing all instances of axiom schemata \ref{axp1}, \ref{axp2} and \ref{axp3} among its axioms.
\begin{itemize}
\item If there exists no formula $A \in F$ such that $\vdash_\mathsf{FS} A $ and $\vdash_\mathsf{FS} \lnot A$, the system $\mathsf{FS}$ is said to be \emph{consistent}.
\item If, for every sentence $A\in \Lambda$, we have $\vdash_\mathsf{FS} A$ or $\vdash \lnot A$, we say that $\mathsf{FS}$ is \emph{syntactically complete} or, for short, \emph{complete}.
\item The system $\mathsf{FS}$ is said to be \emph{semantically complete} if every valid formula is a theorem in $\mathsf{FS}$. Conversely, if every theorem is a valid formula, $\mathsf{FS}$ is said to be \emph{sound}.
\end{itemize}
Let $A$ be an axiom and let $\mathsf{FS}^*$ be the formal system obtained by removing the axiom $A$ from $\mathsf{FS}$. If neither $A$ nor $\lnot A$ are theorems of $\mathsf{FS}^*$, $A$ is said to be an \emph{independent axiom}. Ideally, we want all axioms to be independent in order to avoid redundancy.
\end{definition}

\begin{example} \label{dedaa}
We will prove that $\vdash A \limplies A$ for any formula $A$. We will write down all the steps of the deduction together with their justification.

\begin{deduction}{dtp}
\dstep[a1]{\ref{axp1}}{A\limplies([A\limplies A]\limplies A),}
\dstep[a2]{\ref{axp2}}{(A\limplies([A\limplies A]\limplies A))\limplies( (A\limplies[A\limplies A])\limplies(A\limplies A)),}
\dstep[a3]{MP on \dref{a1}, \dref{a2}}{( (A\limplies[A\limplies A])\limplies(A\limplies A)),}
\dstep[a4]{\ref{axp1}}{A\limplies(A\limplies A),}
\dstep{MP on \dref{a4}, \dref{a3}}{A\limplies A.}
\end{deduction}
\end{example}

\begin{theorem}[Deduction theorem in $\mathsf{P}$]
\label{dedthmprop}
For any collection of propositional forms $\Gamma\subseteq F_P$ and any formulas $A,B\in F_P$, one can deduce $\Gamma\cup\{A\}\vdash_{\mathsf{P}} B$ if and only if $\Gamma \vdash_\mathsf{P} (A\limplies B)$.
\label{}
\end{theorem}

\begin{proof}

We will first show that $\Gamma \cup \{A\} \vdash B$ implies $\Gamma \vdash (A\limplies B)$ following a proof by induction on the length $n$ of the deduction of $\Gamma\cup\{A\}\vdash B$.
If $n = 1$, there are only three possibilities: either $B = A$, $B\in \Gamma$, or $B\in \Xi_P$.

According to \ref{dedaa}, any formula $A$ verifies $\vdash (A\limplies A)$, so, in particular, $\Gamma \vdash (A\limplies A)$.
Thus, if $B = A$, it is obvious that $\Gamma\cup\{A\}\vdash A$ implies $\Gamma \vdash (A\limplies A)$.

If $B\in \Gamma$ or $B\in \Xi_P$, $\Gamma \vdash (A\limplies B)$ follows from a trivial application of MP to $B$ and \ref{axp1}.\footnote{Be aware that, when applying \ref{axp1}, ``$A$'' in \ref{axp1} should be substituted by ``$B$'' and ``$B$'' by ``$A$.''}

Let us now assume the result to hold for deductions of an arbitrary length $n$ and prove it for those of length $n+1$.
If the deduction is of length $n+1$, the formula $B$ may be, as in the base case, an axiom, equal to $A$, or an element of $\Gamma$.
But it may also have been obtained from an application of MP on two previous elements of the deduction.
In this case, those elements have deductions of length smaller than $n+1$ and, therefore, they satisfy the result by the inductive hypothesis. Let us then assume that $B$ has been obtained from an application of MP to two formulas of the form $X$ and $X\limplies B$ verifying $\Gamma \vdash (A\limplies X)$ and $\Gamma \vdash (A\limplies(X \limplies B))$. Under these conditions, we can make the following deduction from $\Gamma$.

\begin{deduction}{thdedprop1}
\dstep[h1]{By hypothesis, can be deduced from $\Gamma$}{A\limplies X,}
\dstep[h2]{By hypothesis, can be deduced from $\Gamma$}{A\limplies (X\limplies B),}
\dstep[a1]{\ref{axp1}}{(A \limplies (X\limplies B))\limplies ( (A\limplies X) \limplies (A\limplies B) ),}
\dstep[c1]{MP on \dref{h2}, \dref{a1}}{(A\limplies X)\limplies (A\limplies B),}
\dstep[c2]{MP on \dref{h1}, \dref{c1}}{A\limplies B.}
\end{deduction}

We shall now prove the converse: assuming that $\Gamma \vdash (A\limplies B)$, we will show that $\Gamma\cup \{A\} \vdash B$.
This is easy. Keeping in mind that $\Gamma \vdash (A\limplies B)$ and, therefore, that $\Gamma\cup\{A\}\vdash (A\limplies B)$, we can write an explicit deduction of $\Gamma\cup\{A\}\vdash B$:
\begin{deduction}{thdedprop2}
\dstep[h1]{By hypothesis, can be deduced from $\Gamma\cup\{A\}$}{A\limplies B,}
\dstep[h2]{Belongs to $\Gamma\cup\{A\}$}{A,}
\dstep{MP on \dref{h2}, \dref{h1}}{B.}
\end{deduction}
This concludes the proof.
\end{proof}

\begin{para}
\label{remarkdedp}
The deduction theorem is, perhaps, one of the most significant results in this section, for it explains the confusion that the implication connective $\limplies$ generates.

The formula $A\limplies B$ is a formula in the object language, full stop.
What we have shown is that the meta-theoretic statement $\vdash (A\limplies B)$ meaning ``$(A\limplies B)$ is a theorem in $\mathsf{P}$'' is equivalent to the meta-theoretic statement $A\vdash B$ meaning ``$B$ can be deduced from $A$''.

We will later introduce the first-order version of this metatheorem, which will shed even more light on this matter.
\end{para}

\begin{theorem}
\label{pprop}
The following metatheorems about propositional logic are true:
\begin{statements}
\item \label{pprop:sound} If $\Gamma \subseteq F_P$ and $X\in F_P$ are such that $\Gamma \vdash X$, then $\Gamma\vDash X$. In particular, if a formula $X\in F$ is a theorem in $\mathsf{P}$, it is a tautology; which is to say that $\mathsf{P}$ is sound.
\item The formal system $\mathsf{P}$ is consistent.
\item Every tautology is a theorem in $\mathsf{P}$. In other words, $\mathsf{P}$ is semantically complete.
\end{statements}
These results show beyond any doubt that $\mathsf{P}$ is a correct formalisation of propositional logic.
\end{theorem}

\begin{proof}
\begin{parlist}
\item We proceed by induction on the length $n$ of the deduction.
If $n = 1$, then either $X \in \Gamma$ (in which case the result is obvious) or $X$ is an axiom of $\mathsf{P}$.
In order for the result to hold, we need to see that every axiom of $\mathsf{P}$ is true under any interpretation, i.e., that it is a tautology.

We shall first analyse \ref{axp1}.
I think we can both agree that, given any $A,B\in F$, the formula $A\limplies (B\limplies A)$ either is or is not a tautology.
Thus, we just need to show that it is impossible for $A\limplies (B\limplies A)$ not to be a tautology.
Were that formula not a tautology, there would necessarily exist an interpretation $i$ under which it would be false.
Nonetheless, according to the semantic rules of propositional logic, that would mean that $v_i(A) = 1$ yet $v_i(B\limplies A) = 0$.
But, by those same rules, $v_i(B\limplies A) = 0$ can only mean that $v_i(B) = 1$ and $v_i(A) = 0$.\
Consequently, $A\limplies (B\limplies A)$ can only be false under an interpretation $i$ verifying both $v_i(A) = 0$ and $v_i(A) = 1$.
As that is impossible, we can safely conclude that all the axioms defined by the schema \ref{axp1} are tautologies.

We can proceed in a similar fashion regarding \ref{axp2}.
Let $A,B,C\in F_P$ be formulas.
If an interpretation $i$ is such that
\[ v_i( \underbrace{(A\limplies(B\limplies C))}_{D_1} \limplies \overbrace{((A\limplies B) \limplies (A\limplies C))}^{D_2}) = 0,\]
then we necessarily have $v_i(D_1) = 1$ and $v_i(D_2) = 0$.
Having $v_i(D_2) = 0$ implies that $v_i(A\limplies C) = 0$ and $v_i(A\limplies B) = 1$, which can only mean that $v_i(A) = 1$, that $v_i(C) = 0$ and that $v_i(B) = 1$.
Simultaneously, $v_i(D_1) = 1$ with $v_i(A) = 1$ leads to $v_i(B\limplies C) = 1$, which --- with $v_i(C) = 0$ --- could only be the case if $v_i(B) = 0$.
Having reached a contradiction, we can conclude that all the axioms defined by \ref{axp2} need be true under any interpretation and, therefore, that they are all tautologies.

Finally, let us tackle \ref{axp3}. Given any two formulas $A,B\in F_P$, if we assume an interpretation $i$ to exist such that
\[ v_i\left( (\lnot A \limplies \lnot B) \limplies (B \limplies A) \right) = 0,\]
it will need to verify $v_i(B \limplies A) = 0$ and $v_i(\lnot A\limplies \lnot B) = 1$.
The former of these conditions implies that $v_i(A) = 0$ and $v_i(B) = 1$, which --- according to the semantic rules --- is equivalent to having $v_i(\lnot A) = 1$ and $v_i(\lnot B) = 0$. If $v_i(\lnot A\limplies \lnot B) = 1$ and, as we have just shown, $v_i(\lnot A) = 1$, then we necessarily have $v_i(\lnot B) = 1$, which is, as expected, a contradiction.
This proves that all the axioms defined by \ref{axp3} are tautologies.

Now that we have completed the base case, let us assume the result to hold for deductions of length equal to or smaller than $n$, and we will prove it for those of length $n+1$.
If the deduction has length $n+1$, $X$ may be an element of $\Gamma$ or an axiom as in the base case, or it may have been obtained from an application of MP on two previous elements of the deduction that, therefore, verify the result according to the inductive hypothesis.
Thus, we need to show that, given any two formulas of the form $A$ and $A\limplies B$, if they are true in any particular interpretation $i$, so is $B$.

If $v_i(A) = 1$ and $v_i(A\limplies B) = 1$, it is obvious that we need to have $v_i(B) = 0$. Indeed, if $v_i(B) = 0$ and $v_i(A) = 1$, that would yield $v_i(A\limplies B) = 0$.
Thus, we have shown that, for any interpretation $i$ in which any two formulas $A$ and $A\limplies B$ are true, $B$ is true too.

\item Let $A$ be a theorem in $\mathsf{P}$.
By \ref{pprop:sound}, $A$ need be a tautology and, therefore, for an interpretation $i$, we will have $v_i(A) = 1$.
According to the semantic rules, this means that, under any interpretation $i$, $v_i(\lnot A) = 0$.
Consequently, $\lnot A$ is not a tautology and since, by \ref{pprop:sound}, being a tautology is a necessary condition for any formula to be a theorem in $\mathsf{P}$, $\lnot A$ cannot be a theorem.

This shows that no formula $A$ can verify both $\vdash_{\mathsf{P}} A$ and $\vdash_{\mathsf{P}} \lnot A$, and, therefore, that $\mathsf{P}$ is consistent.

\item The details of this proof are pretty tedious to go through. If you feel motivated enough to do it, feel free to visit \ref[appendix]{psemcom} in the appendices.
\end{parlist}
\end{proof}

\begin{lemma}[Conjunction introduction rule]
Let $\Gamma$ be a collection of propositional forms and let $A$ and $B$ be two arbitrary propositional forms. One can deduce $\Gamma\vdash_\mathsf{P} (A\land B)$ if and only if one can deduce both $\Gamma \vdash_{\mathsf{P}}A$ and $\Gamma \vdash_{\mathsf{P}}B$.
\label{cinr}
\end{lemma}

\begin{proof}
If $\Gamma \vdash (A\land B)$, then, since $(A\land B) \limplies A$ and $(A\land B)\limplies B$ are both tautologies --- and, therefore, theorems in $\mathsf{P}$ --- it follows by a direct application of the MP rule that $\Gamma \vdash A$ and $\Gamma \vdash B$.

Conversely, if $\Gamma \vdash A$ and $\Gamma \vdash B$, we know $A\limplies (B\limplies (A\land B))$ to be another tautology. Two applications of MP yield $\Gamma \vdash (A\land B)$.
\end{proof}

\begin{proposition}
\label{piff}
Given any propositional forms $A$ and $B$, $\Gamma \vdash_{\mathsf{P}} (A \liff B)$ if and only if $\Gamma  \vdash_\mathsf{P} (A\limplies B)$ and $\Gamma \vdash_\mathsf{P} (B\limplies A)$.

In particular, if $\Gamma = \emptyset$, $A\liff B$ is a theorem of $\mathsf{P}$ if and only if so are $A\limplies B$ and $B\limplies A$.
\end{proposition}

\begin{proof}
If we have both $\Gamma\vdash (A\limplies B)$ and $\Gamma \vdash (B\limplies A)$, by \ref{cinr}, we know that $\Gamma \vdash ( (A\limplies B) \land (B\limplies A))$, which is, according to our definition of $\liff$, the same as $\Gamma \vdash (A\liff B)$.
The converse is also a direct consequence of \ref{cinr}.
\end{proof}

\begin{lemma}
Let $A$, $X$ and $Y$ be propositional forms. If $X\liff Y$ is a tautology and $A'$ denotes the propositional form resulting from replacing each appearance of $X$ in $A$ by $Y$, then $A\liff A'$ is a tautology and, therefore, a theorem in $\mathsf{P}$.
\label{replacetautology}
\end{lemma}

\begin{proof}
Let $i$ be any interpretation.
It suffices to notice that, as $X \liff Y$ is a tautology, we always have $v_i(X) = v_i(Y)$.
Therefore, as $A'$ is obtained by replacing every occurrence of $X$ by an occurrence of $Y$, we necessarily have $v_i(A) = v_i(A')$.
Consequently, $v_i(A\liff A') = 1$.
\end{proof}

\begin{para}
\label{lpinformal}
It is very easy to see that the following formulas are tautologies for any propositional forms $A$, $B$ and $C$:
\begin{statements}
\item $(A\liff B) \liff (B\liff A)$,
\item $(A\land B) \liff (B\land A)$,
\item $((A\land B) \land C) \liff (A\land (B \land C))$,
\item $((A\lor B) \lor C) \liff (A\lor (B \lor C))$,
\end{statements}
This, together with \ref{replacetautology}, should be enough to convince you that the conventions we introduced in \ref[prel]{hierarchy} can be safely used when working with $L_P$ in $\mathsf{P}$.
In particular, this shows that there is no harm in swapping formulas around the $\lor$, $\land$ and $\liff$ connectives.
\end{para}

\begin{proposition}
\label{impsystemp}
Let $A$, $B$, $A_1$, $A_2$, $B_1$ and $B_2$ be propositional forms and $\Gamma$ a set of propositional forms.
\begin{statements}
\item One can deduce $\Gamma \vdash_\mathsf{P} (A \limplies (B_1\land B_2))$ if and only if one can deduce both $\Gamma \vdash_\mathsf{P} (A\limplies B_1)$ and $\Gamma \vdash_\mathsf{P} (A\limplies B_2)$. In particular, if $\Gamma = \emptyset$, $A\limplies (B_1\land B_2)$ is a theorem of $\mathsf{P}$ if and only if so are $A\limplies B_1$ and $A \limplies B_2$.

\item One can deduce $\Gamma \vdash_\mathsf{P} ( (A_1\land A_2) \limplies B_1 )$ if and only if one can deduce $\Gamma \vdash_\mathsf{P} (A_1 \limplies (A_2 \limplies B))$ or $\Gamma \vdash_\mathsf{P} (A_2 \limplies (A_1 \limplies B)$. In particular, if $\Gamma = \emptyset$, $(A_1\land A_2) \limplies B$ is a theorem if and only if so are $A_1\limplies (A_2\limplies B)$ or $A_2 \limplies (A_1 \limplies B)$.
\end{statements}
\label{implesmani}
\end{proposition}

\begin{proof}
\begin{parlist}
\item Follows from a direct application of MP taking into account \ref{piff} and the fact that \[(A\limplies (B_1\land B_2)) \liff ((A\limplies B_1) \land (A\limplies B_2))\] is a tautology.
\item Follows from a direct application of MP taking \ref{piff} into account together with the fact that both
\begin{gather*}
((A_1 \land A_2)\limplies B) \liff (A_1 \limplies (A_2 \limplies B)),\\
((A_1 \land A_2)\limplies B) \liff (A_2 \limplies (A_1 \limplies B))
\end{gather*}
are tautologies.
\end{parlist}
\end{proof}

\begin{proposition}[Principle of explosion]
\label{pexpprop}
Anything can be deduced from a false premise: given any two propositional forms $A,B\in F_P$, we have $A,\lnot A \vdash B$.
\end{proposition}

\begin{proof}
It is easy to see that the formulas $A\limplies (A\lor B)$ and $\lnot A \limplies ( (A\lor B) \limplies B )$ are tautologies. We know $\mathsf{P}$ to be semantically complete and, therefore, we know those tautologies to be theorems of $\mathsf{P}$. The deduction of $B$ from $A,\lnot A$ is then very simple.
\begin{deduction}{dedpexpprop}
\dstep[h1]{Premise}{A,}
\dstep[h2]{Premise}{\lnot A,}
\dstep[t1]{Theorem}{A\limplies (A\lor B),}
\dstep[t2]{Theorem}{\lnot A \limplies ( (A\lor B) \limplies B),}
\dstep[d1]{MP on \dref{h1}, \dref{t1}}{A \lor B,}
\dstep[d2]{MP on \dref{h2}, \dref{t2}}{(A\lor B) \limplies B,}
\dstep{MP on \dref{d1}, \dref{d2}}{B.}
\end{deduction}
This completes the proof.
\end{proof}


\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{geometry}
\usepackage{mathtools}

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

\title{Sample LaTex Document}
\author{Tom Grubb}
\date{January 2021}

\begin{document}

\maketitle

\abstract{Abstract abstract abstract abstract abstract wow what a useful informative abstract.}

\section{Introduction}
This is a very basic LaTex document. It was created for UCSD's Math 157 class to highlight some of LaTex's functionality. The .tex file starts with a \emph{preamble}, which includes details on the title of this document, as well as several import statements. The result of compiling that .tex file is this pdf. This document was created online using Overleaf.

\section{A Theorem, a Proof, and the Align Environment}
In this section we will prove a basic fact about \textbf{natural numbers}. Look at how the phrase natural numbers is \emph{bolded} and how the word bolded is italicized; you can see how this was done in the source file.

\begin{theorem}
For an integer $n,$ $n\geq 1$, we have
$$
\sum_{k = 1}^{n} k = \frac{n(n+1)}{2}
$$
\end{theorem}

\begin{proof}
We induct on $n$. In the base case, $n=1$. In this case the sum on the left hand side has a single term equal to $1$ in it. The right hand side simplifies to
$$
\frac{1\cdot 2}{2} = 1.
$$
Thus the base case holds.

For the induction step, assume the theorem holds for some integer $n$. Then
$$
\sum_{k=1}^{n+1} = (n+1) + \sum_{k=1}^nk.
$$
By the induction hypothesis,
$$
\sum_{k=1}^{n}k = \frac{n(n+1)}{2},
$$
and thus
$$
\sum_{k=1}^{n+1} = (n+1)+ \frac{n(n+1)}{2}.
$$
Simplifying the right hand side gives
\begin{align*}
\sum_{k=1}^{n+1} &= \frac{2(n+1)+n(n+1)}{2} \\
&=\frac{(n+1)(n+2)}{2}.
\end{align*}
This finishes the proof of our theorem.
\end{proof}

In the next section we will explore other LaTex environments.

\section{LaTex Lists}
In LaTex you can make bulleted and numbered lists. A bulleted list uses the itemize environment:
\begin{itemize}
    \item This is the first entry in a bulleted list.
    \item This is the second entry in a bulleted list.
\end{itemize}
A numbered list uses the enumerate environment:
\begin{enumerate}
    \item This is the first entry in a numbered list.
    \item This is the second entry in a numbered list. It has a sublist in it!
    \begin{enumerate}
        \item This is a sublist within my numbered list! It uses a nested enumerate environment.
        \item Wow!
    \end{enumerate}
\end{enumerate}

\section{LaTex Tables}
There are two ways of making tables in LaTex. The tabular environment is for making \emph{text based tables}. Often you highlight a tabular environment using the \emph{center} environment:
\begin{center}
    \begin{tabular}{c|c}
    The columns are separated by ampersands & This is column 2 \\
    The rows are separated by two backslashes.  & This is row 2, column 2
\end{tabular}
\end{center}
You can add horizontal lines to the table using the hline command. Vertical lines are formed by adding pipes into the table metadata: \{ $\vert$ c $\vert$ c $\vert$\} means you have two columns which are \emph{centrally aligned} and have vertical lines in between each column:
\begin{center}
    \begin{tabular}{|c|c|}
    \hline
    The columns are separated by ampersands & This is column 2 \\
    \hline
    The rows are separated by two backslashes.  & This is row 2, column 2\\
    \hline
\end{tabular}
\end{center}
You could optionally change the alignment using l, c, or r in the table metadata:
\begin{center}
    \begin{tabular}{|l|c|r|}
    \hline
    Col 1& Col 2& Col3\\
    \hline
    Left aligned & Centrally aligned & Right aligned \\
    \hline

\end{tabular}
\end{center}

An array environment is similar to a tabular environment, but it is for math mode/numeric data. In particular, it should go between double dollar signs, or in an equation environment:
\begin{equation}
    \begin{array}{|c|c|}
    \hline
        \pi & \tau \\
        \hline
         3.14\dots&6.28\dots \\
         \hline
    \end{array}
\end{equation}
Note that the equation environment implicitly numbers the equations. You can change this by messing around with the settings if you wanted.

\section{Tikz}
If you want to get fancy with your files, you can use Tikz to create images/plots within your file. This is more advanced and will not be necessary for this class, but here are some examples that I have taken from Overleaf's documentation (available here: \url{https://www.overleaf.com/learn/latex/TikZ_package}):
\begin{center}
\begin{tikzpicture}

\draw (-2,0) -- (2,0);
\filldraw [gray] (0,0) circle (2pt);
\draw (-2,-2) .. controls (0,0) .. (2,-2);
\draw (-2,2) .. controls (-1,0) and (1,0) .. (2,2);

\end{tikzpicture}

\end{center}

\begin{center}
\begin{tikzpicture}[
roundnode/.style={circle, draw=green!60, fill=green!5, very thick, minimum size=7mm},
squarednode/.style={rectangle, draw=red!60, fill=red!5, very thick, minimum size=5mm},
]
%Nodes
\node[squarednode]      (maintopic)                              {2};
\node[roundnode]        (uppercircle)       [above of=maintopic] {1};
\node[squarednode]      (rightsquare)       [right of=maintopic] {3};
\node[roundnode]        (lowercircle)       [below of=maintopic] {4};

%Lines
\draw[->] (uppercircle.south) -- (maintopic.north);
\draw[->] (maintopic.east) -- (rightsquare.west);
\draw[->] (rightsquare.south) .. controls +(down:7mm) and +(right:7mm) .. (lowercircle.east);
\end{tikzpicture}
\end{center}
For more on TikZ, I recommend Google or Office Hours.
\section{Conclusion}
Hopefully this document helps! LaTex is very well documented online, so Googling is always a good way to get more information. But you can always reach out to course staff for a more in depth discussion of LaTex!

\end{document}


\documentclass{article}
\usepackage{bbold}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{commath}
\usepackage{bm}
\usepackage[makeroom]{cancel}

\begin{document}

\section{TCRen scoring}

\subsection{Deriving empirical contact scoring matrices}

Let $\tilde{n}_{ab}$ denote number of contacts between residues of amino acid $a$ of TCR CDR regions and $b$ of an epitope. We compute the symmetrized matrix $n_{ab} = \frac{1}{2} \left(\tilde{n}_{ab} + \tilde{n}_{ba}\right)$ and marginals $n_a = \sum_{b} n_{ab}$ and $n = \sum_a n_{a}$.

We define an observed-to-expected contact frequency matrix as

\begin{equation}
\phi_{ab} = n^{obs}_{ab} /  n^{exp}_{ab} = \frac{n_{ab} n}{n_a n _b}
\end{equation}

and use it to derive scores for amino acid pairs similar to BLOSUM matrix derivation where scores are calculated as $S_{ab} \sim \log \phi_{ab}$.

We decompose $\phi_{ab}$ into (empirical) baseline interaction score $S_{a}$ for a given amino acid defined as

\begin{equation}
S_{a} = \frac{1}{20} \sum_{b} \log \phi_{ab}
\end{equation}

and specific interaction score $S_{ab}$ defined based on the formula

\begin{equation}
\log \phi_{ab}= S_{ab} + S_{a} + S_{b}
\end{equation}

effectively decoupling pairwise interactions from raw amino acid frequencies in contacting regions. E.g. by using this correction we account for Glycine residues that are frequent in the central region of CDR3$\beta$ that is almost always close to an antigen in any TCR:pMHC complex.

In present study we compute a single scoring matrix based on CDR1,2,3 regions of both TCR$\alpha$ and $\beta$ chains.

\subsection{Scoring TCR:pMHC pairs}

We score each TCR:pMHC pair having residues $\left\{a_i\right\}$ of the TCR and $\left\{b_i\right\}$ of the antigen using by subtracting the non-specific binding score from the specific one:

\begin{equation}
S\left(\left\{a_i\right\},\left\{b_i\right\}\right)=\sum_{i,j} S_{a_{i}b_{j}} \delta_{ij} - \sum_{i} S_{a_{i}} - \sum_{j} S_{b_{j}}
\end{equation}

where $\delta_{ij} \in \left\{0, 1\right\}$ is $1$ for contacting residues and $0$ otherwise. We subtract baseline scores in order to account for intrinsic properties of amino acids to bind in a non-specific manner. As four flanking residues from both sides of CDR3 are involved in the $\Omega$-loop formation, are almost never involved in TCR:antigen contacts and are subject to strong bias from V/J segment choice, we would substitute $\left\{a_i\right\}$ by $\left\{a_i\right\} / \left\{a_{1..4}\right\} \cup \left\{a_{-4..-1}\right\}$ for CDR3 regions in our calculations.

\subsection{Physical interpretation of scoring}

(Experimental, not sure it should be included) The scoring can be decomposed into the following components

\begin{align}
\begin{split}
S\left(\left\{a_i\right\},\left\{b_i\right\}\right) &= \sum_{i,j} S_{a_{i}b_{j}} \delta_{ij} \\ &- \sum_{i} S_{a_{i}} \left(1 - \delta_i\right) - \sum_{j} S_{b_{j}} \left(1 - \delta_j\right) \\ &- \sum_{i} S_{a_{i}} \delta_i - \sum_{j} S_{b_{j}} \delta_j \\
 &= -\left(E_{bound} - E_{unbound} - E_{bound,nonspec}\right) \\
 &= -\left(\Delta E_{bound} - E_{bound,nonspec}\right) = -\Delta \Delta E
\end{split}
\end{align}

where $\delta_i = \max_{j} \delta_{ij}$ identifying a residue having at least one contact, assuming $E_{unbound,nonspec}=0$.

\end{document}


\section{Basic advance}
To change between the different ways of advancing the solution, change
the code in advance() between the godunov, molrk2 and molrk3 options.

MOLRK2 follows the same RK2 algorithm as CNS.
MOLRK3 follows the algorithm described in gottlieb, et al.
$$
u^(1) = u^n +  + \dt L(u^n)  \\
u^(2) = (3/4) u^n + (1/4) u^(1)  + (1/4) L(u^(1))
u^{n+1} = (1/3) u^n + (2/3) u^(2)  + (2/3) L(u(2))
$$

\subsection{Flux register factors}

Since
$$
u^{n+1} = (1/3) u^n + (2/3) u^(2)  + (2/3) \dt L(u(2))
$$

This means
$$
u^{n+1} = (1/3) u^n + (2/3)((3/4)(u^n) + (1/4)(u^1) + (1/4)\dt L(u^1))  + (2/3)( \dt L(u(2)))
$$

which, in turn, means
$$
u^{n+1} = (1/3) u^n + (2/3)((3/4)(u^n) + (1/4)(u^n + \dt L(u^n)) + (1/4)\dt L(u^1))  + (2/3)( \dt L(u^2))
$$

So the coefficient of $L(u^n) = (2/3)(1/4)\dt$, so I should set the
flux register coefficient for the first evaluation $c_n = (1/6)\dt$.
The coeffcient of $L(u^1) = (2/3)(1/4)\dt = 1/6 \dt$
The coeffcient of $L(u^2) = (2/3) \dt$.   So for the three evaluations
of the operator, the time step  that fluxes should see are $\dt/6,
dt/6, 2\dt/3$, respectively.

\section{Stuff I am not sure about}

\begin{itemize}
  \item I am not sure where to set the time levels  in the fill patch thing.
  \item I am not sure what time to use for time dependent
    vellocities.
\end{itemize}

\section{Basic Algorithm}

We start with cell averaged scalar $<\phi>$ and a pointwise velocity at faces.

\begin{itemize}
  \item Get pointwise $\phi$ because I will need this to get higher
    order gradient at faces.
$$
\phi = <\phi> -\frac{h^2}{24}(L(<\phi>)),
$$
   where $L$ is the standard second order Laplacian.
\item Get the average of the scalar over the faces .
$$
<\phi>_{i+1/2} =  \frac{7}{12}(<\phi>_i    + <\phi>_{i+1})
                -\frac{1}{12}(<\phi>_{i-1} + <\phi>_{i+2})
$$

\item Get the point values of the scalar on faces from the face
  average:
$$
\phi_{i+1/2} = <\phi>_{i+1/2} - \frac{1}{24} L^T(<phi>)_{i+1/2},
$$
where $L^T$ is the Laplacian that does not include terms normal to the
face (what McCorquodale refers to as the ``transverse Laplacian'').

\item Compute pointwise fluxes $F$ (including diffusion fluxes).
$$
F_{i+1/2} = u_{i+1/2} \phi_{i+1/2}  - nu G^x(phi)_{i+1/2}
$$
where the normal gradient $G^x$ is computed using fourth order finite
differences  of the pointwise cell-centered scalar $\phi$.
$$
G^x(\phi)_{i+1/2} = \frac{\partial \phi}{\partial x} + O(h^4)
= (1/h)(\phi_{i+1}-\phi_{i})
- (1/(4h))((\phi_{i+2} + \phi_i - 2\phi_{i+1}) - (\phi_{i+1} + \phi_{i-1} - 2\phi_{i}))
$$

\item Transform the pointwise fluxes $F$ into face-averaged fluxes $<F>$
$$
<F> = F - (1/24) L^T(F).
$$

Algorithm seems to work.  To fully test, I need to
\begin{itemize}
  \item Write MPI=based convergence script.
  \item Run tests (with and without AMR), record results.
  \item Write up document.
\end{itemize}
\end{itemize}


\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
$\tau \sim (\rho H R^2_p/\sigma)^{1/2}$

\section*{Charge}
We find that
\[q = k E_0 V_d^{2/3},\]
with $k=5.01 \times 10^{-11} \pm  2.85 \times 10^{-11}$ and $R^2 = 0.946$.
\\
\begin{eqnarray*}
q = k E_0 V_d^{2/3},
\end{eqnarray*}
with $k \approx 1.3 \times 10^{-10}$ (Griffiths, 1999).
\\
\[q = 4 \pi \epsilon_0 \beta E_0 R_d^2, \]
with $\beta \approx 2.63$, (Takamatsu \emph{et al.}, 1981).
\\
Surface potential $\varphi_s$ is related to characteristic electric field by
\[ E_0  = \frac{\varphi_s \kappa}{4 \pi \epsilon l}. \]

\section*{Parameter Estimation}
We can't directly measure $q$ experimentally, but we can estimate it by fitting the dynamical model to the data. Bayes' theorem:
\[\begin{array}{lll}
& \centering \mbox{prob}(X|D, I) & \mbox{posterior probability density function},\\
& \centering \mbox{prob}(D|X, I) & \mbox{likelihood function},\\
& \centering \mbox{prob}(X|I) &  \mbox{prior probability density function},\\
& \centering \mbox{prob}(D|I) &  \mbox{evidence}.
\end{array}
\]
The Maximum Likelihood Estimate of the model parameters is found by maximizing the probability
\[\mathcal{M} = \ln(\mathcal{L}) = \ln(\mbox{prob}(D|X, I)) = \mbox{const} - \frac{\chi^2}{2}.\]

\section*{Parameter Estimation}
Mathematically we state that we find the parameters $\mathbf{x}$ that solve the inverse problem $G(\mathbf{x}) = \mathbf{d}$, using a direct search method (\emph{Nelder-Mead}).
\[
\mbox{min} \hspace{2 mm} \chi^2 = \mbox{min} \hspace{2 mm} \sum^n_{i=1} \frac{\left({y_d(t)}_i - y_G(t, \mathbf{x})_i \right)^2}{y_G(t, \mathbf{x})_i}
\]
\begin{eqnarray*} \mbox{} \hspace{2 mm} \begin{split} \mathbf{x} = \left\{ \begin{array}{ll}      & q\\
		  &	V_d\\
          & \sigma
          \end{array} \right.
          \end{split} \hspace{2 mm} \mbox{subject to constraints} \hspace{2 mm} \begin{split}
          g = \left\{ \begin{array}{ll}
           V_d &\pm \hspace{2 mm} u_{exp}\\
      	   \sigma &\pm  \hspace{2 mm} u_{exp}\\
      	   y_0 &\pm \hspace{2 mm} u_{exp}\\
      	   t_0 &\pm \hspace{2 mm} u_{exp}\\
          \end{array} \right.
          \end{split}
\end{eqnarray*}
where $y_G(t, \mathbf{x})$ is a numerical solution of the equation of motion
\[
m y'' = \frac{1}{2} \rho C_D A_d {y'}^2 + q E(y) + K q^2 y^{-2} \]

\section*{Governing Equation}
\begin{equation*}
m y'' = - \mathbf{F}_D - \mathbf{F}_E, \hspace{5 mm} y(0) = R_d, \hspace{5 mm} y'(0) = U_0,
\label{gov_eqn}
\end{equation*}
\\
\begin{equation*}\label{force_density}
\mathbf{F}_E = \rho_f \mathbf{E} + \frac{1}{2} \left| E \right|^2 \nabla \epsilon - \nabla \left( \frac{1}{2} \rho \left( \frac{\partial \epsilon}{\partial \rho} \right)_T \left| E \right|^2 \right) .
\end{equation*}
\\
\begin{eqnarray*}
 \mathbf{F}_E &=& q \mathbf{E} + \mathbf{F}_{DEP} + \mathbf{F}_I \\
 &=& q \mathbf{E} + \frac{k q^2}{16 \pi \epsilon_0 } y^{-2} \hat{\mathbf{j}} + 2 \pi R_d^3 \kappa_1 \epsilon_0 K \nabla E^2,
\end{eqnarray*}
\\
\begin{eqnarray*} \label{gov_eqn_subs}
&m y'' = - \frac{1}{2} C_D \rho A {y'}^2 - q E - \frac{k q^2}{16 \pi \epsilon_0} y^{-2}- 2 \pi R_d^3 \kappa_1 \epsilon_0 K \nabla E^2,& \nonumber \\
&y(0) = R, \hspace{1 mm} y'(0) = U_0 .&
\end{eqnarray*}
\\
We note we can neglect polarization stresses when
\begin{eqnarray}
\frac{ \kappa_2 \epsilon_0 K R_d^2 E_0}{q} \ll 1. \nonumber
\end{eqnarray}

\newpage
\section*{Scaling}
Introducing the scaled variables
\begin{equation*}
 \bar{t} = \frac{t}{t_c}, \hspace{10 mm} \bar{y} = \frac{y}{y_c},
 \end{equation*}
where $y_c$ and $t_c$ are characteristic length and time scales respectively, and using the coordinate transformation $y(0) - R = 0$, the governing equation becomes
\begin{eqnarray*}
& \bar{y}'' = - \mathbf{\Pi}_1 \bar{y}'^2
- \mathbf{\Pi}_2 \bar{E} ( \bar{y} )
- \mathbf{\Pi}_3 \left( \mathbf{\Pi}_4  \bar{y} + 1 \right)^{-2}, & \nonumber \\
& \bar{y}(0) = 0, \hspace{1 mm} \bar{y}'(0) = \mathbf{\Pi}_5&, \label{scaled_eqn}
\end{eqnarray*}
with
\[ \mathbf{\Pi}_1 = \frac{C_D \rho A y_c}{2 m}, \hspace{5 mm}
\mathbf{\Pi}_2 = \frac{q E_0 t_c^2}{m y_c}, \hspace{5 mm}
\mathbf{\Pi}_3 = \frac{k q^2 t_c^2}{16 \pi \epsilon_0 R^2 m y_c}, \hspace{5 mm}
\mathbf{\Pi}_4 = \frac{y_c}{R}, \hspace{5 mm}
\mathbf{\Pi}_5 = \frac{U_0 t_c}{y_c}.\]
\section*{Scaling: short-times limit}
With $y_c \sim U_0 t_c$ and picking $t_c$ such that Coulombic force $\mathbf{\Pi}_2 \sim \mathcal{O}(1)$, the intrinsic scales become
\[ t_c \sim \frac{m U_0}{q E_0}, \hspace{5 mm}
y_c \sim \frac{m U_0^2}{q E_0} .
\]
With these scales the governing equation is
\begin{eqnarray*}
& \bar{y}'' = -1 - \mathbb{I}\mbox{m} \left( \mathbb{E}\mbox{u}\bar{y} + 1 \right)^{-2} ,& \nonumber \\
& \bar{y}(0) = 0, \hspace{1 mm} \bar{y}'(0) = 1 .& \label{img_limit}
\end{eqnarray*}
with
\[ \mathbb{I}\mbox{m} \equiv \frac{k q}{16 \pi \epsilon_0 R_d^2 E_0} = \mathbf{\Pi}_3 = \frac{\mbox{Image force}}{\mbox{Coulomb force}}, \hspace{5 mm}
\mathbb{E}\mbox{u} \equiv \frac{m U_0^2}{q E_0 R_d} = \mathbf{\Pi}_4 = \frac{\mbox{Inertia}}{\mbox{Coulomb force}}.
\]
\section*{Scaling: long-times limit}
\[ t_c \sim \frac{R_d^2}{L^2} \frac{4 \pi m U_0}{q E_0}, \hspace{5mm} y_c \sim \frac{R_d^2}{L^2} \frac{4 \pi m U_0^2}{q E_0}.
\]
With this scaling the non-dimensional governing equation is
\begin{eqnarray*}
&\bar{y}'' = - \mathbb{D}\mbox{g} \mathbb{E}\mbox{u}_+ \bar{y}'^2 - \left( \mathbb{E}\mbox{u}_+ \bar{y} + 1 \right)^{-2}, & \nonumber \\
& \bar{y}(0) = 0, \hspace{1 mm} \bar{y}'(0) = 1 & \label{drag_limit}
\end{eqnarray*}
where $\mathbb{D}\mbox{g}$ the drag number, $\mathbb{D}\mbox{g} \equiv \frac{C_D \rho_a}{\rho_l} = \mathbf{\Pi}_1 {\mathbb{E}\mbox{u}}_+^{-1}$ and $\mathbb{E}\mbox{u}_+ = 4 \pi \frac{R_d^2}{L^2} \mathbb{E}\mbox{u}$.

\newpage
\section*{Escape Velocity}
As ${\mathbb{E}\mbox{u}}_+$ grows, the time-of-flight grows rapidly, approaching an asymptote at a certain critical velocity; this is an electrostatic escape velocity, $U_e$. From
\[ m u' = - \frac{q E_0 y_c^2}{y^2}, \]
we find
\[ u(y) = \pm U_0 \left[1 + \frac{2q E_0 y_c^2}{m U_0^2} \left( \frac{1}{y} - \frac{1}{R_d} \right) \right]^{1/2}.
\]
This equation has an asymptotic velocity, $U_{\infty}$ at $y = \infty$ which is real if
\[ U_0 \geq  U_e = y_c \sqrt{\frac{2 q E_0 }{m R_d}}.
\]
Drops will escape the electric field when
\begin{equation*}\label{escape}
{\mbox{B}^2 \mathbb{E}\mbox{u}}^3 > 1,
\end{equation*}
where $B^2= 8 \pi\frac{ R_d^2}{L^2}$.
\newpage
\section*{Asymptotic Estimate of Trajectory Apoapse}
The scaled equation is still non-linear but we can get an approximate analytical solution by means of a regular perturbation, using the naive expansion
\[ \bar{y}(\bar{t}) \sim \bar{y}_0(\bar{t}) + \epsilon \bar{y}_1(\bar{t}) + \epsilon^2 \bar{y}_2(\bar{t}) \ldots \epsilon^n\bar{y}_n(\bar{t})
,\]
we obtain
\begin{eqnarray*}
&\bar{y}(\bar{t}) = \bar{t} + \frac{\bar{t}^{2}}{2} \left(-1 - \alpha\right) + \epsilon \left(\frac{\alpha \bar{t}^{3}}{3} + \frac{\alpha \bar{t}^{4}}{12} \left(-1 - \alpha\right)\right)& \\
&+ \epsilon^{2} \left(- \frac{\alpha \bar{t}^{4}}{4} + \frac{\alpha \bar{t}^{5}}{60} \left(9 + 11 \alpha\right) + \frac{\alpha \bar{t}^{6}}{360} \left(-9 - 20 \alpha - 11 \alpha^{2}\right)\right) + \mathcal{O}(\epsilon^3).&
\end{eqnarray*}

\end{document}


%!TEX root =  ../main.tex

\subsection{Numerical, Graphical, Algebraic, and Verbal}

\objective{Use functions defined numerically, graphically, algebraically, or verbally.}

A \gls{function} is a relation that uniquely associates members of one \gls{set}
with members of another set.
More simply, a function connects members of a \gls{domain} to members of a \gls{range},
with the proviso that each element in the domain maps onto only one element in the range.
When graphing a function, it is customary to plot the \emph{input} or \gls{independent variable}
on the $x$-axis (going left to right), and the \emph{output} or \gls{dependent variable} on
the $y$-axis (going down to up).  The independent variable is so-called because it may
be arbitrarily chosen from within the domain.  The dependent
variable is then forced to be a particular value (by the function).

\subsubsection{Numerically}
Typically, information is gathered about the physical world as \gls{discrete} numbers,
occurring at fixed points. Such information may be represented as in table~\ref{tab:Numerically}.

\columntable[-0.75in]{1.6in}{
  \begin{tabular}{ lr }
  \hline
  \textbf{x} (months since) & \textbf{y} (100's of \$)\\
  \hline
  0 & 1200.00 \\
  1 & 840.00 \\
  10 & 1680.24 \\
  16 & 2072.98 \\
  23 & 2264.72 \\
  36 & 4303.93 \\
  48 & 6770.53 \\
  \hline
  \end{tabular}
   }{Monthly income represented numerically\label{tab:Numerically}}

\subsubsection{Graphical}
A helpful way to visualize relationships between input and output
sets is a \gls{graph} of the function.  Similar techniques
include diagrams (see Figure for an example) and maps (see Figure for an example).
``Mapping diagrams'' blur the line between numerical and graphical data
(see Figure ~\ref{fig:graphically} for an example).

\begin{figure}[h]
\centering
\begin{tikzpicture}
\begin{axis}[samples=500,domain=0:48,restrict y to domain =0:8500]
\addplot[very thick,orange ]plot (\x, {1000*(pow(1.04,\x))+200*cos((\x r)*3.1415)});
\end{axis}
\end{tikzpicture}
\caption[Graph]{Monthly Income  - Graphically\label{fig:graphically}}
\end{figure}

\subsubsection{Algebraically}
Typically, graphs come from humans or machines plotting many,
many points derived from an \gls{algebraic} formula.
Algebra is a powerful tool for describing natural phenomena,
but it cannot do everything.  Important numbers
--- such as \gls{pi} or $e$ --- cannot be defined via algebraic techniques.
Worse, many confuse manipulation of the symbols with actual mathematics.
However, the symbols are very concise, as you might see in Tab.~\ref{tab:algebra}.

\columntable[-0.75in]{0.3in}{
\begin{center}
$y=1000\cdot1.04^x+200\cos(\pi x)$.
\end{center}}
{Monthly Income - Algebraically\label{tab:algebra}}

\subsubsection{Verbally}
Ordinary language serves us well most of the time, with an average level of
precision and an average level of
emotional content.  Sometimes, however, what we wish to convey is more
meaningful and deep than
regular wording can describe.  Conversely, we might wish to exclude a whole
host of meanings, and narrowly
zoom in on precise terminology, in order to avoid error to the fullest extent possible
(see Fig.~\ref{fig:lol}).

\marginfig[-0in]{\chapdir/pics/levelsoflanguage}{Levels of language\label{fig:lol}}

Most of us encounter poetic language\index{language} in the form of songs, since ours is an
age sadly bereft of
poetry, something that was not true a century ago or more.  Another common
phenomenon is to meet
technical language when it is not expected or welcome, such as when we read the
instruction manual for new
hardware or legal documents.  However, such documents are typically not aiming at
easy comprehension, but
precision.  Like most jargon, they tend to use mostly ordinary words in extraordinary
ways, similar but opposite
to poetry.

Mathematics is no different.  This textbook is a formal setting, and as such,
it uses technical language, carefully
choosing each word according the conventions and definitions ``in house''.
As you cross the threshold into the
beginning stages of advanced mathematics, you must cultivate the skill of
using this ``jargon'', something you
do not ordinarily do.  It may help your comprehension to paraphrase
what you are learning into the ``vernacular,''
but you should not consider a topic concluded until you are able to
re-articulate the mater in mathematical terminology.
For example, the equation above might be described as in Fig.~\ref{fig:verbally}.

\begin{figure}
\emph{The income ($y$) may be modeled by the number of months since
inception ($x$) as a sinusoid with an amplitude of 200, a period of 2, and a
midline of an exponential growth rate of 4\% beginning at \$1,000.}
\caption{Monthly Income - Verbally\label{fig:verbally}}
\end{figure}

\subsubsection{Mathematical Models}
Functions that can be used to make predictions and
interpretations of real-world phenomena are called \textbf{mathematical
models}.
It is important to be clear which variable is being used as input
and which is output, so that a meaningful
relationship between independent and dependent variables
can be ascertained.  In the model of income above,
time does not depend upon money, but rather money upon time.
The domain of the function is the initial time
index of zero until four years later, so in months $0\le x \le 48$.
The income varies from as low as \$840 but
generally goes up from there, so the range is $y\ge840$.

\begin{example}
	\exProblem
There are only so many hours in a day.  If you decide to stay up \emph{all} night studying,
you will surely get
a bad grade on the test tomorrow, due to sleep deprivation.
Sketch a reasonable graph showing hours spent sleep the day before
a test and the grade you will get on said test.  Give the domain and range of the function.

	\exSolution
One cannot possibly get less than zero hours of sleep, and presumedly around
12 or so hours of sleep is
long enough to have slept through the exam and angered one's parents!
Test scores are typically measured in percents, ranging from 0 to 100.

\marginfig[-1.8in]{\chapdir/pics/sleep.png}{Possible graph of sleep vs. grade}
\end{example}

~\vfill