Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, math;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Edit1: TEdit;
- Edit2: TEdit;
- Label1: TLabel;
- StaticText1: TStaticText;
- StaticText2: TStaticText;
- procedure Button1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- public
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.Button1Click(Sender: TObject);
- var
- x, i, EPS: real;
- a, a1: real;
- begin
- x:=strtofloat (Edit1.Text);
- EPS:=strtofloat (Edit2.Text);
- if EPS < 0 then
- halt;
- a := x;
- a1 := 0;
- i := 2;
- while abs(a - a1) > EPS do begin
- a1 := a;
- a := 2 + (1/(EPS**i))* cos(a1 - 2*x)**2;
- i += 1;
- end;
- Label1.Caption:=floattostr(a);
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement