Can you calculate Pi using a Solver? - Printable Version +- HP Forums ( https://www.hpmuseum.org/forum)+-- Forum: HP Calculators (and very old HP Computers) ( /forum-3.html)+--- Forum: General Forum ( /forum-4.html)+--- Thread: Can you calculate Pi using a Solver? ( /thread-14132.html) |

Can you calculate Pi using a Solver? - EdS2 - 12-09-2019 01:12 PM
I'm wondering what approaches there might be for computing Pi using one of the Solvers on the various HP calculators. Of course, no trig functions allowed! Let's call this a mini-challenge, unless it turns out to be so easy and obvious that it's a nano-challenge. RE: Can you calculate Pi using a Solver? - SlideRule - 12-09-2019 01:44 PM
Reference: Using A Minicalculator to Find An Approximate Value for Π, E. J. Bolduc (University of Florida) "One of the many ways to use a minicalculator in a classroom is in the calculation of an approximate value for n using a variation of the method of Archimedes … if a circle of radius 1 is chosen, then the area of any inscribed polygon is less than Π and the area of any circumscribed polygon is greater than n. He finally arrived at the fact that 3(10/17) < Π < 3(1/7). We can use the idea that, as the numbers of sides of an inscribed polygon increases, the perimeter of the polygon approaches the circumference of the circle and the ratio of the perimeter to the diameter of the circle is an approximation for Π … We now have our iterative formula, S’ = √2r² - r√4r² - S²" I leave the recursion and subsequent calculation to the reader, but after nine iterations, the equation yields 3.141592… BEST! SlideRule RE: Can you calculate Pi using a Solver? - jthole - 12-09-2019 01:50 PM
This does not answer your question directly, but on the back of my 12C I have a sticker with "355 / 113". For my purposes, that is good enough RE: Can you calculate Pi using a Solver? - toml_12953 - 12-09-2019 01:56 PM
(12-09-2019 01:44 PM)SlideRule Wrote: Reference: Here's a simple BASIC version from Problems for Computer Solution by Stephen J. Rogowski: Code: `50 PRINT "ARCHIMEDEAN DETERMINATION OF PI!"` RE: Can you calculate Pi using a Solver? - Valentin Albillo - 12-09-2019 03:35 PM
(12-09-2019 01:12 PM)EdS2 Wrote: I'm wondering what approaches there might be for computing Pi using one of the Solvers on the various HP calculators. Of course, no trig functions allowed! If your Solver has Square Root and Factorial, this one from Ramanujan converges very fast and it's quite simple, few bytes to program it and only a few terms to add up for full precision... ... and no trigs used, as requested, just basic arithmetic. Once you get 1/Pi just invert it with 1/x Regards. V. RE: Can you calculate Pi using a Solver? - Csaba Tizedes - 12-09-2019 03:53 PM
Code: `120 LET T= 3 . 1 4 1 5 9 2 7 *(D/180)` WHAT? Code: `120 LET T=3.1415927*(D/180)` Err... this looks like a checking how precise the arithmetics of that computer... BTW: HP32SII - a fraction finder Code: `---------------------` Csaba RE: Can you calculate Pi using a Solver? - jthole - 12-09-2019 06:38 PM
(12-09-2019 03:35 PM)Valentin Albillo Wrote: If your Solver has Square Root and Factorial, this one from Ramanujan converges very fast and it's quite simple, few bytes to program it and only a few terms to add up for full precision... Very nice! Here is the equation for the 17Bii: 1 ÷ PIVAL = ( ( 2 x SQRT( 2 ) ) ÷ 9801 ) x sigma ( I : 0 : N : 1 : ( FACT( 4 x I ) x ( 1103 + 26390 x I ) ÷ ( ( FACT( I ) ^ 4 ) x ( 396 ^ ( 4 x I ) ) ) ) I only tested it on the iPhone emulator, but it goes to full precision very quickly (N=2) indeed. RE: Can you calculate Pi using a Solver? - mfleming - 12-10-2019 02:48 AM
Needs one more closed parenthesis at the end. Works on the 27S! RE: Can you calculate Pi using a Solver? - JurgenRo - 12-10-2019 07:45 PM
(12-09-2019 03:35 PM)Valentin Albillo Wrote:(12-09-2019 01:12 PM)EdS2 Wrote: I'm wondering what approaches there might be for computing Pi using one of the Solvers on the various HP calculators. Of course, no trig functions allowed! (Pi^2)/6=sum_{n=1}^{infinity}1/n^2 might fall into the same category. Juergen RE: Can you calculate Pi using a Solver? - jthole - 12-10-2019 09:07 PM
(12-10-2019 07:45 PM)JurgenRo Wrote:(12-09-2019 03:35 PM)Valentin Albillo Wrote: If your Solver has Square Root and Factorial, this one from Ramanujan converges very fast and it's quite simple, few bytes to program it and only a few terms to add up for full precision... Converges much more slowly though. I just let it run from n=0 to 1 million (on the 17Bii simulator on my iPhone), and the difference with the Pi constant is still -9,5x10E-7. In contrast, the one suggested by Valentin already equals the Pi constant for n=2. I'll test it on the 17Bii later, to see how much slower than the iPhone 7 it is Edit: in order not to pollute this thread, I posted the results here: https://www.hpmuseum.org/forum/thread-14101.html RE: Can you calculate Pi using a Solver? - Albert Chan - 12-10-2019 09:35 PM
Pi via AGM, Emu71 HP-71B basic Code: `10 A=1 @ B=SQRT(.5) @ S=1 @ P=1` >RUN 3.14040401902 3.1415926456 3.1415926536 3.14159265359 RE: Can you calculate Pi using a Solver? - EdS2 - 12-11-2019 10:29 AM
Ah, always interesting to get some unexpected results - thanks everyone! In some, then, we see a 'sigma' function being used to do most of the work, and the solver is only needing to cope with a simple transformation like reciprocal or square root. I hadn't realised a 'sigma' function might be to hand - of course these offerings are valid, for the machines which offer 'sigma'. For the first submission, the iterative one posted by sliderule, is there a way to render this as a Solver problem? Quote:We now have our iterative formula, S’ = √2r² - r√4r² - S² Likewise, for the AGM method posted by Albert Chan, is there a way to get a Solver to do the work, rather than a program? RE: Can you calculate Pi using a Solver? - toml_12953 - 12-11-2019 11:50 AM
(12-09-2019 03:53 PM)Csaba Tizedes Wrote: It shows that both an inscribed and circumscribed polygon approach PI as the number of sides increases. I agree it was poorly named. RE: Can you calculate Pi using a Solver? - Albert Chan - 12-11-2019 01:09 PM
(12-11-2019 11:50 AM)toml_12953 Wrote: It shows that both an inscribed and circumscribed polygon approach PI as the number of sides increases. We can do this with right triangles, starting from a hexagon ("radius" = side = 2S = 1) 10 N=6 @ S=.5 20 H=SQRT(1-S*S) @ A=N*S @ B=A/H 30 DISP N,A,B 40 N=N+N @ S=.5*SQRT(S^2+(1-H)^2) 50 IF A<B THEN 20 Code: `>RUN` Edit: line 40 may be replaced with simpler formula (approx. same accuracy) 40 N=N+N @ S=S/SQRT(H+H+2) RE: Can you calculate Pi using a Solver? - Roland57 - 12-11-2019 05:49 PM
Hi, May be it is too easy, but what about this pi = 2 * integral(1 / sqr(1-x*x), x, 0, 1) It gives 3.141592(48348) on the iOS prime-emulator Roland RE: Can you calculate Pi using a Solver? - Albert Chan - 12-11-2019 08:00 PM
(12-11-2019 05:49 PM)Roland57 Wrote: pi = 2 * integral(1 / sqr(1-x*x), x, 0, 1) Some calculators have problem with singularity at the limits. We can do this instead: pi = 6 asin(.5) = integrate(6 / sqrt(1-x*x), x = 0 .. 0.5) or, to speed it up a bit ... pi = 4 atan(1) = integrate(4 / (1+x*x), 0, 1) RE: Can you calculate Pi using a Solver? - EdS2 - 12-12-2019 08:18 AM
ah yes, like summation, integration certainly has ways to reach pi. I'm still curious about the solver though. If any HP calculator's solver worked in the complex domain (and I imagine none do) then Euler's identity would give a route to pi. (By the solver, I mean the facility which takes a function of one variable and finds a value of that variable which makes the function zero.) As we know that pi isn't algebraic, it might be that we know there's no way to do this. But finding a fixed point of a recurrence feels a bit like finding a zero of a function, so I wonder if that could be a way. RE: Can you calculate Pi using a Solver? - EdS2 - 12-12-2019 11:24 AM
I found a couple of not-great examples of the sort of thing I might hope exists... There's a good approximation for pi as a root of an 8th order polynomial: 0=1−1635840576x−343853312x^2 +60576043008x^3 +1865242664960x^4 −16779556159488x^5 +37529045696512x^6 −29726424956928x^7 +6181548457984x^8 And there's a bad approximation as a solution to x=(1+1/x)^(x+1) Here's a quartic: 0=16-160x+168600x^2-841000x^3+250625x^4 RE: Can you calculate Pi using a Solver? - SlideRule - 12-12-2019 02:12 PM
(12-12-2019 11:24 AM)EdS2 Wrote: I found a couple of not-great examples of the sort of thing I might hope exists... An excerpt from PI a source book, Springer (2e), 96-40196, © 2000 [attachment=7919] The PDF title says it all. BEST! SlideRule RE: Can you calculate Pi using a Solver? - EdS2 - 12-12-2019 03:02 PM
Thanks! Also of interest (and relevant) is The Quest for Pi, a 16 page paper by BBP. (I'm still not sure how to get the solver to make use of this kind of iterative approach. Merely evaluating an expression doesn't feel like it's making proper use of a solver.) |