Post Reply 
Another wp34s program
07-25-2017, 01:53 PM (This post was last modified: 10-19-2017 03:47 PM by Gerson W. Barbosa.)
Post: #1
Another wp34s program
This is a somewhat belated Pi Approximation Day celebration, which took place last Saturday.

This is simple implementation of a 22-century old algorithm (lines 001 through 021), followed by a minor tweaking to improve accuracy. Perhaps a Free42 version would have been more appropriate here, but I chose wp34s for convenience.

0001 **LBL A
0002 STO 00
0003 STO 01
0004 # 003
0005 [sqrt]
0006 STO+ X
0007 FILL
0008 # 004
0009 RCL/ L
0010 /
0011 [times]
0012 [sqrt]
0013 DSE 00
0014 SKIP 001
0015 SKIP 006
0016 STO 02
0017 ||
0018 STO+ X
0019 FILL
0020 RCL 02
0021 BACK 010
0022 RCL+ X
0023 +
0024 # 004
0025 RCL[times] 01
0026 RCL+ L
0027 # [gamma]EM
0028 # 005
0029 [times]
0030 +/-
0031 e[^x]
0032 +
0033 +/-
0034 2[^x]
0035 INC X
0036 /
0037 # 003
0038 /
0039 END



Usage: n A, where n is the number of iterations.

You might want to set double mode on (DBLON).

-------------------
PS: The expression involving the EM constant is just an approximation of the pattern below:

   0   █..█                                                                                                                               
   1   ███.████                                                                                                                       
   2   █......███...                                                                                                             
   3   █....█....███.██.                                                                                                      
   4   █....█..██.█.███████.                                                                                              
   5   █....█..████████....█..██                                                                                      
   6   █....█.█....█...██..███.█████                                                                               
   7   █....█.█....█.██.█.......█...████                                                                      
   8   █....█.█....█.████.███..█..██.█.██.██                                                              
   9   █....█.█....██........███.█.█████..█████.                                                     
  10   █....█.█....██......██.█.███.█..██..████...█. 
  11   █....█.█....██......███████..██....██.█.█████..█.
  12   █....█.█....██.....█....█.....█..██.██.█████..█.█....
  13   █....█.█....██.....█....█.█.█..██.....█.█.██....██...█..█
  14   █....█.█....██.....█....█.██..██.█...██████......█.█.█..█.██.
  15   █....█.█....██.....█....█.██.█.██.███..█..█.██....███...█.██....█
  16   █....█.█....██.....█....█.██.██..█.█.█.█.███████..██...██.██......█.█
  17   █....█.█....██.....█....█.██.██..█████..█..█..█████.████████........██.█.
  18   █....█.█....██.....█....█.██.██.█....██..█.██..█...██████............█...█.██ 
  19   █....█.█....██.....█....█.██.██.█...█...██..█.█..██.█.██.██..█........█...█..██.​.                                      
  20   █....█.█....██.....█....█.██.██.█...█..█.██..██.█.█████..█.███.█.......██..█.███​██..█ 
  21   █....█.█....██.....█....█.██.██.█...█..██...██.███.█..██...██.██.█.....█.███.█..​..██..███
  22   █....█.█....██.....█....█.██.██.█...█..██..█.████..██....█..█.█.██.█...█.██.█.██​.█..██.██..██
  23   █....█.█....██.....█....█.██.██.█...█..██..██.█.....█..██..█.██.█.██.█.█.██.█..█​...█.█.........█.
  24   █....█.█....██.....█....█.██.██.█...█..██..██.█.█.█..█.████.█..██.█.███..██.█...​█....█.██..██.█..████
  25   █....█.█....██.....█....█.██.██.█...█..██..██.█.██..██..███████..██.██..█.█.█...​.██...█.........██..█..█.


12     1000010100001100000100001

12*4+4=52
    -5=47
    -2=45
    -5=40
    -1=39
    -6=33
    -5=28

                           (2*a + b)
        ----------------------------------------------
                               1
         1 + ---------------------------------------
             2^52 + 2^47 + 2^45 + 2^40 + 2^39 + 2^33 
Find all posts by this user
Quote this message in a reply
Post Reply 




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