unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, math;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Memo1: TMemo;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Label5: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit1.text:='0,1';
  Edit2.text:='0,8';
  Edit3.text:='0,1';
  Edit4.text:='0,001';
  Memo1.Clear;
  Memo1.Lines.Add('лаб. работа гр.020601 Куликовская М.А.');
end;

procedure TForm1.Button1Click(Sender: TObject);
 var xn,xk,x,h,e,a,s,c,b,y,d :extended;
     n,k:integer;

begin
memo1.clear;
Memo1.Lines.Add('лаб. работа гр.020601 Куликовская М.А.');
 xn:=StrToFloat(Edit1.Text);
 Memo1.Lines.Add(' xn='+FloatToStrF(xn,ffFixed,6,2));
 xk:=StrToFloat(Edit2.Text);
 Memo1.Lines.Add(' xk='+FloatToStrF(xk,ffFixed,6,2));
 h:=StrToFloat(Edit3.Text);
 Memo1.Lines.Add(' h='+FloatToStrF(h,ffFixed,8,3));
 e:=StrToFloat(Edit4.Text);
 Memo1.Lines.Add(' e='+FloatToStrF(e,ffFixed,8,5));
 x:=xn;

   repeat
   a:=-1; s:=0; n:=0; b:=-1; c:=1; d:=1;
   while  (abs(a) > e) do begin
            n:=n+1;
            b:=b*(-1);
            c:=c*x*x;
            d:=d*((2*n-1)*n);
            a:=b*c/(2*d);
            s:=s+a;
           end;
            y:=x*arctan(x) - Ln(sqrt(1+sqr(x)));
Memo1.Lines.Add('при x='+FloatToStrF(x,ffFixed,6,2)  +'  сумма ='+ FloatToStrF(s,ffFixed,8,4)  +' y ='
   + FloatToStrF(y,ffFixed,8,4)   +'   N ='+IntToStr(n));
x:=x+h;
until x>(xk+h/2)

end;

end.
