Professional Documents
Culture Documents
Table of Contents
Input ................................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1
Output ............................................................................................................................... 1
Solver ............................................................................................................................... 1
Input
SC_SIMP38(0,10,10,@(x)(1./(1+x.^2)))
y0=feval(fun,x0);
h=(xn-x0)/n;
yn=feval(fun,xn);
temp1=0;
temp2=0;
for i=1:(n-1)
temp1=temp1+feval(fun,(x0+i*h));
end
for i=3:3:(n-3)
temp2=temp2+feval(fun,(x0+i*h));
end
I=3*h/8*(y0+yn+3*(temp1-temp2)+2*temp2);
fprintf('The value of the 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