%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Contents: Math typesetting with LaTeX
% File: math.tex (lshort2e.tex)
% Change: 21/11/1994 (to)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
\section{Typesetting Mathematical Formulae}
 
\subsection{General}

\LaTeX{} has a special mode for typesetting \wi{mathematics}.
Mathematical text within a paragraph is entered between \ci{(}
and \ci{)}, \index{$@\texttt{\$}} between |$| and |$| or between
|\begin{|\ei{math}|}| and |\end{math}|.\index{formulae}

\begin{example}
Add $a$ squared and $b$ squared 
to get $c$ squared. Or using 
a more mathematical approach:
$c^{2}=a^{2}+b^{2}$
\end{example}

\begin{example}
\TeX{} is pronounced as 
$\tau\epsilon\chi$.\\[6pt]
100~m$^{3}$ of water\\[6pt]
This comes from my $\heartsuit$
\end{example}

Larger mathematical equations or formulae are preferably typeset on
separate lines. Therefore you enclose them between \ci{[} and \ci{]}
or between |\begin{|\ei{displaymath}|}| and |\end{displaymath}|. This
produces formulae which are not enumerated. If you want \LaTeX{} to
enumerate them, you can use the \ei{equation} environment.

\begin{example}
Add $a$ squared and $b$ squared 
to get $c$ squared. Or using 
a more mathematical approach:
\begin{displaymath}
c^{2}=a^{2}+b^{2}
\end{displaymath}
And just one more line.
\end{example}

With \ci{label} and \ci{ref} you can reference an equation within the
text.

\begin{example}
\begin{equation} \label{eps}
\epsilon > 0
\end{equation}
From (\ref{eps}) we gather \ldots
\end{example}
\pagebreak

The are diffrences between \emph{math mode} and \emph{text mode}. For
example, in \emph{math mode}: 

\begin{enumerate}

\item Most spaces and linebreaks do not have any significance, as all spaces
are either derived logically from the mathematical expressions or
have to be specified using special commands such as \ci{,}, \ci{quad} or
\ci{qquad}.

\begin{example}
\begin{equation}
\forall x \in \mathbf{R}:
\qquad x^{2} \geq 0
\end{equation}
\end{example}
 
\item Empty lines are not allowed. Only one paragraph per formula.

\item Each letter is considered to be the name of a variable and will be
typeset as such. If you want to typeset normal text within a formula
(normal upright font and normal spacing) then you have to enter the
text using the |\textrm{...}| commands.

\begin{example}
\begin{equation}
x^{2} \geq 0\qquad
\textrm{for all }x\in\mathbf{R}
\end{equation}
\end{example}
 
\end{enumerate}

%
% Add AMSSYB Package ... Blackboard bold .... R for realnumbers
%

\subsection{Grouping in Math Mode}

Most math mode commands act only on the next character. So if you
want several characters affected by a command you have to group them
together using curly braces: |{...}|.

\begin{example}
\begin{equation}
a^x+y \neq a^{x+y}
\end{equation}
\end{example}
 
\subsection{Building Blocks of a Mathematical Formula}

In this section the most important commands used in mathematical
typesetting will be described. For a list of all symbols available
take a look at section~\ref{symbols} on page~\pageref{symbols}.

\textbf{Lowercase \wi{Greek letters}} are entered as |\alpha|,
|\beta|, |\gamma|, \ldots, uppercase letters\footnote{There is no
  uppercase Alpha defined in \LaTeXe{} because it looks the same as a
  normal roman A. Once the new math coding is done, things will
  change.} are entered as |\Gamma|, |\Delta|, \ldots

\begin{example}
$\lambda,\xi,\pi,\mu,\Phi,\Omega$
\end{example}
 
\textbf{Exponents and Subscripts} can be specified using
\index{exponent}\index{subscript}
the |^|\index{^@"|^"|} and the |_|\index{_@"|_"|} character.

\begin{example}
$a_{1}$ \qquad $x^{2}$ \qquad
$e^{-\alpha t}$ \qquad
$a^{3}_{ij}$\\
$e^{x^2} \neq {e^x}^2$
\end{example}

The \textbf{\wi{square root sign}} is entered as \ci{sqrt}, the
$n^\mathrm{th}$ root is generated with |\sqrt[|$n$|]|. The size of
the root sign is determined automatically by \LaTeX.

\begin{example}
$\sqrt{x}$ \qquad 
$\sqrt{ x^{2}+\sqrt{y} }$ 
\qquad $\sqrt[3]{2}$
\end{example}

The commands \ci{overline} and \ci{underline} create
\textbf{horizontal lines} directly over or under an expression.
\index{horizontal!line}
\begin{example}
$\overline{m+n}$
\end{example}

The commands \ci{overbrace} and \ci{underbrace} create
\textbf{horizontal braces} over or under an expression.
\index{horizontal!brace}
\begin{example}
$\underbrace{ a+b+\cdots+z }_{26}$
\end{example}

\index{mathematical!accents} To add mathematical accents such as small
arrows or \wi{tilde} signs to variables you can use the commands given
in Table~\ref{mathacc}.  Wide hats and tildes, covering several
characters are generated with \ci{widetilde} and \ci{widehat}. With
the |'|\index{'@"|'"|} symbol you enter a \wi{dash}.

\begin{example}
\begin{displaymath}
y=x^{2}\qquad y'=2x\qquad y''=2
\end{displaymath}
\end{example}

Often \textbf{\wi{vectors}} are specified by adding small \wi{arrow
  symbols} on top of a variable. This is done with the \ci{vec}
command. To denote the vector from $A$ to $B$ the two commands
\ci{overrightarrow} and \ci{overleftarrow} are useful.

\begin{example}
\begin{displaymath}
\vec a\quad\overrightarrow{AB}
\end{displaymath}
\end{example}


Names of log-like functions are often typeset in an upright
font and not italic as variables. Therefore \LaTeX{} supplies the
following commands to typeset the most important function names:
\index{mathematical!functions}

\begin{verbatim}
\arccos   \cos    \csc   \exp   \ker     \limsup  \min   \sinh
\arcsin   \cosh   \deg   \gcd   \lg      \ln      \Pr    \sup
\arctan   \cot    \det   \hom   \lim     \log     \sec   \tan
\arg      \coth   \dim   \inf   \liminf  \max     \sin   \tanh
\end{verbatim}

\begin{example}
\[\lim_{n \rightarrow 0}
\frac{\sin x}{x}=1\]
\end{example}

For the \wi{modulo function} there are two commands: \ci{bmod} for the
binary operator ``$a \bmod b$'' and \ci{pmod}
for expressions
such as ``$x\equiv a \pmod{b}$.''

A built-up \textbf{\wi{fraction}} is typeset with the
\ci{frac}|{...}{...}| command.
Often the slashed form $1/2$ is preferable, because it looks better
for small amounts of `fraction material.'
\begin{example}
$1\frac{1}{2}$~hours
\begin{displaymath}
\frac{ x^{2} }{ k+1 }\qquad
x^{ \frac{2}{k+1} }\qquad
x^{ 1/2 }
\end{displaymath}
\end{example}

To typeset binominal coefficients or similar structures you can use
either the command |{... |\ci{choose}| ...}| or 
|{... |\ci{atop}| ...}|. The second command produces the 
same output as the first one, but without braces.

\begin{example}
\begin{displaymath}
{n \choose k}\qquad {x \atop y+2}
\end{displaymath}
\end{example}
 
\medskip

The \textbf{\wi{integral operator}} is generated with \ci{int}, the
\textbf{\wi{sum operator}} with \ci{sum}. The upper and lower limits
are specified with~|^| and~|_| as with subscripts and superscripts.

\begin{example}
\begin{displaymath}
\sum_{i=1}^{n} \qquad
\int_{0}^{\frac{\pi}{2}} \qquad
\end{displaymath}
\end{example}

For \textbf{\wi{braces}} and other \wi{delimiters} there exist all
types of symbols in \TeX{} (e.g.~$[\;\langle\;\|\;\updownarrow$).
Round and square braces can be entered with the corresponding keys,
curly braces with |\{|, all other delimiters are generated with special
commands (eg.~|\updownarrow|).

\begin{example}
\begin{displaymath}
{a,b,c}\neq\{a,b,c\}
\end{displaymath}
\end{example}

If you put the command \ci{left} in front of an opening delimiter or
\ci{right} in front of a closing delimiter, \TeX{} will automatically
determine the correct size of the delimiter. 

\begin{example}
\begin{displaymath}
1 + \left( \frac{1}{ 1-x^{2} }
    \right) ^3
\end{displaymath}
\end{example}

In some cases it is necessary to specify the correct size of a
mathematical delimiter\index{mathematical!delimiter} by hand,
therefore you can use the commands \ci{big}, \ci{Big}, \ci{bigg} and
\ci{Bigg} as prefixes to most delimiter commands\footnote{These
  commands do not work as expected if a size changing command has been
  used, or the |11pt| or |12pt| option has been specified.  Use the
  \pai{exscale} or \pai{amstex} packages to correct this behaviour}.

\begin{example}
$\Big( (x+1) (x-1) \Big) ^{2}$\\
$\big(\Big(\bigg(\Bigg($\quad
$\big\}\Big\}\bigg\}\Bigg\}$\quad
$\big\|\Big\|\bigg\|\Bigg\|$
\end{example}

To enter \textbf{\wi{theer dots}} into a formula you can use several
commands. \ci{ldots} typesets the dots on the baseline, \ci{cdots}
sets them centred. Beside that there are the commands \ci{vdots} for
vertical and \ci{ddots} for \wi{diagonal dots}.  \index{vertical
  dots}\index{horizontal!dots}

\begin{example}
\begin{displaymath}
x_{1},\ldots,x_{n} \qquad
x_{1}+\cdots+x_{n}
\end{displaymath}
\end{example}
 
\subsection{Math Spacing}

\index{math spacing} If the spaces within formulae chosen by \TeX{}
are not satisfactory, they can be adjusted by inserting special
spacing commands. The most important are: \ci{,} for a tiny space,
\verb*.\. for a medium sized space (\verb*. . stands for a ``space''
character), \ci{quad} and \ci{qquad} for large spaces and |\!|\cih{"!}
which shrinks a space.

\begin{example}
\begin{displaymath}
\int\!\!\!\int_{D} dx\,dy \quad 
\textrm{instead of} \quad 
\int\int_{D} dx dy
\end{displaymath}
\end{example}
 
\subsection{Vertically Aligned Material}

To typeset \textbf{arrays}, use the \ei{array} environment. It works
somewhat similar to the |tabular| environment. The |\\| command is
used to break the lines.

\begin{example}
\begin{displaymath}
\mathbf{X} =
\left( \begin{array}{ccc}
x_{11} & x_{12} & \ldots \\
x_{21} & x_{22} & \ldots \\
\vdots & \vdots & \ddots
\end{array} \right)
\end{displaymath}
\end{example}

For formulae running over several lines or for \wi{equation system}s
you can use the environments \ei{eqnarray} and |eqnarray*| instead of
|equation|. In |eqnarray| each line gets a equation number. In the
|eqnarray*| no line numbers are produced. For equation systems which
should get one common number you can use the \ci{nonumber} command
on all the lines which should \emph{not} get a number.

The |eqnarray| and the |eqnarray*| environments work like a 3-column
table of the form |{rcl}|, where the middle column can be used for the
equal sign or the non-equal sign. The |\\| command breaks the lines.

\begin{example}
\begin{eqnarray}
f(x) & = & \cos x       \\
f'(x) & = & -\sin x     \\
\int_{0}^{x} f(y)dy &
 = & \sin x
\end{eqnarray}
\end{example}

\index{long equations} \textbf{Long equations} will not be
automatically divided into neat bits.  The author has to specify
where to break them and how much to indent. The following two methods
are the most common ones to achieve this.

\begin{example}
\begin{eqnarray}
\sin x & = & x -\frac{x^{3}}{3!}
     +\frac{x^{5}}{5!}-{}
                    \nonumber\\
 & & {}-\frac{x^{7}}{7!}+{}\cdots
\end{eqnarray}
\end{example}
\pagebreak[1]

\begin{example}
\begin{eqnarray}
\lefteqn{ \cos x = 1
     -\frac{x^{2}}{2!} +{} }
                    \nonumber\\
 & & {}+\frac{x^{4}}{4!}
     -\frac{x^{6}}{6!}+{}\cdots
\end{eqnarray}
\end{example}

The \ci{nonumber} command causes \LaTeX\ not to generate a number for
this equation.


\subsection{Math Font Size}

\index{math font size} In math mode \TeX\ normally switches the font
size according to context. Superscripts for example get typeset in a
smaller font. If you want to add roman text to an equation and use the
|\textrm| command, the font size switching mechanism will not work, as
|\textrm| temporarily escapes to text mode. Use |\mathrm| instead to
keep the size switching mechanism active. But pay attention,
\ci{mathrm} will only work well on short items. Spaces are still not
active and accented charactes don't work\footnote{The AMS-\LaTeX{}
  package makes the \ci{textrm} command work with size changing.}.

\begin{example}
\begin{equation}
2^\textrm{nd} \quad 
2^\mathrm{nd}
\end{equation}
\end{example}

Sometimes you need to tell \LaTeX{} about the correct font size
nevertheless. In math mode the fontsize is set with the four
commands: 
\begin{flushleft}
\ci{displaystyle}~($\displaystyle 123$),
 \ci{textstyle}~($\textstyle 123$), 
\ci{scriptstyle}~($\scriptstyle 123$) and
\ci{scriptscriptstyle}~($\scriptscriptstyle 123$).
\end{flushleft}

%\begin{example}
%\begin{displaymath}
%\mathrm{corr}(X,Y)= 
% \frac{\displaystyle 
%   \sum_{i=1}^n(x_i-\bar x)
%   (y_i-\bar y)} 
%  {\displaystyle\sqrt{
% \sum_{i=1}^n(x_i-\bar x)^2
%\sum_{i=1}^n(y_i-\bar y)^2}}
%%\end{displaymath}    
%\end{example}
 
\endinput

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "lshort2e"
%%% End: 


