The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Trapezoidal Rule and Simpson's Rule
06-06-2016, 04:19 AM
Post: #1
Trapezoidal Rule and Simpson's Rule
Trapezoidal Rule
Link to blog entry: http://edspi31415.blogspot.com/2016/06/h...oidal.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/h...-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;
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Trapezoidal Rule and Simpson's Rule - Eddie W. Shore - 06-06-2016 04:19 AM



User(s) browsing this thread: 1 Guest(s)