Note: this is a modified and extended version of the Tour of Mathematica included in The Mathematica Book and in A First Look at Mathematica 3.0.

If you have a complete Mathematica system, you can edit any of the examples given, and you can evaluate input by pressing  ⇧|⏎.  If you have MathReader only, then you will be able to view this Tour, but not modify it.

Mathematica as a Calculator

You can use Mathematica just like a calculator: you type in questions, and Mathematica prints back answers.

6^20

6^200

(6^200)

Eigenvalues[(({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}))]

An important feature of Mathematica is its ability to handle formulas as well as numbers.

Solve[(Sqrt[x]) + a == 2  x, x]

∫(Sqrt[x]) (Sqrt[a + x]) \[DifferentialD]x

You can use Mathematica to make 2D and 3D graphics.

Plot[Sin[x] + Sin[1.6  x], {x, 0, 40}]

Plot3D[Sin[x y], {x, 0, 4}, {y, 0, 4}, PlotPoints -> 30]

Power Computing with Mathematica

Even though you can use it as easily as a calculator, Mathematica gives you access to immense computational power.

ListPlot[Abs[Eigenvalues[m]]]

Mathematica can handle numbers of any size. On most computers  Mathematica  takes under a second to compute the exact factorial of 1000.

1000!

N[π, 500]

Factor[(x^99) + (y^99)]

Simplify[%]

Mathematica has achieved world records—for both size and speed—in many kinds of computations.

PartitionsP[8000]

Accessing Algorithms in Mathematica

Whenever you use Mathematica, you are accessing the world's largest collection of computational algorithms.

FindRoot[Cos[x] == x + Log[x], {x, 1}]

NIntegrate[Log[x + Sin[x]], {x, 0, 2}]

NSolve[x^5 - 6  x^3 + 8  x + 1 == 0, x]

FactorInteger[2^105 - 1]

m = Table[2^i  +  x^j, {i, 3}, {j, 4}]

MatrixForm[m]

NullSpace[m]

Mathematica can solve differential equations both symbolically and numerically.

\(NDSolve[{\(\(x'\)'\)[t] + x[t]^3 == Sin[t], x[0] == \(x'\)[0] == 0}, 

      									x, {t, 0, 50}]\)

ParametricPlot[Evaluate[{x[t], x'[t]} /. %], {t, 0, 50}]

Mathematical Knowledge in Mathematica

Mathematica incorporates the knowledge from the world's mathematical handbooks — and uses its own revolutionary algorithms to go much further.

Mathematica knows about all the hundreds of special functions in pure and applied mathematics.

LegendreQ[3, x]

N[MathieuC[1  +  I,  2 I,  3], 40]

Mathematica is now able to do vastly more integrals than were ever before possible for either humans or computers.

∫(Sqrt[x]) ArcTan[x] \[DifferentialD]x

(∫_0^∞) Log[x] Exp[-(x^3)] 
        \[DifferentialD]x

(∫_0^∞) Sin[(x^2)] Exp[-x] 
        \[DifferentialD]x

(∑_(k = 1)^n) (1/(k^6))

DSolve[y''[x] + y'[x] + x y[x] == 0, y[x], x]

FullSimplify[(∏_(n = 1)^5) Gamma[((2 n)/5)]]

Log[2] < Zeta[3] < (Sqrt[2])

TrigReduce[Cos[x]^4]

Prime[(10^9)]

Building Up Computations

Being able to work with formulas lets you easily integrate all the parts of a computation.

Eigenvalues[{{3,  1},  {2,  6}}]

v  =  Eigenvalues[{{3,  1},  {2,  b}}]

Mathematica's functions are carefully designed so that output from one can easily be used as input to others.

Plot[Evaluate[v],  {b,  -10,  10}]

Solve[First[v]  ==  0,  b]

int = (∫_0^c) First[v] \[DifferentialD]b

Series[%,  {c,  0,  5}]

FindRoot[int == 1 + c, {c, 1}]

Being able to work with formulas is also important in summarizing data.

Table[Prime[i],  {i,  40}]

Fit[%, {Log[x], x, (x^2)}, x]

Sum[%,  {x,  1,  40}]

Sum[Prime[i], {i, 1, 40}]

ListPlot[
      Table[Sum[
            Evaluate[
              Fit[Table[Prime[i], {i, imax}], {Log[x], x, (x^2)}, x], {x, 
                imax}]] - (∑_(i = 1)^imax) Prime[i], {imax, 2, 50}], 
      PlotJoined -> True]

Handling Data

Mathematica lets you import data in any format, then manipulate it using powerful and flexible functions.

ListDensityPlot[data, Mesh -> False, FrameTicks -> None];

ListDensityPlot[Exp[Sqrt[data]], Mesh -> False, 
      FrameTicks -> None, ColorFunction -> Hue];

ListDensityPlot[MapIndexed[RotateRight, data], Mesh -> False, 
      FrameTicks -> None, ColorFunction -> Hue];

ListContourPlot[data, ContourShading -> False, 
      Contours -> 6, FrameTicks -> None];

\(\(ListDensityPlot[
      Re[InverseFourier[

          MapIndexed[If[Max[#2] < 60, #, 0]&, Fourier[data], {2}]]], 
      Mesh -> False, FrameTicks -> None]; \)\)

ListPlot[Sort[Flatten[data]]];

\(\(ListPlot3D[data, ColorFunction -> Hue, 
	\ Mesh -> False, 
      ViewPoint\  -> \ {0.2, \(-2\), 5}]; \)\)

Mathematica can work with data of any kind — not just numbers.

Take[data, 40]

Select[data, (# == StringReverse[#]  &&  StringLength[#] > 2)&]

Table[Count[wordLengths, i], {i, Max[wordLengths]}]

ListPlot[%, PlotStyle -> PointSize[0.02]];

Visualization with Mathematica

Mathematica makes it easy to create stunning visual images.

ParametricPlot3D[{u Cos[u] (4 + Cos[v + u]), 
        u Sin[u] (4 + Cos[v + u]), u Sin[v + u]}, {u, 0, 4 π}, {
        v, 0, 2 π}, PlotPoints -> {60, 12}]

Show[%, PlotRange -> {-10, 0}, FaceGrids -> All, 
      BoxRatios -> {1, 1, .5}, 
      FaceGrids -> {{0, 0, -1}, {0, -1, 0}, {1, 0, 0}}, 
      ViewPoint -> {-1, 3, 2}, Ticks -> None, 
      AxesLabel -> {(Subscript[α, 1]), (Subscript[β, 1]), (Subscript[γ, 1])}]

Mathematica includes primitives from which you can build up 2D and 3D graphics of any complexity.

Take[%, 5]

Show[Graphics[gr, Frame -> True]]

Take[%, 5]

Show[Graphics3D[gr]]

Mathematica lets you produce animated movies as well as static graphics.

Do[
      Plot3D[Sin[2 x] Sin[2 y] Cos[t], {x, 0, π}, {y, 0, π}, 
        PlotRange -> {-1, 1}, BoxRatios -> {1, 1, 1}, 
        Ticks -> None], {t, 0, π, π/6}];

\(\(Do[
      ParametricPlot3D[{
          Cos[i\ π\/50]\ Cos[τ] + Sin[i\ π\/50]\ Sin[σ], 
          Sin[τ], Cos[σ]}, {σ, 0, 2\ π}, {τ, 0, 
          2\ π}, Axes -> None, Boxed -> False, 
        PlotPoints -> 20, 	
        PlotRange 
          -> {{\(-1.5\), 1.5}, {\(-1.1\), 1.1}, {\(-1.1\), 1.1}}], {i, 
        0, 25}]; \)\)

Mathematica also lets you generate sound.

Play[
      Sin[((π t)/2)] 
        (∑_(ν = 0)^24) If[(ν/12) < t < (ν/12) + (1/4), 
            (1/24) (E^(-(1/36) 
                  (((3 + 2 ν - 24 t))^2))) ν 
              Sin[1625 ν t - 13000 t], 0], {t, 0, 2}, 
      PlayRange -> All]

Mathematica has made possible many new kinds of scientific, technical and artistic images.

Mathematica Notebooks

Every Mathematica notebook is a complete interactive document which combines text, tables, graphics, calculations and other elements.

Notebooks are automatically organized in a hierarchy of cells.

You can close groups of cells so you see only their headings.

You can use hyperlinks to jump within a notebook or between notebooks.

Each cell can be assigned a style from a style sheet.

Mathematica notebooks are automatically retargeted for screen or printout—optimizing fonts and layout for each medium.

Mathematica provides hundreds of options that allow you to give notebooks any look you want and to generate full publication-quality documents.

Here is some ordinary text. It can be in any font, face, size, color, etc.  You can have special characters such as 🐺 as well as formulas such as ∫(1/((x^5) - 1)) dx embedded in text.

Like other objects in Mathematica, the cells in a notebook, and in fact the whole notebook itself, are all ultimately represented as Mathematica expressions. With the standard notebook front end, you can use the command Show Expression to see the text of the Mathematica expression that corresponds to any particular cell.

Like other objects in Mathematica, the cells in a notebook, and in fact the whole notebook itself, are all ultimately represented as Mathematica expressions. With the standard notebook front end, you can use the command Show Expression to see the text of the Mathematica expression that corresponds to any particular cell.

The Mathematica language can be used to specify all aspects of notebooks.

This is a typical cell.

Cell["This is a typical cell.", "Text",
  CellFrame->True,
  FontWeight->"Bold",
  FontSlant->"Italic",
  Background->RGBColor[0, 1, 1],
  CellTags->"T.8"]

Mathematica notebooks can be built up using explicit commands as well as interactively.

Do[
      StylePrint[StringJoin["Heading ",  ToString[i]], 
        "Subsubsection"], {i, 3}]

Heading 1

Heading 2

Heading 3

Palettes and Buttons

Palettes and buttons provide a simple but fully customizable point-and-click interface to Mathematica.

Mathematica comes with a collection of ready-to-use standard palettes.

Palettes work like extensions to your keyboard.

It is easy to create your own custom palettes.

You can create custom palettes to do any function or manipulate any expression.

Mathematical Notation

Mathematica notebooks fully support standard mathematical notation—for both output and input.

Mathematica combines the compactness of mathematical notation with the precision of a computer language.

Integrate[Log[1 + x]/Sqrt[x], x]

∫Log[1 + ξ]/(Sqrt[ξ]) \[DifferentialD]ξ

∫Log[1 + ξ]/(Sqrt[ξ]) \[DifferentialD]ξ  //  
      TraditionalForm

(∑_(μ = 0)^∞)(( (φ^μ) 
            Cos[((π μ)/4)])/(((μ!)^2) 
            ((μ^2) + κ) ((μ^2) - λ))) // 
      TraditionalForm

\(Table[
      𝒢⋄\(α\_i⊕β\_i\)\&_
            ⟹Ϡ\+i\%\(6 - i\), {i, 6}]\)

Mathematica and Your Computing Environment

Mathematica runs compatibly across all major computer systems, and lets you exchange data in many standard formats.

Mathematica notebooks allow importing and exporting of many formats.

Notebook files contain only plain text and are completely portable.

\!\(\[Integral]\(Log[1 + \[Xi]]\/\@\[Xi]\)\[DifferentialD]\[Xi]\)

Mathematica uses the Unicode standard to ensure portability of international character sets.

Mathematica provides system-independent functions for file manipulation.

The Unifying Idea of Mathematica

Mathematica is built on the powerful unifying idea that everything can be represented as a symbolic expression.

All symbolic expressions are built up from combinations of the basic form head[(Subscript[arg, 1]), (Subscript[arg, 2]), …]

The uniformity of symbolic expressions makes it easy to add to Mathematica any construct you want.

All operations in Mathematica are ultimately transformations of symbolic expressions. Mathematica has a uniquely powerful pattern matcher for applying transformation rules.

{a, b, c, d} /. b -> 1 + x

{a + b, c + d, a + c} /. x_ + y_ -> (x^2) + (y^2)

{a + b, c + d, a + c} /. a + x_ -> (x^3)

Mathematica uses patterns to generalize the notion of functions.

f[6] + f[a + b] + f[0]

An important feature of using patterns is that they allow "functions" to take arguments in any structure.

g[{4, a b}]

area[Circle[{2, 3}, u]]

Mathematica as a Programming Language

Mathematica is an unprecedentedly flexible and intuitive programming language.

Mathematica incorporates a range of programming paradigms—so you can write every program in its most natural way.

Procedural Programming

\(z = a; 
Do[Print[z *= z + i], {i, 3}]\)

List-based Programming

1 + {a, b, c}^2

Table[(i^j), {i, 4}, {j, i}]

Flatten[%]

Partition[%, 2]

Functional Programming

NestList[f, x, 4]

NestList[(((1 + #))^2) &, x, 3]

Rule-Based Programming

p[a + b + c]

s[{1, 2, 3, 4, 5, 6}, 4]

Object-Oriented Programming

h[a] + h[b] + f[h[r]] + h[h[x]]

String-Based Programming

StringReplace[
      "aababbaabaabababa", {
        "aa" -> 
          "𝔄𝔄𝔄", 
        "ba" -> "\[VerticalSeparator]"}]

Mixed Programming Paradigms

Position[{1, 2, 3, 4, 5}/2, _Integer]

MapIndexed[Power, {a, b, c, d}]

FixedPointList[If[EvenQ[#1], #(1/2), #1]&, (10^5)]

ReplaceList[{a, b, c, d, e}, {x__, y__} -> {{x}, {y}}]

Mathematica gives you the flexibility to write programs in many different styles.

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.

ListPlot[RandomWalk[200], PlotJoined -> True];

Show[Graphics3D[Line[RandomWalk[1000, 3]]]];

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

Show[
      CAGraphics[ CAEvolveList[ElementaryRule[30], CenterList[101],  50]]
         ];

\(Impedance[
        SeriesElement[
          Table[ParallelElement[Table[SeriesElement[{Resistor[R\_n]}], {n}]], 
            
			{n, 1, 4}]], ω]\  // Simplify\)

Mathematica programs provide unprecedentedly clear ways to express algorithms.

{(Subscript[ϕ, 1])[20], (Subscript[ϕ, 2])[20], N[GoldenRatio, 20]}

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

{𝔓[1000], PrimePi[1000]}

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

\(Show[Graphics[
		SpectrumData\ /@\ FareySequence[20]]]\)

Building Systems with Mathematica

Mathematica has everything you need to create complete systems for technical and non-technical applications.

Combinatorica is a system for doing discrete mathematics that comes as a standard add-on package with Mathematica.

<< DiscreteMath`Combinatorica`

ShowGraph[LineGraph[LineGraph[CirculantGraph[5, Range[1, 3]]]]];

WorldPlot is another standard add-on package that comes with Mathematica.

WorldPlot[World, 
      WorldProjection -> 
        N[{#2 (((Abs[Sin[# (Degree/60)]] + 1))/2), #}&], 
      WorldBackground -> Hue[.5]];

Optica is a large Mathematica package for doing optical engineering.

\(\(\(DrawSystem[{
	ConeOfRays[10, NumberOfRays -> 10], 
	
        Move[PlanoConvexLens[100, 50, 10], {100, 0, 0}], 
	
        Move[PlanoConvexCylindricalLens[100, \ {50, \ 50}, 10], 
          \ {130, 0, 0}], 
	
        Move[BeamSplitter[{50, 50}, {50, 50}, 10], \ {180, 0, 45}], 
	
        Boundary[{\(-100\), \(-100\), \(-100\)}, {250, 100, 200}]}]; \)

    \)\)

Mathematica has made possible a new generation of notebook-based educational courseware.

Technical Trader is a Mathematica system for financial analysis.

({{ACAD, Autodesk,  Inc.}, {BORL, Borland  International}, {INGR, Intergraph  Corp. }, {INTU, Intuit  }, {MSFT, Microsoft }, {NOVL, Novell,  Inc.}, {ORCL, Oracle System  Corp.    }, {SYBS, Sybase }})

Historical Daily Data for Microsoft (MSFT)

High-Low-Open-Close

Summary Statistics

Any system you build in Mathematica will run unchanged across all computer platforms.

Mathematica as a Software Component

Mathematica has a modular architecture that makes it easy to use as a highly powerful software component.

∫(Sqrt[Log])[x] \[DifferentialD]x

Integrate[Sqrt[Log[x]], x]

MathLink provides a general program-level interface between Mathematica and external programs.

BitAnd[22222, 33333]

You can use MathLink to access the Mathematica kernel from many kinds of programs.

MathLink can also be used to access other programs from within the Mathematica kernel.

\(\(ParametricPlot3D[

      	{\((2\  + \ Cos[u\/2]\ Sin[v]\  - \ Sin[u\/2]\ Sin[2  v])\)\ Cos[u], 
        
\ \ \ \ 
        \((2\  + \ Cos[u\/2]\ Sin[v]\  - \ Sin[u\/2]\ Sin[2  v])\)\ Sin[u], 

        \ \ \ \ Sin[u\/2]\ Sin[v]\  + \ Cos[u\/2]\ Sin[2  v]}, 

      	{v, \ 0, \ 2  Pi}, \ {u, \ 0, \ 2  Pi}, PlotPoints -> 30, 
      Boxed -> False, Axes -> None]; \)\)

You can use MathLink to communicate between Mathematica kernels — on one computer or several.

LinkRead[link]

LinkRead[link]

$SessionID

The World of Mathematica

With over a million users worldwide, a vast array of Mathematica products and services now exists.

There are now hundreds of books in over a dozen languages about Mathematica.

Several periodicals are devoted to Mathematica.

There is a growing library of professional applications based on Mathematica.

Hundreds of courses have been developed in Mathematica.

Wolfram Research's MathSource is a vast repository of Mathematica material.

A vast range of products use Mathematica in their development or implementation.

The Wolfram Research Mathematica web site contains thousands of pages of material, and is constantly being updated.