Another Ramanujan Trick
09-29-2019, 06:45 AM
Post: #1
 ttw Member Posts: 239 Joined: Jun 2014
Another Ramanujan Trick
Just for fun, I came across with another Ramanujan trick:

Pi=Sqrt(Sqrt(2142/22))

It's better than 355/113 but at the cost of a couple of square roots (or a fourth root.)
09-29-2019, 09:17 AM
Post: #2
 Thomas Okken Senior Member Posts: 1,304 Joined: Feb 2014
RE: Another Ramanujan Trick
(09-29-2019 06:45 AM)ttw Wrote:  Pi=Sqrt(Sqrt(2142/22))

Are you sure that's correct? It seems a bit off, for one because the fraction is not in least terms, and for another it's not very good, only accurate to three decimals.
09-29-2019, 09:55 AM
Post: #3
 Massimo Gnerucci Senior Member Posts: 2,330 Joined: Dec 2013
RE: Another Ramanujan Trick
(09-29-2019 06:45 AM)ttw Wrote:  Just for fun, I came across with another Ramanujan trick:

Pi=Sqrt(Sqrt(2142/22))

It's better than 355/113 but at the cost of a couple of square roots (or a fourth root.)

Isn't it Pi=Sqrt(Sqrt(2143/22)) ?

Greetings,
Massimo

-+×÷ ↔ left is right and right is wrong
09-29-2019, 11:19 AM (This post was last modified: 09-29-2019 02:45 PM by Gerson W. Barbosa.)
Post: #4
 Gerson W. Barbosa Senior Member Posts: 1,405 Joined: Dec 2013
RE: Another Ramanujan Trick
(09-29-2019 09:55 AM)Massimo Gnerucci Wrote:
(09-29-2019 06:45 AM)ttw Wrote:  Just for fun, I came across with another Ramanujan trick:

Pi=Sqrt(Sqrt(2142/22))

It's better than 355/113 but at the cost of a couple of square roots (or a fourth root.)

Isn't it Pi=Sqrt(Sqrt(2143/22)) ?

Ciao, Massimo,

Yes, you are right.

Let us take our HP-32S or 33S and do some “reverse engineering”:

pi x^2 x^2 -> 97.409091034
99 * -> 96435.50001237
ENTER + IP -> 19287
198 / FDISP -> 97 9/22
1/x -> 22/2143

=> pi ~ sqrt(sqrt(2143/22)) = 3.14159265258

This fourth power oddity is common to both ln(pi) and e^x as well:

(ln(pi))^4 = 1.7171652254

and

(e^pi)^4 = 286751.313138,

e^(sqrt(sqrt(170/99))) = 3.14159605245

and

ln(sqrt(sqrt(28388380/99))) = 3.14159265359

These don’t make for efficient pi approximations, though.

P.S.:

You might want to check this out:

$\ln\left(\sqrt[4]{\frac{{305}^{3}+{25}^{3}+{5}^{3}+5+\frac{33}{{9}^{5}+{5}^{5}+{3}^{5}+3}}{99}} \right )$

P.P.S.:

Or that one:

$\sqrt[4]{\frac{2143+{\left(6+\sqrt{\frac{6}{1+{6}^{-6}}}\right)}^{-6}}{22}}$
09-29-2019, 01:28 PM
Post: #5
 ttw Member Posts: 239 Joined: Jun 2014
RE: Another Ramanujan Trick
(Sorry about the typo.)

The method works by developing the continued fraction for Pi^4. The continued fraction for Pi has a 292 real early and 355/113 comes from stopping just before the 292.

The continued fraction for Pi^4 is (97; 2, 2, 3, 1, 16539...) so one stops before the 16539.

Continued fractions (to anything) give a sequence of p(i))/q(i) of numerators and denominators. The error in the ith term is less than 1 part in q(i)*(q(i)+q(i-1)). (Assuming I'm not off 1 in counting.)
09-29-2019, 03:23 PM
Post: #6
 Albert Chan Senior Member Posts: 1,597 Joined: Jul 2018
RE: Another Ramanujan Trick
(09-29-2019 01:28 PM)ttw Wrote:  Continued fractions (to anything) give a sequence of p(i))/q(i) of numerators and denominators.
The error in the ith term is less than 1 part in q(i)*(q(i)+q(i-1)). (Assuming I'm not off 1 in counting.)

The statement is true, but you can tighten the bound with error < $$\Large{1 \over q_{i}q_{i+1} }$$

(97; 2, 2, 3, 1) = 2143 / 22
(97; 2, 2, 3, 1, 16539) = 35444733 / 363875

Pi^4 must be between 2 convergents.

gap = 1 / (22 * 363875) = 1 / 8005250

To get first fraction for Pi^4 with estimate better than 2143/22
Convergent before 2143/22 is 1656/17, solve for semi-convergent with less |error|

XCas> fsolve(pi^4 - (1656+2143k)/(17+22k) = 2143/22 - pi^4, k) → k ≈ 8269.54

Semi-convergent error switched sign when k=8270. To confirm:

XCas> float(pi^4 .- [2143/22, 17724266/181957]) → (1.24912e-7, -1.24898e-7)
09-29-2019, 05:09 PM
Post: #7
 ttw Member Posts: 239 Joined: Jun 2014
RE: Another Ramanujan Trick
OK, I was off by 1.
09-29-2019, 09:36 PM
Post: #8
 Valentin Albillo Senior Member Posts: 776 Joined: Feb 2015
RE: Another Ramanujan Trick
.
Hi, Gerson:

(09-29-2019 11:19 AM)Gerson W. Barbosa Wrote:  You might want to check this out:$\ln\left(\sqrt[4]{\frac{{305}^{3}+{25}^{3}+{5}^{3}+5+\frac{33}{{9}^{5}+{5}^{5}+{3}^{5}+3}}{99}} \right )$Or that one:$\sqrt[4]{\frac{2143+{\left(6+\sqrt{\frac{6}{1+{6}^{-6}}}\right)}^{-6}}{22}}$

Nice, they're indeed aesthetically pleasing but as approximations to Pi they use far too many digits, functions and operations for the accuracy they achieve.

On the other hand, the following theoretically-based approximation to Pi is much better in that regard: just ten individual digits, two functions and two arithmetic operations to achieve almost 17 digits (save for 2 units in the last place):$\frac{3 Ln 640320}{\sqrt{163}} =3,1415926535897930...$
A small modification, essentially adding just three digits and one sum gets you almost 32 digits (again save for 2 units in the last place).$\frac{Ln{({ 640320}^{3}+744})}{\sqrt{163}} =3,1415926535897932384626433832797...$Regards.
V.
.

All My Articles & other Materials here:  Valentin Albillo's HP Collection

09-30-2019, 03:10 AM (This post was last modified: 09-30-2019 03:11 AM by Gerson W. Barbosa.)
Post: #9
 Gerson W. Barbosa Senior Member Posts: 1,405 Joined: Dec 2013
RE: Another Ramanujan Trick
(09-29-2019 09:36 PM)Valentin Albillo Wrote:
(09-29-2019 11:19 AM)Gerson W. Barbosa Wrote:  You might want to check this out:$\ln\left(\sqrt[4]{\frac{{305}^{3}+{25}^{3}+{5}^{3}+5+\frac{33}{{9}^{5}+{5}^{5}+{3}^{5}+3}}{99}} \right )$Or that one:$\sqrt[4]{\frac{2143+{\left(6+\sqrt{\frac{6}{1+{6}^{-6}}}\right)}^{-6}}{22}}$

Nice, they're indeed aesthetically pleasing but as approximations to Pi they use far too many digits, functions and operations for the accuracy they achieve.

On the other hand, the following theoretically-based approximation to Pi is much better in that regard: just ten individual digits, two functions and two arithmetic operations to achieve almost 17 digits (save for 2 units in the last place):$\frac{3 Ln 640320}{\sqrt{163}} =3,1415926535897930...$
A small modification, essentially adding just three digits and one sum gets you almost 32 digits (again save for 2 units in the last place).$\frac{Ln{({ 640320}^{3}+744})}{\sqrt{163}} =3,1415926535897932384626433832797...$

Hello, Valentin,

My second approximation uses 10 digits and produces 17 significant digits, but it requires four functions, twice as much compared to the first approximation you mention. By no means I intend to compete with Ramanujan, Dedekind and others. That was just an idle Sunday morning play.
Anyway, thanks for bringing these really nice approximations to my attention again. They have prompted me to search for an 82-digit one belonging to the same group. I’ve finally found it in Tito Pieza’s blog here.

Best regards,

Gerson.
09-30-2019, 10:24 PM
Post: #10
 Valentin Albillo Senior Member Posts: 776 Joined: Feb 2015
RE: Another Ramanujan Trick
.
Hi again, Gerson:

(09-30-2019 03:10 AM)Gerson W. Barbosa Wrote:  My second approximation uses 10 digits and produces 17 significant digits, but it requires four functions, twice as much compared to the first approximation you mention.

Funny, it seems that my counting methods and yours do differ. In your second approximation I count 13 digits (4,2,1,4,3,6,6,1,6,-6,-6,2,2) and 9 operations (3 additions, 2 divisions, 2 roots and 2 powers).

Quote:They have prompted me to search for an 82-digit one belonging to the same group. I’ve finally found it in Tito Pieza’s blog here

I did follow the link you mention but I was less than impressed. It may produce 82 correct digits but it's far too complex to be regarded as a remarkable approximation, the number of digits and operations needed is on the same ballpark as the number of correct digits produced.

Compare it with the two truly remarkable approximations I gave, or even the simple 355/133, where 6 digits and 1 division gets you almost 8 digits (save for 2 or 3 units in the last place, depending on rounding).

Best regards.
V.
.

All My Articles & other Materials here:  Valentin Albillo's HP Collection

10-02-2019, 04:03 AM (This post was last modified: 10-02-2019 04:12 AM by Gerson W. Barbosa.)
Post: #11
 Gerson W. Barbosa Senior Member Posts: 1,405 Joined: Dec 2013
RE: Another Ramanujan Trick
(09-30-2019 10:24 PM)Valentin Albillo Wrote:  .
Hi again, Gerson:

(09-30-2019 03:10 AM)Gerson W. Barbosa Wrote:  My second approximation uses 10 digits and produces 17 significant digits, but it requires four functions, twice as much compared to the first approximation you mention.

Funny, it seems that my counting methods and yours do differ. In your second approximation I count 13 digits (4,2,1,4,3,6,6,1,6,-6,-6,2,2) and 9 operations (3 additions, 2 divisions, 2 roots and 2 powers).

I would consider one 4 and the two instances of -6 as functions (fourth root and the reciprocals of sixth roots). But I have yet another trick up my sleeve:

10 DESTROY ALL
20 OPTION BASE 1 @ DIM A(35) @ COMPLEX B(34)
30 A(1)=3 @ A(34)=-1.E+12 @ A(35)=-2.4E+17
40 MAT B=PROOT(A)
50 DISP REPT(B(2))

The four significant digits in line 30 of the HP-71B program above yield 10 correct digits of pi.

Best regards,

Gerson.
10-02-2019, 11:14 PM
Post: #12
 Valentin Albillo Senior Member Posts: 776 Joined: Feb 2015
RE: Another Ramanujan Trick
(10-02-2019 04:03 AM)Gerson W. Barbosa Wrote:  I would consider one 4 and the two instances of -6 as functions (fourth root and the reciprocals of sixth roots).

The fourth root would be the function nthroot(4,x) so the nthroot would be one function and the 4 would be one digit.

Same with the various -6, they would be power(-6,x), i.e: one function, power, and one-digit argument, -6. And that 's being generous and not counting the "-" as one unary operation.

Else, you could have 2^1,651496129472 = 3,141592653589+ and claim that the underlined power is just one function. Nope.

Quote:But I have yet another trick up my sleeve:

10 DESTROY ALL
20 OPTION BASE 1 @ DIM A(35) @ COMPLEX B(34)
30 A(1)=3 @ A(34)=-1.E+12 @ A(35)=-2.4E+17
40 MAT B=PROOT(A)
50 DISP REPT(B(2))

The four significant digits in line 30 of the HP-71B program above yield 10 correct digits of pi.

You forgot to include the <justjoking> ... </justjoking> tags.

If something as immensely complicated as a function capable of finding the real part of one root of a 34th degree polynomial with 32 zero coefficients and 3 real-valued coefficients is to be counted as just one function applied to 3 parameters then you can go the whole hog and simply use:

4*arctan(1) = 3,1415926535897932384626433832795+

which uses just 2 digits and one function, which is many orders of magnitude simpler than your function which gives the root of the 34th-degree polynomial, and further agrees with infinitely many correct digits of Pi.

Anyway, quite ingenious on your part, but hopelessly useless as a simple approximate formula.

Best regards.
V.
.

All My Articles & other Materials here:  Valentin Albillo's HP Collection

10-03-2019, 07:21 AM
Post: #13
 ijabbott Senior Member Posts: 1,026 Joined: Jul 2015
RE: Another Ramanujan Trick
(10-02-2019 11:14 PM)Valentin Albillo Wrote:  If something as immensely complicated as a function capable of finding the real part of one root of a 34th degree polynomial with 32 zero coefficients and 3 real-valued coefficients is to be counted as just one function applied to 3 parameters then you can go the whole hog and simply use:

4*arctan(1) = 3,1415926535897932384626433832795+

which uses just 2 digits and one function, which is many orders of magnitude simpler than your function which gives the root of the 34th-degree polynomial, and further agrees with infinitely many correct digits of Pi.

Surely going the whole hog would be arccos(-1)?

— Ian Abbott
10-03-2019, 05:47 PM
Post: #14
 Valentin Albillo Senior Member Posts: 776 Joined: Feb 2015
RE: Another Ramanujan Trick
(10-03-2019 07:21 AM)ijabbott Wrote:  Surely going the whole hog would be arccos(-1)?

Surely !

Did you visit my new HP site ? If yes, did some contents gather your interest ? Any comments welcome, especially constructive ones.

Regards,
V.
.

All My Articles & other Materials here:  Valentin Albillo's HP Collection

10-03-2019, 07:58 PM (This post was last modified: 10-03-2019 08:04 PM by Gerson W. Barbosa.)
Post: #15
 Gerson W. Barbosa Senior Member Posts: 1,405 Joined: Dec 2013
RE: Another Ramanujan Trick
(10-02-2019 11:14 PM)Valentin Albillo Wrote:
(10-02-2019 04:03 AM)Gerson W. Barbosa Wrote:  I would consider one 4 and the two instances of -6 as functions (fourth root and the reciprocals of sixth roots).

The fourth root would be the function nthroot(4,x) so the nthroot would be one function and the 4 would be one digit.

Two nested square roots woudn't help, so I'll leave it as is.

(10-02-2019 11:14 PM)Valentin Albillo Wrote:  Same with the various -6, they would be power(-6,x), i.e: one function, power, and one-digit argument, -6. And that 's being generous and not counting the "-" as one unary operation.

Else, you could have 2^1,651496129472 = 3,141592653589+ and claim that the underlined power is just one function. Nope.

You do have a point here.

(10-02-2019 11:14 PM)Valentin Albillo Wrote:
Quote:But I have yet another trick up my sleeve:

10 DESTROY ALL
20 OPTION BASE 1 @ DIM A(35) @ COMPLEX B(34)
30 A(1)=3 @ A(34)=-1.E+12 @ A(35)=-2.4E+17
40 MAT B=PROOT(A)
50 DISP REPT(B(2))

The four significant digits in line 30 of the HP-71B program above yield 10 correct digits of pi.

You forgot to include the <justjoking> ... </justjoking> tags.

No need to. I knew I could count on your sense of humor.

(10-02-2019 11:14 PM)Valentin Albillo Wrote:  Anyway, quite ingenious on your part, but hopelessly useless as a simple approximate formula.

Yes, I am aware of its uselessness as an approximation to pi, but I thought the associated polynomial is interesting just the same. It arises from noticing that the 34th power of pi is 8.00010471505E16, whose underlined digits match the first digits of pi/3.

Best regards,

Gerson.

P.S.:

I forgot to mention that it take more than 3 minutes for the HP-71B to show the result. The HP-50g is faster, still it takes 38 seconds which certainly most of you will find too much time.

« { 1 35 } 0 CON 1 3 PUT 34 -1.E12 PUT 35 -2.4E17 PUT PROOT 6 GET RE
»

EVAL -> 3.14159265364
10-03-2019, 08:23 PM
Post: #16
 ijabbott Senior Member Posts: 1,026 Joined: Jul 2015
RE: Another Ramanujan Trick
(10-03-2019 05:47 PM)Valentin Albillo Wrote:
(10-03-2019 07:21 AM)ijabbott Wrote:  Surely going the whole hog would be arccos(-1)?

Surely !

Did you visit my new HP site ? If yes, did some contents gather your interest ? Any comments welcome, especially constructive ones.

Regards,
V.
.

I've visited it, but haven't delved into the articles yet, apart from the "Time Voyager" story that someone linked to earlier (although I'm pretty sure I'd already read your story some time ago, and definitely wasn't confusing it with Paul Nahin's "Newton's Gift" story from Omni magazine).

— Ian Abbott
10-03-2019, 08:26 PM
Post: #17
 Gerson W. Barbosa Senior Member Posts: 1,405 Joined: Dec 2013
RE: Another Ramanujan Trick
(10-03-2019 05:47 PM)Valentin Albillo Wrote:
(10-03-2019 07:21 AM)ijabbott Wrote:  Surely going the whole hog would be arccos(-1)?

Surely !

Not quite! If you are interested only in the exact representation of the constant, than there is nothing more simple than $$\pi$$ .

It looks like somehow I've failed to make myself clear this is all about original approximations to $$\pi$$, not about exact formulas or other well known approximations. My bad.

The real thing

Just an approximation

Best regards,

Gerson.
10-03-2019, 09:44 PM
Post: #18
 Valentin Albillo Senior Member Posts: 776 Joined: Feb 2015
RE: Another Ramanujan Trick
(10-03-2019 07:58 PM)Gerson W. Barbosa Wrote:
(10-02-2019 11:14 PM)Valentin Albillo Wrote:  You forgot to include the <justjoking> ... </justjoking> tags.

No need to. I knew I could count on your sense of humor.

Of course you can count on it.

Quote:I thought the associated polynomial is interesting just the same. It arises from noticing that the 34th power of pi is 8.00010471505E16, whose underlined digits match the first digits of pi/3.

Nice find, indeed. Did you mention it in the past ? I seem to remember having read about it in one of your old posts but I may just be mistaken.

Quote:I forgot to mention that it take more than 3 minutes for the HP-71B to show the result.

To be fair, you must consider that it's not simply computing just the one root you're interested in for your approximation to Pi, but rather it's simultaneously computing all 34 complex roots to full accuracy (using 15 digits internally). By the time the 3 minutes have elapsed you have the 68 components of the 34 complex roots readily stored in complex array B(), though you then go and use just one of them.

Considering this fact, 3 minutes doesn't seem that long, it comes to less than 5.3 seconds per 12-digit root. And, perhaps, using FNROOT instead to compute just the one root you're interested in would be much faster than using PROOT to compute all 34 roots. Did you try ?

Regards.
V.

All My Articles & other Materials here:  Valentin Albillo's HP Collection

10-04-2019, 04:14 PM
Post: #19
 Gerson W. Barbosa Senior Member Posts: 1,405 Joined: Dec 2013
RE: Another Ramanujan Trick
(10-03-2019 09:44 PM)Valentin Albillo Wrote:
(10-03-2019 07:58 PM)Gerson W. Barbosa Wrote:  I thought the associated polynomial is interesting just the same. It arises from noticing that the 34th power of pi is 8.00010471505E16, whose underlined digits match the first digits of pi/3.

Nice find, indeed. Did you mention it in the past ? I seem to remember having read about it in one of your old posts but I may just be mistaken.

I think I have used that in a near-integer expression, but I can't find it right now.

(10-03-2019 09:44 PM)Valentin Albillo Wrote:
Quote:I forgot to mention that it take more than 3 minutes for the HP-71B to show the result.

To be fair, you must consider that it's not simply computing just the one root you're interested in for your approximation to Pi, but rather it's simultaneously computing all 34 complex roots to full accuracy (using 15 digits internally). By the time the 3 minutes have elapsed you have the 68 components of the 34 complex roots readily stored in complex array B(), though you then go and use just one of them.

Considering this fact, 3 minutes doesn't seem that long, it comes to less than 5.3 seconds per 12-digit root. And, perhaps, using FNROOT instead to compute just the one root you're interested in would be much faster than using PROOT to compute all 34 roots. Did you try ?

No, I didn't. But that surely would have been much faster. At first, I tried Wolfram Alpha, which does it instantaneously, but I thought the HP-71B code would fit better here. Anyway, here it is, just for the record:

Solve x^34 - (1/3)*10^12*x - 8*10^16 = 0

Best regards,

Gerson.
10-06-2019, 09:07 PM
Post: #20
 Gerson W. Barbosa Senior Member Posts: 1,405 Joined: Dec 2013
RE: Another Ramanujan Trick
(09-30-2019 10:24 PM)Valentin Albillo Wrote:
(09-30-2019 03:10 AM)Gerson W. Barbosa Wrote:  They have prompted me to search for an 82-digit one belonging to the same group. I’ve finally found it in Tito Pieza’s blog here

I did follow the link you mention but I was less than impressed. It may produce 82 correct digits but it's far too complex to be regarded as a remarkable approximation, the number of digits and operations needed is on the same ballpark as the number of correct digits produced.

Ok, then the following might almost double that. Well, sort of cheating, but at least no use of any inverse trig function that would just kill the fun.

ln(640320^3 + 744)/√163 + sinh(sin(ln(640320^3 + 744)/√163))

Best regards,

Gerson.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)