# HG changeset patch # User Rik # Date 1305062052 25200 # Node ID 8673b08a52bfe5bf25d9573abb6de3b7a230024c # Parent 08f8fc1e9872fb53ecca03d7b47aec8b1d7c9575 betaln.m: Improve documentation string, particularly for Tex format. * betaln.m: Improve DOCSTRING. Space out function with newlines. diff --git a/scripts/specfun/betaln.m b/scripts/specfun/betaln.m --- a/scripts/specfun/betaln.m +++ b/scripts/specfun/betaln.m @@ -21,16 +21,17 @@ ## Return the natural logarithm of the Beta function, ## @tex ## $$ -## B (a, b) = \log {\Gamma (a) \Gamma (b) \over \Gamma (a + b)}. +## {\rm betaln} (a, b) = \ln (B (a,b)) \equiv \ln ({\Gamma (a) \Gamma (b) \over \Gamma (a + b)}). ## $$ ## @end tex ## @ifnottex ## ## @example -## betaln (a, b) = gammaln (a) + gammaln (b) - gammaln (a + b) +## betaln (a, b) = log (beta (a, b)) ## @end example ## ## @end ifnottex +## calculated in a way to reduce the occurrence of underflow. ## @seealso{beta, betainc, gammaln} ## @end deftypefn @@ -39,14 +40,18 @@ ## Keywords: log beta special function function retval = betaln (a, b) + if (nargin != 2) print_usage (); endif retval = gammaln (a) + gammaln (b) - gammaln (a + b); + endfunction -%!assert (betaln(3,4),log(beta(3,4)),eps) + +%!assert (betaln (3,4), log (beta(3,4)),eps); -%!error (betaln(1.)) -%!error (betaln(1.,1.,1.)) +%% Test input validation +%!error (betaln (1)) +%!error (betaln (1,2,3))