## 1.9.1 Basic Plotting

 Plot[f, {x, , }] plot f as a function of x from to Plot[{, , ... }, {x, , }] plot several functions together

Basic plotting functions.
This plots a graph of as a function of from 0 to .
 In[1]:=  Plot[Sin[x], {x, 0, 2Pi}]

 Out[1]=
You can plot functions that have singularities. Mathematica will try to choose appropriate scales.
 In[2]:=  Plot[Tan[x], {x, -3, 3}]

 Out[2]=
You can give a list of functions to plot.
 In[3]:=  Plot[{Sin[x], Sin[2x], Sin[3x]}, {x, 0, 2Pi}]

 Out[3]=

To get smooth curves, Mathematica 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 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, , }] it is the second of these approaches that is used. This has the advantage that Mathematica 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 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 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, , }].

This makes a plot of the Bessel functions with running from to . The Evaluate tells Mathematica first to make the table of functions, and only then to evaluate them for particular values of x.
 In[4]:=  Plot[Evaluate[Table[BesselJ[n, x], {n, 4}]], {x, 0, 10}]

 Out[4]=
This finds the numerical solution to a differential equation, as discussed in Section 1.6.4.
 In[5]:=  NDSolve[{y'[x] Sin[y[x]], y[0] 1}, y, {x, 0, 4}]
 Out[5]=
Here is a plot of the solution. The Evaluate tells Mathematica to first set up an InterpolatingFunction object, then evaluate this at a sequence of x values.
 In[6]:=  Plot[Evaluate[ y[x] /. % ], {x, 0, 4}]

 Out[6]=

 Plot[f, {x, , }] first choose specific numerical values for x, then evaluate f for each value of x Plot[Evaluate[f], {x, , }] first evaluate f, then choose specific numerical values of x Plot[Evaluate[Table[f, ... ]], {x, , }] generate a list of functions, and then plot them Plot[Evaluate[y[x] /. solution], {x, , }] plot a numerical solution to a differential equation obtained from NDSolve

Methods for setting up objects to plot.

THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.