gmp for R and other sols

67 views Asked by At

implemented a solution to a problem in arithmetic precision handeling in gmp - but the results are rather strange . as a part of troubleshooting I was wondering whether there is any other package hich woudl allow similar operatiosn as gmp in R. I would need something like chooseZ and multiplication of numbers larger than 2^64 - jsu to make sure that I am not having an error somewhere in this step of my script

need to compute nubers like

choose(2450,765) then multiply it with a floating point number like 0.0034

the log solution is not really working becasue the expression can aslo be

sum for 2 to k of (k* k*choose(1800,800)*0.089)

so Iw ould need a wauy to sum over (k kchoose(1800,800)*0.089)

1

There are 1 answers

6
Roland On BEST ANSWER

You could just work on the logarithmic scale:

lchoose(2450,765) + log(0.0034)
#[1] 1511.433

If you exponentiate this, you get a really big number. I simply do not believe that this number would be different from Inf for any practical purpose and I believe even less that you'd need it to exact precision.

Edit:

If you want to calculate \sum_{i=2}^k{i^2 * choose(1800, 800) * 0.089}, you should see that this is the same as choose(1800, 800) * \sum_{i=2}^k{i^2 * 0.089} and then you can again work on the logarithmic scale.