solution_hw8

# solution_hw8 - Solution attachment to homework 8 Problem...

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

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

View Full Document

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

View Full Document
Solution attachment to homework 8 Problem 1, (c) We write a script file to run Jacobi and Gauss_Seidel program with different lamda: % solution to homework #8, problem 1 (c) A=[17, -2, -3; -5, -21, -2; -5, -5, 22]; b=[500, 200, 30]'; xguess=[0 0 0]'; % ues Jacobi method [x,iter]=Jacobi(A,b,xguess); fprintf( 'Jacobi method, iteration #: %d \n' , iter); % use Gauss_Seidel lamda=1.0, 0.8 1.2 respectively lamda=1.0; [x,iter]=Gauss_Seidel(A,b,xguess,lamda); fprintf( 'Gauss_Seidel method, lamda = %f, iteration #: %d \n' ,lamda, iter); lamda=0.8; [x,iter]=Gauss_Seidel(A,b,xguess,lamda); fprintf( 'Gauss_Seidel method, lamda = %f, iteration #: %d \n' ,lamda, iter); lamda=1.2; [x,iter]=Gauss_Seidel(A,b,xguess,lamda); fprintf( 'Gauss_Seidel method, lamda = %f, iteration #: %d \n' ,lamda, iter); Running this file, we can get: Jacobi method, iteration #: 26 Gauss_Seidel method, lamda = 1.000000, iteration #: 13 Gauss_Seidel method, lamda = 0.800000, iteration #: 25 Gauss_Seidel method, lamda = 1.200000, iteration #: 26

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

solution_hw8 - Solution attachment to homework 8 Problem...

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

View Full Document
Ask a homework question - tutors are online