Hi All, I was wodering if it is possible to increase the precision using R. I ran the script below in R and MAPLE and I got different results when k is large. Any idea how to fix this problem? thanks for your help for (k in 0:2000){ s=0 for(i in 0:k){ s=s+((-1)^i)*3456*(1+i*1/2000)^3000 } } -- View this message in context: http://n4.nabble.com/problem-with-the-precision-of-numbers-tp1017727p1017727.html Sent from the R help mailing list archive at Nabble.com.
kayj <kjaja27 <at> yahoo.com> writes:> > > Hi All, > > I was wodering if it is possible to increase the precision using R. I ran > the script below in R and MAPLE and I got different results when k is large. > Any idea how to fix this problem? thanks for your help > > for (k in 0:2000){ > s=0 > for(i in 0:k){ > s=s+((-1)^i)*3456*(1+i*1/2000)^3000 > } > }(1) see http://wiki.r-project.org/rwiki/doku.php?id=misc:r_accuracy:high_precision_arithmetic (2) consider whether there is more accurate algorithm you could use. I don't recognize the series, but perhaps it has a closed form solution, maybe as a special function? How much accuracy do you really need in the solution? Ben Bolker
Maybe bc(..., args = "") or perhaps install a more standard version of bc. See links at http://r-bc.googlecode.com On Tue, Jan 19, 2010 at 5:43 PM, kayj <kjaja27 at yahoo.com> wrote:> > Hi , > > Thanks for your help, I have been trying to use the bc package but I am > getting the following error > > "Error in system(cmd, input = input, intern = TRUE) : -l not found" > > > any idea?? > > -- > View this message in context: http://n4.nabble.com/problem-with-the-precision-of-numbers-tp1017727p1017996.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Hi All, I was wondering if R can deal with high precsion numbers, below is an example that I tried on using R and Maple where I got different results. I was not able to use the r-bc package in R, instead I used the Rmpfr package, below are both R and Maple results> library(Rmpfr) > > s<-mpfr(0,500) > j <- mpfr(-1,500) > > for (i in 0:80){+ p<-as.numeric(i) + c<-choose(80,i) + s=s+((j^i)*c*(1-(i+1)*1/200)^200) + + }> s1 'mpfr' number of precision 500 bits [1] 4.6484825769379918039202329231788093343835337105287241996630873753794810915791302829474613042869191092322033403649086087872119205043462728841279067042348e-6 Maple result 6.656852479*10^(-20) why are the two results different? I appreciate your help -- View this message in context: http://n4.nabble.com/problem-with-the-precision-of-numbers-tp1288905p1288905.html Sent from the R help mailing list archive at Nabble.com.