{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 1 0 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 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0
0 0 0 1 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }
{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1
262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 263 "" 0 1 0 0
0 0 1 0 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 ""
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }
{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0
0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1
{CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 0 }3 0 0 -1 12 12
0 0 0 0 0 0 19 0 }{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 58 "1.5. Working with expre
ssions and Maple functions (review)" }}{PARA 0 "" 0 "" {TEXT -1 403 "T
here are many operations that you might want to perform on a function,
for example, graph it, evaluate it, differentiate or integrate it, co
mpose it with another function, etc. How you do these operations in Ma
ple depends on how you choose to represent the function in Maple, as e
ither a Maple expression or as a Maple function. In this section we re
view these ideas by looking at a number of examples." }}{PARA 0 "" 0 "
" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 85 "First, an example of gr
aphing a mathematical function defined as an Maple expression." }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "plot( x^2, x=-5..5 );" }}}
{PARA 0 "" 0 "" {TEXT -1 71 "Now graph the same mathematical function \+
defined as a Maple function. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1
0 22 "plot( x->x^2, -5..5 );" }}}{PARA 0 "" 0 "" {TEXT -1 130 "Notice \+
the subtle difference in the syntax of these two commands. For example
, both of the following Maple commands are incorrect." }}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 19 "plot( x^2, -5..5 );" }}}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 24 "plot( x->x^2, x=-5..5 );" }}}{EXCHG {PARA 0 "
> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0
"" 0 "" {TEXT -1 84 "Let us do an example where we give the functions \+
names. Here is an expression named " }{TEXT 0 1 "f" }{TEXT -1 28 " and
a Maple function named " }{TEXT 0 1 "g" }{TEXT -1 52 " that both repr
esent the same mathematical function." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 18 "f := x^2 - 3*x-10;" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 21 "g := x -> x^2-3*x-10;" }}}{PARA 0 "" 0 "" {TEXT -1
14 "Now plot them." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "plot( \+
f, x=-3..6 );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "plot( g, -
3..6 );" }}}{PARA 0 "" 0 "" {TEXT -1 147 "Notice that both of the foll
owing commands are incorrect. You need to be very careful to distingui
sh between Maple expressions and Maple functions." }}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 17 "plot( f, -3..6 );" }}}{EXCHG {PARA 0 "> " 0 "
" {MPLTEXT 1 0 19 "plot( g, x=-3..6 );" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 ""
{TEXT -1 167 "Let us see why it makes sense that Maple would have a di
fferent syntax for plotting Maple expressions and Maple functions. Sup
pose we give Maple the following command." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 21 "plot( a*x^2, -5..5 );" }}}{PARA 0 "" 0 "" {TEXT -1
513 "We have asked Maple to plot an expression with two variables but \+
we have given Maple only one range. Which of the variables should Mapl
e assign the range to? We have to tell Maple which of the variables th
e range is to be associated with (and the other variable has to be giv
en a value so that it acts like a constant). So when we plot an expres
sion, it makes sense to specify which variable the range is associated
with (even if there might only be one variable). Now suppose we give \+
Maple the following command." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
24 "plot( x->a*x^2, -5..5 );" }}}{PARA 0 "" 0 "" {TEXT -1 376 "The fun
ction being graphed does not have two variables. The arrow notation sp
ecifies that the function has only one variable (and one \"parameter\"
). Since the function only has one variable and there is one range giv
en, it is clear that the range is supposed to be associated with the s
ingle variable. The command is not ambiguous (as long as we make sure \+
that the \"parameter\" " }{TEXT 0 1 "a" }{TEXT -1 50 " has a value). N
ow consider the following command." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 39 "plot3d( (x,a)->a*x^2, -5..5, -10..10 );" }{TEXT -1 0
"" }}}{PARA 0 "" 0 "" {TEXT -1 220 "The arrow notation specifies that \+
the function being graphed is a function of two variables and there ar
e two ranges given in the command. The ranges are associated with the \+
variables in the order they are given, so the " }{TEXT 0 5 "-5..5" }
{TEXT -1 39 " range is associated with the variable " }{TEXT 0 1 "x" }
{TEXT -1 9 " and the " }{TEXT 0 7 "-10..10" }{TEXT -1 26 " range is as
sociated with " }{TEXT 0 1 "a" }{TEXT -1 185 ". Again, there is no amb
iguity about the variables, so there is no need when plotting a functi
on to explicitly associate the range with a variable name as when you \+
graph an expression. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0
"" {TEXT 258 8 "Exercise" }{TEXT -1 37 ": How would you graph the expr
ession " }{TEXT 0 5 "a*x^2" }{TEXT -1 32 " as a function of two variab
les?" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "plot3d( );" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT
-1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 152 "Here are some other difference
s in how Maple treats an expression and a Maple function. The followin
g command tells us the definition of the expression " }{TEXT 0 1 "f" }
{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "f;" }}}
{PARA 0 "" 0 "" {TEXT -1 67 "But the following command does not tell u
s much about the function " }{TEXT 0 1 "g" }{TEXT -1 1 "." }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "g;" }}}{PARA 0 "" 0 "" {TEXT -1 39 "
Here is a way to get the definition of " }{TEXT 0 1 "g" }{TEXT -1 1 ".
" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "print( g );" }}}{PARA 0
"" 0 "" {TEXT -1 48 "Here are two more ways to get the definition of \+
" }{TEXT 0 1 "g" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 10 "eval( g );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "op( g \+
);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 ""
{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 178 "Now suppose we wanted to
evaluate our mathematical function at a point, say at 1. We use diffe
rent syntax for the Maple expression and the Maple function. For the e
xpression, we " }{TEXT 0 4 "subs" }{TEXT -1 7 "titute " }{TEXT 0 1 "1
" }{TEXT -1 5 " for " }{TEXT 0 1 "x" }{TEXT -1 4 " in " }{TEXT 0 1 "f
" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "subs( x=
1, f );" }}}{PARA 0 "" 0 "" {TEXT -1 66 "For the Maple function we can
use traditional functional notation." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 5 "g(1);" }}}{PARA 0 "" 0 "" {TEXT -1 51 "Notice that the
following two commands do not work." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 5 "f(1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "su
bs( x=1, g );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA
0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 107 "We should ment
ion that there is another way to evaluate an expression at a point. We
can use a form of the " }{TEXT 0 4 "eval" }{TEXT -1 50 " command (whi
ch is, of course, an abbreviation of " }{TEXT 0 4 "eval" }{TEXT -1 7 "
uate). " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "eval( f, x=1 );"
}}}{PARA 0 "" 0 "" {TEXT -1 44 "Notice the difference in the syntax be
tween " }{TEXT 0 4 "eval" }{TEXT -1 5 " and " }{TEXT 0 4 "subs" }
{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "subs( x=1, \+
f );" }}}{PARA 0 "" 0 "" {TEXT -1 17 "Think of reading " }{TEXT 0 11 "
eval(f,x=1)" }{TEXT -1 5 " as \"" }{TEXT 0 4 "eval" }{TEXT -1 5 "uate \+
" }{TEXT 0 1 "f" }{TEXT -1 4 " at " }{TEXT 0 3 "x=1" }{TEXT -1 23 "\" \+
and think of reading " }{TEXT 0 11 "subs(x=1,f)" }{TEXT -1 5 " as \""
}{TEXT 0 4 "subs" }{TEXT -1 7 "titute " }{TEXT 0 3 "x=1" }{TEXT -1 6 "
into " }{TEXT 0 1 "f" }{TEXT -1 85 "\". As you should expect, the fol
lowing command does not work with the Maple function " }{TEXT 0 1 "g"
}{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "eval( g, x
=1 );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "
" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 49 "The following command w
ill factor the expression " }{TEXT 0 1 "f" }{TEXT -1 1 "." }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "factor( f );" }}}{PARA 0 "" 0 ""
{TEXT -1 61 "But the following command does not factor the Maple funct
ion " }{TEXT 0 1 "g" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 12 "factor( g );" }}}{PARA 0 "" 0 "" {TEXT -1 29 "Here is
how we can factor it." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "fa
ctor( g(x) );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA
0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 83 "Here are comman
ds for finding the derivative of an expression and a Maple function."
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "diff( f, x );" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "D( g );" }}}{PARA 0 "" 0 "" {TEXT
-1 17 "(Explain why the " }{TEXT 0 4 "diff" }{TEXT -1 31 " command nee
ded a reference to " }{TEXT 0 1 "x" }{TEXT -1 15 " in it but the " }
{TEXT 0 1 "D" }{TEXT -1 109 " command did not. ) As you might expect b
y now, the following two commands do not do what we want them to do."
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "D( f );" }}}{EXCHG {PARA 0
"> " 0 "" {MPLTEXT 1 0 13 "diff( g, x );" }}}{PARA 0 "" 0 "" {TEXT -1
51 "Why is the following command's output like that of " }{TEXT 0 4 "D
(f)" }{TEXT -1 1 "?" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "D( g(
x) );" }}}{PARA 0 "" 0 "" {TEXT -1 708 "Notice how Maple did not compl
ain about any of these last three commands. They were not syntacticall
y incorrect. As far as Maple is concerned, we asked it to do something
valid, and it did it. What we asked it to do is not clear at this poi
nt, but what ever it was, Maple did it. But what Maple did was not wha
t we were expecting. There are two lessons to be learned from this. Fi
rst, be careful to keep track of when you are working with expressions
and when you are working with Maple functions. Second, you need to al
ways look carefully at your Maple outputs. Just because Maple computed
something does not mean that it computed something that made sense or
that it computed what you wanted it to compute." }}{EXCHG {PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "
" 0 "" {TEXT -1 110 "Let us do an example of combining two mathematica
l functions f and g by composing them to make a new function " }
{XPPEDIT 18 0 "h(x) = f(g(x));" "6#/-%\"hG6#%\"xG-%\"fG6#-%\"gG6#F'" }
{TEXT -1 98 ". Here is how we would compose two mathematical function
s if they are represented by expressions." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 15 "f := x^2 + 3*x;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 11
"g := x + 1;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "h := subs( x=g, f )
;" }}}{PARA 0 "" 0 "" {TEXT -1 33 "We substitute the inner function "
}{TEXT 0 1 "g" }{TEXT -1 25 " into the outer function " }{TEXT 0 1 "f
" }{TEXT -1 27 " and we get the expression " }{TEXT 0 1 "h" }{TEXT -1
33 " that represents the composition " }{XPPEDIT 18 0 "f(g(x));" "6#-%
\"fG6#-%\"gG6#%\"xG" }{TEXT -1 81 ". Now here is how we would do this \+
if f and g are represented by Maple functions." }}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 20 "f := x -> x^2 + 3*x;" }}{PARA 0 "> " 0 ""
{MPLTEXT 1 0 16 "g := x -> x + 1;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9
"h := f@g;" }}}{PARA 0 "" 0 "" {TEXT -1 50 "Here is how we can verify \+
that the Maple function " }{TEXT 0 1 "h" }{TEXT -1 31 " represents the
composition of " }{TEXT 0 1 "f" }{TEXT -1 5 " and " }{TEXT 0 1 "g" }
{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "h(x);" }}}
{PARA 0 "" 0 "" {TEXT -1 43 "We do not need to use a separate name lik
e " }{TEXT 0 1 "h" }{TEXT -1 64 " for the composition of the Maple fun
ctions f and g. The symbol " }{TEXT 0 3 "f@g" }{TEXT -1 135 " can be u
sed as a name for the composition, but we need to put parentheses arou
nd this name when we use it to evaluate the composition." }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "(f@g)(x);" }}}{PARA 0 "" 0 "" {TEXT
-1 13 "The at sign (" }{TEXT 0 1 "@" }{TEXT -1 328 ") is used in Maple
to mean composition of two Maple functions. The at sign is used becau
se it is the closest character on the standard computer keyboard to th
e little raised circle used in mathematics books to denote composition
of functions. (If you do not remember the symbol, look up composition
in almost any calculus book.)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}
{PARA 0 "" 0 "" {TEXT 259 8 "Exercise" }{TEXT -1 60 ": In what way are
the following four expressions similar to " }{TEXT 0 8 "(f@g)(x)" }
{TEXT -1 1 "?" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "(f+g)(x);" }
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "(f-g)(x);" }}}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 9 "(f*g)(x);" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 9 "(f/g)(x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0
"" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 260 8 "Exe
rcise" }{TEXT -1 92 ": Explain the results of the following two comman
ds. (Try executing these two commands with " }{TEXT 0 1 "f" }{TEXT -1
5 " and " }{TEXT 0 1 "g" }{TEXT -1 26 " as unassigned variables.)" }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "((f+g)@g-f)(x);" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "((f+g)@(g-f))(x);" }}}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}
{PARA 0 "" 0 "" {TEXT -1 118 "Let us do an example of representing a m
athematical function of two variables. Here is an expression in two va
riables." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "f := (x^2+y^2)/(
x+x*y);" }}}{PARA 0 "" 0 "" {TEXT -1 59 "And here is the equivalent Ma
ple function of two variables." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1
0 32 "g := (x,y) -> (x^2+y^2)/(x+x*y);" }}}{PARA 0 "" 0 "" {TEXT -1
73 "Here is how we evaluate the expression and the Maple function at a
point." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "subs( x=1, y=2, f
);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "eval( f, \{x=1, y=2
\} );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "g(1,2);" }}}{PARA
0 "" 0 "" {TEXT -1 39 "Neither of the next two commands works." }}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "f(1,2);" }}}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 20 "subs( x=1, y=2, g );" }}}{PARA 0 "" 0 ""
{TEXT -1 38 "Here is how we get the definitions of " }{TEXT 0 1 "f" }
{TEXT -1 5 " and " }{TEXT 0 1 "g" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 2 "f;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
11 "print( g );" }}}{PARA 0 "" 0 "" {TEXT -1 52 "Notice that Maple can
simplify the expression a bit." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 18 "f; simplify( f );" }}}{PARA 0 "" 0 "" {TEXT -1 8 "But the " }
{TEXT 0 8 "simplify" }{TEXT -1 25 " command does nothing to " }{TEXT
0 1 "g" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "si
mplify( g );" }}}{PARA 0 "" 0 "" {TEXT -1 47 "Here is how we can do th
e simplification using " }{TEXT 0 1 "g" }{TEXT -1 1 "." }}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "simplify( g(x,y) );" }}}{PARA 0 ""
0 "" {TEXT -1 61 "Here is how we compute partial derivatives of the ex
pression." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "diff( f, x );"
}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "simplify( % );" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "diff( f, y );" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "simplify( % );" }}}{PARA 0 "" 0 ""
{TEXT -1 69 "Here is how we compute the partial derivatives of the Map
le function." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "D[1](g);" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "simplify( %(x,y) );" }}}
{PARA 0 "" 0 "" {TEXT -1 14 "(What did the " }{TEXT 0 1 "%" }{TEXT -1
31 " refer to in the last command?)" }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 8 "D[2](g);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19
"simplify( %(x,y) );" }}}{PARA 0 "" 0 "" {TEXT -1 167 "Notice how the \+
notation for partial derivatives of expressions uses the name of the i
ndependent variable but with Maple functions the partial derivative no
tation does " }{TEXT 256 3 "not" }{TEXT -1 47 " use the name of the in
dependent variable. The " }{TEXT 0 1 "D" }{TEXT -1 157 " operator uses
a number to indicate the first, second, third, etc, independent varia
ble. This is an indication of the fact that, for example, the expressi
on " }{TEXT 0 11 "3*x^2+5*y^2" }{TEXT -1 32 " is not the same expressi
on as " }{TEXT 0 11 "3*u^2+5*v^2" }{TEXT -1 25 ", but the Maple funct
ion " }{TEXT 0 18 "(x,y)->3*x^2+5*y^2" }{TEXT -1 4 " is " }{TEXT 257
7 "exactly" }{TEXT -1 22 " the same function as " }{TEXT 0 18 "(u,v)->
3*u^2+5*v^2" }{TEXT -1 12 ". (Consider " }{TEXT 0 18 "(s,t)->3*t^2+5*s
^2" }{TEXT -1 35 ". Is it the same function?) So the " }{TEXT 0 1 "D"
}{TEXT -1 345 " operator differentiates with respect to the position o
f the independent variable in the input list on the left hand side of \+
the arrow operator, not with respect to the name given to the independ
ent variable. For Maple functions, it is the position of the independe
nt variable in this list that matters, not the name of the independent
variable." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT
-1 71 "Suppose we want to compose our mathematical function with the f
unction " }{XPPEDIT 18 0 "h(z) = sqrt(z);" "6#/-%\"hG6#%\"zG-%%sqrtG6#
F'" }{TEXT -1 60 " where h will be the outer function in the compositi
on. Let " }{TEXT 0 2 "h1" }{TEXT -1 38 " represent h as an expression \+
and let " }{TEXT 0 2 "h2" }{TEXT -1 38 " represent h as a Maple functi
on. Let " }{TEXT 0 2 "k1" }{TEXT -1 57 " be the name of the compositio
n as an expression and let " }{TEXT 0 2 "k2" }{TEXT -1 52 " be the nam
e of the composition as a Maple function." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 14 "h1 := sqrt(z);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 19 "h2 := z -> sqrt(z);" }}}{PARA 0 "" 0 "" {TEXT -1 42 "Here is t
he composition using expressions." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 22 "k1 := subs( z=f, h1 );" }}}{PARA 0 "" 0 "" {TEXT -1
46 "Here is the composition using Maple functions." }}{EXCHG {PARA 0 "
> " 0 "" {MPLTEXT 1 0 11 "k2 := h2@g;" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 8 "k2(x,y);" }}}{PARA 0 "" 0 "" {TEXT -1 12 "Explain why \+
" }{TEXT 0 2 "k1" }{TEXT -1 22 " is the same thing as " }{TEXT 0 7 "k2
(x,y)" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}
}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 44 "In a pre
vious section we defined a function " }{TEXT 0 1 "h" }{TEXT -1 12 " as
follows." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "h := 2*sin - 9/
exp;" }}}{PARA 0 "" 0 "" {TEXT 0 1 "h" }{TEXT -1 67 " is a function, n
ot an expression. The next two commands show that " }{TEXT 0 1 "h" }
{TEXT -1 48 " really is a function, not an expression, since " }{TEXT
0 1 "h" }{TEXT -1 68 " must be plotted using the syntax for a function
, not an expression." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "plot
( h, 0..10 ); # The function syntax works." }{TEXT -1 0 "" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "plot( h, x = 0..10 ); # The
expression syntax does not work." }}}{PARA 0 "" 0 "" {TEXT -1 48 "Her
e is another way to define the same function " }{TEXT 0 1 "h" }{TEXT
-1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "h := x -> 2*sin(x
) - 9/exp(x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA
0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 261 8 "Exercise" }
{TEXT -1 6 ": Let " }{XPPEDIT 18 0 "f(x,y) = 3*x+5*y;" "6#/-%\"fG6$%\"
xG%\"yG,&*&\"\"$\"\"\"F'F,F,*&\"\"&F,F(F,F," }{TEXT -1 9 " and let " }
{XPPEDIT 18 0 "h(z) = sqrt(z+1);" "6#/-%\"hG6#%\"zG-%%sqrtG6#,&F'\"\"
\"F,F," }{TEXT -1 58 ". We have already seen how to compute the compos
ition h(f(" }{XPPEDIT 18 0 "x,y;" "6$%\"xG%\"yG" }{TEXT -1 80 ")) usin
g either expressions or Maple functions. Explain why the composition f
(h(" }{XPPEDIT 18 0 "z;" "6#%\"zG" }{TEXT -1 68 ")) does not make sens
e mathematically. Compute the compositions f(h(" }{XPPEDIT 18 0 "x;" "
6#%\"xG" }{TEXT -1 2 ")," }{XPPEDIT 18 0 "y;" "6#%\"yG" }{TEXT -1 5 ")
, f(" }{XPPEDIT 18 0 "x;" "6#%\"xG" }{TEXT -1 3 ",h(" }{XPPEDIT 18 0 "
y;" "6#%\"yG" }{TEXT -1 12 ")), and f(h(" }{XPPEDIT 18 0 "x;" "6#%\"xG
" }{TEXT -1 4 "),h(" }{XPPEDIT 18 0 "y;" "6#%\"yG" }{TEXT -1 106 ")). \+
First do this exercise using expressions. Can you do these composition
s using Maple functions and the " }{TEXT 0 1 "@" }{TEXT -1 10 " operat
or?" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 ""
{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 262 8 "Exercise" }{TEXT -1 6 ": \+
Let " }{TEXT 0 1 "f" }{TEXT -1 44 " be the following function of two v
ariables." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "f := (x,y) -> 3
*x^2+x*y+5*y^2;" }}}{PARA 0 "" 0 "" {TEXT -1 32 "If we hold one of the
inputs to " }{TEXT 0 1 "f" }{TEXT -1 77 " fixed, then we get a functi
on of one variable that we will call a \"slice of " }{TEXT 0 1 "f" }
{TEXT -1 7 "\". Let " }{TEXT 0 3 "fx3" }{TEXT -1 17 " be the slice of \+
" }{TEXT 0 1 "f" }{TEXT -1 20 " defined by letting " }{TEXT 0 1 "y" }
{TEXT -1 47 " be fixed at 3. Find a Maple command that uses " }{TEXT
0 1 "f" }{TEXT -1 11 " to define " }{TEXT 0 3 "fx3" }{TEXT -1 21 " as \+
a Maple function." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}
{PARA 0 "" 0 "" {TEXT -1 133 "Note: The following Maple command repres
ents the function we want as an expression, so it is not the correct a
nswer to this exercise." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "f
x3 := f(x,3);" }}}{PARA 0 "" 0 "" {TEXT -1 4 "Let " }{TEXT 0 3 "f3y" }
{TEXT -1 21 " denote the slice of " }{TEXT 0 1 "f" }{TEXT -1 6 " with \+
" }{TEXT 0 1 "x" }{TEXT -1 17 " fixed at 3. Use " }{TEXT 0 1 "f" }
{TEXT -1 11 " to define " }{TEXT 0 3 "f3y" }{TEXT -1 21 " as a Maple f
unction." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 ""
0 "" {TEXT -1 36 "Explain the mathematical meaning of " }{TEXT 0 14 "d
iff(fx3(x),x)" }{TEXT -1 5 " and " }{TEXT 0 14 "diff(f3y(y),y)" }
{TEXT -1 83 ". (The following two commands do not mean anything until \+
you have properly defined " }{TEXT 0 3 "fx3" }{TEXT -1 5 " and " }
{TEXT 0 3 "f3y" }{TEXT -1 2 ".)" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT
1 0 18 "diff( fx3(x), x );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
18 "diff( f3y(y), y );" }}}{PARA 0 "" 0 "" {TEXT -1 28 "Find another w
ay to compute " }{TEXT 0 14 "diff(fx3(x),x)" }{TEXT -1 5 " and " }
{TEXT 0 14 "diff(f3y(y),y)" }{TEXT -1 39 " that does not use the slice
functions " }{TEXT 0 3 "fx3" }{TEXT -1 5 " and " }{TEXT 0 3 "fy3" }
{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA
0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 685 "Almost anythin
g you would like to do with an expression you can do with a Maple func
tion, and visa versa. Unfortunately, as we have seen above, the syntax
for doing the same thing with an expression and a Maple function can \+
be quite different. Is one of the two methods \"better\" than the othe
r? Most people do most of their Maple work using expressions to repres
ent mathematical functions. Overall, expressions seem to be a bit easi
er to work with. But Maple functions are indispensable at times, so yo
u must get used to working with both concepts. In addition, working wi
th Maple functions is very much like working with Maple procedures (si
nce, as we will see later, Maple functions " }{TEXT 263 3 "are" }
{TEXT -1 93 " procedures) so getting used to Maple functions is a good
prerequisite for Maple programming." }}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 0 "" }}}}}{MARK "4 4 0 0" 0 }{VIEWOPTS 1 1 0 1 1
1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }