MODULE graph1; (* DEE 2023-07-21 *) (* From PASCAL: user manual and report, Second Edition, pg. 30. * graphic representation of a function * f(x) = exp(-x) * sin(2*pi*x *) FROM MathLib0 IMPORT exp, sin; FROM InOut IMPORT Write, WriteLn; CONST d = 0.0625; (*1/16, 16 lines for interval [x,x+1]*) s = 32; (*32 character widths for interval [y,y+1]*) h = 34; (*character position of x-axis*) c = 6.28318; (*2*pi*) lim = 32; VAR x, y: REAL; i, n: INTEGER; BEGIN FOR i := 0 TO lim DO x := d*FLOAT(i); y := exp(-x)*sin(c*x); n := TRUNC((FLOAT(s)*y) + 0.5) + h; (* 0.5 to round before truncating. *) REPEAT Write(' '); DEC(n) UNTIL n = 0; Write('*'); WriteLn END END graph1.