Beta Function
Returns Beta(X,Y) using a Series Expansion for 1/Gamma (X) as defined in Abramowitz & Stegun.

Unit
QESBPCSMath

Declaration
Function Beta(const X, Y: Extended): Extended;

Description
Defined for all values of X and Y except negative integers and 0.

Accuracy: Gives about 15 digits.

Parameters
First Value to process.
Second Value to process.

Category
Arithmetic Routines for Floats

Implementation

function Beta (const X, Y: Extended): Extended;
var
     R1, R2: Extended;
begin
     if FloatIsZero (X) or (FloatIsNegative (X) and SameFloat (X, Int (X))) then
          raise EMathError.Create (rsNotDefinedForValue);
     if FloatIsZero (Y) or (FloatIsNegative (Y) and SameFloat (Y, Int (Y))) then
          raise EMathError.Create (rsNotDefinedForValue);

     R1 := InverseGamma (X);
     R2 := InverseGamma (Y);

     if FloatIsZero (R1) or FloatIsZero (R2) then
          raise EMathError.Create (rsNotDefinedForValue);

     Result := InverseGamma (X + Y) / (R1 * R2);
End;


HTML generated by Time2HELP
http://www.time2help.com