Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.07 KB | None | 0 0
  1. Program EYLER;
  2. {$APPTYPE CONSOLE}
  3. Uses
  4.     SysUtils;
  5. { TODO -oUser -cConsole Main : Insert code here }
  6. const m = 100000;
  7. var i, k, da: integer;
  8.     n, h, t0, t01, y0, eps, emax, e: real;
  9.     yy, y, t: array of real;
  10. Function f(t, y: real): real;   {функция уравнения}
  11. Begin
  12.     f:= -(3 / t) * y  + (6 / (t * y)) - 5 * t;
  13. END;
  14. Begin
  15.     SetLength(y, m);
  16.     SetLength(yy, m);
  17.     SetLength(t, m);
  18.     writeln ('Uravnenie dy / dx = -(3 / t) * y  + (6 / (t * y)) - 5 * t');
  19.     writeln ('Vvedite tochnost` e: '); read(e);
  20.     write ('Vvedite tochku t0: '); readln (t0);
  21.     writeln ('Tochka t01 = ', t0+1);
  22.     t01:= t0 + 1;
  23.     write ('Vvedite shag h: '); readln (h);
  24.     write ('Vvedite nachal`noe znachenie Y(0): '); readln (y0);
  25.     k:= 1;
  26.     while da = 0 do
  27. Begin
  28.     h:= h / k;
  29.     writeln ('Shag h = ', h);
  30.     n:= 1 / h;
  31.     writeln ('Chislo uzlov n = ', n);
  32.     t[0]:= t0;
  33.     y[0]:= y0;
  34.     writeln ('T':15, 'Y':19);
  35.     i:= 1;
  36.     while i <= (n + 1) do
  37. Begin
  38.     y[i]:= y[i-1] + h * f(t[i-1], y[i-1]);  {делаем шаг метода}
  39.     t[i]:= t[i-1] + h;
  40.     i:= i + 1;
  41. END;
  42.     i:= 0;
  43.     while i <= n do
  44. Begin
  45.     writeln (t[i]:15, y[i]:19);
  46.     i:= i + 1;
  47. END;
  48.     h:= h / 2;
  49.     writeln ('Shag h = ', h);
  50.     n:= 1 / h;
  51.     writeln ('Chislo uzlov n = ', n);
  52.     t[0]:= t0;
  53.     yy[0]:= y0;
  54.     writeln ('T':15, 'Y':19);
  55.     i:= 1;
  56.     while i <= (n + 1) do
  57. Begin
  58.     yy[i]:= yy[i-1] + h * f(t[i-1], yy[i-1]);   {делаем шаг метода}
  59.     t[i]:= t[i-1] + h;
  60.     i:= i + 1;
  61. END;
  62.     i:= 0;
  63.     while i <= n do
  64. Begin
  65.     writeln (t[i]:15, yy[i]:19);
  66.     i:= i + 1;
  67. END;
  68.     emax:= 0;
  69.     i:= 1;
  70.     while i <= (n + 1) do
  71. Begin
  72.     eps:= abs(y[i] - yy[1+2*(i-1)]);
  73.     i:= i + 1;
  74.     if eps > emax then
  75.     emax:= eps;
  76. END;
  77.     if emax < e then
  78. Begin
  79.     writeln ('Tochnost` dostignuta.');
  80.     da:= 1;
  81. END
  82.     else
  83.     writeln(' Tochnost` ne dostignuta.');
  84.     k:= k + 1;
  85. END;
  86.     writeln (' Tochnost` dostigaets`a pri shage h = ', h, ' na ', k, '-oy iteracii.');
  87.     readln;
  88.     readln;
  89. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement