Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-14 Thread Martin Maechler
P == ProfJCNash profjcn...@gmail.com on Sat, 4 Jul 2015 21:42:27 -0400 writes: P n163 - mpfr(163, 500) P is how I set up the number. Yes, and you have needed to specify the desired precision. As author and maintainer of Rmpfr, let me give my summary of this overly long thread

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread Duncan Murdoch
to do? Best, Ravi From: David Winsemius dwinsem...@comcast.net Sent: Friday, July 3, 2015 2:06 PM To: John Nash Cc: r-help; Ravi Varadhan Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R On Jul 3

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread Duncan Murdoch
On 04/07/2015 8:21 AM, David Winsemius wrote: On Jul 3, 2015, at 11:05 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 04/07/2015 3:45 AM, David Winsemius wrote: On Jul 3, 2015, at 5:08 PM, David Winsemius dwinsem...@comcast.net wrote: It doesn’t appear to me that mpfr was ever

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread David Winsemius
Nash Cc: r-help; Ravi Varadhan Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R On Jul 3, 2015, at 8:08 AM, John Nash john.n...@uottawa.ca wrote: Third try -- I unsubscribed and re-subscribed. Sorry to Ravi for extra traffic

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread Hadley Wickham
It doesn’t appear to me that mpfr was ever designed to handle expressions as the first argument. This could be a start. Obviously one would wnat to include code to do other substitutions probably using the all.vars function to pull out the other “constants” and ’numeric’ values to make

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread David Winsemius
On Jul 4, 2015, at 12:20 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 04/07/2015 8:21 AM, David Winsemius wrote: On Jul 3, 2015, at 11:05 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 04/07/2015 3:45 AM, David Winsemius wrote: On Jul 3, 2015, at 5:08 PM, David

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread Gabor Grothendieck
dwinsem...@comcast.net Sent: Friday, July 3, 2015 2:06 PM To: John Nash Cc: r-help; Ravi Varadhan Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R On Jul 3, 2015, at 8:08 AM, John Nash john.n...@uottawa.ca wrote: Third try -- I

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread ProfJCNash
...@comcast.net Sent: Saturday, July 4, 2015 1:12 PM To: Duncan Murdoch Cc: r-help; John Nash; Ravi Varadhan Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R On Jul 4, 2015, at 12:20 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 04/07/2015 8

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-04 Thread Ravi Varadhan
: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R On Jul 4, 2015, at 12:20 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 04/07/2015 8:21 AM, David Winsemius wrote: On Jul 3, 2015, at 11:05 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread John Nash
-help r-help@r-project.org Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R Message-ID: 14ad39aaf6a542849bbf3f62a0c2f...@dom-eb1-2013.win.ad.jhu.edu Content-Type: text/plain; charset=utf-8 Hi Rich, The Wolfram answer is correct. http

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread RK
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.25007601 and exp(sqrt(mpfr(163, 400)) * Const(pi, 400)) 1 'mpfr' number of precision 400 bits [1]

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread David Winsemius
...@temple.edu, Aditya Singh aps...@yahoo.com Cc: r-help r-help@r-project.org Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R Message-ID: 14ad39aaf6a542849bbf3f62a0c2f...@dom-eb1-2013.win.ad.jhu.edu Content-Type: text/plain; charset=utf

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread David Winsemius
Varadhan ravi.varad...@jhu.edu To: 'Richard M. Heiberger' r...@temple.edu, Aditya Singh aps...@yahoo.com Cc: r-help r-help@r-project.org Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R Message-ID: 14ad39aaf6a542849bbf3f62a0c2f...@dom-eb1

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread Ravi Varadhan
...@jhu.edu To: 'Richard M. Heiberger' r...@temple.edu, Aditya Singh aps...@yahoo.com Cc: r-help r-help@r-project.org Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R Message-ID: 14ad39aaf6a542849bbf3f62a0c2f...@dom-eb1-2013

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread David Winsemius
From: David Winsemius dwinsem...@comcast.net Sent: Friday, July 3, 2015 2:06 PM To: John Nash Cc: r-help; Ravi Varadhan Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R On Jul 3, 2015, at 8:08 AM, John

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-03 Thread Ravi Varadhan
and the accuracy of floating point computations - using Rmpfr in R There is a precedence error in your R attempt. You need to convert 163 to 120 bits first, before taking its square root. exp(sqrt(mpfr(163, 120)) * mpfr(pi, 120)) 1 'mpfr' number of precision 120 bits [1

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Jeff Newmiller
; r-help Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R There is a precedence error in your R attempt. You need to convert 163 to 120 bits first, before taking its square root. exp(sqrt(mpfr(163, 120)) * mpfr(pi, 120)) 1 'mpfr' number

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Richard M. Heiberger
showed. Thanks, Ravi -Original Message- From: Richard M. Heiberger [mailto:r...@temple.edu] Sent: Thursday, July 02, 2015 6:30 PM To: Aditya Singh Cc: Ravi Varadhan; r-help Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Nordlund, Dan (DSHS/RDA)
, July 02, 2015 6:30 PM To: Aditya Singh Cc: Ravi Varadhan; r-help Subject: Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R There is a precedence error in your R attempt. You need to convert 163 to 120 bits first, before taking its square root. exp(sqrt

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Aditya Singh via R-help
Ravi I am a chemical engineer by training. Is there not something like law of corresponding states in numerical analysis? Aditya -- On Thu 2 Jul, 2015 7:28 AM PDT Ravi Varadhan wrote: Hi, Ramanujan supposedly discovered that the number, 163, has this

Re: [R] Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Aditya Singh via R-help
Ravi 1. You may want to check the sqrt too. 2. Why not take log and try? Aditya -- On Thu 2 Jul, 2015 10:18 AM PDT Boris Steipe wrote: Just a wild guess, but did you check exactly which operations are actually done to high precision? Obviously you will need

Re: [R] Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Jeff Newmiller
I don't know much about Rmpfr, but it doesn't look like your pi or sqrt or exp are being handled by that package, so I am not really seeing why your result should be more accurate when you have loaded that package. --- Jeff

[R] Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Ravi Varadhan
Hi, Ramanujan supposedly discovered that the number, 163, has this interesting property that exp(sqrt(163)*pi), which is obviously a transcendental number, is real close to an integer (close to 10^(-12)). If I compute this using the Wolfram alpha engine, I get:

Re: [R] Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Boris Steipe
Just a wild guess, but did you check exactly which operations are actually done to high precision? Obviously you will need high-resolution representations of pi and e to get an improved result. B. On Jul 2, 2015, at 10:28 AM, Ravi Varadhan ravi.varad...@jhu.edu wrote: Hi, Ramanujan

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread jim holtman
This is the standard FAQ 7.31 and then read in detail the referenced paper. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Jul 2, 2015 at 2:02 PM, Aditya Singh via R-help r-help@r-project.org

Re: [R] : Ramanujan and the accuracy of floating point computations - using Rmpfr in R

2015-07-02 Thread Richard M. Heiberger
There is a precedence error in your R attempt. You need to convert 163 to 120 bits first, before taking its square root. exp(sqrt(mpfr(163, 120)) * mpfr(pi, 120)) 1 'mpfr' number of precision 120 bits [1] 262537412640768333.51635812597335712954 ## just the last four characters to the left