unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Button1: TButton;
    Label5: TLabel;
    Memo1: TMemo;
    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
  Memo1.Clear;
  Edit1.Text:='0,1';
  Edit2.Text:='1';
  Edit3.Text:='0,2';
  Edit4.Text:='0,001';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Xn,Xk,h,e,a,s,TimeS,dx,y:extended;
  n:longint;
begin
  try
    Xn:=strToFloat(Edit1.Text);
    Xk:=strToFloat(Edit2.Text);
    h:=strToFloat(Edit3.Text);
    e:=strToFloat(Edit4.Text);
  except
    on EConvertError do Exit;
  end;
  Memo1.Lines.Add('Результаты ст. гр. 722402 Борисок В.В.');
  Memo1.Lines.Add('Xn='+FloatToStrF(Xn,ffFixed,6,3));
  Memo1.Lines.Add('Xk='+FloatToStrF(Xk,ffFixed,6,3));
  Memo1.Lines.Add('h='+FloatToStrF(h,ffFixed,6,3));
  Memo1.Lines.Add('e='+FloatToStrF(e,ffFixed,6,3));
  dx:=Xn;
  while dx<=(Xk+1E-10) do
  begin
    n:=0;
    a:=1;
    TimeS:=a;
    repeat
      inc(n);
      a:=a*dx/n;
      {(cos(n*Pi/4)*dx)/(n*cos(n*pi/4))}
      s:=TimeS;
      TimeS:=TimeS+a*cos(n*pi/4);
    until  abs(TimeS-S)<e;
    y:=exp(dx*cos(Pi/4))*cos(dx*sin(Pi/4));
    Memo1.Lines.Add('При X='+FloatToStrF(dx,ffFixed,6,3)
                   +'  сумма='+FloatToStrF(TimeS,ffFixed,6,3)
                   +'  y='+FloatToStrF(y,ffFixed,6,3)
                   +'  N='+IntToStr(n));
    dx:=dx+h;
  end;

end;

end.
