This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Wolfram Research, Inc.


Programming in Mathematica

The example programs and packages in AddOns/ExtraPackages/ProgrammingInMathematica accompany the book

Roman E. Maeder: Programming in Mathematica, 3rd ed., Addison-Wesley, 1996

ISBN 0-201-85449-X.

The third edition covers Mathematica, Versions 3 and 4, and has been expanded considerably over the first and second editions.

For more information, visit the book's WWW site at

The Files in ProgrammingInMathematica

These programs are not maintained by Wolfram Research, Inc., and Wolfram Research technical support will not answer questions about these programs.

Packages (Files with a .m extension)

Except for the iterated function systems example (Chapter 12), the packages are not documented on line. They are fully described in the book Programming in Mathematica.


BookPictures.nb contains the code and graphics of all chapter-opener pictures.

ChaosGame.nb is a package in notebook form. The package ChaosGame.m is updated automatically everytime the notebook is saved.

NotebookDemo.nb contains examples of frontend programming.

Template.nb is a template for notebooks and packages.

Documentation Directory

The notebooks and the BrowserCategories.m file in Documentation/English are part of the on-line help for Programming in Mathematica. The entry "Programming in Mathematica" should appear under the topic AddOns, subtopic Extras.

Programming in Mathematica Table of Contents


About This Book

    Chapter Overview

    About the Examples

    Notation and Terminology

    Electronic Resources

    Teaching Mathematica Programming

1 Introduction

    1.1 From Calculations to Programs

    1.2 Basic Ingredients of a Package

    1.3 A Second Function in the Package

    1.4 Options

    1.5 Defaults for Positional Arguments

    1.6 Parameter Type Checking

2 Packages

    2.1 Contexts

    2.2 Packages that Use Other Packages

    2.3 Protection of Symbols in a Package

    2.4 Package Framework and Documentation

    2.5 Loading Packages

    2.6 Large Projects

3 Defaults and Options

    3.1 Default Values

    3.2 Options for Your Functions

    3.3 Setting Options of Several Commands

4 Functional and Procedural Programming

    4.1 Procedures and Local Variables

    4.2 Loops

    4.3 Structured Iteration

    4.4 Iterated Function Application

    4.5 Map and Apply

    4.6 Application: The Platonic Solids

    4.7 Operations on Lists and Matrices

5 Evaluation

    5.1 Evaluation of the Body of a Rule

    5.2 Pure Functions

    5.3 Nonstandard Evaluation

    5.4 Nonlocal Flow of Control

    5.5 Definitions

    5.6 Advanced Topic: Scopes of Names

6 Transformation Rules

    6.1 Simplification Rules and Normal Forms

    6.2 Application: Trigonometric Simplifications

    6.3 Globally Defined Rules

    6.4 Pattern Matching for Rules

    6.5 Traversing Expressions

7 Numerical Computations

    7.1 Numbers

    7.2 Numerical Evaluation

    7.3 Numeric Quantities

    7.4 Application: Differential Equations

8 Interaction with Built-In Rules

    8.1 Modifying the Main Evaluation Loop

    8.2 User-Defined Rules Take Precedence

    8.3 Modifying System Function

    8.4 Advanced Topic: A New Mathematical Function

9 Input and Output

    9.1 Input and Output Formatting

    9.2 Input from Files and Programs

    9.3 Running \@Om \ Unattended

    9.4 Session Logging

    9.5 Advanced Topic: Typesetting Mathematics

10 Graphics Programming

    10.1 Graphics Packages

    10.2 Animated Graphics

    10.3 The Chapter Pictures

11 Notebooks

    11.1 Packages and Notebooks

    11.2 The Structure of Notebooks

    11.3 Frontend Programming

12 Application: Iterated Function Systems

    12.1 Affine Maps

    12.2 Iterated Function Systems

    12.3 Examples of Invariant Sets

    12.4 Documentation: Help Notebooks and Manuals

Appendix A Exercises

    A.1 Programming Exercises

    A.2 Solutions

Appendix B Bibliography

    B.1 Background Information and Further Reading

    B.2 References



    Subjects and Names