{VERSION 5 0 "IBM INTEL NT" "5.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0
1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0
0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }
{CSTYLE "" -1 256 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1
257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 258 "" 0 1 0 0
0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Tim
es" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }
{PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1
2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Title" -1 18 1
{CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }3 1 0 0 12
12 1 0 1 0 2 2 19 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times
" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }}
{SECT 0 {PARA 18 "" 0 "" {TEXT -1 20 "Programming in Maple" }}{PARA
256 "" 0 "" {TEXT -1 97 "Roger Kraft\nDepartment of Mathematics, Compu
ter Science, and Statistics\nPurdue University Calumet" }}{PARA 256 "
" 0 "" {TEXT -1 24 "roger@calumet.purdue.edu" }}{PARA 0 "" 0 "" {TEXT
-1 0 "" }}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 16 "1.1 Introduction" }}
{PARA 0 "" 0 "" {TEXT -1 690 "Functions play a major role in Mathemati
cs so it is important to know how to work with them in Maple. Understa
nding functions in Maple is also a good starting point for our discuss
ions about Maple programming. There are two distinct ways to represent
mathematical functions in Maple. We can represent a mathematical func
tion using either an \"expression\" or a \"Maple function\". The disti
nction that Maple makes between \"expressions\" and \"functions\" has \+
its roots in both mathematics and programming. Making this distinction
, and learning to understand it and work with it, will help introduce \+
us to several programming concepts, most notably the idea of a \"data \+
structure\" and a \"procedure\"." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 0 "" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 29 "1.2. Functions in Ma
thematics" }}{PARA 0 "" 0 "" {TEXT -1 679 "We quickly review here the \+
definition of a mathematical function. A function is three things bund
led together. It is a set of inputs (the domain), a set of outputs (th
e codomain), and a rule for associating one of the outputs to each of \+
the inputs. Functions can be defined in several ways, for example by f
ormulas, by tables, and by graphs. Most of the time in mathematics, th
e sets of inputs and outputs are sets of numbers. For most people, the
\"rule\" part of a function's definition seems the most important, bu
t that is not really a good way to think about functions. To demonstr
ate that a mathematical function is really more than just its rule, le
t us look at an example." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "
" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 250 "We \+
shall define three different functions named f, g, and h. The rule for
each of these functions will be given by a formula. In fact we will u
se the same formula in all three cases. What will make the three funct
ions different will be their domains." }}{PARA 0 "" 0 "" {TEXT -1 0 "
" }}{PARA 0 "" 0 "" {TEXT -1 154 "The function f has as its domain th
e set of all real numbers, its codomain is the set of all positive rea
l numbers, and its rule is given by the formula " }{XPPEDIT 18 0 "f(x)
= x^2;" "6#/-%\"fG6#%\"xG*$F'\"\"#" }{TEXT -1 1 "." }}{PARA 0 "" 0 "
" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 163 "The function g has as
its domain the set of all positive real numbers, its codomain is the \+
set of all positive real numbers, and its rule is given by the formula
" }{XPPEDIT 18 0 "g(x) = x^2;" "6#/-%\"gG6#%\"xG*$F'\"\"#" }{TEXT -1
1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 163 "
The function h has as its domain the set of all negative real numbers
, its codomain is the set of all positive real numbers, and its rule i
s given by the formula " }{XPPEDIT 18 0 "h(x) = x^2;" "6#/-%\"hG6#%\"x
G*$F'\"\"#" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0
"" 0 "" {TEXT 257 8 "Exercise" }{TEXT -1 52 ": Draw graphs for each of
the functions f, g, and h." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 309 "
How do we know that these three functions are different? The answer is
that they have different properties. For example, the function f is n
ot invertible (why?). The functions g and h are both invertible (why?)
but they have different inverses. The inverse of the function g has i
ts rule given by the formula " }{XPPEDIT 18 0 "(g^(-1))(x) = sqrt(x);
" "6#/-)%\"gG,$\"\"\"!\"\"6#%\"xG-%%sqrtG6#F+" }{TEXT -1 66 ". The inv
erse of the function h has its rule given by the formula " }{XPPEDIT
18 0 "(h^(-1))(x) = -sqrt(x);" "6#/-)%\"hG,$\"\"\"!\"\"6#%\"xG,$-%%sqr
tG6#F+F)" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "
" 0 "" {TEXT -1 73 "So f, g, and h all have the exact same formula (i.
e., rule) but they are " }{TEXT 256 3 "not" }{TEXT -1 118 " the same f
unction. The domain (and codomain) really are important parts of the d
efinition of a mathematical function." }}{PARA 0 "" 0 "" {TEXT -1 0 "
" }}{PARA 0 "" 0 "" {TEXT 258 8 "Exercise" }{TEXT -1 46 ": What is the
domain and codomain for each of " }{XPPEDIT 18 0 "g^(-1);" "6#)%\"gG,
$\"\"\"!\"\"" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "h^(-1);" "6#)%\"hG,$
\"\"\"!\"\"" }{TEXT -1 1 "?" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 0 "" }}}}}{MARK "4 2 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1
1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }