Lecture 11 Iterative approaches for solving linear systems

  • Slides: 29
Download presentation
Lecture 11 Iterative approaches for solving linear systems Ø Jacobi method Ø Gauss-Seidel method

Lecture 11 Iterative approaches for solving linear systems Ø Jacobi method Ø Gauss-Seidel method Numerical method 1

Iterative approaches n n Guess a solution x(0); t=0; While not halting condition n

Iterative approaches n n Guess a solution x(0); t=0; While not halting condition n Use an updating rule to refine current solution n n x(t+1)=x(t)+ x(t) t=t+1 Numerical method 2

Flow chart Guess x(0) t=0 T Halting condition Use an updating rule to determine

Flow chart Guess x(0) t=0 T Halting condition Use an updating rule to determine x(t+1) t=t+1 Numerical method 3

Updating rule n x(t+1)=x(t)+ x(t) Newton method n Newton-Gauss method n Levenberg-Marquardt method n

Updating rule n x(t+1)=x(t)+ x(t) Newton method n Newton-Gauss method n Levenberg-Marquardt method n n x(t+1)=T*x(t+1)+c n Jacobi method Numerical method 4

Halting condition n n x(t) converges as t is increased to sufficient large values

Halting condition n n x(t) converges as t is increased to sufficient large values x(t+1) – x(t) is sufficiently small in absolute scale Numerical method 5

Jacobi method n An iterative approach for solving Ax=b Where A is nxn and

Jacobi method n An iterative approach for solving Ax=b Where A is nxn and b is nx 1. Both A and b are given Numerical method 6

Updating rule n Convert Ax=b to an equivalent system where T is nxn and

Updating rule n Convert Ax=b to an equivalent system where T is nxn and c is nx 1 Numerical method 7

Example Numerical method 8

Example Numerical method 8

Numerical method 9

Numerical method 9

Numerical method 10

Numerical method 10

Updating rule Numerical method 11

Updating rule Numerical method 11

A=[10 -1 2 0; -1 11 -1 3; 2 -1 10 -1; 0 3

A=[10 -1 2 0; -1 11 -1 3; 2 -1 10 -1; 0 3 -1 8]; b=[6 25 -11 15]'; D=diag(A)); T= inv(D)*(D-A); c=inv(D)*b; Numerical method 12

Numerical method 13

Numerical method 13

Spectral radius Numerical method 14

Spectral radius Numerical method 14

Example A=[1 0 2; 0 1 -1; -1 1 1]; [V, D]=eig(A); max(diag(abs(D))) ans

Example A=[1 0 2; 0 1 -1; -1 1 1]; [V, D]=eig(A); max(diag(abs(D))) ans = 2 Numerical method 15

Example vrho finds the spectral radius A=[1 0 2; 0 1 -1; -1 1

Example vrho finds the spectral radius A=[1 0 2; 0 1 -1; -1 1 1]; vrho(A) ans = 2 Numerical method 16

Sequence Numerical method 17

Sequence Numerical method 17

Convergence n The sequence converges to the unique solution of for any Numerical method

Convergence n The sequence converges to the unique solution of for any Numerical method 18

Convergence >> vrho(T) ans = 0. 4264 Numerical method 19

Convergence >> vrho(T) ans = 0. 4264 Numerical method 19

Jacobi method A, b it_jacob. m x A=[10 -1 2 0; -1 11 -1

Jacobi method A, b it_jacob. m x A=[10 -1 2 0; -1 11 -1 3; 2 -1 10 -1; 0 3 -1 8]; b=[6 25 -11 15]'; inv(A)*b Numerical method 20

Example >> it_jacob(A, b) It takes 24 iterations to converge ans = 1. 0000

Example >> it_jacob(A, b) It takes 24 iterations to converge ans = 1. 0000 2. 0000 -1. 0000 Numerical method 21

Derivation of Gauss-Seidel update Numerical method 22

Derivation of Gauss-Seidel update Numerical method 22

Matrix Decomposition D=diag(A); U=triu(A)-diag(D); L=A-triu(A); Numerical method 23

Matrix Decomposition D=diag(A); U=triu(A)-diag(D); L=A-triu(A); Numerical method 23

Gauss-Seidel method D=diag(A); U=triu(A)-diag(D); L=A-triu(A); T=-inv(diag(D)+L)*U; c=inv(diag(D)+L)*b; Numerical method 24

Gauss-Seidel method D=diag(A); U=triu(A)-diag(D); L=A-triu(A); T=-inv(diag(D)+L)*U; c=inv(diag(D)+L)*b; Numerical method 24

Gauss-Seidel method A, b it_gs. m x A=[10 -1 2 0; -1 11 -1

Gauss-Seidel method A, b it_gs. m x A=[10 -1 2 0; -1 11 -1 3; 2 -1 10 -1; 0 3 -1 8]; b=[6 25 -11 15]'; inv(A)*b Numerical method 25

Matlab codes demo_jacobi. m demo_GS. m Numerical method 26

Matlab codes demo_jacobi. m demo_GS. m Numerical method 26

Speed up convergence >> demo_jacobi i= 15 x= 1. 0000 2. 0000 -1. 0000

Speed up convergence >> demo_jacobi i= 15 x= 1. 0000 2. 0000 -1. 0000 >> demo_GS i= 7 x= 1. 0001 2. 0000 -1. 0000 Numerical method 27

Exercise n n Implement the Jacob method for solving linear systems Give two examples

Exercise n n Implement the Jacob method for solving linear systems Give two examples to verify your matlab codes Implement the Gauss Seidel method for solving linear systems Give two examples to verify your matlab codes Numerical method 28

speed. m cputime: inv 1. 312500 cputime: left division 0. 546875 cputime: pinv 21.

speed. m cputime: inv 1. 312500 cputime: left division 0. 546875 cputime: pinv 21. 640625 Numerical method 29