# [racket] Math library kudos

On 02/20/2013 06:42 AM, Luke Vilnis wrote:
>* No problem. They should be faster even for fairly small numbers since
*>* they usually require the evaluation of a polynomial (an approximation of
*>* (log)gamma) versus repeated multiplication/division. From memory the
*>* code should be something like:
*>*
*>* (exp (fllog-gamma (+ 1.0 n)) - (fllog-gamma (+ 1.0 r)) - (fllog-gamma (+
*>* 1.0 (- n r))))
*>*
*>* fllog-gamma should also be faster than bflog-gamma or log-gamma if you
*>* don't need arbitrary precision. You're also right that this won't always
*>* give completely exact results - the Racket manual says that the only
*>* exact values are for log gamma of 1 and 2, but this usually is not a
*>* problem.
*>*
*>* PS. It looks like Racket's math collection has a built-in log-factorial
*>* function too, to avoid all the +1's, so you could try that.
*
There's also `fllog-binomial', which computes the log number of
combinations directly. IIRC, its maximum observed error is 2 ulps.
Neil ⊥