[R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R
RK
arkay7777 at gmail.com
Fri Jul 3 16:16:27 CEST 2015
Also when I try the following with Rmpfr, it works jut fine.
> exp(sqrt(mpfr(163, 120)) * Const("pi", 120))
1 'mpfr' number of precision 120 bits
[1] 262537412640768743.99999999999925007601
and
> exp(sqrt(mpfr(163, 400)) * Const("pi", 400))
1 'mpfr' number of precision 400 bits
[1]
262537412640768743.99999999999925007259719818568887935385633733699086270
753741037821064791011860731295118134618606450419548
Which compares very nicely with the following:
In[10]:= N[Exp[Sqrt[163] Pi], 125]
Out[10]=
2.6253741264076874399999999999925007259719818568887935385633733699086270
753741037821064791011860731295118134618606450419308389*10^17
In the multiprecision business, you can never be too certain that you
are using the right precision throughout your calculations.
Nordlund, Dan (DSHS/RDA <NordlDJ <at> dshs.wa.gov> writes:
>
> Ravi,
>
> Take a look at the following link.
>
> https://code.google.com/p/r-bc/
>
> I followed the instructions to get a Windows version of the 'nix
utility program , bc (a high precision
> calculator), and the source for an R to bc interface. After
installing them, I executed
>
> exp(sqrt(bc(163))*4*atan(bc(1)))
>
> in R and got this result
>
>
"262537412640768743.9999999999992500725971981856888793538563373369908627
075374103782106479101186073116295306145602054347"
>
> I don't know if this is helpful, but ...
>
> Dan
>
> Daniel Nordlund, PhD
> Research and Data Analysis Division
> Services & Enterprise Support Administration
> Washington State Department of Social and Health Services
>
More information about the R-help
mailing list