8
$\begingroup$

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

For example

Binomial[2, 1/5] // N

correctly returns 1.29929, but if I use Real values coming from numerical computations, for example

Binomial[0.19999999999999996`, 1/5] // N

it returns 5.

Do you have the same problem? Workarounds?

$\endgroup$
  • 4
    $\begingroup$ 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 $\endgroup$ – flinty Jul 2 at 11:32
  • 3
    $\begingroup$ 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 $\endgroup$ – Bob Hanlon Jul 2 at 15:54
  • 2
    $\begingroup$ A possible workaround is to wrap the first argument in Rationalize. Not sure if this is acceptable performance-wise. $\endgroup$ – Natas Jul 3 at 12:24
  • 2
    $\begingroup$ The problem does NOT appear in versions 8.0.4 and 5.2. Can anybody check version 9? $\endgroup$ – innaiz Jul 4 at 7:21
  • 1
    $\begingroup$ @innaiz Same problem with version 9 $\endgroup$ – Ali Hashmi Jul 31 at 14:28
1
$\begingroup$

Try using Rationalize

Binomial[0.19999999999999996//Rationalize,1/5]//N = 1.
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.