implementation
//PROGRAM D9R7
//Driver for routine LINMIN
uses
unit2;
{$R *.DFM}
Function FUNC(X:real):real;
begin
FUNC:= F1DIM(X);
end;
Function FUNC2(X:array of real; N:integer):real;
begin
FUNC2:= Sqr(X[1]-1)+Sqr(X[2]-1)+Sqr(X[3]-1);
end;
procedure TForm1.Button1Click(Sender: TObject);
const
s1='%12.6f'; NDIM = 3; PIO2 = 1.5707963;
var
F:TextFile;
P,XI:array[0..3] of real;
I,J:integer; X,SR2,FRET:real;
begin
//输出计算结果到文件
AssignFile(F, 'd:\delphi_shu\p9\d9r7.dat');
Rewrite(F);
Writeln(F, 'Minimum of a 3-D quadratic centered');
Writeln(F, 'at (1.0,1.0,1.0). Minimum is found');
Writeln(F, 'along a series of radials.');
Writeln(F);
Writeln(F, ' X Y Z MINIMUM');
Writeln(F);
For I:= 0 To 10 do
begin
X:= PIO2 * I / 10;
SR2:= Sqrt(2);
XI[1]:=SR2 * Cos(X);
XI[2]:=SR2 * Sin(X);
XI[3]:=1;
P[1]:=0;
P[2]:=0;
P[3]:=0;
LINMIN(P, XI, NDIM, FRET);
Writeln(F, Format(s1,[P[1]]),Format(s1,[P[2]]),
Format(s1,[P[3]]), Format(s1,[FRET]));
end;
CloseFile(F);
//屏幕显示计算结果
memo1.Lines.LoadFromFile('d:\delphi_shu\p9\d9r7.dat');
end;