数学定数

 投稿者:しばっち  投稿日:2014年 1月 3日(金)22時51分57秒
  http://keisan.casio.jp/keisan/lib/real/user/2006/1369644077/comment.html

http://en.wikipedia.org/wiki/Levy's_constant
http://ja.wikipedia.org/wiki/円周率

OPTION ARITHMETIC DECIMAL_HIGH
PRINT "ゲルフォント・シュナイダー定数"
PRINT LEXP(SQR(2)*LLOG(2)) !' ゲルフォント・シュナイダー定数
PRINT "レヴィの定数"
PRINT LEXP(PI*PI/12/LLOG(2)) !' レヴィの定数
PRINT "ゲルフォントの定数"
PRINT LEXP(PI) !' ゲルフォントの定数
PRINT "i^i"
PRINT LEXP(-PI/2) !' i^i=EXP(i*LOG(i))=EXP(i^2*PI/2)

FOR I=2000 TO 1 STEP -1
   LET S=(I^2+1)/(2*I+1+S)
NEXT I
PRINT 1-2/(2+S) !'i^i
PRINT "i^(-i)"
LET X=-1 !' i^(1/i)=i^(-i)
!'LET X=SQR(2) !' i^sqr(2)i
!'LET X=-PI !' i^(-π)i
!'LET X=1/PI !' i^(1/π)i
PRINT LEXP(-PI/2*X)

LET S=0
FOR N=1 TO 3300
   LET S=S+1/(2^N-1)
NEXT N
PRINT "エルデシュ・ボールウェイン定数"
PRINT S !' エルデシュ・ボールウェイン定数

LET C=0
LET A=1
FOR I=1 TO 2000
   LET C=C+A
   LET A=-A/(2*I-1)/(2*I)
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
PRINT "COS(1)=";C !'1の余弦

LET S=0
LET A=1
FOR I=1 TO 2000
   LET S=S+A
   LET A=-A/(2*I+1)/(2*I)
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
PRINT "SIN(1)=";S !'1の正弦

LET S=0
LET A=1
FOR I=1 TO 2000
   LET S=S+A
   LET A=A/(2*I-1)/(2*I)
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
PRINT "COS(i)=";S !'虚数iの余弦

LET S=0
LET A=1
FOR I=1 TO 2000
   LET S=S+A
   LET A=A/(2*I+1)/(2*I)
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
PRINT "SIN(i)=";S;"i" !'虚数iの正弦

LET A=2
LET XX=A
LET YY=A
DO
   LET X=XX
   LET Y=YY
   LET Z=(4-X)/3
   LET XX=X*Z*Z*Z
   LET YY=Y*Z*Z
LOOP UNTIL XX=X OR Y=YY
PRINT "2の立方根"
PRINT YY !'2の立方根

PRINT "LN(10)"
PRINT 478*ARCCOTANH(251)+180*ARCCOTANH(449)-126*ARCCOTANH(4801)+206*ARCCOTANH(8749) !'LOG(10)
PRINT 239*ARCCOTANH(99)-59*ARCCOTANH(449)+113*ARCCOTANH(4801)-33*ARCCOTANH(8749)    !'LOG(10)
PRINT "LN(2)"
PRINT 18*ARCCOTANH(26)-2*ARCCOTANH(4801)+8*ARCCOTANH(8749)                          !'LOG(2)
PRINT 144*ARCCOTANH(251)+54*ARCCOTANH(449)-38*ARCCOTANH(4801)+62*ARCCOTANH(8749)    !'LOG(2)
PRINT 72*ARCCOTANH(99)-18*ARCCOTANH(449)+34*ARCCOTANH(4801)-10*ARCCOTANH(8749)      !'LOG(2)
PRINT 6*ARCCOTANH(161)+10*ARCCOTANH(49)+14*ARCCOTANH(31)                            !'LOG(2)

PRINT "ネイピア数"
PRINT LEXP(1) !'ネイピア数
LET A=.5
LET N=11
FOR I=1 TO N
   LET A=A*A
NEXT I
LET S=1+A
FOR I=1 TO 2^N
   LET S=S*S
NEXT I
PRINT S

LET A=6-4*SQR(2)
LET Y=SQR(2)-1
FOR I=0 TO 4
   LET S=SQR(SQR((1-Y^4)))
   LET Y=(1-S)/(1+S)
   LET A=(1+Y)^4*A-(2^(2*I+3))*(1+Y+Y*Y)*Y
NEXT I
PRINT "円周率"
PRINT 1/A
PRINT PI
END

EXTERNAL FUNCTION LEXP(X)
OPTION ARITHMETIC DECIMAL_HIGH
FUNCTION S(Y,N)
   LET T=Y*X/N
   IF ABS(T)<=EPS(0) THEN
      LET S=Y+T
   ELSE
      LET S=Y+S(T,N+1)
   END IF
END FUNCTION
LET LEXP=S(1,1)
END FUNCTION

EXTERNAL FUNCTION LLOG(X)
OPTION ARITHMETIC DECIMAL_HIGH
IF X<=0 THEN
   CAUSE EXCEPTION 3004
ELSEIF X<1 THEN
   LET LLOG=-LLOG(1/X)
ELSEIF X>3 THEN
   LET LLOG=2*LLOG(SQR(X))
ELSE         ! 1<=X<=3
   LET H=(X-1)/(X+1)   ! 0<=H<=0.5
   LET T=0
   LET N=1
   LET K=H
   LET H2=H^2
   DO
      LET T=T+K/N
      LET N=N+2
      LET K=K*H2
   LOOP UNTIL K<=EPS(0)
   LET LLOG=2*T
END IF
END FUNCTION

EXTERNAL  FUNCTION ARCCOTANH(X)  !'LOG((X+1)/(X-1))/2
OPTION ARITHMETIC DECIMAL_HIGH
LET A=1/X
LET S=A
FOR N=1 TO 1000
   LET A=A/X/X
   IF ABS(A)<EPS(0) THEN EXIT FOR
   LET S=S+A/(2*N+1)
NEXT N
LET ARCCOTANH=S
END FUNCTION
 

数学定数

 投稿者:しばっち  投稿日:2014年 1月 3日(金)22時52分50秒
  http://ja.wikipedia.org/wiki/フィボナッチ数

OPTION ARITHMETIC DECIMAL_HIGH
DIM A(0 TO 200)
LET SQR2=SQR(2)
LET A(1)=1
LET A(2)=2
FOR N=3 TO 200
   LET A(N)=2*A(N-1)+A(N-2)
   PRINT A(N) !'ベル数
   !'PRINT INT(((1+SQR2)^N-(1-SQR2)^N)/2/SQR2+.5)
NEXT N
PRINT

MAT A=ZER
LET A(2)=1
FOR N=0 TO 197
   LET A(N+3)=A(N)+A(N+1)+A(N+2)
   PRINT A(N+3) !'トリボナッチ数
NEXT N
PRINT

MAT A=ZER
LET A(3)=1
FOR N=0 TO 196
   LET A(N+4)=A(N)+A(N+1)+A(N+2)+A(N+3)
   PRINT A(N+4) !'テトラナッチ数
NEXT N
END
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET A=1
LET B=1
LET S=2
FOR I=1 TO 5000
IF MAXNUM<A+B THEN EXIT FOR
   LET C=A+B
   LET S=S+1/C
   LET A=B
   LET B=C
NEXT I
PRINT S !'フィボナッチ数の逆数の総和
END
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET C=1
FOR K=0 TO 100
   PRINT K;":";C
   LET C=C*(4-6/(K+2))
NEXT K
PRINT

LET C=1
FOR N=1 TO 100
   PRINT N;":";C
   LET C=C*2*(2*N+1)/(N+2)
NEXT N
PRINT

LET S=1
FOR N=1 TO 100
   PRINT FACT(2*N)/FACT(N+1)/FACT(N)
   LET S=S*(2*N)*(2*N-1)/N/(N+1)
   PRINT N;":";S
   PRINT N;":";COMB(2*N,N)-COMB(2*N,N+1)
   PRINT
NEXT N
PRINT

DIM A(0 TO 100)
LET A(0)=1
FOR N=1 TO 100
   FOR K=0 TO N-1
      LET A(N)=A(N)+A(K)*A(N-K-1)
   NEXT K
   PRINT N;":";A(N)
NEXT N
END
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET XX=1
DO
   LET X=XX
   LET XX=X-F(X)/DF(X)
LOOP UNTIL ABS(X-XX)<EPS(0)
PRINT XX
END

EXTERNAL  FUNCTION F(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET F=X*X*X-X-1
END FUNCTION

EXTERNAL  FUNCTION DF(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET DF=3*X*X-1
END FUNCTION
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET T=1/5
LET XX=T
DO
   LET X=XX
   LET XX=X+(X-X*X*X*T)/2
LOOP UNTIL X=XX
LET XX=(1+X)/2
PRINT XX
PRINT 1+1/XX

PRINT 2*LCOS(PI/5)
PRINT 2*LSIN(3/10*PI)
PRINT 1+2*LSIN(PI/10)
PRINT 2*LSIN(PI/10)+1
PRINT 2*LCOS(2*PI/5)+1

LET S=1
FOR I=1 TO 2000
   LET S=1+1/S
NEXT I
PRINT S

LET S=1
FOR I=1 TO 2000
   LET S=1+SQR(S)
NEXT I
PRINT SQR(S)

LET S=13/8
LET A=1
FOR N=0 TO 2000
   IF N=0 THEN
      LET A=-A/2/64
   ELSE
      LET A=-A*(2*N+1)*2*N/(N+2)/N/16
   END IF
   LET S=S+A
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT N
PRINT S

!'SQR(5)=6460/2889*(1-1/8346321)^(-.5)
!'(1-X)^(-1/2)=1+1/2*X+(1*3)/(2*4)*X^2+(1*3*5)/(2*4*6)*X^3+...
LET S=1
LET A=1
LET X=8346321
FOR I=1 TO 1000
   LET A=A*(2*I-1)/(2*I)/X
   LET S=S+A
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
PRINT (1+6460/2889*S)/2
END

EXTERNAL FUNCTION LCOS(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET S=0
LET A=1
FOR I=1 TO 2000
   LET S=S+A
   LET A=-X*X*A/(2*I-1)/(2*I)
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
LET LCOS=S
END FUNCTION

EXTERNAL FUNCTION LSIN(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET S=0
LET A=X
FOR I=1 TO 2000
   LET S=S+A
   LET A=-X*X*A/(2*I+1)/(2*I)
   IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
LET LSIN=S
END FUNCTION
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
PUBLIC NUMERIC N
INPUT N
LET XX=3
DO
   LET X=XX
   LET XX=X-F(X)/DF(X)
LOOP UNTIL ABS(X-XX)<EPS(0)
PRINT XX
PRINT (N+SQR(N*N+4))/2
END

EXTERNAL  FUNCTION F(X)
LET F=X*X-N*X-1
END FUNCTION

EXTERNAL  FUNCTION DF(X)
LET DF=2*X-N
END FUNCTION
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
FOR I=1 TO 400
   LET A$=A$ & STR$(I)
   IF LEN(A$)>=1000 THEN EXIT FOR
NEXT I
LET X=VAL("." & A$)
PRINT X !'チャンパーノウン定数
FOR I=1 TO 100
   IF X=B THEN STOP
   LET X=1/(X-B)
   LET B=INT(X)
   PRINT B;","; !'連分数展開
NEXT I
END
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET A=1.3063778838630806904686144926026057129167845851567136443680537599664340537668 !'ミルズの定数
FOR N=1 TO 6
   PRINT INT(A^(3^N)+.5) !'素数
NEXT N
END
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET Ω=LAMBERTW(1)
PRINT "OMEGA=";Ω
!'PRINT "OMEGA=";LEXP(-Ω) !' Ωexp(Ω)=1  Ω=exp(-Ω)
END

EXTERNAL  FUNCTION LAMBERTW(Z) !'ランベルトのW関数
OPTION ARITHMETIC DECIMAL_HIGH
LET W0=0
DO
   LET W=W0
   LET W0=W-(W*LEXP(W)-Z)/(LEXP(W)*(W+1)-(W+2)*(W*LEXP(W)-Z)/(2*W+2))
LOOP UNTIL ABS(W-W0)<EPS(0)
LET LAMBERTW=W0
END FUNCTION

EXTERNAL FUNCTION LEXP(X)
OPTION ARITHMETIC DECIMAL_HIGH
FUNCTION S(Y,N)
   LET T=Y*X/N
   IF ABS(T)<=EPS(0) THEN
      LET S=Y+T
   ELSE
      LET S=Y+S(T,N+1)
   END IF
END FUNCTION
LET LEXP=S(1,1)
END FUNCTION
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET A=1
FOR K=0 TO 1000
   IF K>0 THEN
      LET A=A*K*K*K*K*K*K*K*K*K*K/(2*K)/(2*K)/(2*K)/(2*K)/(2*K)/(2*K+1)/(2*K+1)/(2*K+1)/(2*K+1)/(2*K+1)
   END IF
   LET S=S+(-1)^K*A*(205*K^2+250*K+77)
   IF S=SS THEN EXIT FOR
   LET SS=S
NEXT K
PRINT S/64 !'ゼータ関数ζ(3)
END
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
LET A=1
FOR K=1 TO 2000
   LET A=A*256*(2*K)*(2*K)*(2*K)*(2*K-1)*(2*K-1)*(2*K-1)*K*K/(4*K-3)/(4*K-3)/(4*K-2)/(4*K-2)/(4*K-1)/(4*K-1)/(4*K)/(4*K)
   LET S=S+(-1)^(K-1)*A*(40*K^2-24*K+3)/(2*K-1)/K/K/K
   IF S=SS THEN EXIT FOR
   LET SS=S
NEXT K
PRINT S/64
END
----------------------------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH
PRINT 4*ARCSINLEMN(1/2)+2*ARCSINLEMN(7/23)
PRINT 4*ARCSINLEMN(2/3)-2*ARCSINLEMN(7/137)
END

EXTERNAL  FUNCTION ARCSINLEMN(X) !'INTEGRAL(1/SQR(1-t^4))dt
OPTION ARITHMETIC DECIMAL_HIGH
LET A=X
LET S=X
DO
   LET I=I+1
   LET A=A*(2*I-1)/2/I*X^4
   LET S=S+A/(4*I+1)
LOOP UNTIL ABS(A)<EPS(0)
LET ARCSINLEMN=S
END FUNCTION
 

戻る