变换规则和定义.ppt

上传人:小飞机 文档编号:6362526 上传时间:2023-10-20 格式:PPT 页数:18 大小:270.99KB
返回 下载 相关 举报
变换规则和定义.ppt_第1页
第1页 / 共18页
变换规则和定义.ppt_第2页
第2页 / 共18页
变换规则和定义.ppt_第3页
第3页 / 共18页
变换规则和定义.ppt_第4页
第4页 / 共18页
变换规则和定义.ppt_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《变换规则和定义.ppt》由会员分享,可在线阅读,更多相关《变换规则和定义.ppt(18页珍藏版)》请在三一办公上搜索。

1、第十讲 变换规则和定义,1.应用变换规则2.对规则的操作3.定义4.赋值的一些特殊形式5.索引的定义6.函数的定义7.定义的次序8.即时和延时的定义9.记住已知值的函数10.定义联系不同的符号11.定义数值值12.修改内置函数13.使用赋值列表,2,November 11,2005,Start Learning Step by Step,1.应用变换规则,expr/.rules在表达式上应用一次规则expr/.rules在表达式上重复应用规则直道结果不再改变,应用变换规则,expr/.lhs-rhs在表达式上应用某个变换规则expr/.lhs1-rhs1,lhs2-rhs,.在表达式上依次应用

2、一系列规则,应用一组变换规则,expr/.rules1,rules2,.应用一组规则得到一个数组,一次或重复应用规则,3,November 11,2005,Start Learning Step by Step,1.应用变换规则(续),Applying rules to whole expressions,expr/.rulesapply rules to all subparts of exprReplace expr,rulesapply rules to the whole of expr onlyReplace expr,rules,levspecapply rules to part

3、s of expr on levels specified by levspec,Applying rules in one way or all possible ways,Replace expr,rulesapply rules in one way onlyReplaceList expr,rulesapply rules in all possible ways,4,November 11,2005,Start Learning Step by Step,2.对规则的操作,Creating and using dispatch tables,Dispatch rulescreate

4、a representation of a list of rules that includes dispatch tablesexpr/.drulesapply rules that include dispatch tables,5,November 11,2005,Start Learning Step by Step,3.定义,Manual and automatic application of transformation rules,expr/.lhs-rhsapply a transformation rule to a specific expressionlhs=rhsa

5、ssign a value which defines a transformation rule to be used whenever possible,Removing assignments,x=.remove the value assigned to the object xClear x,y,.clear all the values of x,y,.,6,November 11,2005,Start Learning Step by Step,4.赋值的一些特殊形式,Modifying values of variables,i+increment the value of i

6、 by 1i-decrement i+ipre-increment i-ipre-decrement ii+=diadd di to the value of ii-=disubtract di from ix*=cmultiply x by cx/=cdivide x by c,7,November 11,2005,Start Learning Step by Step,4.赋值的一些特殊形式(续),Assigning values to several variables at a time,x=y=valueassign the same value to both x and yx,y

7、=value1,value2assign different values to x and y x,y=y,xinterchange the values of x and y,Assignments for modifying lists,PrependTo v,elemprepend elem to the value of vAppendTo v,elemappend elemv=v,elemmake a nested list contaning elem,8,November 11,2005,Start Learning Step by Step,5.索引的定义,Manipulat

8、ing indexed variables,ai=valueadd or overwrite a valueaiaccess a valueai=.remove a value?ashow all defined valuesClearaclear all defined valuesTableai,i,1,n or Arraya,nconvert to an explicit List,9,November 11,2005,Start Learning Step by Step,6.函数的定义,fx=valuedefinition for a specific expression xfx_

9、=valuedefinition for any expression,referred to as x,The difference between defining an indexed variable and a function,10,November 11,2005,Start Learning Step by Step,7.定义的次序,Treatment of definitions in Mathematica,Mathematica tries to put specific definitions before more general definitions,11,Nov

10、ember 11,2005,Start Learning Step by Step,8.即时和延时的定义,lhs=rhs(immediate assignment)rhs is evaluated when the assignment is madelhs:=rhs(delayed assignment)rhs is evaluated each time the value of lhs is requested,The two types of assignments in Mathematica,Interpretations of assignments with the=and:=

11、operators,lhs=rhsrhs is intended to be the final value of lhs(e.g.,fx_=1-x2)lhs:=rhsrhs gives a command or program to be executed whenever you ask for the value of lhs(e.g.,fx_:=Expand1-x2),Defining functions for evaluating expressions,fx_=exprdefine a function which gives the value expr for any par

12、ticular value of x,12,November 11,2005,Start Learning Step by Step,8.即时和延时的定义(续),lhs-rhsrhs is evaluated when the rule is givenlhs:rhsrhs is evaluated when the rule is used,Two types of transformation rules in Mathematica,13,November 11,2005,Start Learning Step by Step,9.记住已知值的函数,fx_:=fx=rhsdefine a

13、 function which remembers values that it finds,Defining a function that remembers values it finds,14,November 11,2005,Start Learning Step by Step,10.定义联系不同的符号,Associating definitions with different symbols,fargs:=rhsdefine a downvalue for ffgargs,.:=rhsdefine an upvalue for g,Shorter ways to define

14、upvalues,fg=value or fgargs=valuemake assignments to be associated with g,rather than ffg:=value or fgargs:=valuemake delayed assignments associated with gfarg1,arg2,.=valuemake assignments associated with the heads of all the argi,15,November 11,2005,Start Learning Step by Step,10.定义联系不同的符号(续),Poss

15、ible positions for symbols in definitions,f.:=rhsdownvalue for ff/:fg.:=rhsdownvalue for fg/:f.,g,.:=rhsupvalue for gg/:f.,g.,.:=rhsupvalue for g,16,November 11,2005,Start Learning Step by Step,11.定义数值值,Defining ordinary and numerical values,expr=valuedefine a value to be used whenever possibleNexpr

16、=valuedefine a value to be used for numerical approximation,Defining numerical valuesthat depend on numerical precision,Nexpr=valuedefine a numerical value to be used when defalut numerical precision is requestedNexpr,n=valuedefine a numerical value to be used when n-digit precision is requested,17,

17、November 11,2005,Start Learning Step by Step,12.修改内置函数,Protection for functions,Unprotectfremove protectionProtectfadd protection,18,November 11,2005,Start Learning Step by Step,13.使用赋值列表,Finding and setting values of symbols,DownValuesfgive the list of downvalues of fUpValuesfgive the list of upvalues of fDownValuesf=rulesset the downvalues of fUpValuesf=rulesset the upvalues of f,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号