# Problem with Binomial numerical computation

Using Mathematica 10.4.1.0 I have a problem with Binomial on numerical computations.

Both of the following correctly return 1.0 as the result:

Binomial[0.1999999999999998, 1/5]
(* 1. *)

Binomial[0.2, 1/5]
(* 1. *)


However, if I change the last digit to 9, it returns 5.0, which is wrong.

Binomial[0.1999999999999999, 1/5]
(* 5. *)


Note that in general, Binomial[x,x] is 1. In this case, both arguments are very close to 1/5, so the correct result is 1.

Do you have the same problem? Are there any workarounds?

• If you remove a single 9, it becomes 1. It has got to be a bug. Try: Binomial[SetPrecision[0.19999999999999996, 50], 1/5] it gives me 0.9999999999999999872024250753568454 Jul 2 '20 at 11:32
• The problem also appears in v12.1.1. (Binomial[m, n] // FunctionExpand) /. {m -> 0.19999999999999996, n -> 1/5} gives 0.9999999999999999 so the problem is with Binomial rather than Gamma Jul 2 '20 at 15:54
• A possible workaround is to wrap the first argument in Rationalize. Not sure if this is acceptable performance-wise. Jul 3 '20 at 12:24
• The problem does NOT appear in versions 8.0.4 and 5.2. Can anybody check version 9? Jul 4 '20 at 7:21
• @innaiz Same problem with version 9 Jul 31 '20 at 14:28

Try using Rationalize

Binomial[0.19999999999999996//Rationalize,1/5]//N = 1.

• Rationalize will not rationalize all real numbers, for example Rationalize[Pi // N]. So, to avoid unexpected results, we have to use Rationalize[#,0]& instead. Sep 3 '20 at 10:02

Actually, the workaround to calculate

Binomial[a, b]


is:

Binomial[Rationalize [a, 0], Rationalize [b, 0]] // N