|
ウォリス積から円周率の探究をしてきました。
!PiEuler.BAS 「十進BASICによる円周率」
! 十進1000桁モード
!OPTION ARITHMETIC DECIMAL_HIGH
! 繰り返し回数
OPTION ARITHMETIC RATIONAL !有理数モード
LET iter = 100 !3500
! 初期値
LET a = 2
LET s = a
!PRINT USING "####":0;
PRINT STR$(s)&"/1"
! 繰り返し
FOR i = 1 TO iter
LET a = a * i / (2 * i + 1)
PRINT a
!PRINT "DATA";NUMER(a) !xの分子(numerator)
!PRINT "DATA";DENOM(a) !xの分母(denominator)
LET s = s + a
!PRINT USING "####":i;
! PRINT s
NEXT i
PRINT s
!PRINT PI
END
-------------------------------------------------
OPTION ARITHMETIC RATIONAL
!OPTION ARITHMETIC DECIMAL_HIGH
!sum [a(n)/b(m)]=PI
LET k=500 !225(1000桁モード)
DIM a(0 TO k-1) !分子
DATA 1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,&
&0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,&
&0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,&
&0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,1,0,1,&
&1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,&
&1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,&
&1,1,0,1,1,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,&
&0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,&
&1,0,0,1,1,0,1,1,0,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0,0,&
&1,1,0,1,1,0,0,1,1,0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,3,2,3,3,4,2,3,3,4,3,4,&
&4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,&
&4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,&
&4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,&
&4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,2,3,3,4,3,4,&
&4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,&
&4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,3,4,&
&4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,&
&4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,5,6,6,7
LET m=0
FOR n=0 TO k-8
IF a(n)=1 THEN
LET nn=n
LET cc=cc+1
LET a1=2^(nn+1)
LET b1=FACT(2*m+1)/(FACT(m)^2*2^b(m))
! PRINT a1/b1
LET s=s+a1/b1
LET m=m+1
LET b2=FACT(2*(m)+1)/(FACT(m)^2*2^b(m))
! PRINT a1/b2
LET s=s+a1/b2
LET m=m+1
END if
NEXT n
!PRINT s
!PRINT pi
PRINT cc;"loop"
PRINT USING"####." & REPEAT$("#",999):s
PRINT USING"####." & REPEAT$("#",999):LPI(1)
END
EXTERNAL FUNCTION LPI(x) !PiRamanujan.BAS
OPTION ARITHMETIC RATIONAL
! 繰り返し回数
LET iter = 130 !127
! 初期値
LET a = 1103 * SQRT(8) / 9801
LET s = a
!PRINT USING "###":0;
LET ss=1 / s
!PRINT USING"####." & REPEAT$("#",999):ss
! 繰り返し
FOR i = 1 TO iter
LET a = a * (4 * i - 1) * (4 * i - 2) * (4 * i - 3) * (26390 * i + 1103)
LET a = a / 6147814464 / i^3 / (26390 * i - 25287)
LET s = s + a
!PRINT USING "###":i;
LET ss=1 / s
!PRINT USING"####." & REPEAT$("#",999):ss
NEXT i
LET LPI=ss
END FUNCTION
EXTERNAL FUNCTION SQRT(n)
OPTION ARITHMETIC RATIONAL
LET x=n !SQR(x)
LET z=0.5
LET a=(1+x)*z
LET b=x/a
DO
LET c=(a+b)*z
LET d=x/c
LET a=c
LET b=d
LET aa=ROUND(a,1000)
LET bb=ROUND(b,1000)
LOOP UNTIL aa=bb
LET SQRT=b
END FUNCTION
----------------------------------
☆---分子----------------------------------------
2^A101925(n).
A005187(n) + 1.
A005187---http://oeis.org/A005187
A079559
MOD(A108918,2)=A079559
A108918
☆---分母----------------------------------------
A001803--http://oeis.org/A001803
A000120
----------------------------------------
これ以上は、私の能力では無理でした。
http://blogs.yahoo.co.jp/donald_stinger
|
|