Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function func(x: double) : double;
- begin
- Result := x * exp(x)*sin(x);;
- end;
- function f2(x, h: double) : double;
- begin
- Result := (func(x + h) - 2 * func(x) + func(x - h)) / (h * h);
- end;
- var
- n, i: integer;
- a, b, h, e, S, f2max, check, fa, fb, fx, f2n: double;
- conv: string;
- begin
- a := 0; b:= 1; n:= 48; e:= 0.001;
- writeln('Нахождение определенного интеграла функции f(x)=x*e^(x)*sin(x) на отрезке [0;1]. Отрезок разбивается на 48 частей.');
- while (true) do
- begin
- h := (b - a) / n;
- fa:=func(a);
- fb:=func(b);
- S:= h * (fa + fb) / 2;
- for i:= 0 to n - 1 do
- begin
- fx:=func(a + h * i);
- S := S + fx*h;
- end;
- f2max:= f2(a, h);
- for i:= 0 to n - 1 do
- begin;
- f2n:=f2(a + h * i, h);
- if f2n > f2max then f2max:= f2n;
- end;
- check:= f2max * power(b - a, 3) / (12 * n*n);
- if check > e then n := n + 5
- else
- begin
- writeln('Значение интеграла = ', S);
- break;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement