主题: 用变步长辛普森法计算定积分
SIN(X)/X
A下限1,
B上限2,
E精度0.000001
5 REM 用变步长辛普森法计算定积分
6 REM A下限,B上限,E精度,N区间个数10 READ A,B,E,N
14 LET Y1=0
15 DEF FNA(X)=SIN(X)/X
20 LET H=(B-A)/(2*N)
25 LET Y=0
30 FOR I=1 TO N
35 LET Y=Y+4*FNA(A+(2*I-1)*H)+2*FNA(A+(2*I-2)*H)
40 NEXT I
45 LET y=H/3*(Y+FNA(B)-FNA(A))
50 IF ABS(Y1-Y)<=E THEN GOTO 70
55 LET Y1=Y
60 LET N=N*2
65 GOTO 20
70 PRINT "I=";Y
72 DATA 1,2,0.000001,1
75 END