solution_hw8 - Solution attachment to homework 8 Problem...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3

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

View Full Document Right Arrow Icon
Background image of page 4
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
Background image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
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 Right Arrow Icon
Ask a homework question - tutors are online