Latex: Equations

Dr. Tom V. Mathew

4 October 2006

1 Equations

1.1 In line equations

In line equation is produced by giving $ sign before and after an equation. Few simple equation are given below.
\documentclass{article}

\begin{document}

A simple equation with english alphabets $z=x+y$,
another simple equation with greek alphabets $\alpha=\beta+\gamma$,
and an equation with some special notation $\sum z=\frac{\delta}{y^2}$.

\end{document}
This will produce equations like this: A simple equation with english alphabets $z=x+y$, another simple equation with greek alphabets $\alpha=\beta+\gamma$, and an equation with some special notation $\sum z=\frac{\delta}{y^2}$.

A simple equation with english alphabets $z=x+y$, another simple equation with greek alphabets $\alpha=\beta+\gamma$, and $\sum z=\frac{\delta}{y^2}$. Note that the equation number is generated automatically.

1.2 equation Environment

The equation environment will create an equation similar to above, but not in-line. The equation will be placed next line, justified middle, places some space above and below; and auotmatically generate an equation number. To get the equation below, use the source code in:
\begin{equation}
\Pi_{i=0}^{n^{2}}=\frac{\alpha^{\sqrt{y}}}{\sqrt{y-x}}
\end{equation}

\begin{displaymath}
\Pi_{i=0}^{n^{2}}=\frac{\alpha^{\sqrt{y}}}{\sqrt{y-x}}
\end{displaymath} (1)

1.3 eqnarray Environment

The eqnarray environment is similar to the equation; but it can support equation spanning to many lines.
\begin{eqnarray}
z = (x+1)+(y-2) \\
  = x+y+1-2 \\
  = x+y-1\\
\end{eqnarray}

$\displaystyle z = (x+1)+(y-2)$     (2)
$\displaystyle = x+y+1-2$     (3)
$\displaystyle = x+y-1$     (4)

Note that this environment has generated equation on all lines. However, the aligment of the equation is not proper. See the follwoing example which shows a nice alignment as well numbering for only once.
\begin{eqnarray}

\Pi_{i=0}^{n^{2}}&=&\frac{\alpha^{\sqrt{y}}}{\sqrt{y-x}}\\

&=&e^{25\beta}-1\nonumber\\

&=&\Delta+\Gamma\nonumber

\end{eqnarray}
This code will produce the follwing output.
$\displaystyle \Pi_{i=0}^{n^{2}}$ $\textstyle =$ $\displaystyle \frac{\alpha^{\sqrt{y}}}{\sqrt{y-x}}$ (5)
  $\textstyle =$ $\displaystyle e^{25\beta}-1$  
  $\textstyle =$ $\displaystyle \Delta+\Gamma$  

1.4 Matrix

%
\begin{equation}
%
\newcommand{\cellaa}{\frac{\partial^2{f(\bar{x})}}{\partial{x_1^2}}}
%
\newcommand{\cellab}{\frac{\partial^2{f(\bar{x})}}{\partial{x_1x_2}}}
%
\newcommand{\cellac}{\frac{\partial^2{f(\bar{x})}}{\partial{x_1x_3}}}
%
\newcommand{\cellan}{\frac{\partial^2{f(\bar{x})}}{\partial{x_1x_n}}}
%
\newcommand{\cellba}{\frac{\partial^2{f(\bar{x})}}{\partial{x_2x_1}}}
%
\newcommand{\cellbb}{\frac{\partial^2{f(\bar{x})}}{\partial{x_2^2}}}
%
\newcommand{\cellbc}{\frac{\partial^2{f(\bar{x})}}{\partial{x_2x_3}}}
%
\newcommand{\cellbn}{\frac{\partial^2{f(\bar{x})}}{\partial{x_2x_n}}}
%
\newcommand{\cellna}{\frac{\partial^2{f(\bar{x})}}{\partial{x_nx_1}}}
%
\newcommand{\cellnb}{\frac{\partial^2{f(\bar{x})}}{\partial{x_nx_2}}}
%
\newcommand{\cellnc}{\frac{\partial^2{f(\bar{x})}}{\partial{x_nx_3}}}
%
\newcommand{\cellnn}{\frac{\partial^2{f(\bar{x})}}{\partial{x_n^2}}}
%
a=\left(
%
\begin{array}{ccccc}
%
\cellaa&\cellab&\cellac&\dots&\cellan\\
\cellba&\cellbb&\cellbc&\dots&\cellbn\\
\dots  &\dots  & \dots &\dots&\dots\\\hline 
\cellna&\cellnb&\cellnc&\dots&\cellnn\\
%
\end{array}
%
\right)
%
\end{equation}

\begin{displaymath}%
\providecommand{\cellaa}{\frac{\partial^2{f(\bar{x})}}{\par...
...\partial^2{f(\bar{x})}}{\partial{x_n^2}}\\
\end{array}\right)
\end{displaymath} (6)



Prof. Tom V. Mathew 2006-10-04