home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / share / doc / ps1 / 04.pascal / bigger5.p < prev    next >
Encoding:
Text File  |  1990-06-07  |  538 b   |  27 lines

  1. (*
  2.  * Graphic representation of a function
  3.  *    f(x) = exp(-x) * sin(2 * pi * x)
  4.  *)
  5. program graph1(output);
  6. const
  7.     d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
  8.     s = 32;       (* 32 character width for interval [x, x+1] *)
  9.     h = 34;       (* Character position of x-axis *)
  10.     c = 6.28138;  (* 2 * pi *)
  11.     lim = 32;
  12. var
  13.     x, y: real;
  14.     i, n: integer;
  15. begin
  16.     for i := 0 to lim do begin
  17.         x := d / i;
  18.         y := exp(-x) * sin(c * x);
  19.         n := round(s * y) + h;
  20.         repeat
  21.             write(' ');
  22.             n := n - 1
  23.         until n = 0;
  24.         writeln('*')
  25.     end
  26. end.
  27.