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 /  Basic Calculations /  Plotting Curves /

8.5 Plotting Lists of Functions

Plotting more than one function.

You can give a list of functions to plot.

In[1]:= Plot[{Sin[x], Sin[2x], Sin[3x]}, {x, 0, 2Pi}]

Out[1]=

To get smooth curves, Mathematica TE has to evaluate functions you plot at a large number of points. As a result, it is important that you set things up so that each function evaluation is as quick as possible.
When you ask Mathematica TE to plot an object, say f, as a function of x, there are two possible approaches it can take. One approach is first to try and evaluate f, presumably getting a symbolic expression in terms of x, and then subsequently evaluate this expression numerically for the specific values of x needed in the plot. The second approach is first to work out what values of x are needed, and only subsequently to evaluate f with those values of x.
If you type Plot[f, x, xmin, xmax] it is the second of these approaches that is used. This has the advantage that Mathematica TE only tries to evaluate f for specific numerical values of x; it does not matter whether sensible values are defined for f when x is symbolic.
There are, however, some cases in which it is much better to have Mathematica TE evaluate f before it starts to make the plot. A typical case is when f is actually a command that generates a table of functions. You want to have Mathematica TE first produce the table, and then evaluate the functions, rather than trying to produce the table afresh for each value of x. You can do this by typing Plot[Evaluate[f], x, xmin, xmax].

The Evaluate tells Mathematica TE first to make the table of functions, and only then to evaluate them for particular values of the variable x.

In[2]:= Plot[Evaluate[Table[Sin[n x^2], {n, 4}]], {x, 0, 2}]

Out[2]=