You are here

The Mathematica GuideBook for Programming

Publisher: 
Springer
Number of Pages: 
904
Price: 
79.95
ISBN: 
0387942823

By way of explanation: It is uncommon for MAA Reviews to post reviews on software; rarer yet on programming manuals or guides. In the past, because of its pedagogical value for younger people, I wrote a review of Stan Wagon’s Mathematical Explorer, an interactive survey of various mathematical concepts that was built on a “stripped-down” version of Mathematica.

I have been a light-weight user of Mathematica for some years now. I primarily used it as a very powerful “calculator”: a tool for simplifying, solving or manipulating equations encountered in reading, for evaluating integrals, for testing the equivalence of expressions, or for graphing real or complex functions to help gain insights. Only rarely did I need to write programs in Mathematica, and those I wrote generally only required writing a dozen or so short function definitions. Usually, I quickly got what I needed; occasionally I’d receive a strange series of error messages (often about something not being a “machine precision number”) and have to consult on-line documentation or books written about using Mathematica. The latter generally focused on “toy” problems and offered a quick, but superficial, explanation of the principles of the system or its true power. All too frequently, their longer programs would be difficult to understand, as they used efficient, but cryptic, constructs like Plus @@ (NIntegrate[#1, {x, #2[[1]], #2[[-1]]}]& @@@ %[[1]])

The Mathematica GuideBooks are a significant exception to this paradigm. Constructs like the above do appear, but the first volume explains these notations as needed that builds a basis of familiarity and understanding. While the four volumes explain how to use Mathematica’s many functions, they go well beyond this and are indeed books on solving vast classes of real problems in mathematics and physics. As emphasis for Trott’s understanding that Mathematica cannot be learnt only by reading, he concludes each chapter with a generous set of graded exercises and programming problems and, in a separate section he presents detailed analyses, author’s insights, and illustrative solutions to the problems. The following is the first part of a progressing 8-part exercise from the first volume:

18a) For an arbitrary 3 x 3 matrix A,

A3 – tr(A) A2 + ½ (tr(A)2 – tr( A2)) A – det(A) 1 = 0,

where tr is the trace, det is the determinant, and 1 is the 3D identity matrix. (This identity follows from the Theorem of Cayley–Hamilton together with the Newton relations.) [Using Mathematica,] prove this identity.

In all, I have taken over two years to read the four volumes cover-to-cover. They are far more than an encyclopedic treatment or reference manual to Mathematica . This review is the first of a series on the four GuideBooks; it looks specifically at the first volume. Although the publisher claims that each volume is self-contained, the first volume’s content is very much a prerequisite to the other volumes in the set. As noted below, each volume’s DVD provides the complete text of the full four-volume set.

Series Background. PhD solid-state physicist Michael Trott began using version 1.2 of Mathematica in his native Germany in mid-1990. In 1991-2, he developed a 1600-page set of lecture notes from which he began teaching an Introductory Course in Mathematica 2 and an advanced course on the Efficient Use of the Mathematica Programming System , given in 1991/1992 at the Technical University of Ilmenau, Germany. Because of this course, he was invited to join Wolfram Research in 1994 where he is now a senior developer. Over the years, he continued evolving the growing set of lecture to accommodate new Mathematica versions and features and their applications.

Springer-Verlag began publishing the 5,027 densely-printed pages of Michael Trott’s Mathematica GuideBooks in 2004. All four volumes have now been published. The individual books, largely self-contained, address Programming, Graphics, Numerics and Symbolics. Each volume comes with a multiplatform DVD-ROM that contains the complete text, executable programs and evaluated visualizations of the specific volume it accompanies. In addition, the DVD contains the complete text and executable programs of the other three volumes. The printed volumes are actually black-and-white printouts of the 16 notebooks on the DVD which also has a complete hyperlinked table of contents and index the full set. Additionally, the chapter-by-chapter notebooks contain internal hyperlinks to other sections and to hundreds of bibliographic references. Many references are linked to abstracts or papers available on the Internet. Because of the space limitations and cost of printed books, there is far more information in the DVD and its cross-referencing tools than could fit in the bound volumes. The notebooks are compatible with Mathematica versions 4 and 5.

Over the years, many mathematicians and physicists have become familiar with Michael Trott’s functions web site (http://functions.wolfram.com). It contains references to over 87000 formulas with nearly 11000 striking visualizations of elementary functions and pi. His mathematical artwork has become well-known, appearing on posters, T-shirts, and other Mathematica -related materials and logos.

Volume 1: Programming. This book has six chapters: “Introduction to Mathematica”; “Structure of Mathematica Expressions”; “Definitions and Properties of Functions”; “Meta-Mathematica”; “Restricted Patterns and Replacement Rules”; and “Operations on Lists, and Linear Algebra”. The book’s structure follows the general outline of Wolfram’s Mathematica Book . The similarity ends there.

The first chapter provides an extensive overview of Mathematica’s capabilities. The pace is terse and considerably more sophisticated than that of any introduction to Mathematica I’ve seen elsewhere. It includes detailed approaches to solving actual problems including the system of ordinary differential equations for the Burridge–Knopoff model for earthquakes, set of partial differential equations. The author states: “Some of the inputs shown and executed in this chapter represent an intermediate to advanced use of Mathematica. Readers new to Mathematica will probably not understand how they work, neither should they. These inputs and code pieces represent a cross section of the type of problems treated in this book. After reading the GuideBooks , the reader will have no problem understanding these programs.” As the volume progresses, Trott generously shows pedagogical examples but occasionally reverts to the phrase that some of the more obscure constructions “will become intelligible to the reader” later in the book in order that a specific point can be presented in a real (rather than a toy) context. Remarkably, Trott keeps this promise! In the exercises, Trott invites the reader to pick a problem to work on while reading through the series. He suggests over 100 such problems, mostly mathematical with about 30 requiring a sound theoretical background in physics. Examples include: How does one calculate the shape of the two pieces used to cover a baseball? Which point of a hypercube in n dimensions maximizes the product of the distances to its vertices? How does one model the shape of a cracking whip? How does one analytically map a polygon with a hole to an annulus? How does one model the sand flow in a hourglass? Each problem is accompanied by a list of bibliographical references.

The second chapter is a thorough examination of Mathematica expressions and numbers. It presents elementary and transcendental functions, simple and nested expressions, rational, symbolic, real and complex numbers. Structures of expressions and numbers are explored fully, from user- and internal-perspectives, with tree structures shown for nested expressions. This chapter begins to show how the list is the fundamental structure on which Mathematica is based.

The third chapter begins the development of programming Mathematica. In its first section, the third chapter, “Definitions and Properties of Functions,” quickly covers the basics shown in every users’ manual. The six remaining sections systematically develop the concept of functions and their definitions as lists with attributes. This chapter also explores how Mathematica makes extensive use of pattern-representation and interpretation. Somewhat arcane topics are treated at length, including the important notions of immediate and delayed interpretation, up-values and down-values. Finally, pure functions are discussed in the context of Church’s λ-Calculus. The chapter concludes with sections on mapping, iterating and composing Mathematica functions.

The fourth chapter, “Meta-Mathematica” deals with the semantics of Mathematica as a programming system. As in any programming system, users are likely to write programs that fail for obscure reasons and that require debugging. Currently, Mathematica has nearly 2000 commands, and their misuse can produce confusing system messages or baffling results. In this chapter, the very structures of Mathematica are treated as Mathematica objects, and evaluation semantics are treated in excruciating detail, making this possibly the most demanding chapter in the volume. Naming and scoping are treated along with a short treatise on various forms of iteration. Linguistic tools are introduced that can show the full semantic representation and internal bindings of any Mathematica expression. Additionally, Trott shows the use of Mathematica’s execution tracing and trapping tools.

The fifth chapter fully examines patterns and rule-based programming. Mathematica’s pattern notation and interpretation capabilities enable the writing of short and elegant programs that eliminate much of the procedural bookkeeping required in most programming languages. Patterns make it possible to write short program expressions that allow for treating special cases in the context of the special case. But, without deep understanding of the problem and its computational complexity, these tools can also produce very inefficient programs. After developing the variations on Boolean functions and patterns, Trott gives several interesting examples, including development of a short(!) program for evaluating certain complete elliptic integrals from basic principles, complete with definitions, rules and recursive relationships.

The final chapter treats lists and their manipulation in full generality and explores their application to linear and matrix algebra. Mathematica has an extensive set of linear algebra commands that allow one to use lists (vectors, generalized n-dimensional matrices and arrays) as primitive structures. The chapter develops several interesting program applications, including a crossword-puzzle generator, construction and solution of magic squares, and powers and exponents of matrices. The chapter concludes with an illustration of the Cayley-Hamilton Theorem and a wealth of challenging exercises. As a coda, a program is developed that goes through the Standard Mathematica Packages to identify the “Top 10 Built-in Commands”used in producing the distributed Mathematica system. It should come as little surprise to the reader of this review that these are, in order: List, Pattern, Blank, Set, Times, Power, Plus, Null, CompoundExpression, and SetDelayed.This list explains the emphasis Trott has placed on lists, patters and execution semantics in this volume.

Trott maintains a web site for the GuideBooks where additional examples, graphics galleries, and errata and can be found and downloaded. The graphics gallery is well worth the visit!

The Mathematica GuideBook for Programming provided this reviewer with insights into solving and visualizing problems by using Mathematica rather than the other way around. Its wealth of exercises, annotated solutions and integrated bibliographic references should make this set a valuable part of the library of any Mathematica user. I highly recommend it.


Marvin Schaefer (bwapast@erols.com) is a computer security expert and was chief scientist at the National Computer Security Center at the NSA, and at Arca Systems. He has been a member of the MAA for 39 years and now operates an antiquarian book store called Books With a Past.

Date Received: 
Tuesday, August 1, 2006
Reviewable: 
Yes
Include In BLL Rating: 
No
Michael Trott
Publication Date: 
2004
Format: 
Hardcover
Category: 
Manual
Marvin Schaefer
08/1/2006

CHAPTER 0 Introduction and Orientation

0.1 Overview

0.1.1 Content Summaries

0.1.2 Relation of the Four Volumes

0.1.3 Chapter Structure

0.1.4 Code Presentation Style

0.2 Requirements

0.2.1 Hardware and Software

0.2.2 Reader Prerequisites

0.3 What theGuideBooks Are and What They Are Not

0.3.1 Doing Computer Mathematics

0.3.2 Programming Paradigms

0.4 Exercises and Solutions

0.4.1 Exercises

0.4.2 Solutions

0.5 The Books Versus the Electronic Components

0.5.1 Working with the Notebook

0.5.2 Reproducibility of the Results

0.5.3 Earlier Versions of the Notebooks

0.6 Style and Design Elements

0.6.1 Text and Code Formatting

0.6.2 References

0.6.3 Variable Scoping, Input Numbering, and Warning Messages

0.6.4 Graphics

0.6.5 Notations and Symbols

0.6.6 Units

0.6.7 Cover Graphics

0.7 Production History

0.8 Four General Suggestions

References

CHAPTER 1 Introduction to Mathematica

1.0 Remarks

1.1 Basics of Mathematica as a Programming Language

1.1.1 General Background

  • In and Out Numbering
  • General Naming, Spelling, and Capitalization Conventions for Symbols
  • Options and Option Settings
  • Messages
  • Add-On Packages

1.1.2 Elementary Syntax

  • Common Shortcuts
  • Parentheses, Braces, and Brackets
  • Comments Inside Code
  • Font Usage
  • Referring to Outputs
  • Functional Programming Style
  • "Ideal" Formatting

1.2 Introductory Examples

1.2.0 Remarks

1.2.1 Numerical Computations

  • Periodic Continued Fractions
  • Pisot Numbers
  • Fast Integer Arithmetic
  • Digit Sums
  • Numerical Integration
  • Numerical ODE Solving
  • Burridge-Knopoff Earthquake Model
  • Trajectories in a Random Two-Dimensional Potential
  • Numerical PDE Solving
  • Benney PDE
  • Sierpinski Triangle-Generating PDE
  • Monitoring Numerical Algorithms
  • Hilbert Matrices
  • Distances between Matrix Eigenvalues
  • Special Functions of Mathematical Physics
  • Sums and Products
  • Computing a High-Precision Value for Euler's Constant γ
  • Numerical Root-Finding
  • Roots of Polynomials
  • Jensen Disks
  • De Rham's Function
  • Logistic Map
  • Built-in Pseudo-Compiler
  • Forest Fire Model
  • Iterated Digit Sums
  • Modeling a Sinai Billiard

1.2.2 Graphics

  • Gibbs Phenomena
  • Fourier Series of Products of Discontinuous Functions
  • Dirichlet Function
  • Counting Digits
  • Apollonius Circles
  • Generalized Weierstrass Function
  • 3D Plots
  • Plotting Parametrized Surfaces
  • Plotting Implicitly Defined Surfaces
  • Graphics-Objects as Mathematica Expressions
  • Kepler Tiling
  • Fractal Post Sign
  • Polyhedral Flowers
  • Gauss Map Animation
  • Random Polyehdra

1.2.3 Symbolic Calculations

  • Differentiation
  • Integration
  • Symbolic Solutions of ODEs
  • Vandermonde Matrix
  • LU Decomposition of a Vandermonde Matrix
  • Redheffer Matrix
  • Symbolic Representations of Polynomial Roots
  • Solving Systems of Polynomials
  • Eliminating Variables from Polynomial Systems
  • Series Expansions
  • L'Ho^spital's Rule
  • Radical Expressions of Trigonometric Function Values
  • Prime Factorizations
  • Symbolic Summation
  • Proving Legendre's Elliptic Integral Identity
  • Geometric Theorem Proofs Using Gröbner Bases
  • Medial Parallelograms
  • Inequality Solving
  • Symbolic Description of a Thickened Lissajous Curve
  • Simplifications under Assumptions
  • Numbers with Identical Digits in the Decimal and Continued Fraction Expansions
  • Conformal Map of a Square to the Unit Disk
  • Vortex Motion in a Rectangle
  • Magnetic Field of a Magnet with Air Gap
  • Localized Propagating Solution of the Maxwell Equation
  • Customized Notations
  • Schmidt Decomposition of a Two-Particle State

1.2.4 Programming

  • Large Calculations
  • Partitioning Integers
  • Binary Splitting-Based Fast Factorial
  • Bolyai Expansion in Nested Radicals
  • Defining Pfaffians
  • Bead Sort Algorithm
  • Structure of Larger Programs
  • Making Platonic Solids from Tori
  • Equipotential Surfaces of a Charged Icosahedral Wireframe
  • Tube along a 3D Hilbert Curve

1.3 What Computer Algebra and Mathematica 5.1 Can and Cannot Do

  • What Mathematica Does Well
  • What Mathematica Does Reasonably Well
  • What Mathematica Cannot Do
  • Package Proposals
  • What Mathematica Is and What Mathematica Not Is
  • Impacts of Computer Algebra
  • Relevant Quotes
  • Computer Algebra and Human Creativity
  • New Opportunities Opened by Computer Algebra
  • Computer Mathematics--The Joy Now and the Joy to Come

Exercises

  • Computing Wishes and Proposals
  • Computer Algebra Systems

Solutions

  • 100 Proposals for Problems to Tackle
  • Sources of Interesting and Challenging Problems
  • ISSAC Challenge Problems
  • 100$-100-Digit Challenge

References

CHAPTER 2 Structure of Mathematica Expressions

2.0 Remarks

2.1 Expressions

  • Everything Is an Expression
  • Hierarchical Structure of Symbolic Expressions
  • Formatting Possibilities
  • Traditional Mathematics Notation versus Computer Mathematics Notation
  • Typeset Forms
  • Heads and Arguments
  • Symbols
  • Nested Heads
  • Input Form and the Formatting of Programs

2.2 Simple Expressions

2.2.1 Numbers and Strings

  • Formatting Fractions
  • Integers
  • Autosimplifications
  • Rational Numbers
  • Approximate Numbers
  • Real Numbers
  • Complex Numbers
  • Autonumericalization of Expressions
  • Strings
  • High-Precision Numbers
  • Inputting Approximate Numbers
  • Inputting High-Precision Numbers
  • Approximate Zeros

2.2.2 Simplest Arithmetic Expressions and Functions

  • Basic Arithmetic Operations
  • Reordering Summands and Factors
  • Precedences of Simple Operators
  • Algebraic Numbers
  • Domains of Numeric Functions
  • Autoevaluations of Sums, Differences, Products, Quotients, and Powers

2.2.3 Elementary Transcendental Functions

  • Exponential and Logarithmic Functions
  • Trigonometric and Hyperbolic Functions
  • Exponential Singularities
  • Picard's Theorem
  • Secants Iterations
  • Exact and Approximate Arguments
  • Postfix Notation
  • Infix Notation

2.2.4 Mathematical Constants

  • Imaginary Unit
  • pi
  • Autoevaluations of Trigonometric Functions
  • Base of the Natural Logarithm
  • Golden Ratio
  • Euler's Constant γ
  • Directed and Undirected Infinities
  • Indeterminate Expressions

2.2.5 Inverse Trigonometric and Hyperbolic Functions

  • Multivalued Functions
  • Inverse Trigonometric Functions
  • Inverse Hyperbolic Functions
  • Complex Number Characteristics
  • Real and Imaginary Parts of Symbolic Expressions
  • Branch Points and Branch Cuts
  • Branch Cuts Not Found in Textbooks

2.2.6 Do Not Be Disappointed

  • Real versus Complex Arguments
  • Seemingly Missing Simplifications
  • Principal Sheets of Multivalued Functions

2.2.7 Exact and Approximate Numbers

  • Symbols and Constants
  • Numericalization to Any Number of Digits
  • Precision of Real Numbers
  • Precision of Complex Numbers

2.3 Nested Expressions

2.3.1 An Example

  • Constructing Nested Expressions
  • Canonical Order
  • Displaying Outlines of Expressions
  • Displaying Nested Expressions

2.3.2 Analysis of a Nested Expression

  • A Large Expression
  • Parts of Expressions
  • Recursive Part Extraction
  • Depths of Expressions
  • Extracting Multiple Parts
  • Extracting Parts Hierarchically
  • Locating Subexpressions in Expressions
  • Level Specifications
  • Length of Expressions
  • Leaves of Expressions

2.4 Manipulating Numbers

2.4.1 Parts of Fractions and Complex Numbers

  • Rational Numbers as Raw Objects
  • Numerators and Denominators
  • Complex Numbers as Raw Objects
  • Real and Imaginary Parts

2.4.2 Digits of Numbers

  • Digits of Integers
  • Digits of Real Numbers
  • Writing Numbers in Any Base
  • Counting Digits of Numbers
  • Fibonacci Chain Map Animation

Overview

Exercises

  • Analyzing the Levels of an Expression
  • Branch Cuts of Nested Algebraic Functions
  • Analyzing the Branch Cut Structure of Inverse Hyperbolic Functions
  • "Strange" Analytic Functions

Solutions

  • Principal Roots
  • Analyzing a Large Expression
  • Levels Counted from Top and Bottom
  • Branch Cuts of (z^4)^1/4
  • Branch Cuts of sqrt(z+1/z)sqrt(z-1/z)
  • Riemann Surface of arctan(tan(z/2)/2)
  • Repeated Mappings of Singularities

References

CHAPTER 3 Definitions and Properties of Functions

3.0 Remarks

3.1 Defining and Clearing Simple Functions

3.1.1 Defining Functions

  • Immediate and Delayed Function Definitions
  • Expansion and Factorization of Polynomials
  • Expansion and Factorization of Trigonometric Expressions
  • Patterns
  • Nested Patterns
  • Patterns in Function Definitions
  • Recursive Definitions
  • Indefinite Integration
  • Matching Patterns
  • Definitions for Special Values
  • Functions with Several Arguments
  • Ordering of Definitions

3.1.2 Clearing Functions and Values

  • Clearing Symbol Values
  • Clearing Function Definitions
  • Clearing Specific Definitions
  • Removing Symbols
  • Matching Names by Name Fragments
  • Metacharacters in Strings

3.1.3 Applying Functions

  • Univariate and Multivariate Functions
  • Prefix Notation
  • Postfix Notation
  • Infix Notation

3.2 Options and Defaults

  • Meaning and Usage of Options
  • Lists as Universal Containers
  • Options of Functions
  • Plotting Simple Functions
  • Extracting Option Values
  • Setting Option Values

3.3 Attributes of Functions

  • Meaning and Usage of Attributes
  • Assigning Attributes to Functions
  • Commutative Functions
  • Associative Functions
  • Functions Operating Naturally on Lists
  • Numerical Functions
  • Differentiation of Functions
  • Protected Functions
  • Preventing the Evaluation of Expressions
  • Forcing the Evaluation of Expressions

3.4 Downvalues and Upvalues

  • Function Definitions Associated with Heads
  • Function Definitions Associated with Specific Arguments
  • Downvalues and Upvalues
  • Timing for Adding and Removing Definitions
  • Caching
  • Values of Symbols
  • Numerical Values of Symbols

3.5 Functions that Remember Their Values

  • Caching Function Values
  • Multiple Assignments
  • Simplification of Expressions
  • Timings of Computations
  • Takeuchi Function

3.6 Functions in the λ-Calculus

  • λ-Calculus
  • Functions as Mappings
  • Functions without Named Arguments
  • Self-Reproducing Functions
  • Splicing of Arguments
  • Sequences of Arguments
  • Pure Functions with Attributes
  • Nested Pure Functions

3.7 Repeated Application of Functions

  • Applying Functions Repeatedly
  • Iterative Maps
  • Solving an ODE by Iterated Integration
  • Iterated Logarithm in the Complex Plane
  • Fixed Points of Maps
  • Fixed Point Iterations
  • Newton's Method for Square Root Extraction
  • Basins of Attractions
  • Cantor Series

3.8 Functions of Functions

  • Compositions of Functions
  • Applying Lists of Heads
  • Inverse Functions
  • Differentiation of Inverse Functions

Overview

Exercises

  • Predicting Results of Inputs
  • Nice Polynomial Expansions
  • Laguerre Polynomials
  • Puzzles
  • Unexpected Outputs
  • Power Tower
  • Cayley Multiplication

Solutions

  • Matching Unevaluated Arguments
  • Equality of Pure Functions
  • Invalid Patterns
  • Counting Function Applications

References

CHAPTER 4 Meta-Mathematica

4.0 Remarks

4.1 Information on Commands

4.1.1 Information on a Single Command

  • Built-in Function Definitions as Outputs
  • Information about Functions
  • Listing of All Built-in Commands
  • Messages
  • Printing Text and Cells
  • Warnings and Error Messages
  • Wrong and "Unexpected" Inputs
  • Suppressing Messages
  • Carrying out Multiple Calculations in One Input

4.1.2 A Program that Reports on Functions

  • Converting Strings to Expressions
  • Converting Expressions to Strings
  • String Form of Typeset Expressions

4.2 Control over Running Calculations and Resources

4.2.1 Intermezzo on Iterators

  • Do Loops
  • Multiple Iterators
  • Possible Iterator Constructions
  • Iterator Step Sizes

4.2.2 Control over Running Calculations and Resources

  • Aborting Calculations
  • Protecting Calculations from Aborts
  • Interrupting and Continuing Calculations
  • Collecting Data on the Fly
  • Time-Constrained Calculations
  • Memory-Constrained Calculations
  • Time and Memory Usage in a Session
  • Expressions Sharing Memory
  • Memory Usage of Expressions

4.3 The $-Commands

4.3.1 System-Related Commands

  • Mathematica Versions
  • The Date Function
  • Smallest and Largest Machine Real Numbers

4.3.2 Session-Related Commands

  • In and Out Numbering
  • Input History
  • Collecting Messages
  • Display of Graphics
  • Controlling Recursions and Iterations
  • Deep Recursions
  • Ackermann Function

4.4 Communication and Interaction with the Outside

4.4.1 Writing to Files

  • Extracting Function Definitions
  • Writing Data and Definitions to Files
  • Reading Data and Definitions from Files
  • File Manipulations

4.4.2 Simple String Manipulations

  • Concatenating Strings
  • Replacing Substrings
  • General String Manipulations
  • Case Sensitivity and Metacharacters
  • A Program that Prints Itself

4.4.3 Importing and Exporting Data and Graphics

  • Importing and Exporting Files
  • Importing Web Pages
  • Importing From and To Strings
  • Making Low-Resolution JPEGs

4.5 Debugging

  • Displaying Steps of Calculations
  • Evaluation Histories as Expressions
  • Recursion versus Iteration
  • Interactive Inputs

4.6 Localization of Variable Names

4.6.1 Localization of Variables in Iterator Constructions

  • Sums and Products
  • Scoping of Iterator Variables

4.6.2 Localization of Variables in Subprograms

  • Scoping Constructs
  • Lexical Scoping
  • Dynamic Scoping
  • Local Constants
  • Temporary Variables
  • Variable Scoping in Pure Functions
  • Creating Unique Variables
  • Nonlocal Program Flow

4.6.3 Comparison of Scoping Constructs

  • Delayed Assignments in Scoping Constructs
  • Temporarily Changing Built-in Functions
  • Variable Localization in Iterators
  • Scoping in Nested Pure Functions
  • Nesting Various Scoping Constructs
  • Timing Comparisons of Scoping Constructs

4.6.4 Localization of Variables in Contexts

  • Contexts
  • Variables in Contexts
  • Searching through Contexts
  • Manipulating Contexts
  • Beginning and Ending Contexts

4.6.5 Contexts and Packages

  • Loading Packages
  • General Structure of Packages
  • Private Contexts
  • Analyzing Context Changes

4.6.6 Special Contexts and Packages

  • Developer Functions
  • Special Simplifiers
  • Bit Operations
  • Experimental Functions
  • Standard Packages

4.7 The Process of Evaluation

  • Details of Evaluating an Expression
  • Analyzing Evaluation Examples
  • Standard Evaluation Order
  • Nonstandard Evaluations
  • Held Arguments

Overview

Exercises

  • Frequently Seen Messages
  • Unevaluated Arguments
  • Predicting Results of Inputs
  • Analyzing Context Changes
  • Evaluated versus Unevaluated Expressions

Solutions

  • Shortcuts for Functions
  • Functions with Zero Arguments
  • Small Expressions that Are Large
  • Localization of Iterator Variables
  • Dynamical Context Changes
  • Local Values

References

CHAPTER 5 Restricted Patterns and Replacement Rules

5.0 Remarks

5.1 Boolean and Related Functions

5.1.1 Boolean Functions for Numbers

  • Truth Values
  • Predicates
  • Functions Ending with Q
  • Numbers and Numeric Quantities
  • Integer and Real Numbers
  • Compound Numeric Quantities
  • Exact and Inexact Numbers
  • Primality
  • Gaussian Primes
  • Stating Symbolic and Verifying Numeric Inequalities
  • Comparisons of Numbers
  • Ordering Relations
  • Positivity

5.1.2 Boolean Functions for General Expressions

  • Testing Expressions for Being a Polynomial
  • Vectors and Matrices
  • Mathematical Equality
  • Equality and Equations
  • Structural Equality
  • Identity of Expressions
  • Equality versus Identity
  • Canonical Order
  • Membership Tests

5.1.3 Logical Operations

  • Boolean Operations
  • And, Or, Not, and Xor
  • Rewriting Logical Expressions
  • Precedences of Logical Operators

5.1.4 Control Structures

  • Branching Constructs
  • The If Statement
  • Undecidable Conditions
  • While and For Loops
  • Prime Numbers in Arithmetic Progression

5.1.5 Piecewise Functions

  • Piecewise Defined Functions
  • Canonicalization of Piecewise Functions
  • Composition of Piecewise Functions
  • Interpreting Functions as Piecewise Functions
  • Specifying Geometric Regions
  • Endpoint Distance Distribution of Random Flights

5.2 Patterns

5.2.1 Patterns for Arbitrary Variable Sequences

  • Simple Patterns
  • Patterns for Multiple Arguments
  • Testing Patterns
  • Named Patterns
  • Trace of Products of Gamma Matrices
  • Shortcuts for Patterns
  • Avoiding Evaluation in Patterns
  • Literal Patterns

5.2.2 Patterns with Special Properties

  • Optional Arguments
  • Default Values for Optional Arguments
  • Repeated Arguments
  • Excluding Certain Patterns
  • Alternative Arguments
  • Restricted Patterns
  • Pattern Tests
  • Conditional Patterns
  • Recursive Definitions
  • Pattern-Based Evaluation of Elliptic Integrals
  • Generating Tables
  • Selecting Elements from Lists
  • All Syntactically Correct Shortcuts

5.2.3 Attributes of Functions and Pattern Matching

  • Pattern Matching in Commutative and Associative Functions
  • Arguments in Any Order
  • Nested Functions
  • Automatic Use of Defaults
  • Analyzing Matchings and Recursions in Pattern and Attribute Combinations

5.3 Replacement Rules

5.3.1 Replacement Rules for Patterns

  • Immediate and Delayed Rules
  • One-Time and Repeated Replacements
  • Unevaluated Replacements
  • Common Pattern Matching Pitfalls
  • Finding All Possible Replacements
  • Scoping in Rules
  • Replacements and Attributes
  • Modeling Function Definitions
  • Options and Rules
  • Replacing Position-Specified Parts of Expressions

5.3.2 Large Numbers of Replacement Rules

  • Optimized Rule Application
  • Complexity of Optimized Rule Application

5.3.3 Programming with Rules

  • Examples of Rule-Based Programs
  • Splitting Lists
  • Cycles of Permutations
  • Sorting of Complex Numbers
  • Cumulative Maxima
  • Dividing Lists
  • House of the Nikolaus
  • Polypaths
  • Rule-Based versus Other Programming Styles

5.4 String Patterns

  • Strings with Pattern Elements
  • Patterns for Character Sequences
  • String-Membership Tests
  • Shortest and Longest Possible Matches
  • Overlapping Matches
  • Counting Characters
  • Replacing Characters
  • All Possible Replacements
  • Analyzing the Online Documentation
  • Cumulative Letter Frequencies

Overview

Exercises

  • Rule-Based Expansion of Polynomials
  • All Possible Patterns from a Given Set of Shortcuts
  • Extending Built-in Functions
  • General Finite Difference Weights
  • Zeta Function Derivatives
  • Operator Products
  • q-Binomial Theorem
  • q-Derivative
  • Ordered Derivatives
  • Differentiating Parametrized Matrices
  • Ferrer Conjugates
  • Hermite Polynomial Recursions
  • Peakons
  • Puzzles
  • Catching Arguments and Their Head in Calculations
  • Nested Scoping

Solutions

  • Modeling Noncommutative Operations
  • Campbell-Baker-Hausdorff Formula
  • Counting Function Calls Using Side Effects
  • q-Deformed Pascal Triangle
  • Ordered Derivative
  • Avoiding Infinite Recursions in Pattern Matchings
  • Dynamically Generated Definitions

References

CHAPTER 6 Operations on Lists, and Linear Algebra

6.0 Remarks

  • Prevalence of List Manipulations
  • Building Polyhedra by Reflecting Polygons Iteratively
  • Animating the Folding Process Based on Iterated Reflections

6.1 Creating Lists

6.1.1 Creating General Lists

  • Lists and Nested Lists as Arrays, Tables, Vectors, and Matrices
  • Timings of Creating Nested Lists
  • Changing Heads of Expressions
  • Summing Elements of Lists

6.1.2 Creating Special Lists

  • Kronecker Symbol and Identity Matrix
  • Levi-Civita Symbol and Antisymmetric Tensors
  • Creating Multiple Iterators
  • Stirling Numbers
  • Subsets and Tuples

6.2 Representation of Lists

  • 2D Formatting of Tables and Matrices
  • Aligning Rows and Columns
  • Formatting Higher-Dimensional Tensors
  • Tensors and Arrays

6.3 Manipulations on Single Lists

6.3.1 Shortening Lists

  • Extracting Elements from Lists
  • Deleting Elements by Specifying Position, Pattern, or Property
  • Prime Sieving

6.3.2 Extending Lists

  • Prepending, Appending, and Inserting List Elements
  • Working with Named Lists

6.3.3 Sorting and Manipulating Elements

  • Rotating Lists Cyclically
  • Sorting Lists
  • Sorting Criteria
  • Analyzing the Built-in Sorting Algorithm
  • Splitting Lists
  • Mapping Functions over Lists
  • Listable Functions
  • Mapping Functions to Expressions and Parts of Expressions
  • Extracting Common Subexpressions
  • Optimized Expressions

6.3.4 Arithmetical Properties of Lists

  • Average Value of a List
  • Sum of a List
  • Variance of a List
  • Quantiles of a List

6.4 Operations with Several Lists or with Nested Lists

6.4.1 Simple Operations

  • Hadamard Arithmetic on Lists
  • Transposing Tensors
  • Permutations
  • Using Side Effects for Monitoring List Algorithms
  • Joining Lists
  • Intersections and Complements of Lists
  • Finding Approximately Identical Elements

6.4.2 List of All System Commands

  • Working with Unevaluated Expressions
  • Options and Attributes of All Built-in Functions
  • Analyzing All Built-in Function Names
  • Dependencies of Definitions

6.4.3 More General Operations

  • Contractions and Kronecker Products--Inner and Outer Products
  • Rotations in 3D
  • Cross Products
  • Threading Functions over Lists

6.4.4 Constructing a Crossword Puzzle

  • A Large, List-Based Calculation
  • Example Construction
  • Manipulating Function Definitions through Downvalues
  • Crossword Array of All Built-in Functions
  • Crossword Array of All Package Functions
  • Crossword Array of All Named Characters

6.5 Mathematical Operations with Matrices

6.5.1 Linear Algebra

  • Inverse Matrices
  • Determinants
  • Timing Comparisons for Various Element Types
  • Traces of Matrices
  • Modeling Trace Calculations
  • Eigenvalues and Eigenvectors
  • Pauli Matrices
  • Properties of Eigenprojectors
  • Power Method for Finding the Largest Eigenvalue
  • Generalized Eigenvalue Problem
  • Solving Systems of Linear Equations
  • Siamese Sisters
  • Lorentz Transformations in Matrix Form
  • Moore-Penrose Inverse
  • Best Solutions to Overdetermined Linear Systems
  • Algorithms of Linear Algebra
  • Quantum Cellular Automata
  • Extending Linear Algebra Functions

6.5.2 Constructing and Solving Magic Squares

  • Underdetermined Linear Systems
  • Integer Solutions of Linear Systems
  • Decoding and Encoding Magic Squares
  • Finding All Solutions of a Magic Square

6.5.3 Powers and Exponents of Matrices

  • Integer and Fractional Powers of Matrices
  • Exponential Function of a Matrix
  • Trigonometric Functions of Matrices
  • Fractional Powers and Matrix Spectral Decompositions
  • Matrix Evolution Equations
  • Time-Development of a Linear Chain
  • Cayley-Hamilton Theorem
  • Characteristic Polynomials

6.6 The Top Ten Built-in Commands

  • Finding Filenames
  • Working with Unevaluated Expressions
  • Counting Function Uses
  • Reading Packages
  • Zipf's Law
  • Analyzing Notebooks, Cell Types, References, Typeset Structures, and Text

Overview

Exercises

  • Benford's Rule
  • Timing Comparisons for List Operations
  • Sum-Free Sets
  • Generating an Index for This Book
  • Consistency of References
  • Line Length Distribution
  • Spacing Check
  • Moessner's Process
  • Ducci's Iterations
  • Stieltjes Iterations
  • Pseudorandom trees
  • Levi-Civita Tensor Contractions
  • Dirac Matrices Products
  • Determinants of Multidimensional Arrays
  • Mediants
  • d'Hondt Voting
  • Identifying Approximate Vectors Efficiently
  • Unsorted Complements
  • All Arithmetic Expressions
  • Ideal Formatting
  • Functions with Method Options
  • Functions with Level Specifications
  • Changing Formatting by Programs
  • Pattern Instances
  • Matrix Identities
  • Amitsur-Levitzky Identity
  • Frobenius Formula for Block Matrices
  • Iterative Matrix Square Root
  • Differential Matrix Identities
  • Matrix Derivatives
  • Autoloaded Functions
  • Precedences of All Operators
  • One-Liners
  • Changing $1
  • Meissel Formula
  • Binary Bracketing
  • Kolakoski Sequence
  • Puzzles
  • Cloning Functions
  • Hash Values
  • Permutation Digit Sets

Solutions

  • Chemical Element Data
  • Population Data of US Cities and Villages
  • Caching versus List-Lookup
  • Electronic Publication Growth
  • Statistics of Author Initials
  • Analyzing Bracket Frequencies
  • Word Neighbor Statistics
  • Weakly Decreasing Sequences
  • Finding All Built-in Symbols with Values
  • Automated Custom Code Formatting
  • Making Dynamically Formatted Inputs
  • Working with Symbolic Matrices
  • Downvalues and Autoloading
  • Determining Precedence Automatically
  • Permutation Polynomials
  • Working with Virtual Matrices

References

Publish Book: 
Modify Date: 
Monday, August 7, 2006

Dummy View - NOT TO BE DELETED