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.

Mathematica as a Programming LanguageBuilding Systems with Mathematica

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.

This program produces a one-dimensional random walk.

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.

Here is an alternative highly optimized program, which operates on lists of live cells.

Mathematica makes it easy to build up programs from components. This sets up components for a cellular automaton simulation system.

This runs an example.

Mathematica has a compiler for optimizing programs that work with lists and numbers. This sets up a compiled definition for CAStep.

Mathematica programs are often a direct translation of material in textbooks. Here are definitions for impedance in a circuit.

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.

Mathematica as a Programming LanguageBuilding Systems with Mathematica