%% This document created by Scientific Notebook (R) Version 3.0


\documentclass[12pt,thmsa]{article}
\usepackage{amssymb}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{makeidx}
\usepackage{sw20jart}

%TCIDATA{TCIstyle=article/art4.lat,jart,sw20jart}

%TCIDATA{<META NAME="ViewSettings" CONTENT="31">}
%TCIDATA{<META NAME="GraphicsSave" CONTENT="32">}
%TCIDATA{<META NAME="Title" CONTENT="Accessing Maple Functions">}
%TCIDATA{Created=Mon Aug 19 14:52:24 1996}
%TCIDATA{LastRevised=Thu Feb 13 17:01:40 1997}
%TCIDATA{Language=American English}
%TCIDATA{CSTFile=MathHelp.cst}
%TCIDATA{<LINK REL="first" HREF="DM5-1.tex">}
%TCIDATA{<LINK REL="contents" HREF="DM0-0.tex">}
%TCIDATA{<LINK REL="end" HREF="DM5-7.tex">}
%TCIDATA{<LINK REL="next" HREF="DM5-6.tex">}
%TCIDATA{<LINK REL="parent" HREF="DM5.tex">}
%TCIDATA{<LINK REL="previous" HREF="DM5-4.tex">}
%TCIDATA{<LINK REL="top" HREF="DM0-0.tex">}

\input{tcilatex}
\begin{document}


\section{Accessing\label{Maple functions} Maple Functions}

You can access Maple functions that are not supported directly in \textsl{%
Scientific Notebook}.

\begin{quote}
$\blacktriangleright $ To access the Maple function \texttt{pivot} and to
name it $P$
\end{quote}

\begin{enumerate}
\item[1.]  From the \textsf{Define} submenu, choose \textsf{Define Maple Name%
}.

\item[2.]  Respond to the dialog box as follows.

\begin{itemize}
\item  \textsf{Maple Name}: pivot(x,i,\thinspace j)

\item  \textsf{Scientific Word Name}: $P(x,i,j)$

\item  \textsf{File}: (Leave blank.)

\item  \textsf{Packages}: (Check \textsf{Linear Algebra Library}.)
\end{itemize}

\item[3.]  Check \textsf{OK}.
\end{enumerate}

This procedure defines in \textsl{Scientific Notebook} a function $P(x,i,j)$
that performs a pivot on the $i,j$ entry of a matrix $x$.

\begin{example}
Define $x=\left[ 
\begin{array}{cccc}
-85 & -55 & -37 & -35 \\ 
97 & 50 & 79 & 56 \\ 
49 & 63 & 57 & -59
\end{array}
\right] $. Define $P(x,i,j)=$ \texttt{pivot(x,i,j)} as described above.
Then, evaluate $P(x,2,2)$ to get 
\[
P(x,2,2)=\left[ 
\begin{array}{cccc}
\frac{217}{10} & 0 & \frac{499}{10} & \frac{133}{5} \\ 
\stackrel{}{97} & \stackunder{}{50} & 79 & 56 \\ 
-\frac{3661}{50} & 0 & -\frac{2127}{50} & -\frac{3239}{25}
\end{array}
\right] 
\]
\end{example}

\strut

An extensive Maple library is included with \textsl{Scientific Notebook}.
Here is a short list from the many examples that are available using the 
\textsf{Define Maple Name} dialog.

\begin{center}
\begin{tabular}{l|l|l}
Maple Name & Sample \textsl{SNB}\QTR{BookName}{\ }Name & Maple Packages
Needed \\ \hline\hline
\QTR{UserInput}{Heaviside(x)} & $H(x)$ & none \\ 
\QTR{UserInput}{nextprime(x)} & $p(n)$ & none \\ 
\QTR{UserInput}{isprime(n)} & $q(n)$ & none \\ 
\QTR{UserInput}{phi(n)} & $\varphi (n)$ & numtheory \\ 
\QTR{UserInput}{legendre(a,b)} & $L(a,b)$ & numtheory \\ 
\QTR{UserInput}{galois(f)} & $g(f)$ & none \\ 
\QTR{UserInput}{interp(x,y,v)} & $P(x,y,v)$ & none \\ 
\QTR{UserInput}{Psi(x)} & $\psi (x)$ & none \\ 
\QTR{UserInput}{resultant(a,b,x)} & $r(a,b,x)$ & none \\ 
\QTR{UserInput}{finduni(x,F)} & $u(x,F)$ & grobner \\ 
\QTR{UserInput}{gbasis(F,X)} & $G(F,X)$ & grobner
\end{tabular}

\strut
\end{center}

\textsl{Scientific Notebook }supports multiple notations for vectors,
including row or column matrices, or $n$-tuples enclosed by either
parentheses or square brackets. However, to work with a Maple-defined
function, you must use appropriate Maple syntax for the function arguments.
For example, \texttt{gbasis} from the Grobner library accepts a list entered
with square brackets, such as $[a,b,c,d]$, or a set entered with curly
braces, such as $\{x^{2}+3x,5xy\}$\QTR{UserInput}{.}

\strut

\begin{example}
Use \textsf{Define + Define Maple Name} to define a \textsl{Scientific
Notebook} function $G(X,Y)$ from the Maple function \QTR{UserInput}{%
gbasis(X,Y)} in the Grobner library. Apply \textsf{Evaluate} to get each of
the following. 
\[
\begin{array}{l}
G([X+1,Y+1,XY+Z],[X,Y,Z])=\left[ Y+1,1+Z,X+1\right] \\ 
G([Y^{2}Z+1,X^{2}+Y^{2},XZ^{2}+1],[X,Y,Z])=\left[
Z+X,Y^{2}+Z^{2},-1+Z^{3}\right] \\ 
G([Y^{2}Z+1,X^{2}+Y^{2},XZ^{2}+1],[Z,Y,X])=\left[
X^{2}+Y^{2},Z+X,1+X^{3}\right] \\ 
G(\left\{ Y^{2}Z+1,X^{2}+Y^{2},XZ^{2}+1\right\} ,[Y,X,Z])=\left[
Z+X,Y^{2}+Z^{2},-1+Z^{3}\right]
\end{array}
\]
\end{example}

Click \hyperref{Generating Large Primes}{}{}{DM12-2.tex#Large primes} for
another example. In that section, the Maple function \texttt{nextprime} is
given a \textsf{Scientific Notebook} name.\medskip

Maple functions defined in this way can be saved with and restored to a
document with \textsf{Save Definitions} and \textsf{Restore Definitions} as 
\index{Define@Define!restore definitions@restore definitions}\label%
{Define, restore definitions (2)}described 
\index{Define@Define!save definitions@save definitions}\label%
{Define, save definitions (2)}previously for \textsl{Scientific Notebook}%
-defined functions (click 
\hyperref{here}{}{}{DM5-3.tex#Saving definitions}). These functions, with
their Maple name correspondences, appear in the \textsf{Show Definitions}
window but they are \emph{not} removed by \textsf{Clear Definitions}. 
\index{Define@Define!clear definitions@clear definitions}\label%
{Define, clear definitions (2)}To remove a Maple function, select the 
\textsl{Scientific Notebook} name for the function and choose \textsf{Maple +%
} \textsf{Define + Undefine.}

The guidelines for 
\hyperref{valid function and expression names}{}{}{DM5-1.tex#Function name}
apply to the \textsl{Scientific Notebook} names that can be entered in the 
\textsf{Define Maple Name} dialog box. You can give a multicharacter name to
a Maple function as follows. With the \textsf{Define Maple Name} dialog box
open and the insertion point in the \textsf{Scientific WorkPlace Name} box,
click the \textsf{Math Name} icon \FRAME{itbpF}{0.3009in}{0.3009in}{0.0701in%
}{}{}{function.wmf}{\special{language "Scientific Word";type
"GRAPHIC";display "PICT";valid-file "F";width 0.3009in;height 0.3009in;depth
0.0701in;original-width 17.8125pt;original-height 16.9375pt;cropleft
"0";croptop "1";cropright "1";cropbottom "0";filename
'FUNCTION.WMF';file-properties "XNPEU";}}, enter the desired function name,
and click \textsf{OK}.

\strut

\section{Adding\label{User-defined functions} User-Defined Maple Functions}

You can access 
\index{User-defined functions}user-defined functions written in the Maple
language. 
\index{Define!Maple name}\label{Define, Maple name} While in a Maple
session, save the function to a file \emph{filename.m}. While in a \textsl{%
Scientific Notebook} document, from the \textsf{Define} submenu, choose 
\textsf{Define Maple Name}.

To access the function ``myfunc'' and name it ``$M$,'' respond to the dialog
box as follows.

\begin{itemize}
\item  \textsf{Maple Name:} myfunc(x)

\item  \textsf{Scientific Word Name:} $M(x)$

\item  \textsf{File:} /dirname/subdirname/myfunc.m

\item  \textsf{Packages:} (Check the name of all pertinent Maple libraries.
Leave blank if nothing special is called for.)
\end{itemize}

Note the forward slashes in the subdirectory specification for the location
of the \texttt{.m} file. This syntax must be closely followed. It will be
read in Maple as

\begin{itemize}
\item  \texttt{read `/dirname/subdirname/myfunc.m`;}
\end{itemize}

This procedure defines in \textsl{Scientific Notebook} a function $M(x)$
that behaves according to your Maple program. The guidelines at the
beginning of this appendix for valid function and expression names apply to
the \textsl{Scientific Notebook} names that can be entered in the \textsf{%
Define Maple Name} dialog box.

Maple functions accessed through the \textsf{Define Maple Name} dialog can
be saved with and restored to a document with \textsf{Save Definitions} and 
\textsf{Restore Definitions}, as described earlier for \textsl{Scientific
Notebook}--defined functions. The Maple functions accessed through the 
\textsf{Define Maple Name} dialog appear in the \textsf{Show Definitions}
window, but they are\emph{\ not} removed by \textsf{Clear Definitions}. To
remove such a Maple function, select the \textsl{Scientific Notebook} name
for the function and choose \textsf{Maple +} \textsf{Define + Undefine.}\
\smallskip

\subsection{\ Related topics}

\begin{itemize}
\item  
\hyperref{Function and Expression Names}{}{}{DM5-1.tex#Function name}

\item  \hyperref{Defining Variables and Functions }{}{}{DM5-2.tex#Define}

\item  \hyperref{Tables of Maple/Scientific Notebook Equivalents}{}{}{%
DM5-6.tex#Constants}

\item  \hyperref{Exercises and Solutions}{}{}{DM5-7.tex#Exercises}
\end{itemize}

\rule{0.67in}{0.01in}

\hyperref{\FRAME{itbpF}{38.875pt}{24.5pt}{6pt}{}{}{index.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";maintain-aspect-ratio
TRUE;display "PICT";valid-file "F";width 38.875pt;height 24.5pt;depth
6pt;original-width 36.125pt;original-height 22.5625pt;cropleft "0";croptop
"1";cropright "1";cropbottom "0";filename 'index.wmf';file-properties
"XNPEU";}}}{}{}{DMIndex.tex#Math Index}\quad {\small Index entries: 
\hyperref{Accessing maple functions}{}{}{DMIndex.tex#Accessing maple
functions}, \hyperref{Define}{}{}{DMIndex.tex#Define}, \hyperref{Maple
settings}{}{}{DMIndex.tex#Maple settings}, \hyperref{Restoring definitions}{%
}{}{DMIndex.tex#Restoring definitions}, \hyperref{Saving definitions}{}{}{%
DMIndex.tex#Saving definitions}}

\end{document}
