Professional Documents
Culture Documents
Table of Contents
INPUT .............................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1
OUTPUT ........................................................................................................................... 1
SOLVER ........................................................................................................................... 1
INPUT
SC_TRAP(1,2,5,@(x)(x^2+5*x))
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)
OUTPUT
The value of the integration is:9.840000
SOLVER
• quad(@(x)(x.^2+5.*x),1,2,5)
• ans = 9.8333