You are on page 1of 1

SIMPSONS 3/8TH RULE

Table of Contents
Input ................................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1
Output ............................................................................................................................... 1
Solver ............................................................................................................................... 1

Name: Shubham Chapparghare Roll no. : 351013

Input
SC_SIMP38(0,10,10,@(x)(1./(1+x.^2)))

PROGRAM & RESULT


function[]=SC_SIMP38(x0,xn,n,fun)

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

Published with MATLAB® R2017a

You might also like