This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / The Mathematica Book  /
Front Matter
Copyright Information
Contact Information
About the Author
About Mathematica
Some New Features of Mathematica 3.0
The Role of This Book
Suggestions about Learning Mathematica

A Tour of Mathematica
Contents
A Practical Introduction to Mathematica
1.0 Running Mathematica
1.0.1 Notebook Interfaces
1.0.2 Text-Based Interfaces

1.1 Numerical Calculations
1.1.1 Arithmetic
1.1.2 Exact and Approximate Results
1.1.3 Some Mathematical Functions
1.1.4 Arbitrary-Precision Calculations
1.1.5 Complex Numbers
1.1.6 Getting Used to Mathematica
1.1.7 Mathematical Notation in Notebooks

1.2 Building Up Calculations
1.2.1 Using Previous Results
1.2.2 Defining Variables
1.2.3 Making Lists of Objects
1.2.4 Manipulating Elements of Lists
1.2.5 The Four Kinds of Bracketing in Mathematica
1.2.6 Sequences of Operations

1.3 Using the Mathematica System
1.3.1 The Structure of Mathematica
1.3.2 Differences between Computer Systems
1.3.3 Special Topic: Using a Text-Based Interface
1.3.4 Doing Computations in Notebooks
1.3.5 Notebooks as Documents
1.3.6 Active Elements in Notebooks
1.3.7 Special Topic: Hyperlinks and Active Text
1.3.8 Getting Help in the Notebook Front End
1.3.9 Getting Help with a Text-Based Interface
1.3.10 Mathematica Packages
1.3.11 Warnings and Messages
1.3.12 Interrupting Calculations

1.4 Algebraic Calculations
1.4.1 Symbolic Computation
1.4.2 Values for Symbols
1.4.3 Transforming Algebraic Expressions
1.4.4 Simplifying Algebraic Expressions
1.4.5 Advanced Topic: Putting Expressions into Different Forms
1.4.6 Picking Out Pieces of Algebraic Expressions
1.4.7 Controlling the Display of Large Expressions
1.4.8 The Limits of Mathematica
1.4.9 Using Symbols to Tag Objects

1.5 Symbolic Mathematics
1.5.1 Basic Operations
1.5.2 Differentiation
1.5.3 Integration
1.5.4 Sums and Products
1.5.5 Equations
1.5.6 Relational and Logical Operators
1.5.7 Solving Equations
1.5.8 Differential Equations
1.5.9 Power Series
1.5.10 Limits
1.5.11 Packages for Symbolic Mathematics
1.5.12 Advanced Topic: Generic and Non-Generic Cases
1.5.13 Mathematical Notation in Notebooks

1.6 Numerical Mathematics
1.6.1 Basic Operations
1.6.2 Numerical Sums, Products and Integrals
1.6.3 Numerical Equation Solving
1.6.4 Numerical Differential Equations
1.6.5 Numerical Optimization
1.6.6 Manipulating Numerical Data
1.6.7 Statistics Packages

1.7 Functions and Programs
1.7.1 Defining Functions
1.7.2 Functions as Procedures
1.7.3 Repetitive Operations
1.7.4 Transformation Rules for Functions

1.8 Lists
1.8.1 Collecting Objects Together
1.8.2 Making Tables of Values
1.8.3 Vectors and Matrices
1.8.4 Getting Pieces of Lists
1.8.5 Testing and Searching List Elements
1.8.6 Adding, Removing and Modifying List Elements
1.8.7 Combining Lists
1.8.8 Advanced Topic: Lists as Sets
1.8.9 Rearranging Lists
1.8.10 Grouping Together Elements of Lists
1.8.11 Mathematical Operations on Lists
1.8.12 Advanced Topic: Rearranging Nested Lists
1.8.13 Advanced Topic: Combinatorial Operations

1.9 Graphics and Sound
1.9.1 Basic Plotting
1.9.2 Special Topic: How Graphics Are Output
1.9.3 Options
1.9.4 Redrawing and Combining Plots
1.9.5 Advanced Topic: Manipulating Options
1.9.6 Contour and Density Plots
1.9.7 Three-Dimensional Surface Plots
1.9.8 Converting between Types of Graphics
1.9.9 Plotting Lists of Data
1.9.10 Parametric Plots
1.9.11 Some Special Plots
1.9.12 Special Topic: Animated Graphics
1.9.13 Sound

1.10 Input and Output in Notebooks
1.10.1 Entering Greek Letters
1.10.2 Entering Two-Dimensional Input
1.10.3 Editing and Evaluating Two-Dimensional Expressions
1.10.4 Entering Formulas
1.10.5 Entering Tables and Matrices
1.10.6 Subscripts, Bars and Other Modifiers
1.10.7 Special Topic: Non-English Characters and Keyboards
1.10.8 Other Mathematical Notation
1.10.9 Forms of Input and Output
1.10.10 Mixing Text and Formulas
1.10.11 Displaying and Printing Mathematica Notebooks
1.10.12 Creating Your Own Palettes
1.10.13 Setting Up Hyperlinks
1.10.14 Automatic Numbering
1.10.15 Exposition in Mathematica Notebooks

1.11 Files and External Operations
1.11.1 Reading and Writing Mathematica Files
1.11.2 Advanced Topic: Finding and Manipulating Files
1.11.3 Reading Data Files
1.11.4 Generating C and Fortran Expressions
1.11.5 Exporting Graphics
1.11.6 Exporting Formulas from Notebooks
1.11.7 Generating TeX
1.11.8 Converting Notebooks to HTML
1.11.9 Splicing Mathematica Output into External Files
1.11.10 Running External Programs
1.11.11 MathLink

1.12 Special Topic: The Internals of Mathematica
1.12.1 Why You Do Not Usually Need to Know about Internals
1.12.2 Basic Internal Architecture
1.12.3 The Algorithms of Mathematica
1.12.4 The Software Engineering of Mathematica
1.12.5 Testing and Verification

Principles of Mathematica
2.1 Expressions
2.1.1 Everything Is an Expression
2.1.2 The Meaning of Expressions
2.1.3 Special Ways to Input Expressions
2.1.4 Parts of Expressions
2.1.5 Manipulating Expressions like Lists
2.1.6 Expressions as Trees
2.1.7 Levels in Expressions

2.2 Functional Operations
2.2.1 Function Names as Expressions
2.2.2 Applying Functions Repeatedly
2.2.3 Applying Functions to Lists and Other Expressions
2.2.4 Applying Functions to Parts of Expressions
2.2.5 Pure Functions
2.2.6 Building Lists from Functions
2.2.7 Selecting Parts of Expressions with Functions
2.2.8 Expressions with Heads That Are Not Symbols
2.2.9 Advanced Topic: Working with Operators
2.2.10 Structural Operations
2.2.11 Sequences

2.3 Patterns
2.3.1 Introduction
2.3.2 Finding Expressions That Match a Pattern
2.3.3 Naming Pieces of Patterns
2.3.4 Specifying Types of Expression in Patterns
2.3.5 Putting Constraints on Patterns
2.3.6 Patterns Involving Alternatives
2.3.7 Flat and Orderless Functions
2.3.8 Functions with Variable Numbers of Arguments
2.3.9 Optional and Default Arguments
2.3.10 Setting Up Functions with Optional Arguments
2.3.11 Repeated Patterns
2.3.12 Verbatim Patterns
2.3.13 Patterns for Some Common Types of Expression
2.3.14 An Example: Defining Your Own Integration Function

2.4 Transformation Rules and Definitions
2.4.1 Applying Transformation Rules
2.4.2 Manipulating Sets of Transformation Rules
2.4.3 Making Definitions
2.4.4 Special Forms of Assignment
2.4.5 Making Definitions for Indexed Objects
2.4.6 Making Definitions for Functions
2.4.7 The Ordering of Definitions
2.4.8 Immediate and Delayed Definitions
2.4.9 Functions That Remember Values They Have Found
2.4.10 Associating Definitions with Different Symbols
2.4.11 Defining Numerical Values
2.4.12 Modifying Built-in Functions
2.4.13 Advanced Topic: Manipulating Value Lists

2.5 Evaluation of Expressions
2.5.1 Principles of Evaluation
2.5.2 Reducing Expressions to Their Standard Form
2.5.3 Attributes
2.5.4 The Standard Evaluation Procedure
2.5.5 Non-Standard Evaluation
2.5.6 Evaluation in Patterns, Rules and Definitions
2.5.7 Evaluation in Iteration Functions
2.5.8 Conditionals
2.5.9 Loops and Control Structures
2.5.10 Tracing Evaluation
2.5.11 Advanced Topic: The Evaluation Stack
2.5.12 Advanced Topic: Controlling Infinite Evaluation
2.5.13 Advanced Topic: Interrupts and Aborts
2.5.14 Compiling Mathematica Expressions
2.5.15 Advanced Topic: Manipulating Compiled Code

2.6 Modularity and the Naming of Things
2.6.1 Modules and Local Variables
2.6.2 Local Constants
2.6.3 How Modules Work
2.6.4 Advanced Topic: Variables in Pure Functions and Rules
2.6.5 Dummy Variables in Mathematics
2.6.6 Blocks and Local Values
2.6.7 Blocks Compared with Modules
2.6.8 Contexts
2.6.9 Contexts and Packages
2.6.10 Setting Up Mathematica Packages
2.6.11 Automatic Loading of Packages
2.6.12 Manipulating Symbols and Contexts by Name
2.6.13 Advanced Topic: Intercepting the Creation of New Symbols

2.7 Strings and Characters
2.7.1 Properties of Strings
2.7.2 Operations on Strings
2.7.3 String Patterns
2.7.4 Characters in Strings
2.7.5 Special Characters
2.7.6 Advanced Topic: Newlines and Tabs in Strings
2.7.7 Advanced Topic: Character Codes
2.7.8 Advanced Topic: Raw Character Encodings

2.8 Textual Input and Output
2.8.1 Forms of Input and Output
2.8.2 How Input and Output Work
2.8.3 The Representation of Textual Forms
2.8.4 The Interpretation of Textual Forms
2.8.5 Short and Shallow Output
2.8.6 String-Oriented Output Formats
2.8.7 Output Formats for Numbers
2.8.8 Tables and Matrices
2.8.9 Styles and Fonts in Output
2.8.10 Representing Textual Forms by Boxes
2.8.11 Adjusting Details of Formatting
2.8.12 String Representation of Boxes
2.8.13 Converting between Strings, Boxes and Expressions
2.8.14 The Syntax of the Mathematica Language
2.8.15 Operators without Built-in Meanings
2.8.16 Defining Output Formats
2.8.17 Advanced Topic: Low-Level Input and Output Rules
2.8.18 Generating Unstructured Output
2.8.19 Generating Styled Output in Notebooks
2.8.20 Requesting Input
2.8.21 Messages
2.8.22 International Messages
2.8.23 Documentation Constructs

2.9 The Structure of Graphics and Sound
2.9.1 The Structure of Graphics
2.9.2 Two-Dimensional Graphics Elements
2.9.3 Graphics Directives and Options
2.9.4 Coordinate Systems for Two-Dimensional Graphics
2.9.5 Labeling Two-Dimensional Graphics
2.9.6 Making Plots within Plots
2.9.7 Density and Contour Plots
2.9.8 Three-Dimensional Graphics Primitives
2.9.9 Three-Dimensional Graphics Directives
2.9.10 Coordinate Systems for Three-Dimensional Graphics
2.9.11 Plotting Three-Dimensional Surfaces
2.9.12 Lighting and Surface Properties
2.9.13 Labeling Three-Dimensional Graphics
2.9.14 Advanced Topic: Low-Level Graphics Rendering
2.9.15 Formats for Text in Graphics
2.9.16 Graphics Primitives for Text
2.9.17 Advanced Topic: Color Output
2.9.18 The Representation of Sound

2.10 Manipulating Notebooks
2.10.1 Cells as Mathematica Expressions
2.10.2 Notebooks as Mathematica Expressions
2.10.3 Manipulating Notebooks from the Kernel
2.10.4 Manipulating the Front End from the Kernel
2.10.5 Advanced Topic: Executing Notebook Commands Directly in the Front End
2.10.6 Button Boxes and Active Elements in Notebooks
2.10.7 Advanced Topic: The Structure of Cells
2.10.8 Styles and the Inheritance of Option Settings
2.10.9 Options for Cells
2.10.10 Text and Font Options
2.10.11 Advanced Topic: Options for Expression Input and Output
2.10.12 Options for Graphics Cells
2.10.13 Options for Notebooks
2.10.14 Advanced Topic: Global Options for the Front End

2.11 Files and Streams
2.11.1 Reading and Writing Mathematica Files
2.11.2 External Programs
2.11.3 Advanced Topic: Streams and Low-Level Input and Output
2.11.4 Naming and Finding Files
2.11.5 Files for Packages
2.11.6 Manipulating Files and Directories
2.11.7 Reading Data
2.11.8 Searching Files
2.11.9 Searching and Reading Strings

2.12 MathLink and External Program Communication
2.12.1 How MathLink Is Used
2.12.2 Installing Existing MathLink-Compatible Programs
2.12.3 Setting Up External Functions to Be Called from Mathematica
2.12.4 Handling Lists, Arrays and Other Expressions
2.12.5 Special Topic: Portability of MathLink Programs
2.12.6 Using MathLink to Communicate between Mathematica Sessions
2.12.7 Calling Subsidiary Mathematica Processes
2.12.8 Special Topic: Communication with Mathematica Front Ends
2.12.9 Two-Way Communication with External Programs
2.12.10 Special Topic: Running Programs on Remote Computers
2.12.11 Special Topic: Running External Programs under a Debugger
2.12.12 Manipulating Expressions in External Programs
2.12.13 Advanced Topic: Error and Interrupt Handling
2.12.14 Running Mathematica from Within an External Program

2.13 Global Aspects of Mathematica Sessions
2.13.1 The Main Loop
2.13.2 Dialogs
2.13.3 Date and Time Functions
2.13.4 Memory Management
2.13.5 Advanced Topic: Global System Information
2.13.6 Advanced Topic: Customizing Your Mathematica Configuration

Advanced Mathematics in Mathematica
3.1 Numbers
3.1.1 Types of Numbers
3.1.2 Numeric Quantities
3.1.3 Converting between Different Forms of Numbers
3.1.4 Numerical Precision
3.1.5 Arbitrary-Precision Numbers
3.1.6 Machine-Precision Numbers
3.1.7 Advanced Topic: Interval Arithmetic
3.1.8 Advanced Topic: Indeterminate and Infinite Results
3.1.9 Advanced Topic: Controlling Numerical Evaluation

3.2 Mathematical Functions
3.2.1 Naming Conventions
3.2.2 Numerical Functions
3.2.3 Pseudorandom Numbers
3.2.4 Integer and Number-Theoretical Functions
3.2.5 Combinatorial Functions
3.2.6 Elementary Transcendental Functions
3.2.7 Functions That Do Not Have Unique Values
3.2.8 Mathematical Constants
3.2.9 Orthogonal Polynomials
3.2.10 Special Functions
3.2.11 Elliptic Integrals and Elliptic Functions
3.2.12 Mathieu and Related Functions
3.2.13 Working with Special Functions
3.2.14 Statistical Distributions and Related Functions

3.3 Algebraic Manipulation
3.3.1 Structural Operations on Polynomials
3.3.2 Finding the Structure of a Polynomial
3.3.3 Structural Operations on Rational Expressions
3.3.4 Algebraic Operations on Polynomials
3.3.5 Polynomials Modulo Primes
3.3.6 Advanced Topic: Polynomials over Algebraic Number Fields
3.3.7 Trigonometric Expressions
3.3.8 Expressions Involving Complex Variables
3.3.9 Simplification

3.4 Manipulating Equations
3.4.1 The Representation of Equations and Solutions
3.4.2 Equations in One Variable
3.4.3 Advanced Topic: Algebraic Numbers
3.4.4 Simultaneous Equations
3.4.5 Equations Involving Functions
3.4.6 Getting Full Solutions
3.4.7 Advanced Topic: Existence of Solutions
3.4.8 Eliminating Variables
3.4.9 Solving Equations with Subsidiary Conditions
3.4.10 Advanced Topic: Solving Logical Combinations of Equations
3.4.11 Advanced Topic: Equations Modulo Integers

3.5 Calculus
3.5.1 Differentiation
3.5.2 Total Derivatives
3.5.3 Derivatives of Unknown Functions
3.5.4 Advanced Topic: The Representation of Derivatives
3.5.5 Defining Derivatives
3.5.6 Indefinite Integrals
3.5.7 Integrals That Can and Cannot Be Done
3.5.8 Definite Integrals
3.5.9 Manipulating Integrals in Symbolic Form
3.5.10 Differential Equations

3.6 Series, Limits and Residues
3.6.1 Making Power Series Expansions
3.6.2 Advanced Topic: The Representation of Power Series
3.6.3 Operations on Power Series
3.6.4 Advanced Topic: Composition and Inversion of Power Series
3.6.5 Converting Power Series to Normal Expressions
3.6.6 Solving Equations Involving Power Series
3.6.7 Summation of Series
3.6.8 Finding Limits
3.6.9 Residues

3.7 Linear Algebra
3.7.1 Constructing Matrices
3.7.2 Getting Pieces of Matrices
3.7.3 Scalars, Vectors and Matrices
3.7.4 Operations on Scalars, Vectors and Matrices
3.7.5 Multiplying Vectors and Matrices
3.7.6 Matrix Inversion
3.7.7 Basic Matrix Operations
3.7.8 Solving Linear Systems
3.7.9 Eigenvalues and Eigenvectors
3.7.10 Advanced Topic: Matrix Decompositions
3.7.11 Advanced Topic: Tensors

3.8 Numerical Operations on Data
3.8.1 Curve Fitting
3.8.2 Approximate Functions and Interpolation
3.8.3 Fourier Transforms

3.9 Numerical Operations on Functions
3.9.1 Numerical Mathematics in Mathematica
3.9.2 The Uncertainties of Numerical Mathematics
3.9.3 Numerical Integration
3.9.4 Numerical Evaluation of Sums and Products
3.9.5 Numerical Solution of Polynomial Equations
3.9.6 Numerical Root Finding
3.9.7 Numerical Solution of Differential Equations
3.9.8 Numerical Minimization
3.9.9 Linear Programming
3.9.10 Advanced Topic: Functions with Sensitive Dependence on Their Input

3.10 Mathematical and Other Notation
3.10.1 Special Characters
3.10.2 Names of Symbols and Mathematical Objects
3.10.3 Letters and Letter-like Forms
3.10.4 Operators
3.10.5 Structural Elements and Keyboard Characters

Formula Gallery
Definite Integral
Pisot Number
Antisymmetric Tensors
Trigonometric Formulas
More Definite Integrals
Partitions
Ellipsoid Surface Area
Iterated Radical Identities
Polylogarithm Identities
Heisenberg-Euler Lagrangian
Homological Algebra
Zeta Function Sums
Green's Function
Matrix Square Root
Indefinite Integrals

Graphics Gallery
2D Graphics
Brillouin Zones
Checkerboard Inversion
Circle Inversions
Iterated Curve Reflections
Koch Curve
L System Curve
Nested Disks
Phyllotaxis Spiral
Random Arc Tree
Sine Wave Superposition
Smooth Random Areas
Voderberg Spiral

3D Graphics
Connected Cylinders
Klein Bottle
Polyhedra
Polyhedral Octopus
Random Interpolation
Random Rotations
Riemann Surface 1
Riemann Surface 2
Space Curve Contraction
Zeta Function

Diagrams and Objects
Archimedean Spiral
Beethoven
Bookshelf
GaAs Crystal
McPherson Strut
Origami Bird
Planisphere
Solar Eclipse Chart
Telescope Optics

Art Images
Composition 1
Composition 2
Composition 3
Composition 4

Animations
Rolling Square
Origami
Cam-follower Mechanism
Deflecting Arch
Gear Mechanism
Interlocking Tori

Color Charts
GrayLevel
Hue
RGBColor
CMYKColor
Light Source Variations
Surface Color Variations

Mathematica Reference Guide
A.1 Basic Objects
A.1.1 Expressions
A.1.2 Symbols
A.1.3 Contexts
A.1.4 Atomic Objects
A.1.5 Numbers
A.1.6 Character Strings

A.2 Input Syntax
A.2.1 Entering Characters
A.2.2 Types of Input Syntax
A.2.3 Character Strings
A.2.4 Symbol Names and Contexts
A.2.5 Numbers
A.2.6 Bracketed Objects
A.2.7 Operator Input Forms
A.2.8 Two-Dimensional Input Forms
A.2.9 Input of Boxes
A.2.10 The Extent of Input Expressions
A.2.11 Special Input
A.2.12 Front End Files

A.3 Some General Notations and Conventions
A.3.1 Function Names
A.3.2 Function Arguments
A.3.3 Options
A.3.4 Part Numbering
A.3.5 Sequence Specifications
A.3.6 Level Specifications
A.3.7 Iterators
A.3.8 Scoping Constructs
A.3.9 Ordering of Expressions
A.3.10 Mathematical Functions
A.3.11 Mathematical Constants
A.3.12 Protection
A.3.13 String Patterns

A.4 Evaluation
A.4.1 The Standard Evaluation Sequence
A.4.2 Non-Standard Argument Evaluation
A.4.3 Overriding Non-Standard Argument Evaluation
A.4.4 Preventing Evaluation
A.4.5 Global Control of Evaluation
A.4.6 Aborts

A.5 Patterns and Transformation Rules
A.5.1 Patterns
A.5.2 Assignments
A.5.3 Types of Values
A.5.4 Clearing and Removing Objects
A.5.5 Transformation Rules

A.6 Files and Streams
A.6.1 File Names
A.6.2 Streams

A.7 Mathematica Sessions
A.7.1 Command-Line Options and Environment Variables
A.7.2 Initialization
A.7.3 The Main Loop
A.7.4 Messages
A.7.5 Termination
A.7.6 Network License Management

A.8 Installation and Organization of System Files
A.8.1 Running and Installing Mathematica
A.8.2 Overall Organization of the CD-ROM
A.8.3 Running the Executable Programs
A.8.4 The Installation Process
A.8.5 File Organization after Installation
A.8.6 Configuration Files
A.8.7 Documentation Files
A.8.8 Add-ons

A.9 Some Notes on Internal Implementation
A.9.1 Introduction
A.9.2 Data Structures and Memory Management
A.9.3 Basic System Features
A.9.4 Numerical and Related Functions
A.9.5 Algebra and Calculus
A.9.6 Output and Interfacing

A.10 Listing of Major Built-in Mathematica Objects
A.10.1 Introduction
A.10.2 Conventions in This Listing
A.10.3 Listing

A.11 Listing of C Functions in the MathLink Library
A.11.1 Introduction
A.12 Listing of Named Characters
A.12.1 Introduction
A.13 Incompatible Changes in Version 3.0
A.13.0 Incompatible Changes in Version 3.0