Post Reply 
Leibniz formula for π on HP 35s
05-07-2020, 09:47 AM (This post was last modified: 05-09-2020 06:47 PM by lipoff.)
Post: #5
RE: Leibniz formula for π on HP 35s
If it's helpful, here's the program with comments, with a very slight update to make it "more optimum" as it now runs in 2 minutes and 34 seconds:

Code:
L001    LBL L                   Name the program
L002    0            
L003    STO P                   Set our accumulator for the series to 0
L004    1
L005    STO L                   Start the series denominator at 1
L006    1.84401            
L007    STO Z                   Start a loop counter at 1, with a max of 844 and increment of 1
L008    RCL L                   This is the start of our calculation loop
L009    1/x                     Take 1/L
L010    STO+ P                  Add this quantity to P
L011    RCL L 
L012    2
L013    +
L014    1/x                     Take 1/(L+2)
L015    STO- P                  Subtract this quantity from P
L016    4
L017    STO+ L                  Add 4 to our denominator
L018    ISG Z                   Increment the loop counter and check if it exceeds the max value
L019    GTO L008                If not, loop back to L008
L020    RCL P            
L021    0.78525            
L022    x>y?                    Check if our estimate, P < 3.141/4 = 0.78525 because the series converges to pi/4
L023    GTO L006                If so, loop back to L006
L024    4
L025    RCLx P                  If not, display 4 times P    
L026    2
L027    RCL+ L                  And display the final denominator in the series
L028    RTN                     End program
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Leibniz formula for π on HP 35s - lipoff - 05-06-2020, 02:45 PM
RE: Leibniz formula for π on HP 35s - lipoff - 05-07-2020 09:47 AM



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