《Delphi常用数值算法集》的配书源码
源代码在线查看: gcf.txt
procedure GCF(var GAMMCF:real; A:real; X:real; var GLN:real);
label 1;
const
ITMAX=100; EPS=0.0000003;
var
N:integer; GOLD,G,FAC,B1,B0,ANF,ANA,AN,A1,A0:real;
begin
GLN:=GAMMLN(A);
GOLD:=0;
A0:=1;
A1:=X;
B0:=0;
B1:=1;
FAC:=1;
For N:=1 To ITMAX do
begin
AN:=N;
ANA:=AN - A;
A0:=(A1 + A0 * ANA)* FAC;
B0:=(B1 + B0 * ANA)* FAC;
ANF:=AN * FAC;
A1:=X * A0 + ANF * A1;
B1:=X * B0 + ANF * B1;
If A1 0 Then
begin
FAC:=1 / A1;
G:=B1 * FAC;
If Abs((G - GOLD)/ G)< EPS Then GoTo 1;
GOLD:=G;
end
end;
ShowMessage('A too large, ITMAX too small');
1: GAMMCF:=Exp(-X + A * Ln(X)- GLN)* G;
end;