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. 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 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 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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)