The Student's Introduction to MATHEMATICA: A Handbook for Precalculus, Calculus, and Linear Algebra

3.5: Producing a Table of Values

3.5 Producing a Table of Values

It is often handy to produce a table of function values for various inputs. Here is a table of the squares of the first ten positive whole numbers:

  In[1]:= <b class="bold">f[x_] := x</b><sup<b class="bold">2</b></sup>  In[2]:= <b class="bold">Table[f[x], {x, 1, 10}]</b>Out[2]= {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}

Like Plot and Manipulate, the Table command takes two arguments, separated by a comma. The first describes the contents of each table entry, while the second (in this case {x, 1, 10}) is an iterator. Unlike Plot and Manipulate, however, the values of the variable will increment by 1 (by default) in a Table. As with Manipulate, a fourth number can be added to the iterator to specify the step size.

  In[3]:= <b class="bold">Table[f[x], {x, 0, 50, 5}]</b>Out[3]= {0, 25, 100, 225, 400, 625, 900, 1225, 1600, 2025, 2500}

You can also shorten the iterator to contain only two items the name of the variable and a stopping number. When you do this, Mathematica starts at 1 and increments the variable in steps of 1 until the stopping number is reached. So for instance, using the iterator {x, 10} is the same as using the iterator {x, 1, 10}:

  In[4]:= <b class="bold">Table[f[x], {x, 10}]</b>Out[4]= {1, 4, 9, 16, 25, 36, 49, 64, 81, 100}

The output of the Table command is a basic data structure in Mathematica

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Pressure Sensors
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.