unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
Function FUN(X:real):real;
procedure FUND(X:real;var FN,DF:real);
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
//PROGRAM D8R8
//Driver for routine RTNEWT
uses
unit2;
{$R *.DFM}
Function FUN(X:real):real;
begin
FUN:= BESSJ0(X);
end;
procedure FUND(X:real;var FN,DF:real);
begin
FN:= BESSJ0(X);
DF:= -BESSJ1(X);
end;
procedure TForm1.Button1Click(Sender: TObject);
const
s1='.###0e+00'; s2='%12.6f'; s3='##';
N = 100; NBMAX = 20; X1 = 1; X2 = 50;
var
F:TextFile; XB1,XB2:array[0..20] of real;
I,NB:integer; XACC,ROOT:real;
begin
NB:=NBMAX;
ZBRAK(X1,X2,N,XB1,XB2,NB);
//输出计算结果到文件
AssignFile(F, 'd:\delphi_shu\p8\d8r8.dat');
Rewrite(F);
Writeln(F, ' Roots of BESSJ0:');
Writeln(F);
Writeln(F, ' x F(x)');
Writeln(F);
For I:= 1 To NB do
begin
XACC:=0.000001*(XB1[I]+XB2[I])/2;
ROOT:=RTNEWT(XB1[I],XB2[I],XACC);
Writeln(F,'Root ',FormatFloat(s3,I),' ',Format(s2,[ROOT]),
' ',FormatFloat(s1,BESSJ0(ROOT)));
end;
CloseFile(F);
//屏幕显示计算结果
memo1.Lines.LoadFromFile('d:\delphi_shu\p8\d8r8.dat');
end;
end.