Skip to Main Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate content levelBeginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
4.7 對 ReplaceRepeated 指令導致的無窮迴圈進行除錯
|
163
以上顯示從原始圖出發的轉換過程,列出每個中介狀態,試著了解規則式如何驅動狀態
之間的轉換。只有透過這類的範例,才能真正了解規則式的概念。[Page-165]
延伸資訊
FixedPoint
指令通常用於需進行迭代的數值方法(如牛頓法,見訣竅 2.12),但其實任
何計算終端平衡狀態的演算法都適用
FixedPoint
指令。
4.7  ReplaceRepeated 指令導致的無窮迴圈進
行除錯
問題點
在使用
//.
ReplaceRepeated
指令)進行運算時,導致 Mathematica 進入無窮迴圈,但
卻不知道原因為何。
解決方案
ReplaceRepeated
指令非常方便但卻也十分危險,因為只有在轉換結果不再改變時才會
終止計算。最簡單的除錯辦法是將最大迭代次數
MaxIterations
設為一個較小的數目
(預設為 65,536)。
ch04.indd 163 2014/4/2 上午 05:39:10
164
|
第四章
當無窮迴圈發生時,這個方法有助於釐清問題。在此強調,任何增加結構的轉換都是很
危險的,但有時候限制最大迭代次數也不太容易找出問題所在,這個情況下,列出每個
轉換步驟會很有幫助,
NestList
搭配
ReplaceAll ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9789863470106