\documentclass[12pt]{article}

\setlength{\topmargin}{-0.5in}
\setlength{\oddsidemargin}{0.33in}
\setlength{\textheight}{9.0in}
\setlength{\textwidth}{6.0in}

\usepackage{amssymb,amsmath,makecell,epsfig,amsthm,listings}

\newtheorem*{thm_pic}{Theorem: Picard}

\lstset{language=Matlab,frame=single}

\title{Example of a \LaTeX\ Document}
\author{Kathryn Gillow}
\date{23rd October 2019}

\begin{document}

\baselineskip=20pt plus1pt

\maketitle

\tableofcontents

\section{Introduction}

Mathematical models based on partial differential equations are being used to
an increasing extent to model the world about us. They can be exploited to
describe many different phenomena in areas ranging from fluid mechanics to
finance, from tumour growth to traffic flow, and from economics to our own
special interest, electrochemistry. Of course a variety of analytical
techniques exist for solving partial differential equations exactly, such as
Laplace or Fourier transform methods, similarity solution methods, series
solutions via separation of variables and Green's function techniques.
However, except in the most simple cases, these analytical techniques are
either inapplicable or impractical; indeed for two-dimensional problems in
electrochemistry the only problem to which there is a known closed form
solution is the simple case of an E reaction mechanism at a microdisc
electrode. Of course the more interesting situations are modelled more
realistically by complicated equations so we need to resort to numerical
methods to solve such problems.  Two obvious candidates for suitable methods
are the finite difference method (FDM) and the finite element method (FEM).


\subsection{Finite Difference Methods}

Finite difference methods date back to the 1920's and are based on two ideas.
First, one approximates the computational domain by a finite set of points
(known as mesh points, grid points or nodes), then one approximates the
differential equation using difference equations. Clearly this leads to a
linear or nonlinear system of algebraic equations to find the approximate
solution at the mesh points. The hope is that as the computational mesh is
refined, the approximate solution will converge to the exact solution;
indeed, provided the solution is sufficiently smooth, error estimates can be
derived to show that this is the case and they indicate the expected rate of
convergence. Although the basic ideas of finite difference methods are
relatively straightforward, there are drawbacks. The first is that the method
does not easily handle domains with curved or irregular boundaries, another
is that there are various ways to handle boundary conditions and it is not
obvious, in advance, which is the best. This means that it is difficult to
write a generally applicable computer code based on the finite difference
method.

\subsubsection{Finite Difference Methods for the Heat Equation}

Now we consider various methods for solving the heat equation in one space
dimension. We will consider the explicit Euler scheme and the implicit Euler
scheme. We will then take the average of these two methods to produce the
Crank-Nicolson scheme. In fact we will see that all of these schemes are
special cases of the so-called ``theta-method''.

\section{Random Maths}

( ) : [ ] . !

\$ \& \% \# \_ \{ \}

% anything after a % is a comment

The equation $\alpha_{1}= \beta^{2}$ tells us

The equation $\alpha_1= \beta^{2}$ tells us

The equation $\alpha_12= \beta^{2}$ tells us

\[
\alpha_{1}= \beta^{2}
\]

\begin{displaymath}
\alpha_{1}= \beta^{2}
\end{displaymath}

\begin{equation}
\alpha_{1}= \beta^{2}
\end{equation}

\begin{equation}
\label{alpha_beta_eqn}
\alpha_{1}= \beta^{2}
\end{equation}

Equation (\ref{alpha_beta_eqn}) explains the relationship between $\alpha_1$ and $\beta$.

Equation \eqref{alpha_beta_eqn} explains the relationship between $\alpha_1$ and $\beta$.

\begin{eqnarray}
\beta & = & 1 \\
\alpha_1 & = & \beta^2 \\
\alpha_2 & = & \beta^3
\end{eqnarray}

\begin{eqnarray}
\beta & = & 1 \\
\alpha_1 & = & \beta^2 \nonumber \\
\alpha_2 & = & \beta^3
\end{eqnarray}

\begin{eqnarray*}
\beta & = & 1 \\
\alpha_1 & = & \beta^2 \\
\alpha_2 & = & \beta^3
\end{eqnarray*}

\begin{eqnarray*}
I & = & \int_{1}^{\infty} x^{-1} {\rm d}x \\
S & = & \sum_{n=0}^{s} n \\
f & = & \frac{3}{2x} \\
u_x & = & \frac{\partial u}{\partial x} \\
& & \sim \cos \tan \log \exp \max min
\end{eqnarray*}
Remember not to just use $min$ in mathmode --- this is formally the product of $m$, $i$ and $n$.

\begin{eqnarray}
A & = & \left(
\begin{array}{c c c}
1 & 2 & 3 \\
4 & 5 & 6
\end{array}
\right)
\end{eqnarray}

\begin{eqnarray*}
|x| & = & \left\{
\begin{array}{r l}
-x & x<0 \\
x & x \ge 0
\end{array}
\right.
\end{eqnarray*}

\begin{eqnarray}
\frac{\partial u}{\partial x} & = & x^2 + \sin x \nonumber \\
& & + \cos x
\end{eqnarray}

\begin{eqnarray}
\frac{\partial u}{\partial x} & = & x^2 + \sin x + \cos x \ = \ 4
\end{eqnarray}

\begin{eqnarray}
\frac{\partial u}{\partial x} & = & x^2 + \sin x + \cos x \\ & = & 4
\end{eqnarray}

\section{Tables}

\begin{table}[ht]
\centering
\begin{tabular}{c c c c }
\hline
mesh & triangles & nodes & current \\
\hline
1 & 32 & 25 & 1.270 \\
2 & 94 & 59 & 1.131 \\
3 & 201 & 116 & 1.066 \\
4 & 372 & 208 & 1.034 \\
5 & 527 & 288 & 1.019 \\
\hline
\end{tabular}
\caption{Triangulations produced by FEM.}
\label{disctab}
\end{table}

In Table \ref{disctab} we see some numbers.

\begin{table}[ht]
\centering
\begin{tabular}{| c |c  |c |c |}
\hline
mesh & triangles & nodes & current \\
\Xhline{5\arrayrulewidth}
1 & 32 & 25 & 1.270 \\
2 & 94 & 59 & 1.131 \\
3 & 201 & 116 & 1.066 \\
4 & 372 & 208 & 1.034 \\
5 & 527 & 288 & 1.019 \\
\hline
\end{tabular}
\caption{Triangulations produced by FEM.}
\label{disctab2}
\end{table}

\section{Figures}

\begin{figure}[ht]
\centering
\includegraphics[width=6cm]{sphere}
\caption{A sphere.}
\label{spherefig}
\end{figure}

In Figure \ref{spherefig} we see a sphere.

\begin{figure}[ht]
\centering
\input{diag.pdf_t}
\caption{Variation of diffusion coefficients.}
\label{diagram}
\end{figure}

In Figure \ref{diagram} we see 

\section{Theorems}

\begin{thm_pic}
Suppose that $f(t,u)$ is a continuous function of $t$ and $u$ in a
region $\Omega = [0,T) \times [u_0 -\alpha , u_0 + \alpha ]$ of the $(t,u)$
plane and that there exists $L>0$ such that
\begin{eqnarray*}
| f(t,u) - f(t,v)| & \leq & L|u-v| \quad \forall t,u,v \in \Omega.
\end{eqnarray*}
$L$ is called a Lipschitz constant and this a Lipschitz
condition. Suppose also that
\begin{eqnarray*}
MT & \leq \alpha ,
\end{eqnarray*}
where $M = \max_{\Omega} |f|$. Then there exists a unique continuously 
differentiable function $u(t)$ defined on $[0,T)$ satisfying
\begin{eqnarray*}
\frac{{\rm d} u}{{\rm d} t} & = & f(t,u), \quad 0<t<T \\
u(0) & = & u_0 .
\end{eqnarray*}
\end{thm_pic}

\begin{proof}
prove the theorem here
\end{proof}

\begin{proof}
prove the theorem another way here
\end{proof}

\section{Code}

\lstinputlisting{mynewt.m}

\section{Referencing}
For an introduction to finite difference methods see \cite{morton}.

\addcontentsline{toc}{section}{References}

\begin{thebibliography}{99}
\bibitem{morton} K.W. Morton and D.F. Mayers. Numerical Solution of Partial
  Differential Equations. Cambridge University Press, 1994.
\bibitem{houston} P. Houston, J. Mackenzie, E. S\"{u}li and G. Warnecke. A
  posteriori error analysis for numerical approximations of Friedrichs
  systems. \textit{Numerische Mathematik}, \textbf{82}:409--432, 1999.
\end{thebibliography}

\end{document}
