maple’s evaluation rules 教授 : 蔡桂宏 博士 學生 : 林佳慧 學號 :95356062 95503...
TRANSCRIPT
Program (continue)
Last name evaluation
Evaluating function definitions
Evaluating function calls
A no evaluation rule
Program (continue)
Evaluating concatenated names
Evaluating indexed names
Online help for evaluation rules
Full evaluation
Introducing the kinds of the data styles by normal programming :
文字 - 字元:『’’』或『 ’’ ’’ 』 數字 - 整數和浮點數: 5 、 5.0 邏輯值( boolean ):『 true 』或『 false 』
What is full evaluation? 一口氣計算完畢
Full evaluation(Continue)There are exceptions to this rule:
delayed evaluation levels evaluation last name evaluation
Levels of evaluation
Purpose: How do we use the command?
The command in levels of evaluation
eval(expression , level )
Delayed evaluation
Purpose : see the command’s output Compare 『 Delay 』 of evaluation with
『 Level 』 of evaluation Compare 『 eval(x) 』 with 『 eval(x,n) 』 What happened to the single quote in left equal
sign
Delayed evaluation What happened to the double quote in left eq
ual sign? Compare 『 % 』 with 『 eval(x,n) 』 Another mean about the command’s output i
n 『‘ ’』 Explain the function output in 『 rand( ) 』 Compare some different in 『 plot( ) 』
Delayed evaluation(continue)The command’s output :
『’變數’』 : one delayed evaluation 『’’變數’’』 : a doubly delayed eval
uation 『’’’變數’’’』 : a trebly delayed
evaluation
Delayed evaluation(continue)Compare 『 Delay 』 of evaluation with 『 Level 』 of evaluation
『 Delay 』 - 由原來的表示式看 delay 幾次
『 Level 』 - 『 eval(x,n) 』 : 程式由前面開始找到 x 後,逐行由上往下顯示
Delayed evaluation(continue)Compare 『 eval(x) 』 with 『 eval(x,n) 』
The call eval(x) means: Two delayed evaluations.(the same of the eval(eval(x,2)) ) or evaluate x
The call eval(x,n) means: To evaluate the n level of the name x
Delayed evaluation(continue)What happened to the single quote in left equal sign
The first x has its evaluation dealyed and the second x is evaluated right away
Delayed evaluation(continue)What happened to the double quote in left equal sign
The first x has its evaluation dealyed and the second x is one delayed evaluated of x
Delayed evaluation(continue) the command’s output in 『 % 』、 『 %% 』
『 % 』 :last expression 『 %% 』 : second last expression
i.e 『 %%% 』 : third last expression
Delayed evaluation(continue)Compare 『 % 』 with 『 eval(x,n) 』
『 % 』 : 由此指令往前找一行 『 eval(x,n) 』 : 程式由前面開始找到
x 後,逐行由上往下顯示
Delayed evaluation(continue)Another mean about the command’s output in 『‘ ’』 :
It can get automatic simplification It is a very safe way to define y It is an often used trick in Maple Explain the command’s output in 『 plot( exp
ression in independent variable x ,the range of the x) 』
Delayed evaluation(continue)Explain the function output in 『 rand( ) 』 :
It can generate a random interger
Delayed evaluation(continue)Compare some different as following:
plot(x^2,x=-5..5); v.s
plot(x^2,'x'=-5..5); plot('x'^2,'x'=-5..5); v.s
plot('x'^2, x=-5..5);
Evaluating function definitions (continue)
How do we define Maple function? use 『 -> 』 use 『 unapply 』 command
Evaluating function call
If f is the name of a Maple function, then an expression of the form
f(any-maple-expression) f was defined using by 『 -> 』
Here is an example of a function and several function calls
Evaluating function call (continue)
Some of the function call: Case 1 : above this page Case 2 : unevaluated function call
A no evaluation rule
Purpose: There have many examples of how unevalu
ations are used Explain the command in 『 assigned( ) 』 What is recursion ?
A no evaluation rule(continue) Explain the command in 『 assigned( ) 』 : The assigned function returns true if n has a
value other than its own name, and returns false
A no evaluation rule(continue)
What is recursion? x=‘x’ f(0)=1
f(1)=1
f(x+2)=f(x+1)+f(x)
EX. f(5)=8
f(x) 1 1 2 3 5 8
x 0 1 2 3 4 5
電腦記憶體 x的地方放 x的位置
Evaluating concatenated names
Purpose: find Maple’s rules for evaluating
concatenated names
What is a concatenated name? the concatenated name’s command is 『 || 』
The next exercise shows that Maple does allow the use of parentheses for grouping around the right pair of vertical lines.
Evaluating indexed names
Purpose: To understand what indexed name is it
Compare 『 x||1:=0 』 with 『 x[1]:=0 』 『 x||1:=0 』 : Maple evaluates x||1 to the
name x1 『 x[1]:=0 』 : x[1] is a name. Maple does
not need to evaluate it