Post Reply 
Leibniz formula for π on HP 35s
05-06-2020, 05:59 PM (This post was last modified: 05-06-2020 06:08 PM by Gerson W. Barbosa.)
Post: #3
RE: Leibniz formula for π on HP 35s
(05-06-2020 02:45 PM)lipoff Wrote:  I got inspired by this vintage computer race to use the slow-converging alternating Leibnitz series method to approximate π.

It’s now known as Madhava-Leibniz Series, as in the video (1:09). Madhava himself would never compute π this way, even if he had a fast computer. Anyway, that’s an interesting experiment.
Madhava would compute just a few terms then he would apply his best correction term to get more digits. Those correction terms (he has provided three of them) can be directly obtained from a continued fraction that was probably known to him. See Madhava of Sangamagrama – The value of π.

Here is an HP-75C program that computes π using the series and the continued fraction. (Commented listing here).

The program asks for the number of digits, but at this early stage an input of 9 will give the familiar 12-digit value:

1 INPUT D
2 N=IP(D/3)+1
3 A=2*N
4 B=8*N
5 C=4*N*N
6 D=4*N-1
7 S1=0
8 S2=0
9 FOR I=1 TO N
10 S1=S1-1/D+1/(D-2)
11 S2=(C-D)/(A+C/(B+S2))
12 C=C-2*(D-1)
13 D=D-4
14 NEXT I
15 S2=1/(B+S2)
16 DISP 4*(S1+S2)

RUN
?9 RTN
-> 3.14159265359 (4 iterations, 0.304 seconds)


As a side note, checking the catalog I noticed two unintentional coincidences:

CAT
-> PI B 314 12:56 06\05\20


314 bytes (~100π), file created at 12:56 hour (~4π) :-)
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 - Gerson W. Barbosa - 05-06-2020 05:59 PM



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