Calcolo integrale the old way

Fonte

5 REM RICHIEDE UN COMMODORE 16 O PLUS 4
10 DEF FN F(X) = 3*X + 5*X*X - SIN(X)
20 PRINT "INTEGRAZIONE CON METODO DI SIMPSON"
30 PRINT "ESTREMO A"
40 INPUT A
50 PRINT "ESTREMO B"
60 INPUT B
70 PRINT "SUDDIVISIONI"
80 INPUT N%
90 PRINT "ATTENDERE PREGO..."
100 N% = N% * 2
110 H = (B-A) / N%
120 I% = 1
130 S = FNF(A)
140 DO WHILE I% < N%
150 X = A + H * I%
160 S = S + 4 * FNF(X)
170 I% = I% + 2
180 LOOP
190 I% = 2 : N1% = N% - 1
200 DO WHILE I% < N1%
210 X = A + H * I%
220 S = S + 2 * FNF(X)
230 I% = I% + 2
240 LOOP
250 S = S + FNF(B)
260 F = H * S / 3
270 PRINT "INTEGRALE DA ";A;" A ";B;" = ";F

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment