變換規(guī)則和定義_第1頁(yè)
變換規(guī)則和定義_第2頁(yè)
變換規(guī)則和定義_第3頁(yè)
變換規(guī)則和定義_第4頁(yè)
變換規(guī)則和定義_第5頁(yè)
已閱讀5頁(yè),還剩13頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

變換規(guī)則和定義第1頁(yè),共18頁(yè),2023年,2月20日,星期一2November18,2004StartLearningStepbyStep1.應(yīng)用變換規(guī)則expr/.rules 在表達(dá)式上應(yīng)用一次規(guī)則expr//.rules 在表達(dá)式上重復(fù)應(yīng)用規(guī)則直道結(jié)果不再改變應(yīng)用變換規(guī)則expr/.lhs->rhs 在表達(dá)式上應(yīng)用某個(gè)變換規(guī)則expr/.{lhs1->rhs1,lhs2->rhs,...} 在表達(dá)式上依次應(yīng)用一系列規(guī)則應(yīng)用一組變換規(guī)則expr/.{rules1,rules2,...} 應(yīng)用一組規(guī)則得到一個(gè)數(shù)組一次或重復(fù)應(yīng)用規(guī)則第2頁(yè),共18頁(yè),2023年,2月20日,星期一3November18,2004StartLearningStepbyStep1.應(yīng)用變換規(guī)則(續(xù))Applyingrulestowholeexpressionsexpr/.rules applyrulestoallsubpartsofexprReplace[expr,rules] applyrulestothewholeofexpronlyReplace[expr,rules,levspec] applyrulestopartsofexpronlevelsspecifiedbylevspecApplyingrulesinonewayorallpossiblewaysReplace[expr,rules] applyrulesinonewayonlyReplaceList[expr,rules] applyrulesinallpossibleways第3頁(yè),共18頁(yè),2023年,2月20日,星期一4November18,2004StartLearningStepbyStep2.對(duì)規(guī)則的操作CreatingandusingdispatchtablesDispatch[rules] createarepresentationofalistofrulesthatincludesdispatchtablesexpr/.drules applyrulesthatincludedispatchtables第4頁(yè),共18頁(yè),2023年,2月20日,星期一5November18,2004StartLearningStepbyStep3.定義Manualandautomaticapplicationoftransformationrulesexpr/.lhs->rhs applyatransformationruletoaspecificexpressionlhs=rhs assignavaluewhichdefinesatransformationruletobeusedwheneverpossibleRemovingassignmentsx=. removethevalueassignedtotheobjectxClear[x,y,...] clearallthevaluesofx,y,...第5頁(yè),共18頁(yè),2023年,2月20日,星期一6November18,2004StartLearningStepbyStep4.賦值的一些特殊形式Modifyingvaluesofvariablesi++ incrementthevalueofiby1i-- decrementi++i pre-incrementi--i pre-decrementii+=di addditothevalueofii-=di subtractdifromix*=c multiplyxbycx/=c dividexbyc第6頁(yè),共18頁(yè),2023年,2月20日,星期一7November18,2004StartLearningStepbyStep4.賦值的一些特殊形式(續(xù))Assigningvaluestoseveralvariablesatatimex=y=value assignthesamevaluetobothxandy{x,y}={value1,value2} assigndifferentvaluestoxandy{x,y}={y,x} interchangethevaluesofxandyAssignmentsformodifyinglistsPrependTo[v,elem] prependelemtothevalueofvAppendTo[v,elem] appendelemv={v,elem} makeanestedlistcontaningelem第7頁(yè),共18頁(yè),2023年,2月20日,星期一8November18,2004StartLearningStepbyStep5.索引的定義Manipulatingindexedvariablesa[i]=value addoroverwriteavaluea[i] accessavaluea[i]=. removeavalue?a showalldefinedvaluesClear[a] clearalldefinedvaluesTable[a[i],{i,1,n}]orArray[a,n] converttoanexplicitList第8頁(yè),共18頁(yè),2023年,2月20日,星期一9November18,2004StartLearningStepbyStep6.函數(shù)的定義f[x]=value definitionforaspecificexpressionxf[x_]=value definitionforanyexpression,referredtoasxThedifferencebetween

defininganindexedvariableandafunction第9頁(yè),共18頁(yè),2023年,2月20日,星期一10November18,2004StartLearningStepbyStep7.定義的次序TreatmentofdefinitionsinMathematicaMathematicatriestoputspecificdefinitionsbeforemoregeneraldefinitions第10頁(yè),共18頁(yè),2023年,2月20日,星期一11November18,2004StartLearningStepbyStep8.即時(shí)和延時(shí)的定義lhs=rhs(immediateassignment) rhsisevaluatedwhentheassignmentismadelhs:=rhs(delayedassignment) rhsisevaluatedeachtimethevalueoflhsisrequestedThetwotypesofassignmentsinMathematicaInterpretationsofassignmentswiththe=and:=operatorslhs=rhs rhsisintendedtobethe"finalvalue"oflhs(e.g.,f[x_]=1-x^2)lhs:=rhs rhsgivesa"command"or"program"tobeexecutedwheneveryouaskforthevalueoflhs(e.g.,f[x_]:=Expand[1-x^2])Definingfunctionsforevaluatingexpressionsf[x_]=expr defineafunctionwhichgivesthevalueexprforanyparticularvalueofx第11頁(yè),共18頁(yè),2023年,2月20日,星期一12November18,2004StartLearningStepbyStep8.即時(shí)和延時(shí)的定義(續(xù))lhs->rhs rhsisevaluatedwhentheruleisgivenlhs:>rhs rhsisevaluatedwhentheruleisusedTwotypesoftransformationrulesinMathematica第12頁(yè),共18頁(yè),2023年,2月20日,星期一13November18,2004StartLearningStepbyStep9.記住已知值的函數(shù)f[x_]:=f[x]=rhs defineafunctionwhichremembersvaluesthatitfindsDefiningafunctionthatremembersvaluesitfinds第13頁(yè),共18頁(yè),2023年,2月20日,星期一14November18,2004StartLearningStepbyStep10.定義聯(lián)系不同的符號(hào)Associatingdefinitionswithdifferentsymbolsf[args]:=rhs defineadownvalueforff[g[args],...]^:=rhs defineanupvalueforgShorterwaystodefineupvaluesf[g]^=valueorf[g[args]]^=value makeassignmentstobeassociatedwithg,ratherthanff[g]^:=valueorf[g[args]]^:=value makedelayedassignmentsassociatedwithgf[arg1,arg2,...]^=value makeassignmentsassociatedwiththeheadsofalltheargi第14頁(yè),共18頁(yè),2023年,2月20日,星期一15November18,2004StartLearningStepbyStep10.定義聯(lián)系不同的符號(hào)(續(xù))Possiblepositionsforsymbolsindefinitionsf[...]:=rhs downvalueforff/:f[g[...]][...]:=rhs downvalueforfg/:f[...,g,...]:=rhs upvalueforgg/:f[...,g[...],...]:=rhs upvalueforg第15頁(yè),共18頁(yè),2023年,2月20日,星期一16November18,2004StartLearningStepbyStep11.定義數(shù)值值Definingordinaryandnumericalvaluesexpr=value defineavaluetobeusedwheneverpossibleN[expr]=value defineavaluetobeusedfornumericalapproximationDefiningnumericalvalues

thatdependonnumericalprecisionN[expr]=value defineanumericalvaluetobeusedwhendefalutnumericalprecisioni

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論