HP Forums

Full Version: (71B) Integral Using Simpson’s Rule
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Reference URL's