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

Problem 1: Analysis of performance of the Richardson extrapolation Write a funct

ID: 3184882 • Letter: P

Question

Problem 1: Analysis of performance of the Richardson extrapolation Write a function implementing the Composite Trapezoidal Rule for calcu- lating the integral Jo vi lating the integral 09 change the number of ,, dx. Keep your programming so that you can T-r7 nodes easily. . Calculate approximations of the integral by the Composite Trapezoidal rule with 101, 201, 1001, and 2001 equally spaced nodes (this corresponds to the step sizes h = 0.0099, h/2, h/10, and h/20). Observe, that the error of approximation decreases in complete agreement with the formula in Theo rem 4.5 on page 200. In particular, that the error drops down 100 times for h/10 as expected.

Explanation / Answer

syms x
fun=input('Enter the function=');
f=inline(fun);
x0=input('Enter the lower limit=');
xn=input('Enter the upper limit=');
n=input('Enter the no. of intervals=');
h=(xn-x0)/n;
area=0;
while (x0<xn)
    area=area+(h/2)*(f(x0)+f(x0+h));
    x0=x0+h;
end
%fprintf('Area by Trapezoidal rule=%f',area);
disp('Area by Trapezoidal rule is');
disp(area);