Question: On the problem below, I've done parts A, i, iv, and v. However, I don't know how to use my Simpson_7 function to do parts

On the problem below, I've done parts A, i, iv, and v. However, I don't know how to use my Simpson_7 function to do parts iii & vi. The highlighted parts of the first image is what I'm stuck on.

On the problem below, I've done parts A, i, iv, and v.However, I don't know how to use my Simpson_7 function to doparts iii & vi. The highlighted parts of the first image is

(a) Create a table with the Method, Value, and MTPRE (magnitude of the true percent relative error) for each of the methods below. Include 4 digits to the right of the decimal point in all numbers. Create an anonymous function to calculate the MTPRE (Do NOT put a semicolon at the end). The table should look like the one below. Note that the in the last three lines of the table is a dash (not a minus sign). Method MIPRE Value --------- 88.3458 Exact Trap Single Simpsons 1/3 Simpsons 3/8 Trap Composite S13 - 513 - 538 538 - 513 - 513 S13 - S38 - S13 xxxx.xxxx XXXX.XXXX XXXX. XXXX XXXX.XXXX XXXX.XXXX xxx.xxxx XXX.XXXX XXX.XXXX xxx.xxxx XXX.XXXX xxx, xxxx xxx.xxxx 1. Using an anonymous function defined to be the indefinite integral. For example, for f(x) = x2, the function is g(x) = 6)x. Then the exact or true value of the integral can be computed as Igue = g(b)- g(a) where a and b are the limits of integration. Do not include a semicolon at the end of the definition of the anonymous function. Do not use the Matlab int function or any similar function ii. A single application of the trapezoidal rule iii. A composite application of the trapezoid rule with n=7 Page 2 of 3 iv. A single application of the Simpson's 1/3 rule v. A single application of the Simpson's 3/8 method, and vi. Three approximations using the composite simpson7 function you created. % MAE 284-01 Numerical Methods % Homework 3 % Connor Wells % 02/24/2020 % Create a function to use Newton Cotes formulas function [tr,y13, y38] = Simpson_7(f, a,b) % Trapezoidal Rule n = 7; h = (b-a)/(2); t = a:h:b; sum = 0; for k = 2: length(t)-1 area = area+2*feval(f,t(k)); end tr - h/2*(feval(f, a)+feval(f,b)+sum); % Simpson's 1/3 Rule n = 7; h = (b-a); area = 0; m = a:h:b; for i = 2: length(m) - 1 if mod(i-1,2) == 1 area = area+4*feval(f, a+(i-1)*h); else if mod(i-1,2)==0 area = area+2*feval(f,a+(i-1)*h); end end end y13 = h/3* (area+feval(f,a)+feval(f,b)); % Simpson's 3/8 Rule n = 7; h = (b-a); t = a:h:b; area = 0; for n = 2: length(t)-1 if mod(n-1,3)==0 area-area+3*f(t(n)); else area-area+2*f(t(n)); end end y38 = 3*h/8*(area+f(t(1))+F(t(end))); end % Part-A: f. () 0.075* (x.^5)+(0.6*x.^4)+(0.2*x.^2)+0.5; a = -5; b = 5; I_ex = integral(f,a,b); [tr 513 538] = Simpson_7(f,a,b) % Relative Error ero = abs(I_ex-I_ex)/I_ex*100; eri = abs(I_ex-tr)/I_ex*100; er2 = abs(I_ex-513)/I_ex*100; er3 - abs (I_ex-538)/I_ex*100; Value fprintf("Method fprintf('---- fprintf('Exact fprintf('Trapezoidal fprintf('Simpson 1/3 fprintf('Simpson 3/8 %1.4f %1.4f %1.4f %1.4f MPTRE '); ------- '); %1.4f ',I_ex, ero); #1.4f ',tryer1); %1.4f ',s13, er2); %1.4f ',s38, er 3); (a) Create a table with the Method, Value, and MTPRE (magnitude of the true percent relative error) for each of the methods below. Include 4 digits to the right of the decimal point in all numbers. Create an anonymous function to calculate the MTPRE (Do NOT put a semicolon at the end). The table should look like the one below. Note that the in the last three lines of the table is a dash (not a minus sign). Method MIPRE Value --------- 88.3458 Exact Trap Single Simpsons 1/3 Simpsons 3/8 Trap Composite S13 - 513 - 538 538 - 513 - 513 S13 - S38 - S13 xxxx.xxxx XXXX.XXXX XXXX. XXXX XXXX.XXXX XXXX.XXXX xxx.xxxx XXX.XXXX XXX.XXXX xxx.xxxx XXX.XXXX xxx, xxxx xxx.xxxx 1. Using an anonymous function defined to be the indefinite integral. For example, for f(x) = x2, the function is g(x) = 6)x. Then the exact or true value of the integral can be computed as Igue = g(b)- g(a) where a and b are the limits of integration. Do not include a semicolon at the end of the definition of the anonymous function. Do not use the Matlab int function or any similar function ii. A single application of the trapezoidal rule iii. A composite application of the trapezoid rule with n=7 Page 2 of 3 iv. A single application of the Simpson's 1/3 rule v. A single application of the Simpson's 3/8 method, and vi. Three approximations using the composite simpson7 function you created. % MAE 284-01 Numerical Methods % Homework 3 % Connor Wells % 02/24/2020 % Create a function to use Newton Cotes formulas function [tr,y13, y38] = Simpson_7(f, a,b) % Trapezoidal Rule n = 7; h = (b-a)/(2); t = a:h:b; sum = 0; for k = 2: length(t)-1 area = area+2*feval(f,t(k)); end tr - h/2*(feval(f, a)+feval(f,b)+sum); % Simpson's 1/3 Rule n = 7; h = (b-a); area = 0; m = a:h:b; for i = 2: length(m) - 1 if mod(i-1,2) == 1 area = area+4*feval(f, a+(i-1)*h); else if mod(i-1,2)==0 area = area+2*feval(f,a+(i-1)*h); end end end y13 = h/3* (area+feval(f,a)+feval(f,b)); % Simpson's 3/8 Rule n = 7; h = (b-a); t = a:h:b; area = 0; for n = 2: length(t)-1 if mod(n-1,3)==0 area-area+3*f(t(n)); else area-area+2*f(t(n)); end end y38 = 3*h/8*(area+f(t(1))+F(t(end))); end % Part-A: f. () 0.075* (x.^5)+(0.6*x.^4)+(0.2*x.^2)+0.5; a = -5; b = 5; I_ex = integral(f,a,b); [tr 513 538] = Simpson_7(f,a,b) % Relative Error ero = abs(I_ex-I_ex)/I_ex*100; eri = abs(I_ex-tr)/I_ex*100; er2 = abs(I_ex-513)/I_ex*100; er3 - abs (I_ex-538)/I_ex*100; Value fprintf("Method fprintf('---- fprintf('Exact fprintf('Trapezoidal fprintf('Simpson 1/3 fprintf('Simpson 3/8 %1.4f %1.4f %1.4f %1.4f MPTRE '); ------- '); %1.4f ',I_ex, ero); #1.4f ',tryer1); %1.4f ',s13, er2); %1.4f ',s38, er 3)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Question You are answering ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!