Chapter 18. Tricks of the Trade

Meine tricks Don’t know what I would do without Tricks yeah yeah Gimme tricks Ihr wisst ich bin alleine ohne meine meine Tricks yeah That’s the only reason my heart still ticks Vishnu, Batu, Fu Manchu too Hu-Hu, Jonny Manushutu Dr. Wu, Peggy Sue Randy Andy too One thing in common when they get up to their tricks They do it for kicks So if you ever see me acting Like a kid from outer space And you think of lending a hand But if you look real close You’ll see a smile on my face Then I’m sure you’ll understand

Falco, “Tricks”

18.0 Introduction

This chapter’s recipes consist of Mathematica techniques and capabilities that every serious user should have in their tool box. Unlike other chapters, the recipes here are not tied together by any one theme. I include them because each recipe will give you some deeper insight into details that are unique to the Mathematica architecture. Each recipe has been a lifesaver to me at various times, and I hope that one or more of them will be helpful to you.

18.1 Cleaning Up During Incremental Development

Problem

You are solving a problem by incremental refinement of a set of functions. As you proceed to refactor and introduce alternative definitions for symbols, you find that code that was working before mysteriously breaks.

Solution

Make judicious use of Clear before every group of functions that are still undergoing development. First, I illustrate what can go wrong if you are sloppy. Suppose you define this function f. ...

Get Mathematica Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.