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

Writing Programs in Mathematica

Mathematica's high-level programming constructs let you build sophisticated programs more quickly than ever before.

Single-line Mathematica programs can perform complex operations.

Single-line Mathematica programs can perform complex operations.

Here is a plot of a 200-step random walk.

The directness of Mathematica programs makes them easy to generalize. This program produces a random walk in d dimensions.

Here is a plot of a 3D random walk.

The richness of Mathematica's programming language makes it easy to implement sophisticated algorithms.

Here is a direct program for a single step in the Life cellular automaton.

Mathematica's rich structure also makes it easy to implement this alternative highly optimized algorithms.

Mathematica makes it easy to build up programs from components.

This runs an example.

Mathematica has a compiler for optimizing programs that work with lists and numbers.

Mathematica programs are often a direct translation of material in textbooks.

This uses the definitions that have been given.

Here is a picture of the circuit, generated from its symbolic specification.

Mathematica programs provide unprecedentedly clear ways to express algorithms.

Both of these programs approximate the Golden Ratio to k digits.

Mathematica programs allow a unique combination of mathematical and computational notation.

These definitions correspond to a recently discovered approximation to the number of primes.

This compares the approximation with the built-in PrimePi function.

Mathematica programs can mix numerical, symbolic, and graphics operations. This short program solves a sophisticated quantum model.

These definitions set up a Kohmoto model for the energy spectrum of a quantum particle in a one-dimensional quasiperiodic potential.

This runs the model, generating symbolic eigenvalue equations from transfer matrices and then solving them numerically.

Look at the Programming Sampler demo to see more examples of Mathematica programs.