Simpsons 1/3Th Rule: Input Program & Result
Simpsons 1/3Th Rule: Input Program & Result
Table of Contents
INPUT .............................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1
Output ............................................................................................................................... 1
Solver ............................................................................................................................... 1
INPUT
SC_SIMP13(0,10,10,@(x)(1./(1+x.^2)))
y0=feval(fun,x0);
h=(xn-x0)/n;
yn=feval(fun,xn);
yeven=0;
yodd=0;
for i=1:2:(n-1)
yodd=yodd+feval(fun,(x0+i*h));
end
for i=2:2:(n-2)
yeven=yeven+feval(fun,(x0+i*h));
end
I=h/3*(y0+yn+(4*yodd)+(2*yeven));
fprintf('The value of given integration is %f\n',I);
Output
The value of given integration is 1.431666
Solver
• quad(@(x)(1./(1+x.^2)),0,10,10)
• ans = 1.4657