uses graph crt var driver mode xp integer x_t real tic string sqr sqr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
uses graph,crt;
var driver, mode,xp,x,y :integer;
x_t :real;
tic :string;
// (sqr(x)+x+1)/(sqr(x)-x+1);
function y_global(y:real):integer;
begin
if y<0 then
y_global:=240+trunc(abs(y*50))
else
y_global:=240-trunc(abs(y*50));
end;
function x_global(x:real):integer;
begin
if x<0 then
x_global:=240-trunc(abs(x*(630/8)))
else
x_global:=240+trunc(abs(x*(630/8)));
end;
begin
Driver:=VGA;
Mode:=VGAHi;// 640x480
InitGraph(Driver, Mode, 'C:\program files\FPC');
//axis
Line(240,0,240,480);
Line(00,240,640,240);
for y:=-4 to 4 do begin
str(y,tic);
if y<>0 then begin
MoveTo(x_global(0), y_global(y));
LineTo(x_global(0)+5,y_global(y));
outtextxy(x_global(0)+8, y_global(y), tic);
end;
end;
for x:=-3 to 5 do begin
x_t:=x;
while x_t<=x+1 do begin
xp:=x_global(x_t);
PutPixel( xp, y_global((sqr(x_t)+x_t+1)/(sqr(x_t)-x_t+1)), red );
x_t:=x_t+0.001;
end;
MoveTo(x_global(x),240);
LineTo(x_global(x),245);
str(x,tic);
outtextxy(x_global(x)+3, 250, tic);
end;
readln;
CloseGraph;
end.