This program has these limitations: You can only plot a single function. The program will over-write
current data plot definitions; use the pn parameter to specify which data plot to use to avoid this. For
simple functions, the built-in function plotter is faster. You must pass the function name as a string, and
the independent variable must be x. Since this program writes to the graph screen, it must be a
program, not a function. The arguments to the newplot command must be global variables, not local
variables, so these will still exist in the folder from which plotxy() is run. You must delete them
manually. Since plotxy() makes a data plot, not a function plot, you cannot perform Math menu
operations such as Zero, Minimum, Maximum and so on.
For even faster plotting, set res to 2 or 3 or even larger.
These timing results (92+, HW2, AMS 2.04) show the advantages of using plotxy(). As an example I
use a user-function called si(x), which calculates the sine integral. I plotted over a range of x=0 to
x=12, with a resolution of 1.
Built-in function plotter, using ZoomFit: 226 seconds
plotxy(): 144 seconds (saves 82 seconds or 36%)
Built-in function plotter, using manual limits: 114 seconds
The fastest method is to use the built-in plotter, and set the ymin and ymax limits manually.
[4.10] Faster plots of integral functions
Suppose you want to plot an integral function with an independent variable x. Such a function might be
in the form
¶
x
0
x
f
(
t
)
dt
where x
0
is a constant. For example, the sine integral function is defined as
Si
(
x
)
=
¶
0
x
sin
(
t
)
t
dt
You should always first try to find a symbolic expression for the integral; in this case, there is no closed
form solution. The most obvious way to plot the function is to define it as a function in the Y= Editor, for
example,
y1=nInt(sin(t)/t,t,0,x)
This certainly works, but it is predictably slow, because the integral must be evaluated for each plotted
point. For a HW2 92+ with AMS 2.05, it takes about 15 minutes to plot the function with ZoomFit, over
a range of 0 to 15 with a plot resolution of one pixel. This is about 3.78 seconds/point. For a HW1 TI89,
the time is about 5.41 seconds/point. The efficiency is even worse if we want to plot the function over a
range that does not include x
0
. In other words, we want to plot the function over some range x
l
to x
h
,
and x
l
> x
0
. Then, the integral from x
0
to x
l
is recalculated for every plotted point, but is really the same
for each point.
We can considerably reduce the plotting time by recognizing that the integral at each point is just the
sum of the integral over the previous plotted points, plus the integral over the interval of the current
point. The plotting time is also shortened by generating a lists of x-coordinates and corresponding
function values, then plotting with a data plot instead of a function plot. This program, plotintg(),
implements these ideas:
4 - 9