home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Antennas
/
Antennas_CD-ROM_Walnut_Creek_September_1996.iso
/
mathaids
/
misc
/
simpsoni.asc
< prev
Wrap
Text File
|
1996-06-30
|
1KB
|
53 lines
1 N$="INTEG1"
2 REM**********************************
3 REM** SIMPSON'S RULE OF ***
4 REM** NUMERICAL INTEGRATION (C) ***
5 REM** K.VANSLETTE - JUNE 1984 ***
6 REM** 32 PGMS FOR C-64, P259 ***
7 REM**********************************
8 S$=" *** "
9 PRINT "";TAB(16-LEN(N$)/2);S$;N$;S$
10 GOTO 90:REM**************************
20 REM
30 REM ENTER EQUATION AT LINE 50
40 REM
50 Y=4/(1+X^2):REM PI
60 REM
70 REM
80 RETURN:REM**************************
90 PRINT " THIS PROGRAM WILL INTEGRATE EQUATIONS USING SIMPSON'S RULE."
100 PRINT " ENTER THE EQUATION AT LINE 50 AS":PRINT" Y = F(X) - - - Y/N"
110 INPUT " ";X$
120 IF X$="Y" THEN LIST 30-50
130 PRINT "======================================="
140 INPUT "ENTER LOWER LIMIT OF X ----";LX
150 INPUT "ENTER UPPER LIMIT OF X ----";UX
160 PRINT "======================================="
170 PRINT " HIT ANY KEY TO HALT..."
180 N=2: PRINT
190 PRINT "=SEGMENTS= =INTEGRAL="
200 GET R$:IF R$=""THEN 200
210 DX=(UX-LX)/N:T=0
220 X=LX:GOSUB50:T=T+Y
230 X=UX:GOSUB50:T=T+Y
240 M=N/2:Z=0
250 FOR J=1 TO M
260 X=LX+DX*(2*J-1)
270 GOSUB 50:Z=Z+Y:NEXT J
275 GOSUB 50:K0=D
280 T=T+4*Z:M=M-1:IF M=0 THEN 320
290 Z=0:FOR J=1 TO M
300 X=LX+DX*2*J
310 GOSUB 50:Z=Z+Y:NEXT J:T=T+2*Z
320 A=DX*T/3
330 PRINT " ";N," ";A
340 N=N*2:GOTO 210
400 END
1000 GET R$
1010 IF R$="" THEN RETURN
1020 GET R$
1030 IF R$="" THEN 1020
1040 RETURN
1050 END