数学算法
源代码在线查看: d8r8.txt
implementation
//PROGRAM D8R8
//Driver for routine RTSAFE
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:=RTSAFE(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;