1

我想为一个函数应用包 mpfr,如下所示:

     f1  =function(x) exp(x)

例如,如果x = c(-1500, -2000, -6400, -7200)

     > x = c(-1500, -2000, -6400, -7200)
     >  mpfr(f1(x), precBits=64)
     4 'mpfr' numbers of precision  64   bits 
     [1] 0 0 0 0

我想得到函数 f1 的值,即使它很小,我怎样才能在 R 中得到它?

4

1 回答 1

0

64位不是很多。但首先,您犯了我们许多人都犯的错误: 的值f1(x)已经为零,因为它是在转换为 bignum之前计算的。

试试这种方式:

> exp(mpfr(c(-1000,-5000),200))
2 'mpfr' numbers of precision  200   bits 
[1]  5.0759588975494567652918094795743369193055992828928373618323948e-435
[2] 3.3696941483089175144500323238132201679550979027292655581078801e-2172
于 2014-01-10T01:18:33.190 回答