имеется код:
unit Unit11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls;
type
FunctionType = function(x: double): double;
TForm11 = class(TForm)
GroupBox1: TGroupBox;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Chart1: TChart;
Series1: TFastLineSeries;
Edit3: TEdit;
Label3: TLabel;
Button2: TButton;
Button3: TButton;
GroupBox2: TGroupBox;
Edit4: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
//интегрируемая функция
function f(x: double): double;
var
Form11: TForm11;
implementation
{$R *.dfm}
{$F+}
//интегрируемая функция
function f(x: double): double;
begin
//Здесь можете ввести свою функцию
f := x * exp(-x)
end;
//Интегрирование методом Симпcона
//от a до b функции f с точностью e
function IntegralSimpson(a, b: double; f: FunctionType; e: double): double;
var
h, x, s, s1, s2, s3, sign: double;
begin
if (a = b) then
begin
IntegralSimpson := 0; exit
end;
if (a > b) then
begin
x := a; a := b; b := x; sign := -1
end
else sign:=1;
h := b - a; s := f(a) + f(b); s2 := s;
repeat
s3 := s2; h := h/2; s1 := 0; x := a + h;
repeat
s1 := s1 + 2*f(x); x := x + 2*h;
until (not(x < b));
s := s + s1; s2 := (s + s1)*h/3; x := abs(s3 - s2)/15
until (not(x > e));
IntegralSimpson := s2*sign;
end;
//Вычислить интеграл заданной функции
procedure TForm11.Button1Click(Sender: TObject);
var x1, x2, epsilon: double;
begin
x1 := StrToFloatDef(Edit1.Text, 0);
x2 := StrToFloatDef(Edit2.Text, 0);
epsilon := StrToFloatDef(Edit3.Text, 0.001);
Edit4.Text := FloatToStr(IntegralSimpson(x1, x2, f, epsilon))
end;
//Построить график
procedure TForm11.Button2Click(Sender: TObject);
var x1, x2, epsilon: double;
begin
x1 := StrToFloatDef(Edit1.Text, 0);
x2 := StrToFloatDef(Edit2.Text, 0);
epsilon := StrToFloatDef(Edit3.Text, 0.001);
Series1.Clear;
while x1 <= x2 do
begin
Series1.AddXY(x1, f(x1));
x1 := x1 + epsilon;
end;
end;
//Выход из программы
procedure TForm11.Button3Click(Sender: TObject);
begin
Close
end;
end.
Как сделать так, чтобы интегрируемую функцию можно было задавать через edit1? Помогите...