\documentclass[11pt]{article}
\usepackage{amsmath}

\textwidth=6.5in
\textheight=9.75in
\topmargin=-.75in
\headheight=0in
\headsep=.1in
\hoffset  -.75in

\def\dst{\displaystyle}

\def\LA{\LaTeX}

\pagestyle{empty}

\begin{document}

\centerline {\large LESSON 3: Multiline Enviroments}
\vskip.25in

Many times it happens that an equation is to long to fit on a
line or, for example, there is a natural sequence of several
steps in a calculation and you would like to display each step.
In such a case it is good to have Multiline Enviroments.  The
main one that is built into \LA is the \textit{eqnarray}
environment but better ones are available if you use the amsmath
package. The general syntax for  \textit{eqnarray} is as follows:
\vskip.1in
\begin{minipage}{2.5in} 
\begin{verbatim}
\begin{eqnarray} 
f(x) & = & \sin^2(x)\cos^2(x) \\
      &=& (\sin(x)\cos(x))^2 \\[2ex] 
      &=&\frac14\sin^2(2 x) 
\end{eqnarray}
\end{verbatim}
\end{minipage}
\hspace{.5in}
\fbox{\parbox{3in}{
\begin{eqnarray} 
f(x) & = & \sin^2(x)\cos^2(x) \\
       &=& (\sin(x)\cos(x))^2 \\[2ex] 
      &=&\frac12\sin(2 x)     
\end{eqnarray}} 
}

 


\vskip.2in
If, in the preamble you use \verb+\usepackage{amsmath}+ then you
can use the \textit{align} environment
\vskip.1in
 \begin{minipage}{2.5in} 
\begin{verbatim}
\begin{align} 
f(x) & =  \sin^2(x)\cos^(x) \\
      &=  (\sin(x)\cos(x))^2 \\[2ex] 
      &= \frac14\sin^2(2 x)    
\end{align}
\end{verbatim}
\end{minipage}
\hspace{.5in}
\fbox{\parbox{3in}{ 
 \begin{align} 
f(x) & =  \sin^2(x)\cos^(x) \\
      &=  (\sin(x)\cos(x))^2 \\[2ex] 
      &= \frac14\sin^2(2 x)   
\end{align}} 
}

\noindent \textbf{N.B.} 
\begin{enumerate}
\item One the last line you do not include the
double backslash.
\item notice the environments automatically put in an equation
number. If you don't want them the use
\verb+ \begin{align*}+ or 
\verb+\begin{eqnarray*}+
\item You can also use \verb+\nonumber+ to cancel a number on a
single row. 
\end{enumerate} 

The \textit{align} environment has many variants. One is that you
can set multiple alignment tabs. In this case the (\&) doubles
as a mark for the \textit{alignment point} and as a
\textit{column separator}. It goes like this
\begin{itemize}
\item the first \& marks the \textit{alignment point} of the
first column;
\item the second \& is a \textit{column separator};
\item the third \& marks the \textit{alignment point} of the
second column. 
\end{itemize}
If the number of columns is three then there must be 5 \& s in
each line. The two even-numbered \& s are column separators, and
the odd ones are alignment marks

\begin{align}
f(x) &= x+yx      & g(x) &= x^2+2xy+y^2 \tag{$\ast$}\\
     &= x(1+y)    &      &= (x+y)^2      \tag{\dag}
\end{align}
 
 \vskip.15in

Another variant is the \textit{aligned} environment which makes
a set of aligned equations into an object that is treated as a
single large symbol. 
One application of this is to center an equation number when the
object has more that one row. At this point I am   also
introducing the \textit{equation} environment:

\setcounter{equation}{0}
\begin{equation} \label{eq1}
   \begin{aligned} 
      h(x) &= \int \left( 
                         \frac{ f(x) + g(x) }
                              { 1 + f^{2}(x) } +
                         \frac{ 1 + f(x)g(x) }
                              { \sqrt{1 - \sin x} } 
                   \right) \, dx\\ 
           &= \int \frac{ 1 + f(x) }
                        { 1 + g(x) } \, dx - 2 \arctan (x - 2) 
   \end{aligned}  
\end{equation}

\noindent\textbf{N.B.} \textit{Note that the \textit{equation}
environment is the main way to display a single equation with an
equation number. Other than the equation number it is the same
as using double dollar signs.}
\vskip.1in

\noindent \textbf{N.B.} To put in a line of text between aligned
rows use the \verb+\intertext{}$+ command:

\begin{align*}
   f(x) &= x + yz & \qquad g(x) &= x + y + z \\
   \intertext{The reader also may find the following 
    polynomials useful:}
   h(x) &= xy + xz + yz 
                  & \qquad k(x) &= (x + y)(x + z)(y + z)
\end{align*}

 \noindent \textbf{N.B.} One final multiline tool is the
\textit{multiline} environment. 
\begin{multline*}
   (x_{1} x_{2} x_{3} x_{4} x_{5} x_{6})^{2}\\ 
   + (x_{1} x_{2} x_{3} x_{4} x_{5} 
    + x_{1} x_{3} x_{4} x_{5} x_{6}
    + x_{1} x_{2} x_{4} x_{5} x_{6} 
    + x_{1} x_{2} x_{3} x_{5} x_{6})^{2}\\
   + (x_{1} x_{2} x_{3} x_{4} + x_{1} x_{2} x_{3} x_{5} 
    + x_{1} x_{2} x_{4} x_{5} + x_{1} x_{3} x_{4} x_{5})^{2}
\end{multline*}
Here we have 
\begin{itemize}
\item   \verb+\\+ separates the lines (but there is  no
\verb+\\+ on the last line).
\item The whole formula is numbered unless it is \verb+\tag+-ed
or numbering is suppressed using a \verb+{multiline*}+.
\item The first line is flush left, lhe last line is flush right
and the middle lines are centered. 
\end{itemize}


\noindent \textbf{PROBLEM:}   
Use  the eqnarray or align environments to typeset the
sequence of equalities between
$$(a+b)^n$$
$$\sum_{r=0}^n \binom{n}{r} a^{n-r}b^r$$
and
$$a^n+na^{n-1}b+ \binom{n}{2} a^{n-2}b^2 +\cdots +\binom{n}{n-2}
a^2b^{n-2}+nab^{n-1} + b^n$$

\vskip.1in

\setlength{\fboxsep}{1.25in}
\noindent \framebox[6.6in]{}
\end{document}