1 / 30

Lecture 2

Lecture 2 . Linear System of Equations. In matrix–vector notation . 1- Iterative Methods start with an initial guess of the solution vector X (0) , and then repeatedly refine the solution until a certain convergence criterion is reached.

naiya
Download Presentation

Lecture 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 2

  2. Linear System of Equations • In matrix–vector notation

  3. 1- Iterative Methods • start with an initial guess of the solution vector X(0), and then repeatedly refine the solution until a certain convergence criterion is reached. • Advantages : have significant computational advantages if the coefficient matrix is very large and sparsely populated (most coefficients are zero). • Disadvantages:less efficient than their direct counterparts due to the large number of iterations required.

  4. Jacobi Method The Jacobi method is an algorithm for determining the solutions of a system of linear equations with largest absolute values in each row and column dominated by the diagonal element.

  5. Definition: The square nonsingular matrix A is called diagonally dominant if the sum of the absolute values of its elements on the main diagonal is greater than or equal to the sum of the absolute values of the remaining elements of the analyzed row of the matrix, i.e., Example: Checking if the coefficient matrix is diagonally dominant

  6. Steps of Jacobi Method: • Rearrange system to be diagonally dominant. • Start with an initial vector • We determine the unknowns x1, x2, and x3 from the first, second, and third equation, respectively:

  7. Perform series of consecutive iterations (k) as in step 3 until the solution converges to an exact solution, i.e., In general:

  8. Example: Solve by Jacobi method: Start with solution guess , and start iterating on the solution

  9. keep on going until the desired level of accuracy is achieved

  10. Iterative convergence • Is the (k+1)th solution better than the kthsolution? • Iterative process can be convergent/divergent A sufficient condition to ensure convergence is that the matrix is diagonally dominant • A poor first guess will prolong the iterative process but will not make it diverge if the matrix is such that convergence is assured. • Therefore better guesses will speed up the iterative process

  11. Criteria for ascertaining convergence • Absolute convergence criteria • Where εa user specified tolerance or accuracy • The absolute convergence criteria is best used if you have a good idea of the magnitude of the xi‘s Relative convergence criteria • This criteria is best used if the magnitude of the ‘s are not known. • There are also problems with this criteria if

  12. Solution: Rearrange the system to be diagonally dominant as the following:

  13. Determine the unknowns x1, x2, and x3 from the first, second, and third equation, respectively:

  14. Continuing this procedure, you obtain the sequence of approximations shown in the following table

  15. Because the last two rows in the table are identical, we can conclude that to three significant digits the solution is

  16. Gauss-Siedel Method • The Gauss–Seidel method is similar to the Jacobi method except that the computation of xi(k) uses only the elements of X(k) that have already been computed, and only the elements of X(k-1) that have yet to be advanced to iteration (k).

  17. Example 4 Solve previous Example using the Gauss–Seidel method you obtain the following new value for x1 Start with Now that you have a new value for x1 , however, use it to compute a new value for x2 That is,

  18. So the first approximation is Continued iterations produce the sequence of approximations shown in the following table. Note that after only six iterations of the Gauss-Seidel method, you achieved the same accuracy as was obtained with eight iterations of the Jacobi method.

  19. Vectors, Functions, and Plots in Matlab

  20. Enter a matrix into Matlab with the following syntax: • > A = [ 1 3 -2 5 ; -1 -1 5 4 ; 0 1 -9 0] • Alsoenter a vector u: • > u = [ 1 2 3 4]’ • To multiply a matrix times a vector Au use *: • A*u • Now enter another matrix B using: • > B = [3 2 1; 7 6 5; 4 3 2] • You can multiply a matrix by a scalar: • > 2*A • Adding matrices A + A will give the same result: • > A + A • You can even add a number to a matrix: • > A + 3 . . . . . .. . . . . . . . .. . . . . . . .% This should add 3 to every entry of A.

  21. Special matrices: • N = ones(5,5) • O=zeros(2,2) • I=eye(3) • D=diag(A) • Inv(A)

  22. Jacobi method in matrix form If we write D, L, and U for the diagonal, strict lower triangular and strict upper triangular and parts of A, respectively, then Jacobi’s Method can be written in matrix-vector notation as

  23. Programing of Jacobi method function x=Jacobi(A,b,n,x0) L=tril(A,-1) U=triu(A,1) d=diag(A) B=-(U+L); g=b; fori=1:n x=(B*x0+g)./d x0=x; end

  24. Assignment 1 1- Solve the system a- Using \ operator in Matlab. b- Using Jacobi method. Start with x(0) = (0, 0), complete a table like the one below,

  25. 2-a) Express the Gauss-Siedel method in matrix form, (upper, lower, and diagonal). 2-b) Write a computer program that applies the Gauss-Siedel method, then solve the previous system of linear equations.

  26. Summary • Iterative methods: • 1- Jacobi method • 2- Gauss-Siedel method • Iterative convergence • diagonally dominant • Matlab programming • Assignment1

  27. End of Chapter 3

More Related