|
http://keisan.casio.jp/exec/system/1360718708
!'/1
!'| f(x)dx
!'/-1
LET N=8
LET H=1/N/7
DIM X(N),W(N)
LET I=1
LET X(1)=-1
LET X(N)=1
LET W(1)=2/N/(N-1)
LET W(N)=W(1)
PRINT " 零点 重み"
FOR XX=-1+H TO 1-H STEP H
LET LO=XX
LET HI=XX+H
IF LEGENDREDIFF(N-1,LO)*LEGENDREDIFF(N-1,HI)<0 THEN
DO
LET M=(LO+HI)/2
IF LEGENDREDIFF(N-1,LO)*LEGENDREDIFF(N-1,M)<0 THEN LET HI=M ELSE LET LO=M
LOOP UNTIL ABS(LO-HI)<1E-13
LET I=I+1
LET X(I)=LO
LET W(I)=WEIGHT(N,X(I))
PRINT I;":";X(I);W(I)
END IF
NEXT XX
LET A=1
INPUT PROMPT "LOG(X) X=":B
LET U=(B+A)/2
LET V=(B-A)/2
FOR I=1 TO N
LET S=S+W(I)*F(U+V*X(I))*V
NEXT I
PRINT S
PRINT LOG(B)
END
EXTERNAL FUNCTION F(X)
LET F=1/X
END FUNCTION
EXTERNAL FUNCTION LEGENDRE(K,X)
LET OLDP=1
LET P=X
FOR N=1 TO K-1
LET NEWP=((2*N+1)*X*P-N*OLDP)/(N+1)
LET OLDP=P
LET P=NEWP
NEXT N
LET LEGENDRE=P
END FUNCTION
EXTERNAL FUNCTION LEGENDREDIFF(N,X)
LET LEGENDREDIFF=(N*X*LEGENDRE(N,X)-N*LEGENDRE(N-1,X))/(X*X-1)
END FUNCTION
EXTERNAL FUNCTION WEIGHT(N,X)
LET WEIGHT=2/N/(N-1)/LEGENDRE(N-1,X)^2
END FUNCTION
|
|