\chapter{Getting Started with Maple}\label{C:Maple_Getting_Started}

\section{The Worksheet Structure}\label{S:Maple-The Basics}

\noi Maple is an interactive, mathematical problem solving software package well-suited for addressing problems that arise in this text.
Perhaps this software's best feature is its versatility. Capabilities of Maple fall into four broad categories.
\be
\item Maple has a symbolic computing component. It can manipulate algebraic expressions, solve equations exactly, perform calculus and linear algebra computations, and so on. The list of symbolic computing capabilities is quite extensive.
\item The software has built-in commands for performing numeric computations, such as those leading to solutions
of differential equations.
\item Maple possesses the ability to produce high-quality graphical output, including those involving functions of one or two variables, implicitly defined functions, and vector quantities.
\item Maple is a programming language in that it is capable of combining all its tools in a programming environment that is intuitive in nature and that requires little to no programming experience.
\ee

\newpar
Maple performs related tasks in what is referred to as a \emph{Maple worksheet}. Each worksheet is comprised of command lines starting with \mf{>} and can be saved for future using the \mf{.mw} file name extension. While the input and output of each worksheet are visible when a previously created file is opened, values in a worksheet are not saved. Two options exist for re-executing a worksheet:
\be
\item Execute, in the order presented, each command line of the worksheet by placing the cursor anywhere in that command line and hitting ``Enter.''
\item Execute the entire worksheet at once, either by selecting the Edit-Execute command or by selecting the !!! button at the
top of the worksheet.
\ee

\newpar
Maple follows certain conventions and requires the user to observe various rules. Among those that are most important
are the following:
\be
\item Maple is case-sensitive.
\item Every Maple command line ends with either a semicolon (;) or colon (:), and the command line is executed by hitting
the ``Enter'' key.
\item When a semicolon is used, output from the command is visible to the user. When a colon is used instead, the command is executed but no output appears. Using a colon is especially helpful when one wishes to perform lengthy calculations, whose results are to be used later in a worksheet but are not important for immediate viewing.
\item Variables and other types of structures are assigned values in Maple using the colon-equal sign combination. For
example, to assign the value of 2 to the variable $a$, type \mf{a:=2;} at the command line.
\item Maple ``remembers,'' in chronological order, how commands within a worksheet are executed. For example, if the variable
\mf{a} is assigned the value of 3 at some command line in the worksheet, and the user executes a subsequent command line
that involves \mf{a}, this subsequent command assumes that $a=3$. Two means exist to ``clear'' variable values. To clear all
values in a worksheet, type \mf{restart} at the first command line and re-execute the worksheet. To clear a specific variable value, such as $a$, type \mf{a:='a';} at the
command line.
\item Frequently one wishes to insert additional lines at some point in a worksheet. If the line to be added is below the current cursor position, type ``CTRL-J.'' If the line to be added is above, type ``CTRL-K'' instead.
\item Maple permits copying and pasting. Short-cut keys for copy and paste are ``CTRL-C'' and ``CTRL-V,'' respectively.
\item Maple provides the means for the user to enter ordinary text using its ``text mode." To switch to this mode,
select the ``T'' button at the top of the worksheet or type ``CTRL-T.''
\item To add documentation to any line of a worksheet, insert a line of text as described previously or type, anywhere in the command line, the
"\mf{\#}" followed by the desired comment. Maple will then ignore all input that follows \mf{\#} in that line.
\item To learn appropriate syntax and to view examples using a particular Maple command, type \mf{?\emph{command name}}
at the command prompt.
\ee

\newpar
With this general background information in mind, we now focus on using Maple to perform specific tasks.

\section{Arithmetic Calculations and Built-In Operations}

\noi Arithmetic in Maple can be performed on either fixed numeric or variable quantities. Multiplication requires the use
of \mf{*} and exponentiation the use of the \mf{\^{}} symbol.  Some examples include the following:
\begin{maplelist}
\item \mf{a:=8;}
\mo{
a:=8
}
\item \mf{3*a;}
\mo{
24
}
\item \mf{2\^{}5;}
 \mo{
32
}
\item \mf{4$/$a;}
 \mo{
\frac{1}{2}
}
\end{maplelist}

\newpar
Commonly used built-in functions are those used to compute square roots, logarithms, exponentials, and trigonometric values. Note how the exponential $e^x$ is written, \mf{exp(x)}, and the constant $\pi$ is written as \mf{Pi}.

 \begin{maplelist}
 \item \mf{x:=}9:
\item \mf{sqrt(x);}
\mo{3}
\item  \mf{ln(1);}
 \mo{0}
\item  \mf{exp(2);}
 \mo{e^2}
\item  \mf{sin(Pi$/$3);}
 \mo{\frac{1}{2}\sqrt{3}}
\end{maplelist}

\noi
Maple returns exact values where possible. To obtain a floating-point representation of a number,
use the \mf{evalf}\index{Maple!\mf{evalf}} command. For example, \mf{evalf(Pi)} returns 3.141592654. The default number of digits Maple
uses for floating point values is 10. To change this number, at the start of a worksheet enter the command \mf{Digits:=N;}, where \mf{N} is the number of desired digits.

\newpar
Frequently one wishes to take output from one command line and use it directly in the next line without retyping the output value or assigning it a name. The \mf{\%} symbol is useful for such situations in that it uses the most recent output as its value.

\begin{maplelist}
\item \mf{theta:=Pi}$/$3\mf{;}
\mo{\theta:=\frac{1}{3}\pi}

\item \mf{sin(theta);}
\mo{
\frac{1}{2}\sqrt{3}
}
\item \mf{evalf(\%);}
\mo{
0.8660254040
}
\end{maplelist}

\noindent
A word of warning is in order regarding the use of \mf{\%}: Its value is the output from the most recently executed command line. This value may or may not be the output from the previous line in the worksheet, depending upon whether or not command lines are executed in the order in which they appear. For this reason, use \mf{\%} with caution.

\section{Expressions and Functions}

\noi
Expressions involving variables can be assigned names and manipulated by passing the assigned name as an argument to the
appropriate command. Typical operations performed on expressions include factoring and simplifying, as well as substitution of values (via the \mf{subs} command)\index{Maple!\mf{subs}} and equation solving. For systems of equations, the equations themselves are listed within braces, as are the unknown variables. Here are more examples:

\begin{maplelist}
\item \mf{y:=(x+1)*(x-3);}
\mo{ y:=(x+1)(x-3)}

\item \mf{expand(y);}
\mo{x^2-2x-3}

\item \mf{z:=t\^{}2-t-6;}
\mo{z:=t^2-t-6}

\item \mf{factor(z);}
\mo{(t-3)(t+2)}

\item \mf{subs(t=1,z);}
\mo{-6}

\item \mf{y:=x\^{}2+3*x+1;}
\mo{y:=x^2+3x+1}

\item \mf{solve(y=0,x);}
\mo{
-\frac{3}{2}+\frac{1}{2}\sqrt{5},\quad -\frac{3}{2}-\frac{1}{2}\sqrt{5} }

\item \mf{fsolve(y=0,x);}
\mo{ -2.618033989, -.3819660113 }

\item \mf{solve(\{y=2x+3,y=-x+4\},\{x,y\});}
\mo{ \left\{x=\frac{1}{3},y=\frac{11}{3} \right\} }

\end{maplelist}

\noi
As a general rule, \mf{solve}\index{Maple!\mf{solve}} returns exact roots, both real- and complex-valued
of an equation or system of equations, to the extent Maple is capable of doing so. If unable
to compute all roots, Maple will return a warning of the form \mf{warning: SolutionsMayBeLost}.
Sometimes, Maple will express certain solutions using placeholders of the form \mf{RootOf}. This
is especially true if one root is difficult for Maple to compute, yet a second root is dependent upon
the first. Here is an example:

\begin{maplelist}
\item  \mf{solve(\{y=2*x, x\^{}4-x\^{}2\},\{x,y\});}
\mo{ \left\{ x=\mbox{RootOf}(Z^4-Z^3+1,\mbox{label = L1}), y=2\mbox{RootOf}(Z^4-Z^3+1,\mbox{label = L1}) \right\}
}
\end{maplelist}

\noi
This output indicates that each solution value $x$, of which there are four, corresponds to
a value of $y$, each of which is twice $x$.

\newpar
Maple's \mf{fsolve}\index{Maple!\mf{fsolve}} command differs from \mf{solve} in that approximate solutions are returned. For single equations having real-valued coefficients, \mf{fsolve} returns approximations of all real-valued roots. For systems of such equations, Maple returns one approximate solution. Further details regarding the \mf{solve} and \mf{fsolve} commands can be found by typing
\mf{?solve/details} or \mf{?fsolve/details} at the command prompt.


\newpar
Functions can be entered in Maple using arrow notation (a dash followed by a greater-than sign) or via the \mf{unapply} command\index{Maple!\mf{unapply}}. For example, to enter the
function $f(x)=x^2+1$, type either \mf{f:=x->x\^{}2-4} or \mf{f:=unapply(x\^{}2-4,x)}. Once a function is defined,
it can be used to evaluate both numeric and variable outputs.

\begin{maplelist}
\item \mf{f:=x->x\^{}2-4;}
\mo{f:=x\rightarrow x^2-4}
\item \mf{f(3);}
\mo{5}
\item \mf{f(3+h);}
\mo{(3+h)^2-4}
\item \mf{expand(\%);}
\mo{5+6h+h^2}
\end{maplelist}

\newpar
Functions of more than one variable are entered in a very similar manner.
\begin{maplelist}
\item \mf{f:=(x1,x2)->sin(x1+x2);}
\mo{f:=(x1,x2) \rightarrow \sin(x_1+x_2)}
\item \mf{f(x1,Pi);}
\mo{\sin(x_1+\pi)}
\end{maplelist}

\newpar
A very important distinction exists in Maple between functions and expressions. The rule \mf{f} defined using the \mf{->}
notation or \mf{unapply} command is a function, whereas quantities such as \mf{f(x)} and \mf{f(3+h)} are expressions in
$x$ and $h$, respectively. Commands for expressions may be applied to \mf{f(x)} and \mf{f(3+h)}. For example,
\mf{solve(f(x)=0,x)} determines the roots of the function $f$ and \mf{factor(f(x))} produces the factored form of $f(x)$,
which is again an expression.

\newpar
Functions are more appropriate than expressions when one wishes to perform ``function-like'' operations, such as evaluating function values or creating new functions from old ones. For example, to compute the derivative function, use the Maple \mf{D} operator. Here is an example utilizing this operator to calculate first and second derivatives of a function, along with critical points and inflection points and their respective function outputs. Note the documentation through the use of the \mf{\#}.

\begin{maplelist}
\item \mf{f:=x->x*exp(x);}
\mo{f:=x\rightarrow xe^x}
\item \mf{D(f)(x); \# Calculate derivative function.}
\mo{e^x+xe^x}
\item \mf{evalf(D(f)(1)); \# Calculate derivative value at x=1.}
\mo{5.436563656}
\item \mf{solve(D(f)(x)=0,x); \# Determine critical point of function.}
\mo{-1}
\item \mf{f(\%); \# Evaluate function at critical point.}
\mo{-e^{-1}}
\item \mf{(D@@2)(f)(x); \# Calculate second derivative function.}
\mo{2e^x+xe^x}
\item \mf{solve((D@@2)(f)(x)=0,x); \# Determine inflection point.}
\mo{-2}
\item \mf{f(\%);\# Evaluate function at inflection point.}
\mo{-2e^{-2}}
\end{maplelist}
\newpar
The commands \mf{diff(f(x),x)} and \mf{diff(f(x),x\$2)} also yield the first and second derivatives as expressions and
could be combined with
the \mf{solve} command to determine the preceding critical point and inflection point.

\section{Arrays, Lists, Sequences, and Sums}\label{S:Maple-Arrays_Sequences}

\noi
An array in Maple can be considered as a table of dimension $n\geq 1$, in which each entry corresponds to an ordered
$n$-tuple. Arrays are created using the \mf{array}\index{Maple!\mf{array}} command, and entries are assigned values through a nested \mf{for-do}\index{Maple!\mf{for-do}} loop structure. This simple programming structure takes the form
\begin{maplelist}
\item \mf{for i from \ma{m} to \ma{n} do \ma{task};od;}
\end{maplelist}
where \ma{m} and \ma{n} represent the smallest and largest index values, respectively,
and \ma{task} denotes the operation to be performed for index value, \mf{i}.

\newpar
For example, here is a 2-by-3 array, in which each entry is assigned the sum of the corresponding column and row indices. The entire array is then printed.
\begin{maplelist}
\item \mf{A:=array(1..2,1..3);}
\mo{A := array(1 .. 2, 1 .. 3, [])}
\item \mf{for i from 1 to 2 do for j from 1 to 3 do A[i,j]:=i+j:od:od:}
\item \mf{print(A);}
\mo{\begin{bmatrix} 2 & 3 & 4 \\ 3 & 4 & 5 \end{bmatrix}}
\end{maplelist}

\noi Later we will see how arrays provide a convenient means for creating variables labeled with double or triple indices.

\newpar
Lists are merely one-dimensional arrays. The only advantage of a list is that it need not be first defined
using the \mf{array} command. For example, the command \mf{L:=[1,2,4,8,16]} defines a list, such that
\mf{L[1]=1}, \mf{L[2]=2}, and so on. A sequence, created using the \mf{seq} command, can be thought of as a list without brackets. It is frequently used to create longer sequences of values as in the following commands, which create a sequence, called \mf{S},
consisting of the first 10 nonnegative powers of two. This sequence is then used to form a list, labeled \mf{T}.

\begin{maplelist}
\item \mf{S:=seq(2\^{}j,j=0..10);}
\mo{S:=1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}
\item \mf{T:=[S];}
\mo{T:=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]}
\end{maplelist}

\noi To extract a sequence from a list, \mf{T}, we use the command \mf{op(T)}\index{Maple!\mf{op}}, and to determine the number of entries
of this list, we use \mf{nops(T)}\index{Maple!\mf{nops}}. Here is an example:
\begin{maplelist}
\item \mf{T:=[1,2,4,8,16,32,64];}
\mo{T:=[1,2,4,8,16,32,64]}
\item \mf{op(T);}
\mo{1,2,4,8,16,32,64}
\item \mf{nops(T);}
\mo{7}
\end{maplelist}
\newpar
The Maple commands \mf{sum}\index{Maple!\mf{sum}} and \mf{add}\index{Maple!\mf{add}} are used to add finite sequences of values together. The first command is used to determine the closed form representation, if one exists, of a sum involving symbolic quantities. The \mf{add} command is used instead to add explicitly a finite sequence of values. The following examples illustrate the commands and their differences:

\begin{maplelist}
\item \mf{sum(r\^{}k,k=0..n);}
\mo{\frac{r^{n+1}}{r-1}-\frac{1}{r-1}}
\item \mf{add(2\^{}k,k=0..5);}
\mo{63}
\end{maplelist}

\section{Matrix Algebra and the \mf{LinearAlgebra} Package}\label{S:Maple_Getting_Started_Linear_Algebra}
\noi
``Packages'' in Maple contain commands that are made available to the user only if the package is loaded into the worksheet.
This is accomplished through typing \mf{with(\emph{package name})} at the command prompt. To load a package without seeing all package
commands, use a colon at the end of the \mf{with} command line; to see all commands listed, use a semicolon. Maple packages used in this text include \mf{LinearAlgebra}, \mf{plots}, \mf{plottools}, \mf{Optimization}, and \mf{VectorCalculus}. To learn about a package's particular command, its uses, and appropriate syntax, type \mf{?\emph{command name}}.

\newpar Maple's \mf{LinearAlgebra} package is capable of performing a wide variety of operations on matrices containing both numeric and symbolic entries. Here the package is loaded in a manner that reveals all its commands:

\begin{maplelist}
\item \mf{restart;}
\item \mf{with(LinearAlgebra);}
\end{maplelist}
%****************************************************************************
$ [Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, \newline
BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, \newline
Column, ColumnDimension, ColumnOperation, ColumnSpace, CompanionMatrix, \newline
ConditionNumber, ConstantMatrix, ConstantVector, Copy, CreatePermutation,\newline
CrossProduct, DeleteColumn, DeleteRow, Determinant, Diagonal, DiagonalMatrix, \newline
Dimension, Dimensions, DotProduct, EigenConditionNumbers, Eigenvalues, \newline
Eigenvectors, Equal, ForwardSubstitute, FrobeniusForm, GaussianElimination, \newline
GenerateMatrix, Generic, GetResultDataType, GetResultShape, \newline
GivensRotationMatrix, HankelMatrix, HermiteForm, HermitianTranspose, \newline
HessenbergForm, HilbertMatrix, HouseholderMatrix, IdentityMatrix, \newline
IntersectionBasis, IsDefinite, IsOrthogonal, IsSimilar, IsUnitary, \newline
JordanBlockMatrix, JordanForm, LA_Main, LUDecomposition, LeastSquares, \newline
LinearSolve, Map, Map2, MatrixAdd, MatrixExponential, MatrixFunction,\newline
MatrixInverse, MatrixMatrixMultiply, MatrixNorm, MatrixPower, \newline
%****************************************************************************
MatrixScalarMultiply,MatrixVectorMultiply, MinimalPolynomial, Minor, Modular, \newline
Multiply, NoUserValue, Norm, Normalize, NullSpace, OuterProductMatrix, \newline
Permanent, Pivot, PopovForm, QRDecomposition, RandomMatrix, RandomVector, \newline
Rank, RationalCanonicalForm, ReducedRowEchelonForm, Row,RowDimension, \newline
RowOperation, RowSpace, ScalarMatrix, ScalarMultiply, ScalarVector, SchurForm, \newline
SingularValues, SmithForm, StronglyConnectedBlocks, SubMatrix, SubVector, \newline
SumBasis, SylvesterMatrix, ToeplitzMatrix, Trace, Transpose, TridiagonalForm, \newline
UnitVector, VandermondeMatrix, VectorAdd, VectorAngle, VectorMatrixMultiply, \newline
VectorNorm, VectorScalarMultiply, ZeroMatrix, ZeroVector, Zip] $

\newpar
Matrices are constructed in two different ways. The first involves
using the \mf{Matrix}\index{Maple!\mf{Matrix}} command, \mf{Matrix(m,n,L)}, where \mf{m} and \mf{n} denote the number of rows and columns, respectively,
and where $L$ is a list of the matrix entries, reading across the rows. For example:

\begin{maplelist}
\item \mf{A:=Matrix(2,3,[1,4,0,2,-3,7]);}
\mo{A=\begin{bmatrix} 1 & 4 & 0 \\ 2 & -3 & 7 \end{bmatrix}}
\end{maplelist}

\noi
A second method for defining a matrix uses column vector notation. A column vector\footnote{Unless specifically stated otherwise, we assume throughout this text that every vector is a column vector.} in $\R^n$ can be entered as \mf{<a1,a2,a3,...,an>},
where \mf{a1,...,an} denote the entries of the vector. Matrices are then formed by adjoining vectors using the
symbols \mf{<}, \mf{|}, and \mf{>}. Here is the preceding matrix $A$ entered in such a manner:
\begin{maplelist}
\item \mf{v1:=<1,2>:}
\item \mf{v2:=<4,-3>:}
\item \mf{v3:=<0,7>:}
\item \mf{A:=<v1|v2|v3>;}
\mo{A=\begin{bmatrix} 1 & 4 & 0 \\ 2 & -3 & 7 \end{bmatrix}}
\end{maplelist}

\noi To ``stack'' vectors vertically, as opposed to aligning them in column vector
form, replace each \mf{|} separating two
entries with a comma instead:

\begin{maplelist}
\item \mf{v1:=<1,2>:}
\item \mf{v2:=<4,-3>:}
\item \mf{v3:=<0,7>:}
\item \mf{A:=<v1,v2,v3>;}
\mo{A=\begin{bmatrix} 1 \\ 2 \\ 4 \\ -3 \\ 0 \\ 7 \end{bmatrix}}
\end{maplelist}

\noi
Once matrices are entered into Maple, various operations can be performed on them. To multiply matrices \mf{A} and \mf{B} use a period. A scalar multiplied by a matrix still requires the asterisk, however. The following worksheet illustrates the use of several \mf{LinearAlgebra}\index{Maple!\mf{Linear Algebra} package commands} package commands:

\begin{maplelist}
\item \mf{restart;}
\item  \mf{with(LinearAlgebra): \# Load Linear Algebra Package.}
\item \mf{v1:=<1,2,3>: v2:=<1,1,1>: v3:=<-1,1,3>: \# Define three 
\newline vectors, v1, v2, and v2.}
\item \mf{A:=<v1|v2|v3>; \# Create a matrix A having v1, v2, and v3 
\newline as columns.}
\mo{A:=\begin{bmatrix} 1 & 1 & -1 \\ 2 & 1 & 1 \\ 3 & 1 & 3 \end{bmatrix}}
\item \mf{RowOperation(A, [1, 3], 2); \# Replace the first row of A with the sum of the first row
and twice the third row.}
\mo{\begin{bmatrix} 7 & 3 &  5 \\ 2 & 1 & 1 \\ 3 & 1 & 3 \end{bmatrix}}

\item \mf{B:=Matrix(3,3,[1,1,2,2,4,-3,3,6,-5]): \# Define a 3 by 3 matrix B using the Matrix command.}
\item \mf{A.B; \# Compute the product matrix AB.}
\mo{\begin{bmatrix} 0 & -1 & 4 \\ 7 & 12 & -4 \\ 14 & 25 & -12 \end{bmatrix}}
\item \mf{2*A+IdentityMatrix(3); \# Compute the sum of 2*A and the 3 by 3 identity matrix.}
\mo{\begin{bmatrix} 3 & 2 & -2 \\ 4 & 3 & 2 \\ 6 & 2 & 7 \end{bmatrix}}

\item \mf{x := Vector[row]([1, 2, 3]); \# Define a row vector x.}
\mo{[1,2,3]}
\item \mf{x.A; \# Compute the vector-matrix product xA.}
\mo{[14,6,10]}
\item \mf{Transpose(A); \# Compute transpose matrix of A.}
\mo{\begin{bmatrix} 1 & 2 & 3 \\ 1 & 1 & 1 \\ -1 & 1 & 3 \end{bmatrix}}
\item \mf{ReducedRowEchelonForm(A); \# Compute reduced row echelon form of A.}
\mo{\begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & -3 \\ 0 & 0 & 0 \end{bmatrix}}
\item \mf{b:=<2,1,0>; \# Define a vector b.}
\mo{b:= \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix}}

\item \mf{LinearSolve(A,b,free=t); \# Solve the matrix equation Ax=b, 
\newline specifying any free variables be labeled using t with 
\newline appropriate subscripts.}
\mo{\begin{bmatrix} -1-2t_3 \\ 3+3t_3 \\ t_3 \end{bmatrix}}

\item \mf{b:=<b1,b2,b3>: \# Define a new vector b having variable entries.}
\item \mf{M:=<A|b>; \# Define the matrix M by augmenting A with b.}
\mo{M:=\begin{bmatrix} 1 & 1 & -1 & b1 \\  2 & 1 & 1 & b2 \\ 3 & 1 & 3 & b3 \end{bmatrix}}
\item \mf{GaussianElimination(M); \# Compute the row echelon form of M.}
\mo{ \begin{bmatrix} 1 & 1 & -1 & b1 \\  0 & -1 & 3 & b2-2b1 \\ 0 & 0 & 0 & b3+b1-2b2 \end{bmatrix}}
\item \mf{Determinant(B); \# Compute the determinant of B.}
\mo{-1}
\item \mf{MatrixInverse(B); \# Compute inverse matrix of B.}
\mo{\begin{bmatrix} 2 & -17 & 11 \\ -1 & 11 &-7 \\ 0 & 3 & -2 \end{bmatrix}}
\end{maplelist}

\newpar
A word of warning is in order regarding Maple's row operation conventions. The \mf{ReducedRowEchelon} command calculates
the reduced row echelon form of a matrix. However, if the matrix contains variable entries, Maple will perform row operations that
may include dividing by variable expressions, ignoring the fact that such expressions could be zero. For example, when
\mf{GaussianElimination(M)} is replaced by \mf{ReducedRowEchelonForm(M)} in the preceding worksheet, the
output changes to
\mo{ \begin{bmatrix} 1 & 0 & 2 & 0 \\  0 & 1 & -3 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}}

\noi
This output reflects Maple's assumption that  the expression $\ds b3+b1-2b2$ is nonzero.

\newpar
Finally, we point out two common issues that frequently arise in the context of arrays and matrices. First, for large arrays and matrices, Maple returns output in summary format. For example, an
 11-by-2 matrix $A$ is displayed as
\mo{A:=\begin{bmatrix} 11 \times 2 \mbox{ Matrix} \\ \mbox{Data Type: anything} \\
\mbox{Storage: rectangular} \\ \mbox{Fortran\_order} \end{bmatrix}
}

\noi
To view the actual contents of the matrix, select the output, right-click, and select ``Browse.'' Actual entries are displayed in table format, which can then be displayed in the worksheet and even exported to Excel. Second, Maple is capable of converting various data types from one form to another. Typical conversions used throughout this text include those converting arrays to matrices and vice versa. For example, \mf{convert(A,Matrix)} converts an array, \mf{A}, to a Matrix type, thereby permitting the use of matrix operations. The command \mf{convert(B,array)} converts a Matrix object, \mf{B}, to an array. A second frequently used conversion will be that from a list to a vector (or vice versa). For example, \mf{convert(L,Vector)} converts a list, \mf{L}, to a Vector. For a thorough list of data types and permissible conversions, type \mf{?convert} at the command prompt.


\section{Plot Structures with Maple}\label{S:Maple_Getting_Started_Plot_Structures}

\noi Maple is very versatile in its ability to create plots of different types. In this section we focus on four of these: functions and expressions, relations, regions defined by inequalities, and point plots.

\newpar
\textbf{Plotting Functions and Expressions}

\noi
To plot a function of one variable, use the command \mf{plot(\emph{function},\emph{interval}, \emph{options})}\index{Maple!\mf{plot}}; for a function of
two variables, use \mf{plot3d(\emph{function},\emph{domain}, \emph{options})} instead\index{Maple!\mf{plot3d}}. In each of these commands, the function should be given in expression form. For a function, \mf{f} of the variable, \mf{x}, this expression is \mf{f(x)}, and for the function \mf{f} of two variables, \mf{x1} and \mf{x2}, it is \mf{f(x1,x2)}. In the former case, the plot interval takes
the form \mf{x=a..b}, where \mf{a} and \mf{b} are real numbers with \mf{a} $<$ \mf{b}. For the function of two variables,
the domain is expressed as a sequence of two intervals. Options can control plot color, range of output values, axes labeling, and numerous other plot features. For a complete list of options, type either \mf{?plot[options]} or \mf{?plot3d[options]} at the command prompt. Here are two examples, which illustrate both the \mf{plot} and \mf{plot3d} commands and a few commonly used options:

\begin{maplelist}
\item \mf{restart;}
\item \mf{f:=x->x+sin(x);}
\mo{f:=x \rightarrow x+\sin(x)}
\item \mf{plot(f(x),x=0..2*Pi,y=0..6,color=blue);
\newline \#plot function in blue on interval [0,2*Pi], restricting 
\newline output values to the interval [0,6].}
\end{maplelist}

\noi The output is shown in Figure \ref{Fi:a01x01x01}.

\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{images/a01x01x01.eps}
\caption{Sample plot of a function of one variable.}
\label{Fi:a01x01x01}
\end{figure}

\begin{maplelist}
\item \mf{g:=(x1,x2)->x1*exp(-x1 \^{}2 -x2 \^{}2);}
\mo{g:=(x1,x2) \rightarrow x_1e^{-x_1^2-x_2^2}}
\item \mf{plot3d(g(x1,x2), x1=-2..2,x2=-2..2,color=red,
\newline style=wireframe,axes=framed);
\newline \#plot function in red on specified rectangle using the \newline wireframe style and a framed set of axes.}
\end{maplelist}

\noi The output is shown in Figure \ref{Fi:a01x01x02}.

\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{images/a01x01x02.eps}
\caption{Sample plot of a function of two variables.}
\label{Fi:a01x01x02}
\end{figure}


\newpar
To plot more than one function or expression on a single set of axes, enter the functions and/or expressions as a list within
the plot command. Colors can be specified using a list in which each color matches the corresponding function or expression entry. Here is an example, in which the functions $f(x)=x+\sin(x)$, $y=x-1$, and $y=x+1$ are plotted on a single set of axes, in black, blue
and red, respectively:

\begin{maplelist}
\item \mf{plot([f(x),x-1,x+1],x=0..2*Pi,y=0..6,color=[black,blue,red]);
\newline \# f, x-1, and x+1 are plotted black, blue, and red,
\newline respectively.}
\end{maplelist}

\noi The output is shown in Figure \ref{Fi:a01x01x03}.

\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{images/a01x01x03.eps}
\caption{Sample plot of three functions of a single variable.}
\label{Fi:a01x01x03}
\end{figure}


\newpar
\textbf{Relations and Other Important Plot Structures}

\noi
Plot structures for functions are the simplest, but Maple is capable of producing numerous
other types as well. Here we illustrate three examples, all of which require the \mf{plots} package.

\newpar
The first uses the \mf{implicitplot}\index{Maple!\mf{implicitplot}} command to plot the
relation $x=y^3-y$.
\begin{maplelist}
\item \mf{restart;}
\item \mf{with(plots):}
\item \mf{implicitplot(x=y\^{}3-y, x=-4..4,y=-4..4,color=blue, 
\newline grid=[50,50]);
\newline \# Plot relation in blue on given rectangle;
\newline the rectangle is divided horizontally and vertically
\newline  into a 50 by 50 grid in order to improve resolution .}
\end{maplelist}

\noi The output is shown in Figure \ref{Fi:a01x01x04}.

\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{images/a01x01x04.eps}
\caption{Example of a plotted relation.}
\label{Fi:a01x01x04}
\end{figure}

\newpar
The \mf{pointplot}\index{Maple!\mf{pointplot}} command plots a list of data points in $\R^2$, with each data point itself expressed as a list of two numbers.
\begin{maplelist}
\item \mf{restart;}
\item \mf{with(plots):}
\item \mf{L:=[[1,2],[1,1],[0,.5],[-1,-1]];}
\mo{L:=[[1,2],[1,1],[0,.5],[-1,-1]]}
\item \mf{pointplot(L,color=blue,symbol=circle,symbolsize=20);
\newline \# Plot points as blue circles using specified size.}
\end{maplelist}

\noi The output is shown in Figure \ref{Fi:a01x01x05}.

\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{images/a01x01x05.eps}
\caption{Example of plotted points.}
\label{Fi:a01x01x05}
\end{figure}

\newpar
To plot points in $\R^3$, one merely uses the \mf{pointplot3d}\index{Maple!\mf{pointplot3d}} command instead, where each point in the list \mf{L} is
expressed as a
list of three numbers.

\newpar
Finally, the \mf{inequal}\index{Maple!\mf{inequal}} command is extremely useful for graphing regions in the $\R^2$ that satisfy a list of linear inequalities. Here is an example, which shades the region bounded by
$x1 \leq 2$, $x2 \geq 1$, $x1+x2 \leq 4$, and $x1-x2 \geq -2$.

\begin{maplelist}
\item \mf{restart;}
\item \mf{with(plots):}
\item \mf{inequal([x1<=2,x2>=1,x1+x2<=4,x1-x2>=-2],x1=-3..3,x2=0..5,
    \newline optionsfeasible=(color=grey),
    \newline optionsexcluded=(color=white),
    \newline optionsclosed=(color=black));
    \newline \# Shade in grey the region of points satisfying all
    \newline \# inequalities in the list. The exterior and boundary
    \newline \# of the region are colored white and black, respectively.}
\end{maplelist}

\noi The output is shown in Figure \ref{Fi:a01x01x06}.

\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{images/a01x01x06.eps}
\caption{Plot of region satisfying list of linear inequalities.}
\label{Fi:a01x01x06}
\end{figure}


\newpar
\textbf{Superimposing Plots}

\noi
One of the most useful Maple tools for combining plot structures is the \mf{display}\index{Maple!\mf{display}} command, which is located
in the \mf{plots} package. It allows one to superimpose a list of plot structures, all of whose members
are plot structures in one of $\R^2$ or in $\R^3$. The general procedure for accomplishing this task first requires creating the individual plot structures themselves (e.g., \mf{plot}, \mf{implicitplot}, \mf{pointplot}, etc.) as discussed previously. However,
each plot structure is assigned a name and the command line performing the assignment ends with a colon so as to suppress output.
Once the structures are all created in this manner, a list is formed using their respective names, and this list is used as the argument for the \mf{display} command. Here is an example, which superimposes results from the preceding \mf{pointplot} and
\mf{inequal} commands.
\begin{maplelist}
\item \mf{restart;}
\item \mf{with(plots):}
\item \mf{L:=[[1,2],[1,1],[0,.5],[-1,-1]];}
\mo{L:=[[1,2],[1,1],[0,.5],[-1,-1]]}
\item \mf{G1:=pointplot(L,color=blue,symbol=circle,symbolsize=20):}
\item \mf{G2:=inequal([x1<=2,x2>=1,x1+x2<=4,x1-x2>=-2],x1=-3..3,
\newline x2=0..5,optionsfeasible=(color=grey),optionsexcluded
\newline =(color=white),optionsclosed=(color=black)): }
\item \mf{display([G1,G2]);}
\end{maplelist}

\noi The output is shown in Figure \ref{Fi:a01x01x07}.

\begin{figure}[h]
\centering
\includegraphics[width=.7\linewidth]{images/a01x01x07.eps}
\caption{Superposition of two plot structures.}
\label{Fi:a01x01x07}
\end{figure}

\endinput
