%% 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="Defining Variables and Functions">}
%TCIDATA{Created=Mon Aug 19 14:52:24 1996}
%TCIDATA{LastRevised=Thu Feb 13 17:15:23 1997}
%TCIDATA{Language=American English}
%TCIDATA{CSTFile=MathHelp.cst}
%TCIDATA{<LINK REL="author" HREF="DM0-1.tex">}
%TCIDATA{<LINK REL="first" HREF="DM5-1.tex">}
%TCIDATA{<LINK REL="contents" HREF="DM0-0.tex">}
%TCIDATA{<LINK REL="copyright" HREF="DM0-2.tex">}
%TCIDATA{<LINK REL="end" HREF="DM5-6.tex">}
%TCIDATA{<LINK REL="index" HREF="DMIndex.tex">}
%TCIDATA{<LINK REL="next" HREF="DM5-3.tex">}
%TCIDATA{<LINK REL="parent" HREF="DM5.tex">}
%TCIDATA{<LINK REL="previous" HREF="DM5-1.tex">}
%TCIDATA{<LINK REL="top" HREF="DM0-0.tex">}
%TCIDATA{MapleDefs=
%$g \left( t\right) =\left\{ \MATRIX{3,5}{c}\VR{,,c,,,}{,,c,,,}{,,c,,,}{,,c,,,}\HR{,,,,,}\CELL{t}\CELL{if}\CELL{t<0}\CELL{0}\CELL{if}\CELL{0\leq t<1}\CELL{1}\CELL{if}\CELL{1\leq t<2}\CELL{2}\CELL{if}\CELL{2\leq t<3}\CELL{6-t}\CELL{if}\CELL{3\leq t}\right. \allowbreak  $
%$z:=25a $
%$x:=a^{2} $
%$y=a^{2} $
%$a=6 $
%}


\input{tcilatex}
\begin{document}


\section{Defining\label{Define} Variables and Functions}

When you choose \textsf{Define} on the Maple menu, the submenu that comes up
has seven items: \textsf{New Definition, Undefine, Show Definitions, Clear
Definitions, Save Definitions,} \textsf{Restore Definitions, }and\textsf{\
Define Maple Name. }The choice \textsf{New Definition} can be applied both
for defining functions and for naming expressions.

\subsection{\ Assigning Values to Variables, or Naming Expressions\label%
{Deferred evaluation}}

You can assign a value to a \emph{variable} with \textsf{Define + New
Definition}. 
\index{Define@Define!variable@variable}\label{Define, variable (2)}There are
two options for the behavior of the defined variable. The default behavior
is ``deferred evaluation,'' meaning the definition is stored exactly as you
make it. The alternate behavior is ``full evaluation,'' meaning the
definition that is stored takes into account earlier definitions in force
that might affect it. See the section 
\hyperref{full evaluation}{}{}{Full evaluation} for a discussion of this
option.

\begin{quote}
$\blacktriangleright $ To assign the value $25$ to $z$
\end{quote}

\begin{enumerate}
\item[1.]  Type $z=25$ in mathematics.

\item[2.]  Leave the insertion point in the equation.

\item[3.]  Click the \textsf{New Definition} button \FRAME{itbpF}{0.3009in}{%
0.3009in}{0.0701in}{}{}{newdef.wmf}{\special{language "Scientific Word";type
"GRAPHIC";display "PICT";valid_file "F";width 0.3009in;height 0.3009in;depth
0.0701in;original-width 19.5625pt;original-height 18.8125pt;cropleft
"0";croptop "1";cropright "1";cropbottom "0";filename
'NEWDEF.WMF';file-properties "XNPEU";}} on the \textsf{Compute} toolbar or,
from the \textsf{Define} submenu, 
\index{New definition@New definition}\label{New definition (2)} \label%
{Define, new definition}choose \textsf{New Definition}.
\end{enumerate}

Thereafter, until you exit the document\textsl{\ }or undefine the variable,
the system recognizes $z$ as $25$. For example, evaluating the expression ``$%
3+z$'' returns ``$=\,28$.''

Another way to describe this operation is to say that an expression such as $%
x^{2}+\sin x$ can be given a name. Enter $y=x^{2}+\sin x$, leave the
insertion point anywhere in the expression, and then from the \textsf{Define}
submenu\textsf{\ }choose \textsf{New Definition}. Now, whenever you operate
on an expression containing $y$, every occurrence of $y$ is replaced by the
expression $x^{2}+\sin x$. For example, \textsf{Evaluate} applied to $%
y^{2}+x^{3}\ $produces 
\[
y^{2}+x^{3}=(x^{2}+\sin x)^{2}+x^{3} 
\]
Note that these \emph{variables} or \emph{names} are single characters.
Click on 
\hyperref{Custom Names}{}{}{DM5-1.tex#Custom Names} for information on
multicharacter names.

The \emph{value assigned} can be any mathematical expression. For example,
you could define a variable to be

\begin{itemize}
\item  A number: $a=245$

\item  A polynomial: $p=x^{3}-5x+1$

\item  A quotient of polynomials: $b=\dfrac{x^{2}-1}{x^{2}+1}$

\item  A matrix: $z=\left[ 
\begin{array}{cc}
a & b \\ 
c & d
\end{array}
\right] $

\item  An integral: $d=\ \int x^{2}\sin xdx$
\end{itemize}

You will find this feature useful for a variety of purposes.\ 

\begin{quotation}
\emph{Note\quad }The symbol $p$ defined previously represents the \emph{%
expression} $x^{3}-5x+1$. It is \emph{not a function}, so, for example, $%
p(2) $ is not the polynomial evaluated at $2$, but rather is $%
p(2)=2p=\,2x^{3}-10x+2$.
\end{quotation}

\subsubsection{\ Compound Definitions}

It is legitimate to define expressions in terms of other expressions. For
example, you can define $r=3p-cq$ and then $s=nr+q$. Evaluating $s$ will
then give you $s=\allowbreak n\left( 3p-cq\right) +q$. Redefining $r$ will
change the evaluation of $s$.

\vspace{1pt}

\subsubsection{Full Evaluation\label{Full evaluation}}

Will full evaluation, variables previously defined are evaluated before the
definition is stored. Thus, definitions of expressions can depend on the
order in which they are made. Use an equals sign preceded by a colon to make
an assignment for full evaluation.

\begin{quote}
$\blacktriangleright $ To assign the value $25$ to $z$
\end{quote}

\begin{enumerate}
\item[1.]  Type $z:=25a$ in mathematics.

\item[2.]  Leave the insertion point in the equation.

\item[3.]  Click the \textsf{New Definition} button \FRAME{itbpF}{0.3009in}{%
0.3009in}{0.0701in}{}{}{newdef.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
'NEWDEF.WMF';file-properties "XNPEU";}} on the \textsf{Compute} toolbar or,
from the \textsf{Define} submenu, 
\index{New definition@New definition} choose \textsf{New Definition}.
\end{enumerate}

Thereafter, until you exit the document\textsl{\ }or undefine the variable,
if $a$ has not been previously defined, the system recognizes $z$ as $25a$.
If $a$ has previously been defined to be $x+y$, then the system recognizes $%
z $ as $25\left( x+y\right) $\strut $.$ Try the following examples that
contrast the two types of assignments, and look at the list displayed under 
\textsf{Define + Show Definitions} for each case.\bigskip

\begin{example}
Make the assignments $a=1$, $x:=a$, $y=a$, and $a=2$ (in that order), and
evaluate $x$ and $y$. \medskip 
\begin{eqnarray*}
x &=&\allowbreak 1 \\
y &=&2
\end{eqnarray*}
\end{example}

\strut

\begin{example}
Make the assignments $a=b$, $x:=a^{2}$, $y=a^{2}$, and $a=6$ (in that
order), and evaluate $x$ and $y$. \medskip 
\begin{eqnarray*}
x &=&b^{2} \\
y &=&36
\end{eqnarray*}
\end{example}

\strut

\subsection{\ Functions \label{Define, function (2)}of One Variable}

By using function notation, you can use the same general procedure to define
a \emph{function} as was described for defining a variable.

\begin{quote}
$\blacktriangleright $ To define the function $f$ whose value at $x$ is $%
ax^{2}+bx+c$
\end{quote}

\begin{enumerate}
\item[1.]  Enter the equation $f\left( x\right) =ax^{2}+bx+c$.

\item[2.]  Place the insertion point in the equation.

\item[3.]  Click the \textsf{New Definition} button 
\FRAME{itbpF}{0.3009in}{0.3009in}{0.0701in}{}{}{newdef.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 'NEWDEF.WMF';file-properties "XNPEU";}} on the 
\textsf{Compute} toolbar or, from the \textsf{Define} submenu, choose 
\textsf{New Definition}.
\end{enumerate}

Now the symbol $f$ represents the defined function and it behaves like a
function. For example, apply \textsf{Evaluate} to $f(t)$ to get $%
f(t)=at^{2}+bt+c$ and apply \textsf{Evaluate} to $f^{\prime }(t)$ to get $%
f^{\prime }(t)=2at+b$.

\subsubsection{Compound Definitions\label{Algebra of functions}}

If $g$ and $h$ are \emph{previously defined} functions (other than
piecewise-defined functions), then the following equations are examples of
legitimate definitions:

\begin{itemize}
\item  $f(x)=2g(x)$

\item  $f(x)=g(x)+h(x)$

\item  $f(x)=g(x)h(x)$

\item  $f(x)=g(h(x))$

\item  $f(x)=\left( g\circ h\right) (x)$
\end{itemize}

Once you have defined both $g(x)$ and $f(x)=2g(x)$, then changing the
definition of $g(x)$ will redefine $f(x)$.

\strut

\begin{quotation}
\label{Inverse function}\textsl{Note}\emph{\quad }The algebra of functions
includes objects such as $f+g$,$f-g$, $f\circ g$, $fg$, and $f^{-1}$. For
the value of $f+g$ at $x$, write $f(x)+g(x)$; for the value of the
composition of two defined functions $f$ and $g$, write $f(g(x))$ or $\left(
f\circ g\right) \left( x\right) $; and for the value of the product of two
defined functions, write $f(x)g(x)$. You can obtain the inverse (or inverse
relation) for some functions $f(x)$ by applying \textsf{Solve + Exact} to
the equation $f(y)=x$ and specifying $y$ as the \textsf{Variable to Solve for%
}.
\end{quotation}

\strut

\subsection{\ Functions\label{Several variables} of Several Variables}

Define functions of several variables by writing an equation such as $%
f(x,y,z)=ax+y^{2}+2z$ or $g(x,y)=2x+\sin 3xy$, placing the insertion point
in the equation, and choosing \textsf{New\ Definition} from the \textsf{%
Define} submenu. Just as in the case of functions of one variable, the
system always operates on expressions that it obtains from evaluating the
function at a point.\smallskip

\subsection{\ \label{Define, piecewise functions (2)}Piecewise-Defined
Functions}

\textsl{Scientific Notebook\/} allows you 
\index{Define@Define!piecewise functions@piecewise functions}to define
functions that are described by different expressions on different parts of
their domain. You can evaluate, plot, differentiate, and integrate these
functions. 
\index{Piecewise-defined function@Piecewise-defined function}\label%
{Piecewise-defined function (2)} 
\index{Function@Function!piecewise definition@piecewise definition}\label%
{Function, piecewise definition (2)}

\emph{Note that there are strict conditions concerning the piecewise
definition of functions}. They must be specified in a three-column matrix
with at least two rows, with the \emph{functional values} in the first
column, ``if'' or ``$if$'' in the second column, and the \emph{range
condition} in the third column. Also, the matrix must be fenced with a left
brace and no right delimiter, as in the following examples. It is advisable
to enter the range conditions in order of increasing range.

\begin{quote}
$\blacktriangleright $ To form the matrix
\end{quote}

\begin{enumerate}
\item[1.]  From the \textsf{Brackets} 
\FRAME{itbpF}{0.3009in}{0.288in}{0.0701in}{}{}{brackets1.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";display "PICT";valid_file
"F";width 0.3009in;height 0.288in;depth 0.0701in;original-width
20.3125pt;original-height 18.8125pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'brackets1.wmf';file-properties "XNPEU";}}\
list, choose \FRAME{itbpF}{0.2361in}{0.3719in}{0.0701in}{}{}{lbrace.wmf}{%
\special{language "Scientific Word";type "GRAPHIC";display "PICT";valid_file
"F";width 0.2361in;height 0.3719in;depth 0.0701in;original-width
15.0625pt;original-height 24.8125pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'lbrace.wmf';file-properties "XNPEU";}}\ for the
left bracket and the dashed vertical line \FRAME{itbpF}{0.2465in}{0.3719in}{%
0.0899in}{}{}{dashline.wmf}{\special{language "Scientific Word";type
"GRAPHIC";display "PICT";valid_file "F";width 0.2465in;height 0.3719in;depth
0.0899in;original-width 15.8125pt;original-height 24.8125pt;cropleft
"0";croptop "1";cropright "1";cropbottom "0";filename
'DASHLINE.wmf';file-properties "XNPEU";}} for the right bracket. (The dashed
vertical line does not normally appear in the printed document. It appears
on screen as a dashed red line only when \textsf{View + Helper Lines} is
turned on.)

\item[2.]  Click \FRAME{itbpF}{0.3009in}{0.3009in}{0.0701in}{}{}{matrix.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 'Matrix.wmf';file-properties "XNPEU";}} or
choose \textsf{Insert + Matrix}.

\item[3.]  Set the numbers for \textsf{Rows} (number of conditions) and 
\textsf{Columns} (3).

\item[4.]  Click \textsf{OK}.
\end{enumerate}

\strut

Functions should be entered as in the following examples. (When entering
such functions, check \textsf{Helper Lines} on the \textsf{View} submenu, to
see important details.)

\begin{itemize}
\item  $f(x)=\left\{ 
\begin{array}{ccl}
x+2 & \text{if} & x<0 \\ 
2 & \text{if} & 0\leq x\leq 1 \\ 
2/x & \text{if} & 1<x
\end{array}
\right. $

\item  $g(t)=\left\{ 
\begin{array}{ccl}
t & \text{if} & t<0 \\ 
0 & \text{if} & 0\leq t<1 \\ 
1 & \text{if} & 1\leq t<2 \\ 
2 & \text{if} & 2\leq t<3 \\ 
6-t & \text{if} & 3\leq t
\end{array}
\right. $

\item  $h(x)=\left\{ 
\begin{array}{ccc}
x+2 & if & x<1 \\ 
3/x & if & 1\leq x
\end{array}
\right. $
\end{itemize}

\begin{quote}
$\blacktriangleright $ To define a piecewise-defined function
\end{quote}

\begin{enumerate}
\item[1.]  Type the function values in a matrix enclosed in brackets as
described.

\item[2.]  Leave the insertion point in the function definition.

\item[3.]  Click \FRAME{itbpF}{0.3009in}{0.3009in}{0.0701in}{}{}{newdef.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 'NEWDEF.WMF';file-properties "XNPEU";}}\ or,
from the \textsf{Define} submenu, choose \textsf{New Definition}.
\end{enumerate}

You can then choose \textsf{Evaluate} to get results such as $f(-1)=1$, $f(%
\frac{1}{2})=2$, $f(2)=1$, $h(-1)=1$ and \medskip 
\[
f^{\prime }(x)=\left\{ 
\begin{array}{ccl}
x+2 & \text{if} & x<0 \\ 
\func{undefined} & \text{if} & x=0 \\ 
2 & \text{if} & 0<x<1 \\ 
\func{undefined} & \text{if} & x=1 \\ 
2/x & \text{if} & 1<x
\end{array}
\right. 
\]

\strut

\begin{quotation}
\textsl{Note}\quad To operate on piecewise-defined functions, such as to
evaluate, plot, differentiate, or integrate such a function, you can make
the definition and then work with the function name $f$ or the expression $%
f(x)$. You can also place the insertion point in the defining matrix to
carry out such operations.
\end{quotation}

\begin{quote}
$\blacktriangleright $ To plot a piecewise-defined function
\end{quote}

\begin{enumerate}
\item[1.]  Define a function $f(x)$ as described above.

\item[2.]  Select the expression $f(x)$ or $f$ or select the defining matrix.

\item[3.]  Click \FRAME{itbpF}{0.3009in}{0.3009in}{0.0701in}{}{}{2dplot.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 '2dplot.wmf';file-properties "XNPEU";}}\ or
choose \textsf{Plot 2D + Rectangular}.
\end{enumerate}

For piecewise-defined functions that are not continuous, the choices of the
expression $f(x)$ or only the function name $f$, can have different results.
For the function $y=g(x)$ defined above, which is not continuous, you can
plot with or without vertical connecting lines by using either the
expression $g(x)$ or the function name $g$ to generate the plot.

\begin{center}
\FRAME{itbpFU}{2.2684in}{1.5056in}{0in}{\Qcb{$g(x)$}}{}{piecews4.wmf}{%
\special{language "Scientific Word";type "GRAPHIC";display "PICT";valid_file
"F";width 2.2684in;height 1.5056in;depth 0in;original-width
216.8125pt;original-height 144.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'Piecews4.wmf';file-properties "XNPEU";}}\FRAME{%
itbpFU}{2.2684in}{1.5056in}{0in}{\Qcb{$g$}}{}{piecews5.wmf}{\special%
{language "Scientific Word";type "GRAPHIC";display "PICT";valid_file
"F";width 2.2684in;height 1.5056in;depth 0in;original-width
216.8125pt;original-height 144.5625pt;cropleft "0";croptop "1";cropright
"1";cropbottom "0";filename 'Piecews5.wmf';file-properties "XNPEU";}}
\end{center}

\strut \strut

See \hyperref{Plotting Defined Functions}{}{}{DM6-4.tex#Plot
piecewise-defined function} for guidelines to plotting piecewise-defined
functions.

\strut

\subsection{\ Defining Generic Functions \label{Generic functions}}

You can use \textsf{Define + New Definition} to 
\index{Generic functions@Generic functions}declare an expression of the form 
$f(x)$ to be a function without specifying any of the function values or
behavior. Thus you can use the function name as input when defining other
functions or performing various operations on the function.

\begin{quote}
$\blacktriangleright $ \textsf{Define + New Definition}
\end{quote}

\begin{quotation}
$f(x)$

$g(x)=x^{2}-3x$
\end{quotation}

\begin{quote}
$\blacktriangleright $ \textsf{Evaluate}
\end{quote}

\begin{quotation}
$f(g(x))=\allowbreak f\left( x^{2}-3x\right) \medskip $

$g(f(x))=\allowbreak f^{2}\left( x\right) -3f\left( x\right) $
\end{quotation}

\strut

\subsection{\ Defining Generic Constants\label{Generic constants}}

You can use \textsf{Define + New Definition} to 
\index{Generic functions@Generic functions}declare any valid expression name
to be a constant. \textsl{Scientific Notebook} will then ignore such names
when identifying dependent and independent variables.

\begin{quote}
$\blacktriangleright $ \textsf{Define + New Definition}
\end{quote}

\begin{quotation}
$a$
\end{quotation}

\begin{quote}
$\blacktriangleright $ \textsf{Calculus + Implicit Differentiation}
\end{quote}

\begin{quotation}
$axy=\sin y$\quad Derivative: $ay+axy^{\prime }=\left( \cos \left( y\right)
\right) y^{\prime }$
\end{quotation}

\strut

\subsection{\ Related topics}

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

\item  \hyperref{Handling Definitions}{}{}{DM5-3.tex#Definitions}

\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{Define}{}{}{DMIndex.tex#Define}}

\end{document}
