Question: Answer the following questions about this code: (a) What mathematical problem is being solved? (b) What numerical method is used to solve the problem? (c)
Answer the following questions about this code:
(a) What mathematical problem is being solved?
(b) What numerical method is used to solve the problem?
(c) What is the significance of the value of n on line 3?
(d) What numerical method is implemented by the function getI?
(e) Explain why there are two factors of 1/2 in line 16.
(f) There are six different estimates of the answer computed in this code. Which one is the least accurate?
1 function problem8_6 2 3 4 5 6 7 8 9 10 11 12 clc n = 3; a = 0; b = 1; j = getI (a, b, n) ; k = getI (a, b, 2*n); m = get I (a, b, 4*n); j)/3; O = (4*k = (4*m k)/3; I = - (16*p o)/15; fprintf('%14.12f ', I) - 13 function out = get I (a, b, n) 14 15 16 17 18 19 h = (b-a)/n; I = 0; I = I + feval (a)/2 + feval (b)/2; for j = 1:n-1 I = I + feval (a + j*h); end out = I*h; 20 21 22 function out = feval (x) 23 out = sin (pi*x^2) *exp(-x);
Step by Step Solution
3.37 Rating (156 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
