3. Theory
Simpson’s 3/8 (Simpson’s second) rule corresponds
to using third-order polynomials to fit four points.
Integration over the four points simplifies to
4. Error in Trapezoidal
Rule
Local Error
Global Error
Global Error O(h4)is sum total of all n/3 local error and
is of an order less than Local error O(h5)
5. Script File
a=input('Enter lower limit: ');
b=input('Enter upper limit: ');
n=input('Enter total no of subintervals: ');
if rem(n,3)
error('subintervals should be of third multiple')
end
h=(b-a)/n
for i=0:n
X(i+1)=a+1*h;
end
X
Y=exp(X)
ans=Y(1)+Y(n+1);
for j=2:3:n-1
ans=ans+(3*Y(j));
end
for k=3:3:n
ans=ans+(3+Y(k));
end
for l=4:3:n
ans=ans+(2*Y(l));
end
I=(3*h/8)*ans
syms x
f=exp(x)
true=int(f,a,b)
true
e=abs(I-true);
fprintf('Error is %f',e)
7. Conclusion
• As in Simpson’s 1/3 and 3/8 rule, the even segment-odd-point formulas
have truncation errors that are the same order as formulas adding one more
point. For this reason, the even-segment odd-point formulas are usually the
methods of preference
• the error term is of same order but smaller than Simpson’s 1/3 rule and thus
provides more accurate result. It converges to estimated integral value more
quickly.
• 3/8ths rule is used for uniformly sampled function integration. Suppose we
have a function at equally spaced points. If the number of points is odd,
then the composite Simpson's rule works fine. If the number of points is
even, then one solution is to use the 3/8ths rule. For example, if the user
passed 6 samples, then we use Simpson's for the first three points, and
3/8ths for the last 4 (the middle point is common to both). This preserves
the order of accuracy without putting an arbitrary constraint on the number
8. Comparison of three
methods
F(x) Y=Exp(x)
h, a, b 30, -1, 5
Trapezoidal Rule I= 148.47 err=0.1173
Simpson 1/3 I=140.7802 err= 7.2650
Simpson 3/8 I=175.6348 err=28.5894
True value=148.045279661
I=Integrated Value by the Rule
9. Caveats
• The number of subintervals should be a multiple of 3
• When calculated manually, this formula is more complicated