\documentclass[20pt,a4paper]{extarticle}
\usepackage[a4paper,margin=6mm]{geometry}
\usepackage{amsmath}
\usepackage{hyperref}

\title{\textsf{\LaTeX{} Mathematics Examples}}
\author{Prof Tony Roberts}

\begin{document}

\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}

Differentials often need a bit of help with their spacing as in
\begin{displaymath}
	\iint xy^2\,dx\,dy 
	=\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\text{and}\quad
	w=0\,.
\end{displaymath}







\section{Arrays}

Arrays of mathematics are typeset using one of the matrix environments as 
in
\begin{displaymath}
	\begin{bmatrix}
		1 & x & 0 \\
		0 & 1 & -1
	\end{bmatrix}\begin{bmatrix}
		1  \\
		y  \\
		1
	\end{bmatrix}
	=\begin{bmatrix}
		1+xy  \\
		y-1
	\end{bmatrix}.
\end{displaymath}
Case statements use cases:
\begin{displaymath}
	|x|=\begin{cases}
		x, & \text{if }x\geq 0\,,  \\
		-x, & \text{if }x< 0\,.
	\end{cases}
\end{displaymath}
Many arrays have lots of dots all over the place as in
\begin{displaymath}
	\begin{matrix}
		-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{matrix}
\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\text{by distributive law}  \\
	 & = & p\wedge T \quad\text{by excluded middle}  \\
	 & = & p \quad\text{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\text{where }n!=\prod_{i=1}^n i\,,  \\
	\overline{U_\alpha} & = & \bigcap_\alpha U_\alpha\,.
\end{eqnarray*}
In inline mathematics the scripts are correctly 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}{\operatorname{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]{\text{\boldmath$#1$}}

This vector identity serves 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}

