How to handle properly big factorials in Maxima?

80 Views Asked by At

When I tried to solve a very basic probability problem using Maxima, I stumbled upon the following error: EXPT: floating point overflow

I got it when I tried to solve this problem related to Yu-Gi-Oh cards:

If 20 million cards are manufactured for a box, of which 185185 are "secret rare", then what is the likelihood that after buying 216 cards, none of them will be secret rare.

It has been like 15 years the last time I encountered probability excercises, so I'm not sure if my solution is good, but I tried to solve it the following way:

  • All possible ways to draw 216 cards from 20 million: 20000000! / (216! * (20000000 - 216)!)
  • There are 20000000 - 185185 = 19814815 cards which are not secret rare
  • All possible ways to draw 216 card from the non-secret rare cards: 19814815! / (216! * (19814815 - 216)!)
  • So the probability is the ratio of the two: (19814815! / (216! * (19814815 - 216)!)) / (20000000! / (216! * (20000000 - 216)!))

But when I enter this into Maxima, it first simplifies it to:

(19814815!*19999784!)/(19814599!*20000000!)

When I right-click and select "To Float", then it gives the above mentioned error. Is my solution wrong or something has to be done in Maxima to handle the big factorials?

1

There are 1 best solutions below

1
On

To make it much, much, much faster, considering $$A=\frac {a!\, b!}{c!\, d!}=\frac{\Gamma(a+1)\,\Gamma(b+1)}{\Gamma(c+1)\,\Gamma(d+1)}$$take logarithms of both sides $$\log(A)=\log (\Gamma (a+1))+\log (\Gamma (b+1))-\log (\Gamma (c+1))-\log (\Gamma (d+1))$$ and use function log_gamma (z) in Maxima.