Anyone know a fast and concise way of calculating the Beta $B(a,b)$ function for smallish (<10) real $a$ and $b$.


For integer $a$ and $b$ I have:


$B(a,b) = \prod\limits\_{j=1}^b \frac{j}{a+j}$


which has tiny code and is also pretty fast. I've see some methods that rely on the Gamma or log Gamma function:


$\log B(a,b) = \log \Gamma(a) + \log \Gamma(b) - \log \Gamma(a+b)$


using approximations of $\log \Gamma$, but I was wondering if there was a more direct way.



Numerical Beta Function
There's nothing more straightforward than using the gamma function relationship, I believe (perhaps using [Lanczos's approximation](http://my.fit.edu/~gabdo/gamma.txt) to compute the gamma functions). Of course, for integer arguments, the product representation is much faster. You could probably also consider the special case when one of the beta function's arguments is a semi-integer, and accordingly construct the appropriate product representation (involving $\sqrt{\pi}$).


