"Calculation of the Constant e" from Popular Computing Weekly 25-31 Aug 83

avoid work duplication! collaborate on the archival of acorn literature!
Post Reply
iamaran
Posts: 586
Joined: Tue Mar 14, 2006 8:08 pm
Contact:

"Calculation of the Constant e" from Popular Computing Weekly 25-31 Aug 83

Post by iamaran »

Popular Computing Weekly, 25-31 August 1983 pp. 22-23
Attachments
Calculation of the Constant e.zip
(4.93 MiB) Downloaded 25 times
E1.jpg
E2.jpg
Last edited by iamaran on Tue Feb 15, 2022 12:27 pm, edited 2 times in total.
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: "Calculation of the Constant e" Popular Computing Weekly

Post by BigEd »

Many thanks!
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: "Calculation of the Constant e" from Popular Computing Weekly 25-31 Aug 83

Post by BigEd »

Uploaded now to the Internet Archive, as agreed. See here. The OCR on this is, not surprisingly, quite patchy. There's a PDF with text layer, and a text-only view.
User avatar
scruss
Posts: 653
Joined: Sun Jul 01, 2018 4:12 pm
Location: Toronto
Contact:

Re: "Calculation of the Constant e" from Popular Computing Weekly 25-31 Aug 83

Post by scruss »

To save you any OCR grief:

Code: Select all

10REM-------------------------------
20
30REM  CALCULATION OF THE CONSTANT e
50
60
70REM   (c) BORIS ALLAN, 1983
90
100REM-------------------------------
110 @%=1 : REM SETS FORMAT
120 INPUT N% : N%=N%+4
130 DIM TERM%(N%), E%(N%)
140 TERM%(0)=1 : E%(0)=1
150 M%=1
160
170 REPEAT SUM%=0 : REM BUILDS UP TERMS
180 FOR I%=0 TO N%
190 IF TERM%(I%)<>0 THEN PROC_DIVISION
200 NEXT I%
210 M%=M%+1
220 UNTIL SUM%=0 : REM ALL TERMS ARE ZERO
230
240 FOR I%=N% TO 1 STEP -1 : REM ISOLATES ENTRIES
250 IF I%=N%-4 THEN E%(I%)=E%(I%)+E%(I%+1) DIV 5 : REM ROUNDING
260 FOR J%=3 TO 1 STEP -1
270 IF I%>J% THEN PROC_SPLITTING
280 NEXT J% : NEXT I%
290
300 N%=N%-4 : REM READY TO PRINT OUT RESULT
305 VDU 2
310 PRINT E%(0);".";
320 FOR I%=1 TO N% : PRINT E%(I%); : NEXT I% : PRINT
325 VDU 3
330 END : REM END OF MAIN PROGRAM
340
350 DEF PROC_DIVISION : REM DIVIDING BY M%
360 IT%=TERM%(I%) DIV M%
370 IF I%<>N% THEN PROC_TERMS
380 ENDPROC : REM _DIVISION
390
400 DEF PROC_TERMS : REM ADDING TERMS
410 TERM%(I%+1) = TERM%(I%+1) + 10*(TERM%(I%)-M%*IT%)
420 TERM%(I%) = IT%
430 E%(I%) = E%(I%)+IT%
440 SUM%=SUM%+IT%
450 ENDPROC : REM _TERMS
460
470 DEF PROC_SPLITTING : REM DISTRIBUTING TERMS
480 SUM%=1 : FOR K%=1 TO J% : SUM% = SUM%*10 : NEXT K%
490 IT%=E%(I%) DIV SUM%
500 E%(I%-J%)=E%(I%-J%) + IT%
510 E%(I%)=E%(I%) - SUM%*IT%
520 ENDPROC : REM _SPLITTING
Notes:
  1. Sends output to the printer: delete lines 305 and 325 if you don't want that
  2. The SUM% variable clashes with the SUM reserved word in later BBC BASIC dialects
  3. It's not very fast. I hate to think how long the 1000 digit example given would have taken to run.

Code: Select all

?1000
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274274663919320030599218174135966290435729003342952605956307381323286279434907632338298807531952510190115738341879307021540891499348841675092447614606680822648001684774118537423454424371075390777449920695517027618386062613313845830007520449338265602976067371132007093287091274437470472306969772093101416928368190255151086574637721112523897844250569536967707854499699679468644549059879316368892300987931277361782154249992295763514822082698951936680331825288693984964651058209392398294887933203625094431173012381970684161403970198376793206832823764648042953118023287825098194558153017567173613320698112509961818815930416903515988885193458072738667385894228792284998920868058257492796104841984443634632449684875602336248270419786232090021609902353043699418491463140934317381436405462531520961836908887070167683964243781405927145635490613031072085103837505101157477041718986106873969655212671546889570350354
User avatar
scruss
Posts: 653
Joined: Sun Jul 01, 2018 4:12 pm
Location: Toronto
Contact:

Re: "Calculation of the Constant e" from Popular Computing Weekly 25-31 Aug 83

Post by scruss »

BigEd wrote: Tue Feb 15, 2022 12:20 pm Uploaded now to the Internet Archive, as agreed.
Seems to take 3840 seconds for 1000 digits on a stock BBC B, if b2 is realistic about time.

Output from n=500:

Code: Select all

RUN
?500
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349076323382988075319525101901157383418793070215408914993488416750924476146066808226480016847741185374234544243710753907774499206955170276183860626133138458300075204493382656029760673711320070932870912744374704723069697720931014169283681902551510865746377211125238978442505695369677078544996996794686445490598793163688923009879313
TIME: 1100.05s
>
I will try it on my somewhat enhanced Beeb here soon ...
User avatar
BigEd
Posts: 6261
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: "Calculation of the Constant e" from Popular Computing Weekly 25-31 Aug 83

Post by BigEd »

Nice work, thanks! I'm all in favour of this sort of thing. And feel I must mention Steve Wozniak's calculation of e on the Apple II.
The Impossible Dream: Computing e to 116,000 Places with a Personal Computer (BYTE, June 1981)
Post Reply

Return to “scanning of books, magazines, ads and letters”