Post Reply 
Creating digits of pi
05-16-2018, 12:21 AM
Post: #52
RE: Creating digits of pi
(05-13-2018 08:26 PM)Gerson W. Barbosa Wrote:  Also, it can be implemented with only one division and one multiplication per term.

...

--------------------------

>LIST
10 DESTROY ALL
12 INPUT K @ IF K=0 THEN END
15 S=0 @ Z=2*MOD(K,2)-1 @ W=Z
20 A=K*(K*(216*K-324)+138)-15
25 N=K*K @ M=2*K-1
30 FOR I=1 TO K
35 S=S+Z/A @ Z=-Z
40 N=N-M @ M=M-2
45 E=648*N+30 @ A=A-E
50 NEXT I
55 DISP 48*S;48*(S-W/(K*K*(432*K+600)))
60 GOTO 12

With one division only, actually. The other slightly more complex series might require at least one division and one multiplication per term, though:

INPUT  PROMPT "Number of terms: ":k
LET s = 0
LET z = 2*MOD(k,2) - 1
LET a = k*(k*(216*k - 324) + 138) - 15
LET g = 648*k*k
LET h = 648*(2*k - 1)
FOR i = 1 TO k
   LET s = s + z/a
   LET z = -z
   LET g = g - h
   LET h = h - 1296
   LET e = g + 30
   LET a = a - e
NEXT i                 
PRINT
LET p = 48*s        !    s = 1/15 - 1/693 + 1/3315 - 1/9177 + 1/19575 -+ ... 
PRINT "pi ~ "; p    ! or s = 1/(1*3*5) - 1/(7*9*11) + 1/(13*15*17) -+ ...
END


Number of terms: 1130

pi ~  3.14159265351279 


=================


INPUT  PROMPT "Number of terms: ":k
LET s = 0
LET a = k*(k*(k*(4096*k + 8192) + 5504) + 1408) + 105
LET g = 64*k*k
LET h = 64*(2*k - 1)
LET j = 256*k
LET e = j*(64*k*k + 11)
FOR i = 1 TO k
   LET a = a - e
   LET s = s + 1/a
   LET g = g - h
   LET h = h - 128
   LET j = j - 256
   LET e = j*(g + 11)
NEXT i                 
PRINT
LET p = 192*s/(2 - SQR(2))  !    s = 1/105 + 1/19305 + 1/156009 + 1/606825 + 1/1666665 + ... 
PRINT "pi ~ "; p            ! or s = 1/(1*3*5*7) + 1/(9*11*13*15) + 1/(17*19*21*23) + ...
END


Number of terms: 702

pi ~  3.14159265351269
 
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Creating digits of pi - brickviking - 02-06-2018, 12:24 AM
RE: Creating digits of pi - Joe Horn - 02-06-2018, 01:38 AM
RE: Creating digits of pi - toml_12953 - 02-06-2018, 09:24 PM
RE: Creating digits of pi - brickviking - 02-06-2018, 10:38 PM
RE: Creating digits of pi - brickviking - 02-08-2018, 04:22 AM
RE: Creating digits of pi - toml_12953 - 02-08-2018, 01:02 PM
RE: Creating digits of pi - TASP - 02-07-2018, 10:30 PM
RE: Creating digits of pi - pier4r - 02-09-2018, 02:59 PM
RE: Creating digits of pi - emece67 - 02-10-2018, 09:14 PM
RE: Creating digits of pi - TASP - 02-11-2018, 12:12 AM
RE: Creating digits of pi - ttw - 02-12-2018, 03:59 AM
RE: Creating digits of pi - EdS2 - 02-17-2018, 12:27 PM
RE: Creating digits of pi - EdS2 - 02-21-2018, 11:01 AM
RE: Creating digits of pi - pier4r - 02-17-2018, 04:25 PM
RE: Creating digits of pi - brickviking - 02-17-2018, 09:27 PM
RE: Creating digits of pi - pier4r - 02-23-2018, 01:34 PM
RE: Creating digits of pi - SlideRule - 05-13-2018, 05:09 PM
RE: Creating digits of pi - Gerson W. Barbosa - 05-16-2018 12:21 AM



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