program Graph2(Output); { Program 6.2 - Generate graphic representation (with X-axis) of the function: f(X) = exp(-X) * sin(2*Pi*X) Compare with Program 4.7. } const XLines = 16 { line spacings per 1 abscissa unit }; Scale = 32 { character widths per 1 ordinate unit}; ZeroY = 34 character position of X axis }; XLimit 32 length of graph in lines }; YLimit type 68 height of graph in character widths}; Domain = 1 .. YLimit; var Delta: Real { increment along abscissa }; TwoPi: Real { 2 * Pi = 8 * ArcTan(1.0) }; X, Y: Real; Point: 0 .. XLimit; Plot, YPosition, Extent: Domain; YPlot: array [Domain] of Char; begin {initialize constants: Delta := 1 / Xlines; TwoPi := 8 * ArcTan(1.0); for Plot := 1 to Ylimit do YPlot[Plot] :="; for Point := 0 to XLimit do end begin X := Delta * Point; Y := Exp(-X) * Sin(TwoPi * X); YPlot [ZeroY] := ':'; YPosition := Round(Scale * Y) + ZeroY; YPlot[YPosition] := '*'; if YPosition < ZeroY then Extent := ZeroY else Extent := YPosition; for Plot := 1 to Extent do Write (Output, YPlot[Plot]); Writeln(Output); YPlot[YPosition] .= ' , end 

