Write a Matlab program that implements the version of the co

Write a Matlab program that implements the version of the composite Simpson\'s rule pre- sented in class. Note that this version is designed to use as few function evaluations as possible and that it produces a conservative error estimate Ei along with the final approximation Si to I The inputs for your program should be: The integration limits a and b A Matlab function to compute f(ar) for any ar E a, bl; An error tolerance tol A safeguard imax to limit the iteration index j The output for your program should be: The final approximation Si to he corresponding conservative error estimate Ei The final iteration index j; The total number nf Count of function evaluations that your program has used.

Solution

Please find below the matlab code of the composite Simpson’s rule :


function integral = cmpsimp(a,b,n,f)
h = (b-a)/n;
Zi0 = feval(’f’,a)+feval(’f’,b);
Zi1 = 0;
Zi2 = 0;
for i = 1:n-1
x = a+i*h;
if mod(i,2) == 0
Zi2 = Zi2+feval(’f’,Z);
else
Zi1 = Zi1+feval(’f’,Z);
end
end
Zi = h*(Zi0+2*Zi2+4*Zi1)/3;
Zi

 Write a Matlab program that implements the version of the composite Simpson\'s rule pre- sented in class. Note that this version is designed to use as few func

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site