Legacy Documentation

Mathematica® Teacher's Edition (2002)

This is documentation for an obsolete product.
Current products and services
 Documentation /  Mathematica Teacher's Edition /  The Teacher's Book /  Front Matter /  Tour of Mathematica /

Lists

This makes a list of the first 15 factorials.

In[1]:= Table[ n!, {n, 1, 15} ]

Out[1]=

This takes the logarithm of each entry in the list, and evaluates the result numerically. Functions like Log have the property of being "listable", so that they apply separately to each element in a list.

In[2]:= N[ Log[ % ] ]

Out[2]=

Here is a plot of the entries in the list.

In[3]:= ListPlot[ % ]

Out[3]=

Fit finds least-squares fits to data. This finds the quadratic formula that gives the best fit to the list of numbers. Here %2 refers to the second result, also stored as Out[2].

In[4]:= Fit[ %2, {1, x, x^2}, x ]

Out[4]=

This creates a two-dimensional array in which the , element is 0 or 1 according to whether or not the greatest common divisor of and is equal to 1. Ending with a semicolon stops Mathematica TE from printing the rather large array.

In[5]:= coprimes = Table[ If[GCD[i, j] == 1, 1, 0],
{i, 30}, {j, 30} ] ;

This makes a plot of the array.

In[6]:= ListDensityPlot[coprimes]

Out[6]=