Skip to Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
744
|
第十九章
解決方案
使用訣竅 2.10 中提到的
Reap
與
Sow
指令,將資料擷取出來以便於利用模式匹配或繪圖
方式進行分析。舉例來說,假設你有一個稱為
func
的函數,你想知道哪些引數會導致
其輸出值為負,為方便起見,以下設計了一個範例以凸顯這個功能,你也可以自行設計
類似的函數進行測試。
以上可以看出共有 90 組引數會導致
func
函數值為負,你可以進一步擷取這些函數值,
並且使用本章其他訣竅技巧進行除錯。
使用
@@@
作用原函數可確認這些函數值均為負值。
討論說明
Reap
與
Sow
指令是威力強大的除錯工具,因為它們可以將資料擷取至任意數量的管道
中,使用
Sow
指令的第二個引數可以指定將資料放置於不同串列。例如,你想同時偵測
func
函數輸出為負值與零的情況,並放置於獨立的串列中。[Page-747]
ch19.indd 744 2014/4/2 下午 05:10:36
19.3 使用堆疊追蹤法對遞迴程式進行除錯
|
745
以下可看出這些串列中的引數具有不同的函數行為。
延伸資訊
訣竅 19.6 介紹
Reap
與
Sow
指令的另一個常見應用,用來對 Mathematica 內建數值演算
法或繪圖指令進行除錯。
訣竅 19.3 介紹如何使用
Reap
與
Sow
指令查看堆疊狀態。
19.3 使用堆疊追蹤法對遞迴程式
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Mathematica Cookbook

Mathematica Cookbook

Sal Mangano
人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar

Publisher Resources

ISBN: 9789863470106