Can you calculate Pi using a Solver?

12092019, 01:12 PM
Post: #1




Can you calculate Pi using a Solver?
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 minichallenge, unless it turns out to be so easy and obvious that it's a nanochallenge. 

12092019, 01:44 PM
Post: #2




RE: Can you calculate Pi using a Solver?
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 

12092019, 01:50 PM
Post: #3




RE: Can you calculate Pi using a Solver?
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 

12092019, 01:56 PM
(This post was last modified: 12092019 01:57 PM by toml_12953.)
Post: #4




RE: Can you calculate Pi using a Solver?
(12092019 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!" Tom L I'm pining for the Fjords 

12092019, 03:35 PM
Post: #5




RE: Can you calculate Pi using a Solver?
(12092019 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. Find All My HPrelated Materials here: Valentin Albillo's HP Collection 

12092019, 03:53 PM
Post: #6




RE: Can you calculate Pi using a Solver?
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 

12092019, 06:38 PM
(This post was last modified: 12092019 06:51 PM by jthole.)
Post: #7




RE: Can you calculate Pi using a Solver?
(12092019 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. 

12102019, 02:48 AM
Post: #8




RE: Can you calculate Pi using a Solver?
Needs one more closed parenthesis at the end. Works on the 27S!
Who decides? 

12102019, 07:45 PM
Post: #9




RE: Can you calculate Pi using a Solver?
(12092019 03:35 PM)Valentin Albillo Wrote:(12092019 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 

12102019, 09:07 PM
(This post was last modified: 12102019 09:36 PM by jthole.)
Post: #10




RE: Can you calculate Pi using a Solver?
(12102019 07:45 PM)JurgenRo Wrote:(12092019 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,5x10E7. 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/thread14101.html 

12102019, 09:35 PM
Post: #11




RE: Can you calculate Pi using a Solver?
Pi via AGM, Emu71 HP71B basic
Code: 10 A=1 @ B=SQRT(.5) @ S=1 @ P=1 >RUN 3.14040401902 3.1415926456 3.1415926536 3.14159265359 

12112019, 10:29 AM
(This post was last modified: 12112019 10:30 AM by EdS2.)
Post: #12




RE: Can you calculate Pi using a Solver?
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? 

12112019, 11:50 AM
Post: #13




RE: Can you calculate Pi using a Solver?
(12092019 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. Tom L I'm pining for the Fjords 

12112019, 01:09 PM
(This post was last modified: 12112019 10:14 PM by Albert Chan.)
Post: #14




RE: Can you calculate Pi using a Solver?
(12112019 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(1S*S) @ A=N*S @ B=A/H 30 DISP N,A,B 40 N=N+N @ S=.5*SQRT(S^2+(1H)^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) 

12112019, 05:49 PM
Post: #15




RE: Can you calculate Pi using a Solver?
Hi,
May be it is too easy, but what about this pi = 2 * integral(1 / sqr(1x*x), x, 0, 1) It gives 3.141592(48348) on the iOS primeemulator Roland 

12112019, 08:00 PM
(This post was last modified: 12122019 04:46 PM by Albert Chan.)
Post: #16




RE: Can you calculate Pi using a Solver?
(12112019 05:49 PM)Roland57 Wrote: pi = 2 * integral(1 / sqr(1x*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(1x*x), x = 0 .. 0.5) or, to speed it up a bit ... pi = 4 atan(1) = integrate(4 / (1+x*x), 0, 1) 

12122019, 08:18 AM
Post: #17




RE: Can you calculate Pi using a Solver?
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. 

12122019, 11:24 AM
Post: #18




RE: Can you calculate Pi using a Solver?
I found a couple of notgreat 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=16160x+168600x^2841000x^3+250625x^4 

12122019, 02:12 PM
Post: #19




RE: Can you calculate Pi using a Solver?
(12122019 11:24 AM)EdS2 Wrote: I found a couple of notgreat examples of the sort of thing I might hope exists... An excerpt from PI a source book, Springer (2e), 9640196, © 2000 Pi iterative algorithms.pdf (Size: 27.64 KB / Downloads: 20) The PDF title says it all. BEST! SlideRule 

12122019, 03:02 PM
(This post was last modified: 12122019 03:05 PM by EdS2.)
Post: #20




RE: Can you calculate Pi using a Solver?
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.) 

« Next Oldest  Next Newest »

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