How can I get the square root for a number to 100 decimal places in R?
I've looked into the gmp and the Rmpfr packages. I can't figure out how I would use them for square roots, (pow.bigz(2,0.5)=1)
but even if I did, I'm not sure how accurate it would be, since I've found that after about 25 decimal places, the digits aren't reliable
eg
mpfr(1/3,400)
# 1 'mpfr' number of precision 400 bits
# [1] 0.333333333333333314829616256247390992939472198486328125
and
as.bigz(1e50/3)
# Big Integer ('bigz') :
# [1] 33333333333333337607355566542238210608487100055552
The question is computing one third prior to mpfr so it has already lost precision by the time mpfr sees it. Do it this way:
mpfr(1, 400)/3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With