hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_specfun_beta_log_real (s14cb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_specfun_beta_log_real (s14cb) returns the value of the logarithm of the beta function, lnBa,b, via the routine name.

Syntax

[result, ifail] = s14cb(a, b)
[result, ifail] = nag_specfun_beta_log_real(a, b)

Description

nag_specfun_beta_log_real (s14cb) calculates values for lnBa,b where B is the beta function given by
Ba,b = 0 1 ta-1 1-t b-1 dt  
or equivalently
Ba,b = Γa Γb Γa+b  
and Γx is the gamma function. Note that the beta function is symmetric, so that Ba,b=Bb,a.
In order to efficiently obtain accurate results several methods are used depending on the parameters a and b.
Let a0=mina,b and b0=maxa,b. Then:
for a08,
lnB = 0.5 ln 2π -0.5 lnb0 + Δa0 + Δ b0 - Δ a0+b0 - u - v ;  
where
for a0<1,
for 2<a0<8,  a0 is reduced to the interval 1,2 by Ba,b=a0-1a0+b0-1 Ba0-1,b0;
for 1a02,
nag_specfun_beta_log_real (s14cb) is derived from BETALN in DiDonato and Morris (1992).

References

DiDonato A R and Morris A H (1992) Algorithm 708: Significant digit computation of the incomplete beta function ratios ACM Trans. Math. Software 18 360–373

Parameters

Compulsory Input Parameters

1:     a – double scalar
The argument a of the function.
Constraint: a>0.0.
2:     b – double scalar
The argument b of the function.
Constraint: b>0.0.

Optional Input Parameters

None.

Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
Constraint: a>0.0.
Constraint: b>0.0.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

nag_specfun_beta_log_real (s14cb) should produce full relative accuracy for all input arguments.

Further Comments

None.

Example

This example reads values of the arguments a and b from a file, evaluates the function and prints the results.
function s14cb_example


fprintf('s14cb example results\n\n');

a = [0.2; 0.4; 0.6; 0.8; 1.0; 1.0; 1.0; 2.0; 3.0; 4.0; ...
     5.0; 6.0; 6.0; 6.0; 6.0; 6.0; 7.0];
b = [1.0; 1.0; 1.0; 1.0; 0.2; 0.4; 1.0; 2.0; 3.0; 4.0; ...
     5.0; 2.0; 3.0; 4.0; 5.0; 6.0; 7.0];
lb = zeros(numel(a), 1);
for i = 1:numel(a)
  [lb(i), ifail] = s14cb(a(i), b(i));
end
fprintf('\n  a    b        ln(beta(a,b))\n');
fprintf('%5.2f%5.2f%17.4e\n', vertcat(a', b', lb'));


s14cb example results


  a    b        ln(beta(a,b))
 0.20 1.00       1.6094e+00
 0.40 1.00       9.1629e-01
 0.60 1.00       5.1083e-01
 0.80 1.00       2.2314e-01
 1.00 0.20       1.6094e+00
 1.00 0.40       9.1629e-01
 1.00 1.00       0.0000e+00
 2.00 2.00      -1.7918e+00
 3.00 3.00      -3.4012e+00
 4.00 4.00      -4.9416e+00
 5.00 5.00      -6.4457e+00
 6.00 2.00      -3.7377e+00
 6.00 3.00      -5.1240e+00
 6.00 4.00      -6.2226e+00
 6.00 5.00      -7.1389e+00
 6.00 6.00      -7.9273e+00
 7.00 7.00      -9.3937e+00

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015