This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / The Mathematica Book /

Front Matter

About the Author

About Mathematica

New in Version 5

The Role of This Book

Suggestions about Learning Mathematica

Tour of Mathematica

Contents

A Practical Introduction to Mathematica

Introduction

Running Mathematica

Introduction

1.0.1 Notebook Interfaces

1.0.2 Text-Based Interfaces

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

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

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

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 Advanced Topic: Simplifying with Assumptions

1.4.7 Picking Out Pieces of Algebraic Expressions

1.4.8 Controlling the Display of Large Expressions

1.4.9 The Limits of Mathematica

1.4.10 Using Symbols to Tag Objects

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 Inequalities

1.5.9 Differential Equations

1.5.10 Power Series

1.5.11 Limits

1.5.12 Integral Transforms

1.5.13 Recurrence Equations

1.5.14 Packages for Symbolic Mathematics

1.5.15 Advanced Topic: Generic and Non-Generic Cases

1.5.16 Mathematical Notation in Notebooks

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

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

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 Ordering in Lists

1.8.12 Advanced Topic: Rearranging Nested Lists

Graphics and Sound

1.9.1 Basic Plotting

1.9.2 Options

1.9.3 Redrawing and Combining Plots

1.9.4 Advanced Topic: Manipulating Options

1.9.5 Contour and Density Plots

1.9.6 Three-Dimensional Surface Plots

1.9.7 Converting between Types of Graphics

1.9.8 Plotting Lists of Data

1.9.9 Parametric Plots

1.9.10 Some Special Plots

1.9.11 Special Topic: Animated Graphics

1.9.12 Sound

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

Files and External Operations

1.11.1 Reading and Writing Mathematica Files

1.11.2 Advanced Topic: Finding and Manipulating Files

1.11.3 Importing and Exporting Data

1.11.4 Exporting Graphics and Sounds

1.11.5 Exporting Formulas from Notebooks

1.11.6 Generating TeX

1.11.7 Exchanging Material with the Web

1.11.8 Generating C and Fortran Expressions

1.11.9 Splicing Mathematica Output into External Files

1.11.10 Running External Programs

1.11.11 MathLink

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

Introduction

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

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

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

Manipulating Lists

2.4.1 Constructing Lists

2.4.2 Manipulating Lists by Their Indices

2.4.3 Nested Lists

2.4.4 Partitioning and Padding Lists

2.4.5 Sparse Arrays

Transformation Rules and Definitions

2.5.1 Applying Transformation Rules

2.5.2 Manipulating Sets of Transformation Rules

2.5.3 Making Definitions

2.5.4 Special Forms of Assignment

2.5.5 Making Definitions for Indexed Objects

2.5.6 Making Definitions for Functions

2.5.7 The Ordering of Definitions

2.5.8 Immediate and Delayed Definitions

2.5.9 Functions That Remember Values They Have Found

2.5.10 Associating Definitions with Different Symbols

2.5.11 Defining Numerical Values

2.5.12 Modifying Built-in Functions

2.5.13 Advanced Topic: Manipulating Value Lists

Evaluation of Expressions

2.6.1 Principles of Evaluation

2.6.2 Reducing Expressions to Their Standard Form

2.6.3 Attributes

2.6.4 The Standard Evaluation Procedure

2.6.5 Non-Standard Evaluation

2.6.6 Evaluation in Patterns, Rules and Definitions

2.6.7 Evaluation in Iteration Functions

2.6.8 Conditionals

2.6.9 Loops and Control Structures

2.6.10 Collecting Expressions During Evaluation

2.6.11 Advanced Topic: Tracing Evaluation

2.6.12 Advanced Topic: The Evaluation Stack

2.6.13 Advanced Topic: Controlling Infinite Evaluation

2.6.14 Advanced Topic: Interrupts and Aborts

2.6.15 Compiling Mathematica Expressions

2.6.16 Advanced Topic: Manipulating Compiled Code

Modularity and the Naming of Things

2.7.1 Modules and Local Variables

2.7.2 Local Constants

2.7.3 How Modules Work

2.7.4 Advanced Topic: Variables in Pure Functions and Rules

2.7.5 Dummy Variables in Mathematics

2.7.6 Blocks and Local Values

2.7.7 Blocks Compared with Modules

2.7.8 Contexts

2.7.9 Contexts and Packages

2.7.10 Setting Up Mathematica Packages

2.7.11 Automatic Loading of Packages

2.7.12 Manipulating Symbols and Contexts by Name

2.7.13 Advanced Topic: Intercepting the Creation of New Symbols

Strings and Characters

2.8.1 Properties of Strings

2.8.2 Operations on Strings

2.8.3 String Patterns

2.8.4 Characters in Strings

2.8.5 Special Characters

2.8.6 Advanced Topic: Newlines and Tabs in Strings

2.8.7 Advanced Topic: Character Codes

2.8.8 Advanced Topic: Raw Character Encodings

Textual Input and Output

2.9.1 Forms of Input and Output

2.9.2 How Input and Output Work

2.9.3 The Representation of Textual Forms

2.9.4 The Interpretation of Textual Forms

2.9.5 Short and Shallow Output

2.9.6 String-Oriented Output Formats

2.9.7 Output Formats for Numbers

2.9.8 Tables and Matrices

2.9.9 Styles and Fonts in Output

2.9.10 Representing Textual Forms by Boxes

2.9.11 Adjusting Details of Formatting

2.9.12 String Representation of Boxes

2.9.13 Converting between Strings, Boxes and Expressions

2.9.14 The Syntax of the Mathematica Language

2.9.15 Operators without Built-in Meanings

2.9.16 Defining Output Formats

2.9.17 Advanced Topic: Low-Level Input and Output Rules

2.9.18 Generating Unstructured Output

2.9.19 Generating Styled Output in Notebooks

2.9.20 Requesting Input

2.9.21 Messages

2.9.22 International Messages

2.9.23 Documentation Constructs

The Structure of Graphics and Sound

2.10.1 The Structure of Graphics

2.10.2 Two-Dimensional Graphics Elements

2.10.3 Graphics Directives and Options

2.10.4 Coordinate Systems for Two-Dimensional Graphics

2.10.5 Labeling Two-Dimensional Graphics

2.10.6 Making Plots within Plots

2.10.7 Density and Contour Plots

2.10.8 Three-Dimensional Graphics Primitives

2.10.9 Three-Dimensional Graphics Directives

2.10.10 Coordinate Systems for Three-Dimensional Graphics

2.10.11 Plotting Three-Dimensional Surfaces

2.10.12 Lighting and Surface Properties

2.10.13 Labeling Three-Dimensional Graphics

2.10.14 Advanced Topic: Low-Level Graphics Rendering

2.10.15 Formats for Text in Graphics

2.10.16 Graphics Primitives for Text

2.10.17 Advanced Topic: Color Output

2.10.18 The Representation of Sound

2.10.19 Exporting Graphics and Sounds

2.10.20 Importing Graphics and Sounds

Manipulating Notebooks

2.11.1 Cells as Mathematica Expressions

2.11.2 Notebooks as Mathematica Expressions

2.11.3 Manipulating Notebooks from the Kernel

2.11.4 Manipulating the Front End from the Kernel

2.11.5 Advanced Topic: Executing Notebook Commands Directly in the Front End

2.11.6 Button Boxes and Active Elements in Notebooks

2.11.7 Advanced Topic: The Structure of Cells

2.11.8 Styles and the Inheritance of Option Settings

2.11.9 Options for Cells

2.11.10 Text and Font Options

2.11.11 Advanced Topic: Options for Expression Input and Output

2.11.12 Options for Graphics Cells

2.11.13 Options for Notebooks

2.11.14 Advanced Topic: Global Options for the Front End

Files and Streams

2.12.1 Reading and Writing Mathematica Files

2.12.2 External Programs

2.12.3 Advanced Topic: Streams and Low-Level Input and Output

2.12.4 Naming and Finding Files

2.12.5 Files for Packages

2.12.6 Manipulating Files and Directories

2.12.7 Importing and Exporting Files

2.12.8 Reading Textual Data

2.12.9 Searching Files

2.12.10 Searching and Reading Strings

MathLink and External Program Communication

2.13.1 How MathLink Is Used

2.13.2 Installing Existing MathLink-Compatible Programs

2.13.3 Setting Up External Functions to Be Called from Mathematica

2.13.4 Handling Lists, Arrays and Other Expressions

2.13.5 Special Topic: Portability of MathLink Programs

2.13.6 Using MathLink to Communicate between Mathematica Sessions

2.13.7 Calling Subsidiary Mathematica Processes

2.13.8 Special Topic: Communication with Mathematica Front Ends

2.13.9 Two-Way Communication with External Programs

2.13.10 Special Topic: Running Programs on Remote Computers

2.13.11 Special Topic: Running External Programs under a Debugger

2.13.12 Manipulating Expressions in External Programs

2.13.13 Advanced Topic: Error and Interrupt Handling

2.13.14 Running Mathematica from Within an External Program

Global Aspects of Mathematica Sessions

2.14.1 The Main Loop

2.14.2 Dialogs

2.14.3 Date and Time Functions

2.14.4 Memory Management

2.14.5 Advanced Topic: Global System Information

Advanced Mathematics in Mathematica

Introduction

Numbers

3.1.1 Types of Numbers

3.1.2 Numeric Quantities

3.1.3 Digits in 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

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

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.3.10 Using Assumptions

Manipulating Equations and Inequalities

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 Generic and Non-Generic Solutions

3.4.6 Eliminating Variables

3.4.7 Solving Logical Combinations of Equations

3.4.8 Inequalities

3.4.9 Equations and Inequalities over Domains

3.4.10 Advanced Topic: The Representation of Solution Sets

3.4.11 Advanced Topic: Quantifiers

3.4.12 Minimization and Maximization

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.5.11 Integral Transforms and Related Operations

3.5.12 Generalized Functions and Related Objects

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 Solving Recurrence Equations

3.6.9 Finding Limits

3.6.10 Residues

Linear Algebra

3.7.1 Constructing Matrices

3.7.2 Getting and Setting 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 Matrix Operations

3.7.11 Advanced Topic: Tensors

3.7.12 Sparse Arrays

Numerical Operations on Data

3.8.1 Basic Statistics

3.8.2 Curve Fitting

3.8.3 Approximate Functions and Interpolation

3.8.4 Fourier Transforms

3.8.5 Convolutions and Correlations

3.8.6 Cellular Automata

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 Optimization

3.9.9 Advanced Topic: Controlling the Precision of Results

3.9.10 Advanced Topic: Monitoring and Selecting Algorithms

3.9.11 Advanced Topic: Functions with Sensitive Dependence on Their Input

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

Mathematica Reference Guide

Introduction

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

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

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

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

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

Files and Streams

A.6.1 File Names

A.6.2 Streams

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

Mathematica File Organization

A.8.1 Mathematica Distribution Files

A.8.2 Loadable Files

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

Listing of Major Built-in Mathematica Objects

A.10.1 Introduction

A.10.2 Conventions in This Listing

A.10.3 Listing

Listing of C Functions in the MathLink Library

A.11.1 Introduction

Listing of Named Characters

A.12.1 Introduction

Incompatible Changes

A.13.1 Since Version 1

A.13.2 Between Versions 1 and 2

A.13.3 Between Versions 2 and 3

A.13.4 Between Versions 3 and 4

A.13.5 Between Versions 4 and 5

Developer Context Objects in Mathematica 5

A.14.1 Introduction

Experimental Context Objects in Mathematica 5

A.15.1 Introduction