We've seen that Mathematica uses parentheses for grouping
and square brackets in functions. Mathematica uses **curly
braces** to delimit **lists** of numbers. For example,
a list of the first ten prime numbers would be

If you enter this as Mathematica input, you'll get the exact same list as output:{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29}This is because we haven't asked Mathematica to

The reason we want to discuss lists now is that Mathematica represents (x, y) points as lists of two numbers. For example the point (x = 1, y = 3.7) is represented in Mathematica as

{1, 3.7}

Suppose we have a list of three (x, y) points: (1, 2), (2, 3),
and (3, 5). These points are represented as lists of two numbers.
The list of the three points is then a **nested** list, or
a list of lists:

To plot a graph of these three points, we use a new Mathematica command:{ {1, 2}, {2, 3}, {3, 5} }

This tells Mathematica to plot the list of points inside the square brackets. The spaces are optional and are included here mainly for the sake of clarity. To plot ten points representing the first ten prime numbers, we would therefore typeListPlot[ { {1, 2}, {2, 3}, {3, 5} } ]

Again, the extra space is optional. If you type the input as it is shown here, however, you'll notice that your input cell grows large enough to accomodate all three lines of the command. If you forget a curly brace (or add an extra one), Mathematica will inform you of this. One of the points may be hard to see; look closely at the origin of the x and y axes to convince yourself that there is a point there.ListPlot[ { {1, 2}, {2, 3}, {3, 5}, {4, 7},{5, 11}, {6, 13}, {7, 17}, {8, 19},{9, 23}, {10, 27} } ]

Now let's join the points with straight line segments. Type

The modifierListPlot[ { {1, 2}, {2, 3}, {3, 5}, {4, 7},{5, 11}, {6, 13}, {7, 17}, {8, 19},{9, 23}, {10, 27} }, PlotJoined -> True ]

tells Mathematica to connect the points with lines.PlotJoined -> True

Here's another shortcut that can save you a lot of typing. Suppose we wanted to store the list of the first ten primes in memory, so that we don't have to type it in every time we want to use it. Enter

Mathematica will respond withprimes = { {1, 2}, {2, 3}, {3, 5}, {4, 7},{5, 11}, {6, 13}, {7, 17}, {8, 19},{9, 23}, {10, 27} }

{ {1, 2}, {2, 3}, {3, 5}, {4, 7}, {5, 11}, {6, 13}, {7, 17}, {8, 19}, {9, 23}, {10, 27} }This list is now stored in the variable "primes". We can use this variable in a

It's good stylistic practice to give your own variables names that begin with lowercase letters. This prevents us from trying to use the name of a Mathematica command or function as a variable name. Mathematica commands are allListPlot[primes, PlotJoined -> True]

If you just want to see what is stored in the variable primes, type

and Mathematica will respond withprimes

{ {1, 2}, {2, 3}, {3, 5}, {4, 7}, {5, 11}, {6, 13}, {7, 17}, {8, 19}, {9, 23}, {10, 27} }

Other parts of the Mathematica tutorial:

- Mathematica's user interface
- Simple calculations
- Plotting functions
- Combining two or more plots
- Fitting data to polynomials
- Generating and manipulating lists of numbers
- Complex numbers
- Derivatives and integrals
- Special functions
- Contour and surface plots