The error for the Trapezoidal rule is given by E_T = -1/12 f\"(c) (b - a)^3, whe
ID: 3576761 • Letter: T
Question
The error for the Trapezoidal rule is given by E_T = -1/12 f"(c) (b - a)^3, where c [a, b]. Estimate the errors for both (aa) and (bb) and compare them with the actual errors. Implement the composite trapezoidal rule by writing a function of the form ctrap(f, a, b, n), where the input n is the number of subintervals. Use clrap(f, a, b, n) with n= 10, 20, 40, 80, 160 to estimate both integrals (aa) and (bb). The error for the composite trapezoidal rule is given by E_CT = -1/12, f"(c) (b - a) h^2, where r. c [a, b] and h = (b - a)/n. Estimate the errors for n= 10, 20, 40, 80, 160 for both (aa) and (bb) and compare them with the actual errors. Implement Simpson's rule by writing a function of the form simp (f, a, b) and use it to compute both integrals (aa) and (bb). The error for the Simpson's rule is given by E_S = -1/2880, f(4) (c) (b - a)^5, where c. [a, b]. Estimate the errors for both (aa) and (bb) and compare them with the actual errors. Implement the composite Simpson's rule by writing a function of the form csimp(f, a, b, n), where the input p n is the number of subintervals. Use csimp (f, a, b, n) with n= 10, 20, 40, 80, 160 to estimate both integrals (aa) and (bb). The error for the composite Simpson s rule is given by E_CS = - 1/180 f(4) (c) (b - a) h^4, where c [a, b] and h = (b, a)/n. Estimate the errors for n= 10, 20, 40, 80, 160 for both (aa) and (bb) and compare them with the actual errors. Make a table with all the estimated and actual errors obtained above for comparison. Consider the Gaussian 3-point quadrature rule integral_-1^1 f(x) dx G_3 (f) = 5/9 f(- Squareroot 3/5) + 8/9 f(0) + 5/9 f (Squareroot 3/5) Use the change of interval formula to apply this rule to I = integral_2^7 Squareroot 2 + 5t dt.Explanation / Answer
3)
function res = ctrap(f,a,b,n)
h = (b - a)/n; %getting first interval
res = 0;
for z=1:(n-1), %iteratiing values
xx = a + h*z;
res = res + feval(f,xx); %evaluating value at every iteration
end
res = h*(feval(f,a)+feval(f,b))/2 + h*res; %finally returning the calculated result.
---------------------------------------------------------------------------------------------------------------------------------
5)
function res = simp(f,a,b,m)
h = (b-a)/m; %getting first interval
x = linspace(a,b,m);
y4=0;
y2=0;
for p=2:2:b %iteratiing values
y4 = y4 + f(y4);
end
for q=3:2:b %iteratiing values
y2= y2 + f(y2);
end
res = (h/3)*(f(a)+ f(b) + 4*(y4)+ 2*(y2)); %finally returning the calculated result.
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.