Question: Answer the following questions about this MATLAB program. You can assume that the norm computed by MATLAB is the 1-norm. (We are using the 1-norm
Answer the following questions about this MATLAB program. You can assume that the norm computed by MATLAB is the 1-norm. (We are using the 1-norm to simplify the problem, not because MATLAB actually uses the 1-norm.)
(a) What mathematical problem is solved by this program?
(b) What numerical method is implemented by this program?
(c) What are the criteria for stopping the while loop?
(d) When you run this program in MATLAB (assuming that norm is the 1 norm), what is the third line printed to the screen?
(e) When you run this program in MATLAB (assuming that norm is the 1-norm), what is the fourth line printed to the screen?
1 2 x1 = 0; 3 x2 = 0; 4 5 6 count = 0; 1285233 38 function problem2_77 19 7 fprintf('= 8 fprintf('k \t x1 \t x2 \t norm(R) ') 9 fprintf('%d\t 89.6f \t 89.6f \t %6.4e ', count, x1, x2, error) 10 while error > 10^(-4) 11 12 13 14 15 16 17 20 R = residual (x1, x2); error = norm (R); end count = count + 1; x1_old = x1; x1 = 2*(1-x2)/3; x2 = (x1_old+1); R = residual (x1, x2); error norm (R); ==STARTING CALCULATION== end fprintf('%d\t 89.6f \t 89.6f \t %6.4e ', count, x1, x2, error) if count> 20 fprintf('Did not converge. ') break; 24 function 25 out (1,1) = 3*x1+2+x2-2; out = residual (x1, x2) = ') 26 out (2, 1) = x1-x2+1;
Step by Step Solution
3.50 Rating (153 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
