任意精度

  • こちらで数値誤差の話などを聞いた
  • Mathematicaに任意精度というのがあることを思い出した(こちら)
  • 任意精度のWikiこちら
  • 任意精度の英語がわかればRにあるかどうかの検索もできる、ということで、こちらWikiの英語版
  • Arbitrary-precision arithmeticと言うらしい
  • "Arbitrary-precision arithmetic CRAN"で検索
  • "Rmpfr"
    • こちらが解説記事
    • "mpfr"は"Multiple Precision Floating-Point Reliably"の略
x <- mpfr(0:7, 100)/7 # a more precise version of  k/7, k=0,..,7
x
1 / x
> x <- mpfr(0:7, 100)/7 # a more precise version of  k/7, k=0,..,7
> x
8 'mpfr' numbers of precision  100   bits 
[1]                                  0
[2] 0.14285714285714285714285714285711
[3] 0.28571428571428571428571428571423
[4] 0.42857142857142857142857142857154
[5] 0.57142857142857142857142857142846
[6] 0.71428571428571428571428571428538
[7] 0.85714285714285714285714285714308
[8]                                  1
> 1 / x
8 'mpfr' numbers of precision  100   bits 
[1]                               Inf                                 7
[3]                               3.5 2.3333333333333333333333333333323
[5]                              1.75 1.4000000000000000000000000000013
[7] 1.1666666666666666666666666666661 
library(mpc)
mpc(3 + (0+3i), 52)