|
振り子周期
PUBLIC NUMERIC TH
INPUT PROMPT "角度(度):":TH
LET TH=RAD(TH)
INPUT PROMPT "ひもの長さ(m):":L
LET G=9.80665
LET T=4*SQR(L/G)*INTEGRAL(0,PI/2,100)
PRINT "振り子周期:";T;"秒"
END
EXTERNAL FUNCTION FUNC(X)
LET FUNC=1/SQR(1-SIN(TH/2)^2*SIN(X)^2)
END FUNCTION
EXTERNAL FUNCTION INTEGRAL(A1,B1,N1) !'数値積分
DIM R(0 TO 2)
LET R(0)=1/3
LET R(1)=4/3
LET R(2)=1/3
LET H1=(B1-A1)/N1/2
FOR K1=0 TO N1-1
FOR J1=0 TO 2
LET S=S+R(J1)*H1*FUNC(A1+H1*(2*K1+J1))
NEXT J1
NEXT K1
LET INTEGRAL=S
END FUNCTION
|
|