HP Forums
(71B) Integral Using Simpson’s Rule - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (71B) Integral Using Simpson’s Rule (/thread-6462.html)



(71B) Integral Using Simpson’s Rule - Eddie W. Shore - 06-27-2016 03:28 AM

Line 10 is where you have to define your function (of X).
Code:

Program SIMPSON  (200+ bytes)

10 DEF FNF(X)=insert function of X here
30 INPUT “LOWER:”;A
32 INPUT “UPPER:”;B
34 INPUT “# PART’NS (EVEN):”;N
36 RADIANS
38 T=FNF(A)+FNF(B)
40 H=(B-A)/N
50 FOR I=1 TO N-1
52 IF FP(I/2)=0 THEN 54 ELSE 56
54 T=2*FNF(A+I*H)+T @ GOTO 58
56 T=4*FNF(A+I*H)+T
58 NEXT I
60 T=T*H/3
62 DISP “INTEGRAL:”;T