\documentclass[12pt,a5paper]{article}
\usepackage[a5paper]{geometry}
\usepackage{hyperref}

\begin{document}

% Definition of title page:
\title{\textsf{\LaTeX{} Mathematics Examples}}
\author{Prof Tony Roberts}
\maketitle

\tableofcontents



\section{Delimiters}

See how the delimiters are of reasonable size in these examples
\begin{displaymath}
	\left(a+b\right)\left[1-\frac{b}{a+b}\right]=a\,,
\end{displaymath}
\begin{displaymath}
	\sqrt{|xy|}\leq\left|\frac{x+y}{2}\right|\,,
\end{displaymath}
even when there is no matching delimiter
\begin{displaymath}
	\int_a^bu\frac{d^2v}{dx^2}dx
	=\left.u\frac{dv}{dx}\right|_a^b
	-\int_a^b\frac{du}{dx}\frac{dv}{dx}dx\,.
\end{displaymath}






\section{Spacing}

Integrals often need a bit of help with their spacing as in
\begin{displaymath}
	\int\!\!\!\int xy^2\,dxdy 
	=\frac{1}{6}x^2y^3\,,
\end{displaymath}
whereas vector problems often lead to statements such as
\begin{displaymath}
	u=\frac{-y}{x^2+y^2}\,,\quad
	v=\frac{x}{x^2+y^2}\,,\quad\mbox{and}\quad
	w=0\,.
\end{displaymath}







\section{Arrays}

Arrays of mathematics are typeset using a tabular like environment as 
in
\begin{displaymath}
	\left[
	\begin{array}{ccc}
		1 & x & 0 \\
		0 & 1 & -1
	\end{array}\right] 
	\left[
	\begin{array}{c}
		1  \\
		y  \\
		1
	\end{array}\right]
	=\left[ 
	\begin{array}{c}
		1+xy  \\
		y-1
	\end{array} \right]\,,
\end{displaymath}
or in a case statement such as
\begin{displaymath}
	|x|=\left\{
	\begin{array}{rl}
		x & \mbox{if }x\geq 0  \\
		-x & \mbox{if }x< 0
	\end{array}\right.
\end{displaymath}
Many arrays have lots of dots all over the place as in
\begin{displaymath}
	\left[
	\begin{array}{cccccc}
		-2 & 1 & 0 & 0 & \cdots & 0  \\
		1 & -2 & 1 & 0 & \cdots & 0  \\
		0 & 1 & -2 & 1 & \cdots & 0  \\
		0 & 0 & 1 & -2 & \ddots & \vdots \\
		\vdots & \vdots & \vdots & \ddots & \ddots & 1  \\
		0 & 0 & 0 & \cdots & 1 & -2
	\end{array}\right]
\end{displaymath}






\section{Equation arrays}

In the flow of a fluid film we may report
\begin{eqnarray}
	u_\alpha & = & \epsilon^2 \kappa_{xxx} 
	\left( y-\frac{1}{2}y^2 \right)\,,
	\label{equ}  \\
	v & = & \epsilon^3 \kappa_{xxx} y\,,
	\label{eqv}  \\
	p & = & \epsilon \kappa_{xx}\,.
	\label{eqp}
\end{eqnarray}
Alternatively, the curl of a vector field $(u,v,w)$ may be written 
with only one equation number:
\begin{eqnarray}
	\omega_1 & = &
	\frac{\partial w}{\partial y}-\frac{\partial v}{\partial z}\,,
	\nonumber  \\
	\omega_2 & = & 
	\frac{\partial u}{\partial z}-\frac{\partial w}{\partial x}\,,
	\label{eqcurl}  \\
	\omega_3 & = & 
	\frac{\partial v}{\partial x}-\frac{\partial u}{\partial y}\,.
	\nonumber
\end{eqnarray}
Whereas a derivation may look like
\begin{eqnarray*}
	(p\wedge q)\vee(p\wedge\neg q) & = & p\wedge(q\vee\neg q)
	\quad\mbox{by distributive law}  \\
	 & = & p\wedge T \quad\quad\mbox{by excluded middle}  \\
	 & = & p \quad\quad\mbox{by identity}
\end{eqnarray*}






\section{Functions}

Observe that trigonometric and other elementary functions are typeset 
properly, even to the extent of providing a thin space if followed by 
a single letter argument:
\begin{displaymath}
	\exp(i\theta)=\cos\theta +i\sin\theta\,,\quad
	\sinh(\log x)=\frac{1}{2}\left( x-\frac{1}{x} \right)\,.
\end{displaymath}
With sub- and super-scripts placed properly on more complicated 
functions,
\begin{displaymath}
	\lim_{q\to\infty}\|f(x)\|_q 
	=\max_{x}|f(x)|\,,
\end{displaymath}
and large operators, such as integrals and
\begin{eqnarray*}
	e^x & = & \sum_{n=0}^\infty \frac{x^n}{n!}
	\quad\mbox{where }n!=\prod_{i=1}^n i\,,  \\
	\overline{U_\alpha} & = & \bigcap_\alpha U_\alpha\,.
\end{eqnarray*}
Although in inline mathematics the scripts are placed to the side in 
order to conserve vertical space, as in
\begin{math}
	1/(1-x)=\sum_{n=0}^\infty x^n\,.
\end{math}






\section{Accents}

Mathematical accents are performed by a short command with one 
argument, such as
\begin{displaymath}
	\tilde f(\omega)=\frac{1}{2\pi}
	\int_{-\infty}^\infty f(x)e^{-i\omega x}\,dx\,,
\end{displaymath}
or
\begin{displaymath}
	\dot{\vec \omega}=\vec r\times\vec I\,.
\end{displaymath}





\section{Command definition}

\newcommand{\Ai}{\mbox{Ai}} 
The Airy function, $\Ai(x)$, may be incorrectly defined as this 
integral
\begin{displaymath}
	\Ai(x)=\int\exp(s^3+isx)\,ds\,.
\end{displaymath}

\newcommand{\D}[2]{\frac{\partial #2}{\partial #1}}
\newcommand{\DD}[2]{\frac{\partial^2 #2}{\partial #1^2}}
\renewcommand{\vec}[1]{\mbox{\boldmath$#1$}}
This vector identity will serve nicely to illustrate two of the new 
commands:
\begin{displaymath}
	\vec\nabla\times\vec q
	=\vec i\left(\D yw-\D zv\right)
	+\vec j\left(\D zu-\D xw\right)
	+\vec k\left(\D xv-\D yu\right)\,.
\end{displaymath}





\end{document}
