You are on page 1of 1

TRAPEZOIDAL RULE

Table of Contents
INPUT .............................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1
OUTPUT ........................................................................................................................... 1
SOLVER ........................................................................................................................... 1

Name : Shubham Chapparghare Roll no. :351013

INPUT
SC_TRAP(1,2,5,@(x)(x^2+5*x))

PROGRAM & RESULT


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

y0=feval(fun,x0);
h=(xn-x0)/n;
yn=feval(fun,xn);
yr=0;
for i=1:(n-1)
yr=yr+feval(fun,(x0+i*h));
end
I=h/2*(y0+yn+2*yr);
fprintf('the value of the integration is:%f\n',I)

the value of the integration is:9.840000

OUTPUT
The value of the integration is:9.840000

SOLVER
• quad(@(x)(x.^2+5.*x),1,2,5)

• ans = 9.8333

Published with MATLAB® R2017a

You might also like