<Ted.Harding <at> manchester.ac.uk> writes:

> [...]
> 
> I suspect this is an invented computation -- the "3456" strikes
> me as "unlikely" (it reminds me of my habitual illustrative use
> of set.seed(54321)).
> 
> There is a definite problem with the development given by kayj.
> When k=2000 and i=k, the formula requires evaluation of
> 
>   3456*(2^3000)
> 
> on a log10 scale this is
> 
>   log10(3456) + 3000*log10(2) = 906.6286
> 
> Since R "gives up" at 10^308.25471 = 1.79767e+308
> (10^308.25472 => Inf), this algorithm is going to be tricky to
> evaluate!

Just to finish this off: 'Rmpfr' works fine with this example case and 
computes the total sum in less than 2 seconds:

    library(Rmpfr)

    j <- mpfr(-1, 120)
    i <- mpfr(0:2000, 120)
    s <- sum(j^i * 3456 * (1+i*1/2000)^3000)
    s
    # 1 'mpfr' number of precision  120   bits 
    # [1] 2.8876826480125324342665158348085465188e906

which is the same result that Maple returns. But Maple (I admit, mine is
quite old) and 'bc' (couldn't wait for the answer) are much slower at it.

It is said that 'gmp' (on which Rmpfr is based) is faster than any other
multi-precison library "on earth" --- seems to be true.

Hans Werner


> I don't know how well Rmpfr copes with very large numbers (the
> available documentation seems cryptic). However, I can go along
> with the recommendation in the URL the Ben gives, to use 'bc'
> ("Berkeley Calculator"), available on unix[oid] systems since
> a long time ago. That is an old friend of mine, and works well
> (it can cope with exponents up to X^2147483647 in the version
> I have). It can eat for breakfast the task of checking whether
> Kate Bush can accurately sing pi to 117 significant figures:
> 
>   http://www.absolutelyrics.com/lyrics/view/kate_bush/pi
> 
> (Try it in R).
> 
> Ted.
> 
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding <at> manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 19-Jan-10                                       Time: 18:41:27
> ------------------------------ XFMail ------------------------------
> 
>

______________________________________________
R-help@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.

Reply via email to