如何使用R中的mpfr包检查一个数字是否是一个完美的正方形?
我知道一个行列式是整数的平方,但因为它的值大于如何使用R中的mpfr包检查一个数字是否是一个完美的正方形?,r,integer,mpfr,perfect-square,R,Integer,Mpfr,Perfect Square,我知道一个行列式是整数的平方,但因为它的值大于.Machine$integer.max,所以我使用了mpfr包 但我仍然有问题 以下是算法: > a<- mpfr(sqrt(det(M)), precBits=512);a 1 'mpfr' number of precision 512 bits [1] 430080000000001.1875 性能是一个问题吗?如果没有,那么下面的方法应该有效 > x<-mpfr(3141592653589793238462
.Machine$integer.max
,所以我使用了mpfr包
但我仍然有问题
以下是算法:
> a<- mpfr(sqrt(det(M)), precBits=512);a
1 'mpfr' number of precision 512 bits
[1] 430080000000001.1875
性能是一个问题吗?如果没有,那么下面的方法应该有效
> 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
>x是完整的(sqrt(x))
[1] 假的
>y y
1“mpfr”精度为500位的数字
[1] 986960440108935918772069008410384076085841574993068761741787136
>is.整体(sqrt(y))
[1] 真的
我对mpfr/matrices没有太多的研究,但它看起来像是有一个determinate()
函数与Rmpfr
包打包在一起。看,我已经尽力了,但还是有问题。