Trapezoidal Rule and Simpson's Rule - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Trapezoidal Rule and Simpson's Rule (/thread-6362.html) Trapezoidal Rule and Simpson's Rule - Eddie W. Shore - 06-06-2016 04:19 AM Trapezoidal Rule Link to blog entry: http://edspi31415.blogspot.com/2016/06/hp-prime-and-ti-84-plus-ce-trapezoidal.html Code: ```EXPORT TRAPRULE() BEGIN // EWS 2016-06-05 HAngle:=0; // Radians LOCAL f; INPUT({{f,[8]},A,B,N}, "Trapezoidal Rule", {"f(X)=","Low:","High:", "Intervals:"}); H:=(B-A)/N; X:=A; T:=EVAL(f); X:=B; T:=EVAL(f)+T; FOR I FROM 1 TO N-1 DO X:=A+I*H; T:=2*EVAL(f)+T; END; T:=T*H/2; RETURN T; END;``` Simpson's Rule Link to blog entry: http://edspi31415.blogspot.com/2016/06/hp-prime-and-ti-84-plus-ce-simpsons-rule.html Code: ```EXPORT SIMPRULE() BEGIN // EWS 2016-06-05 HAngle:=0; // Radians LOCAL f; INPUT({{f,[8]},A,B,N}, "Simpson Rule", {"f(X)=","Low:","High:", "Intervals (Even):"}); H:=(B-A)/N; X:=A; T:=EVAL(f); X:=B; T:=EVAL(f)+T; FOR I FROM 1 TO N-1 DO X:=A+I*H;  IF FP(I/2)==0 THEN T:=2*EVAL(f)+T; ELSE T:=4*EVAL(f)+T; END; END; T:=T*H/3; RETURN T; END;```