boris.steipe at utoronto.ca
Fri May 15 14:46:47 CEST 2015
Please keep discussion son the list.
On May 15, 2015, at 5:19 AM, chasiotisv at math.auth.gr wrote:
> Yes, I am asking whether that integer can be exactly represented on a computer.
Yes, but it requires significant effort to do so because you need arbitrary-precision algorithms.
> I use 64 bit.
> I have changed 64 up to 1024 but nothing changed.
I don't think we are talking about the same thing here.
> I have tried also to use Rmpfr package, but I haven't solved my problem?
You have not clearly stated what the problem is you are trying to solve. Clearly you don't need to know whether the number is an integer - you already know it is. You also know that a number of that size cannot be exactly represented natively in your computer. So asking whether it turns out to be a whole number or not is asking a question about the machine precision and the algorithm, not about the number.
> How do you think I can use the Rmpfr package?
> print(2^63 - 1, digits=19)
 9223372036854775808 # wrong!
a <- mpfr(2, 64)
print(a^63 - 1, digits=19)
1 'mpfr' number of precision 64 bits
 9223372036854775807 # correct!
... but you will need to change the code that does the calculation so that it uses mpfr-class number with enough precision to safely avoid rounding errors for the size of all intermediate values in your calculation. Probably this means you will write your own determinant algorithm - and if this is just for one matrix it doesn't need to be fast so why not. Google tells me there are division-free algorithms for calculating determinants that are O(n^4). But as I wrote above, I can't imagine why this makes sense.
More information about the R-help