Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Matlab program that implements the version of the composite Simpson\'s r

ID: 3775553 • Letter: W

Question

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.

Explanation / Answer

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote