hw6_part2_solutions

# hw6_part2_solutions - Problem 3 MATLAB Command Window EDU>...

This preview shows pages 1–3. Sign up to view the full content.

Problem 3 MATLAB Command Window EDU>> HW6_Prob3 The result using the Jacobi method: x = 1.4999 1.9999 1.4999 Number of iteration = 29 MATLAB m-file HW6_Prob3.m clear all; A = [2 -1 0; -1 2 -1; 0 -1 2]; b = [1; 1; 1]; % initial guess xo = [0; 0; 0]; % Jacobi method x = xo; iteN = 0; while norm(A*x-b,2) >= 10^(-4) x_new(1,1) = (b(1)-A(1,2)*x(2)-A(1,3)*x(3))/A(1,1); x_new(2,1) = (b(2)-A(2,1)*x(1)-A(2,3)*x(3))/A(2,2); x_new(3,1) = (b(3)-A(3,1)*x(1)-A(3,2)*x(2))/A(3,3); x = x_new; iteN = iteN + 1; end % results disp(' '); disp(' '); disp('The result using the Jacobi method: '); disp(' '); disp(' x = ') disp(x); disp([' Number of iteration = ', num2str(iteN)])

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
MATLAB Command Window EDU>> HW6_Prob4 The result using the fixed point iteration: x = 1.6005 1.5616 Number of iteration = 9 MATLAB m-file HW6_Prob4.m % initial guess x1 = 1; x2 = 1; f1 = x1^2 + x2^2 - 5; f2 = x1^2 - x2 - 1; f = [f1; f2]; % Fixed-Point iteration iteN = 0;
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

hw6_part2_solutions - Problem 3 MATLAB Command Window EDU>...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online