How to | Enter Ranges and Options for Functions

The main expression or object that a built-in Mathematica function acts on is given as the first argument to the function. As part of the syntax, a built-in Mathematica function can take more arguments, which may be required or may be generalizations or extensions of the function. After the arguments come options, which allow further extensions to control the behavior of the function.

Many visualization functions in Mathematica require you to enter the bounds over which to create a plot as the second argument to the plotting function.

Here, Sin[x] is the first argument in Plot, while the second argument gives the variable and the range for the plot:

In[7]:=
Click for copyable input
Out[7]=

If you try to use Plot without specifying a range, Mathematica produces an error message:

In[2]:=
Click for copyable input
Out[2]=

Other visualization functions are similar in requiring a range to plot over.

Here, a parametric curve is plotted with range between and . These bounds are specified in the second argument to ParametricPlot:

In[5]:=
Click for copyable input
Out[5]=

When plotting functions of two variables, the ranges for each variable are entered in the second and third arguments:

In[6]:=
Click for copyable input
Out[6]=

To see the exact syntax for a visualization function, see its page in the documentation. For help in finding the documentation page for a function, see How to: Find Information about Functions.

    

While the default behavior of Mathematica's built-in functions is suitable in the majority of cases, you can use options with functions to control exactly how they behave.

Options are entered using rules. The short form for a rule uses a right arrow, which you get by typing (with no space between - and >). The Mathematica front end automatically converts into upon further typing. Either symbol is a short form for Rule.

When entering options for functions, the option is on the left side of the rule and its setting is on the right side. Options are always positioned after any arguments required by the function.

Use the Filling option with Plot to create a filled plot:

In[8]:=
Click for copyable input
Out[8]=

Import some data from the Mathematica documentation example data and display it in a Grid:

In[9]:=
Click for copyable input
In[10]:=
Click for copyable input
Out[10]=

Use the Frame option with Grid:

In[11]:=
Click for copyable input
Out[11]=

You can also use several options together, and unlike arguments, the order does not matter:

In[12]:=
Click for copyable input
Out[12]=

The options that are available depend upon the function being used. To find out which options you can use with a function, see How to: Find Available Options.

New to Mathematica? Find your learning path »
Have a question? Ask support »