hw6_part2_solutions - Problem 3 MATLAB Command Window...

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

View Full Document Right Arrow Icon
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)])
Background image of page 1

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

View Full DocumentRight Arrow Icon
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;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/20/2010 for the course ASE 311 taught by Professor Kraczek during the Spring '08 term at University of Texas at Austin.

Page1 / 3

hw6_part2_solutions - Problem 3 MATLAB Command Window...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online