Const e=0.00001; var x0,xk,h,x,r,s,y:real; n,i,k:integer; begin write('x0=');readln(x0); write('xk=');readln(xk); h:=0.1; x:=x0-h; n:=round((xk-x0)/h)+1; writeln(' № x S(x) y(x)'); for i:=1 to n do begin x:=x+h r:=2*x; s:=r; k:=0; while abs(r)>e do begin inc(k); r:=r*4*x*x/((2*k)*(2*k+1)); s:=s+r; end; y:=sinh(2*x); writeln(i:2,' ',x:3:1,' ',s:8:5,' ',y:8:5); end; end.
Answers & Comments
Verified answer
Varx0, xk, h, e, x, a, s: real;
i: integer;
begin
readln(x0, xk, h, e);
x := x0;
repeat
a := 2 * x;
s := a;
i := 0;
repeat
i := i + 1;
a := a * 4 * x * x / (2 * i - 1) / (2 * i);
s := s + a;
until abs(a) < e;
writeln(s:15:5, ' ', Sinh(2*x):15:5);
x := x + h;
until x >= xk;
end.
Verified answer
Const e=0.00001;var x0,xk,h,x,r,s,y:real; n,i,k:integer;
begin
write('x0=');readln(x0);
write('xk=');readln(xk);
h:=0.1;
x:=x0-h;
n:=round((xk-x0)/h)+1;
writeln(' № x S(x) y(x)');
for i:=1 to n do
begin
x:=x+h
r:=2*x; s:=r; k:=0;
while abs(r)>e do begin
inc(k);
r:=r*4*x*x/((2*k)*(2*k+1));
s:=s+r;
end;
y:=sinh(2*x);
writeln(i:2,' ',x:3:1,' ',s:8:5,' ',y:8:5);
end;
end.
Пример:
x0=1
xk=2
№ x S(x) y(x)
1 1.0 3.62686 3.62686
2 1.1 4.45711 4.45711
3 1.2 5.46623 5.46623
4 1.3 6.69473 6.69473
5 1.4 8.19192 8.19192
6 1.5 10.01787 10.01787
7 1.6 12.24588 12.24588
8 1.7 14.96536 14.96536
9 1.8 18.28546 18.28546
10 1.9 22.33941 22.33941
11 2.0 27.28992 27.28992