Computing 208 Decimal Digits Of e

Description

by Valentin Albillo (PDF)

Quote: "This 64-step program will compute from 8 to 208 decimal places of Euler’s constant, the well-known transcendental number e = 2.71828. It is by no means optimized for performance but tries instead to be as short and straightforward as possible. Although you can compute more decimal places in an HP-15C, for the purposes of this article this simpler program will do nicely."

Usage instructions
  1. After keying in the program, make sure you’re not in complex mode (press g CF 8 if in doubt), then you must commit enough storage registers to the common pool for the matrix operations. To that effect, press: 2 f DIM (i)
  2. Now, enter the number of 8-digit blocks you want to use, from 1 (8 digits) to 26 (208 digits). For example, if you want to compute 200 decimal digits of e, you must specify 200/8 = 25 blocks. Start the program by pressing either

    R/S or GSB A or (in User mode) A

    While running, it will briefly show each succesive divisor used (2, 3, ...), then once the computation is over, it will display each block of 8 decimal digits (with an initial “0.”, in order to preserve leading zeros at the left end of the block), starting with decimals 1st-8th. The very last block will be marked negative, to signal the end of the output.
    Let’s see an example: to compute the first 24 decimal digits of e, we specify 24/8 = 3 blocks, and proceed like this (in USER mode):

    3 A →  (2.00000000) [divisor = 2]
                 …       [after 2’26”]
         → (25.00000000) [divisor = 25]
         →   0.71828182  [decimals 1st- 8th]
     R/S →   0.84590452  [decimals 9th-16th]
     R/S →  -0.35360274  [decimals 17th-24th]
    

    so, after adding a “2.” at the front and writing down all 8-digit blocks (that is, minus the initial “0.” or “-0.”) in their proper order, we finally get:

    e = 2.71828182 84590452 35360274


    where, due to the accumulation of rounding errors during the process, the last block of the computed answer comes out as “3536 0274” while correct is “3536 0287”, so we have an error of 13 ulps (units in the last place).
  3. Should you need to display the output again, press: GSB 4

Program Resources

Labels

Name Description
 A Program Start
 0 # - internal use -
 1 # - internal use -
 2 # - internal use -
 3 # - internal use -
 4 # - internal use -
 5 # - internal use -

Storage Registers

Name Description
 0 Row index for matrix elements
 2 Column index for matrix elements
I Current divisor (2, 3, ...)

Program

Line Display Key Sequence Line Display Key Sequence Line Display Key Sequence
000 022 42,21, 3 f LBL 3 044 22 5 GTO 5
001 42,21,11 f LBL A 023 45 11 RCL A 045 42 44 f FRAC
002 42,16, 0 f MATRIX 0 024 43 20 g x=0 046 16 CHS
003 42,16, 1 f MATRIX 1 025 42, 6, 2 f ISG 2 047 43 32 g RTN
004 1 1 026 42,21, 0 f LBL 0 048 42,21, 5 f LBL 5
005 42,23,11 f DIM A 027 45 11 RCL A 049 42 44 f FRAC
006 42,23,12 f DIM B 028 45,10,25 RCL ÷ I 050 45 12 RCL B
007 42,26,12 f RESULT B 029 43 44 g INT 051 43 44 g INT
008 44 2 STO 2 030 u 44 11 USER STO A 052 45 36 RCL RAN #
009 44 25 STO I 031 22 2 GTO 2 053 20 ×
010 26 EEX 032 45 25 RCL I 054 40 +
011 8 8 033 42 31 f PSE 055 31 R/S
012 44 11 STO A 034 45,16,11 RCL MATRIX A 056 22 4 GTO 4
013 15 1/x 035 42,16, 7 f MATRIX 7 057 42,21, 2 f LBL 2
014 44 36 STO RAN # 036 43,30, 0 g TEST x≠0 058 45,20,25 RCL × I
015 42,21, 1 f LBL 1 037 22 1 GTO 1 059 30
016 45,16,11 RCL MATRIX A 038 45,16,12 RCL MATRIX B 060 45 36 RCL RAN #
017 45,16,12 RCL MATRIX B 039 45 36 RCL RAN # 061 10 ÷
018 40 + 040 20 × 062 44,40,11 STO + A
019 45 2 RCL 2 041 42, 7, 8 f FIX 8 063 45 11 RCL A
020 44 0 STO 0 042 42,21, 4 f LBL 4 064 22 0 GTO 0
021 42, 6,25 f ISG I 043 u 45 12 USER RCL B