2

I have a determinant which I know is a square of an integer, but because its value is bigger than .Machine$integer.max I used the mpfr package.

But I still have problems.

Here is the algorithm:

> a<- mpfr(sqrt(det(M)), precBits=512);a
1 'mpfr' number of precision  512   bits 
[1] 430080000000001.1875

Could you please help me?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Vassilis Chasiotis
  • 427
  • 1
  • 3
  • 15
  • 1
    I haven't worked with mpfr/matrices very much, but it looks like there's a `determinant()` function packaged with the `Rmpfr` package. See http://www.inside-r.org/packages/cran/Rmpfr/docs/determinant.mpfrMatrix. – bgoldst Apr 24 '15 at 09:58
  • I have done it bgoldst but I still have problems. – Vassilis Chasiotis Apr 24 '15 at 14:49

1 Answers1

2

Is performance an issue? If not, then the following should work.

> x<-mpfr(31415926535897932384626433832795, 500)
> is.whole(sqrt(x))
[1] FALSE


> y<-mpfr(31415926535897932384626433832794, 500)^2
> y
1 'mpfr' number of precision  500   bits
[1] 986960440108935918772069008410384076085841574993068761741787136
> is.whole(sqrt(y))
[1] TRUE
k.c.
  • 116
  • 1
  • 3