Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program EYLER;
- {$APPTYPE CONSOLE}
- Uses
- SysUtils;
- { TODO -oUser -cConsole Main : Insert code here }
- const m = 100000;
- var i, k, da: integer;
- n, h, t0, t01, y0, eps, emax, e: real;
- yy, y, t: array of real;
- Function f(t, y: real): real; {функция уравнения}
- Begin
- f:= -(3 / t) * y + (6 / (t * y)) - 5 * t;
- END;
- Begin
- SetLength(y, m);
- SetLength(yy, m);
- SetLength(t, m);
- writeln ('Uravnenie dy / dx = -(3 / t) * y + (6 / (t * y)) - 5 * t');
- writeln ('Vvedite tochnost` e: '); read(e);
- write ('Vvedite tochku t0: '); readln (t0);
- writeln ('Tochka t01 = ', t0+1);
- t01:= t0 + 1;
- write ('Vvedite shag h: '); readln (h);
- write ('Vvedite nachal`noe znachenie Y(0): '); readln (y0);
- k:= 1;
- while da = 0 do
- Begin
- h:= h / k;
- writeln ('Shag h = ', h);
- n:= 1 / h;
- writeln ('Chislo uzlov n = ', n);
- t[0]:= t0;
- y[0]:= y0;
- writeln ('T':15, 'Y':19);
- i:= 1;
- while i <= (n + 1) do
- Begin
- y[i]:= y[i-1] + h * f(t[i-1], y[i-1]); {делаем шаг метода}
- t[i]:= t[i-1] + h;
- i:= i + 1;
- END;
- i:= 0;
- while i <= n do
- Begin
- writeln (t[i]:15, y[i]:19);
- i:= i + 1;
- END;
- h:= h / 2;
- writeln ('Shag h = ', h);
- n:= 1 / h;
- writeln ('Chislo uzlov n = ', n);
- t[0]:= t0;
- yy[0]:= y0;
- writeln ('T':15, 'Y':19);
- i:= 1;
- while i <= (n + 1) do
- Begin
- yy[i]:= yy[i-1] + h * f(t[i-1], yy[i-1]); {делаем шаг метода}
- t[i]:= t[i-1] + h;
- i:= i + 1;
- END;
- i:= 0;
- while i <= n do
- Begin
- writeln (t[i]:15, yy[i]:19);
- i:= i + 1;
- END;
- emax:= 0;
- i:= 1;
- while i <= (n + 1) do
- Begin
- eps:= abs(y[i] - yy[1+2*(i-1)]);
- i:= i + 1;
- if eps > emax then
- emax:= eps;
- END;
- if emax < e then
- Begin
- writeln ('Tochnost` dostignuta.');
- da:= 1;
- END
- else
- writeln(' Tochnost` ne dostignuta.');
- k:= k + 1;
- END;
- writeln (' Tochnost` dostigaets`a pri shage h = ', h, ' na ', k, '-oy iteracii.');
- readln;
- readln;
- END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement