Uses Graph, CRT;
Const
Dx=0.1;
x0=1.0;
b=4.0;
y0=2.0;
Var
GraphDevice, GraphMode: integer;
x,y,Kx,Ky,D:Real;
i,N:Integer;
S:String;
Function Accur(z:real):real;
begin
Accur:=z+1;
end;
Function Der(Xd,Yd:real):real;
begin
Der:=Yd/(Xd+1);
end;
Begin
N:=Round((b-x0)/Dx);
GraphDevice := Detect;
GraphMode := Detect;
InitGraph(GraphDevice, GraphMode, '');
if GraphResult <> grOk then
begin
writeln('Error');
Exit;
end;
SetLineStyle(SolidLn,0,ThickWidth);
Line(30,GetMaxY-40,GetMaxX-10,GetMaxY-40);
Line(30,GetMaxY-40,30,20);
SetTextJustify(CenterText,TopText);
OutTextXY(GetMaxX-15,GetMaxY-30,'X');
SetTextJustify(LeftText,CenterText);
OutTextXY(12,25,'Y');
Kx:=(GetMaxX-40)/5;
Ky:=(GetMaxY-60)/7;
SetLineStyle(SolidLn,0,NormWidth);
SetTextJustify(CenterText,TopText);
for i:=0 to 4 do
begin
Line(Round(30+i*Kx),GetMaxY-34,Round(30+i*Kx),GetMaxY-40);
Str(i,S);
OutTextXY(Round(30+i*Kx),GetMaxY-30,S);
end;
SetTextJustify(RightText,CenterText);
for i:=0 to 6 do
begin
Line(30,Round(GetMaxY-40-i*Ky),24,Round(GetMaxY-40-i*Ky));
Str(i,S);
OutTextXY(20,Round(GetMaxY-40-i*Ky),S);
end;
SetColor(LightRed);
Line(30,Round(GetMaxY-40-Accur(0)*Ky),Round(30+5*Kx),Round(GetMaxY-40-Accur(5)*Ky));
SetTextJustify(LeftText,CenterText);
Line(50,50,70,50);
OutTextXY(80,50,'Accurate function');
SetColor(Yellow);
Line(50,80,70,80);
OutTextXY(80,80,'Euler method');
SetFillStyle(SolidFill,Yellow);
FillEllipse(60,80,2,2);
x:=x0;
y:=y0;
SetFillStyle(SolidFill,Yellow);
FillEllipse(Round(30+x*Kx),Round(GetMaxY-40-y*Ky),2,2);
MoveTo(Round(30+x*Kx),Round(GetMaxY-40-y*Ky));
for i:=1 to N do
begin
D:=Der(x,y);
x:=x+Dx;
y:=y+D*Dx;
FillEllipse(Round(30+x*Kx),Round(GetMaxY-40-y*Ky),2,2);
LineTo(Round(30+x*Kx),Round(GetMaxY-40-y*Ky));
end;
ReadKey
End.