2.Программа:
uses
crt;
const
n=10;
var
x:
array[0..n] of real;
y:
array[0..n] of real;
y_t:
array [0..n] of real;
a,b,h,k1,k2:real;
j:
integer;
Begin
clrscr;
a:=Pi/2;
b:=(Pi/2)+1;
h:=(b-a)/n;
y[0]:=pi;
x[0]:=pi/2;
for
j:=0 to n do begin
x[j]:=a+h*j;
k1:=y[j]/(x[j])+(sin(x[j])*x[j]);
k2:=(y[j]+h/2*k1)/(x[j]+h/2)+(sin(x[j]+h/2)*(x[j]+h/2));
y[j+1]:=y[j]+h*k2;
end;
for
j:=0 to n do begin
y_t[j]:=-(x[j])*cos(x[j])+2*x[j];
end;
writeln('n
y_v y_t raznost');
for
j:=0 to n do writeln( y[j]:6:3,' ',y_t[j]:6:3, ' ' ,
(y_t[j]-y[j]):9:8);
readln;
end.
3.Результаты:
Turbo
Pascal Version 7.0 Copyright (c) 1983,92 Borland International
'n
y_v y_t raznost
3.142
3.142 0.00000000
3.508
3.508 0.00007848
3.893
3.893 0.00012362
4.294
4.294 0.00013388
4.709
4.709 0.00010843
5.134
5.134 0.00004712
5.567
5.567 -0.00004954
6.005
6.004 -0.00018049
6.443
6.443 -0.00034408
6.878
6.877 -0.00053820
7.306
7.305 -0.00076027
4.Результаты:
Turbo
Pascal Version 7.0 Copyright (c) 1983,92 Borland International
'n
y_v y_t raznost
3.142
3.142 0.00000000
3.893
3.893 0.00051009
4.709
4.709 0.00049358
5.567
5.567 -0.00007103
6.443
6.442 -0.00116465
7.308
7.305 -0.00273330
5.Вывод
:
Чем
меньше шаг на отрезке, тем ближе решение
к истинному.
|