PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_beta_log_real (s14cb)
Purpose
nag_specfun_beta_log_real (s14cb) returns the value of the logarithm of the beta function, , via the routine name.
Syntax
Description
nag_specfun_beta_log_real (s14cb) calculates values for
where
is the beta function given by
or equivalently
and
is the gamma function. Note that the beta function is symmetric, so that
.
In order to efficiently obtain accurate results several methods are used depending on the parameters and .
Let and . Then:
for
,
where
-
,
- and
- .
for , is reduced to the interval by ;
for
,
- for ,
- for , is reduced to the interval ;
- for ,
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:
– double scalar
-
The argument of the function.
Constraint:
.
- 2:
– double scalar
-
The argument of the function.
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
The result of the function.
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
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 and from a file, evaluates the function and prints the results.
Open in the MATLAB editor:
s14cb_example
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015