plotintg(fname,x0,xl,xh,pn,res)
Prgm
©(f(x) or "f(x)",lower · limit,xlow,xhigh,plot#,xres) plot ·(f(x))
©leaves global variables xx and yy
©11dec00/dburkett@infinet.com
local dxx,k,p
© dxx is the x-distance between the plotted points
© k is a counter in the loops
© p is (screen width - 2)
©Delete any existing xx and yy variables
delvar xx,yy
©Find x-step and make x-list
getconfg()[dim(getconfg())-10]-2→p ©Get 'p' for 89 or 92+
res*((xh-xl)/p)→dxx ©dxx set by screen width & resolution
seq(k*dxx+xl,k,0,floor(p/res))→xx ©Use floor() so we never try to plot
©beyond xh
©Find integral at 1st point
©Note that the calculation method depends on whether fname was passed as an
©expression or a string
if gettype(fname)="STR" then
when(x0=xl,0,nint(expr(fname),x,x0,xl))→yy[1]
else
when(x0=xl,0,nint(fname,x,x0,xl))→yy[1]
endif
©Find integral at remaining points
© For each plotted point, find the integral between the current value of x and
© the previous value of x, then add the previous integral to find the total
©Handle case where fname is passed as a string
if gettype(fname)="STR" then
for k,2,dim(xx)
nint(expr(fname),x,xx[k-1],xx[k])+yy[k-1]→yy[k]
endfor
©Handle case where fname is passed as an expression
else
for k,2,dim(xx)
nint(fname,x,xx[k-1],xx[k])+yy[k-1]→yy[k]
endfor
endif
©Set graph window limits
xl→xmin
xh→xmax
min(yy)→ymin
max(yy)→ymax
©Create plot; display graph
fnoff ©Turn off all function plots
plotsoff ©Turn off all data plots
newplot pn,2,xx,yy,,,,5 ©Generate xyline plot with dot symbols
dispg ©Display the plot
EndPrgm
4 - 10