Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

program Euler;

uses crt,graph;
var x,y:array[0..1000] of real;
a,b,h,yo,u:real;
i,M:integer;
x0,y0,j,n:integer;
Gd, Gm: integer;
ux,uy : real;

function f(u,v:real):real;
begin
f:=1/(1+u*u);
end;

function sol(u:real):real;
begin
sol:=arctan(u);
end;

procedure grafica;
var m1:integer;
pas,xx:real;
begin
Gd := Detect;
InitGraph(Gd, Gm, 'c:\bp\bgi');
{ux := getmaxX/(abs(x1)+abs(x2))/2;
uy := getmaxy/(abs(f(x1))+abs(f(x2))+abs(f(x1/2+x2/2)))/2;}
ux:=70;
uy:=100;
{x0 := round(2*ux*abs(x1));
y0 := getmaxy+round(uy+abs(f(xx)));}
x0:=getmaxx div 2;
y0:=getmaxy div 2;
line(0,y0,getmaxx,y0);
line(x0,0,x0,getmaxy);
m1 := 100;
pas := (b - a)/m1;
moveto(x0+round(ux*a),y0 - round(uy*sol(a)));
for i := 1 to m1 do
begin
xx := a+pas*i;
lineto(x0+round(ux*xx),y0 - round(uy*sol(xx)));
end;
readln;
for i := 0 to M-1 do
begin
circle(x0+round(ux*x[i]),y0 - round(uy*y[i]));
end;
end;

BEGIN
write('Capete interval: ');
readln(a,b);
write('Pasul: '); readln(h);
write('Valoare initiala: '); readln(yo);
M:=round((b-a)/h);
x[0]:=a;
y[0]:=yo;
for i:=1 to M-1 do
begin
x[i]:=x[i-1]+h;
y[i]:=y[i-1]+h*f(x[i],y[i]);
end;
writeln('x[i] y[i] sol(x[i]) ');
for i:=0 to M-1 do
writeln(x[i]:10:7,' ',y[i]:10:7,' ',sol(x[i]):10:7,' ');
readln;
grafica;
END.

You might also like