This program, entitled "COPLOT" incorporates two previously published routines: 1. A plotting routine by J. S. Barney, Pet User Notes, July/August 1978, page 1; 2. An automatic selection of plotting limits routine by Wm. D. Johnston, Microcomputing, May 1980, page 26.
The former raises the normal resolution by a factor of 8 (singe-pixel resolution) in any one direction. I have chosen the vertical (Y) direction for the function values, and both for the positioning of the coordinate leaders.
The latter receives as input the numeric variable limits and the number of divisions which are desired on the axis. It then returns a new rounded-up interval for the limits, as well as the value of the interval in the same units. In the present program, it is used twice, once for each axis.
As in any program of this type, calculation of f(x) can lead to illegal quantities such as division by 0 or log(-x), etc. Since the function is entered (or edited) in line 120 as DEFNA(X) = ... by the user, there is no way to anticipate which values will cause an error message in the course of scanning from the low to the high X-bounds, and the user has to anticipate this by applying elementary considerations. For instance, if DEFNA(X) = 1/(X*X - 5*X114) then a? DIVISION BY 0 ERROR will occur at x = -2 if the X bounds are, say, - 5 and 3, and at × = 7 if they are 3 and 10. If the function is log of the above, then the entire range from - 2 to + 7 is illegal. The function is evaluated at line 290, and an appropriate line 285 such as IF X*X - 5*X -14 = 0 THEN NEXTI should take care of that.
Notwithstanding the high resolution which leads to attractive looking displays, the program is not intended to allow an exact evaluation of function values, e.g. replace graph paper ruled in mm or 1/20 inch divisions. Theoretically, the values are located at the left ends of the bars and this, moreover, can create the illusion of a displacement in cases where a symmetrical curve is known to peak at some known value, because the viewer (unintentionally) tends to look at the center of the bars. In order to avoid overprinting of labels, the number of divisions are limited to 8 in the abscissa and 10 on the ordinate. At least on the abscissa, anything denser would create confusion even in the case of integer-labels, because these are not in good registry with the high-resolution leaders, especially considering the leading space which the PET places in front of positive numbers, including 0.
All things considered, this program should prove to be a valuable aid to any one desiring a quick sketch of some function within any reasonable limits.