home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / sm30a.zip / PLOT.(X) < prev    next >
Text File  |  1993-10-16  |  774b  |  31 lines

  1. #    plot y=f(x) on xy-plane
  2. #    by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
  3. #    e.g.    plot(x^3,x)
  4.  
  5. plot(y_, x_, xmin_, xmax_, ymin_, ymax_) := block(numeric:=on,
  6.     dx:=(xmax-xmin)/getmaxx,
  7.     dy:=(ymax-ymin)/getmaxy,
  8.     xstep:=dx*10,
  9.     graph,
  10.     getmaxy3:=getmaxy-30,
  11.     line(40,getmaxy3,getmaxx,getmaxy3),
  12.     line(40,0,40,getmaxy3),
  13.     moveto(0,0),
  14.     writes(ymax),
  15.     moveto(0,getmaxy3),
  16.     writes(ymin),
  17.     moveto(40,getmaxy-20),
  18.     writes(xmin),
  19.     moveto(getmaxx-30,getmaxy-20),
  20.     writes(xmax),
  21.     setviewport(40,0,getmaxx,getmaxy3,1),
  22.     moveto(0,getmaxy3),
  23.     do( lineto((x-xmin)/dx,getmaxy3-(y-ymin)/dy),
  24.     x,xmin,xmax,xstep),
  25.     numeric:=off,
  26.     readchar,
  27.     text,
  28.     local(dx,dy,xstep))
  29. plot(y_, x_, xmin_, xmax_) := plot(y,x,xmin,xmax,-5,5)
  30. plot(y_, x_) := plot(y,x,-5,5,-5,5)
  31.