6. LU Factorization Kim Hong Soo Kim Jin Soo

Slides:



Advertisements
Similar presentations
Method If an nxn matrix A has an LU-factorization, then the solution of AX = b can be determined by a Forward substitution followed by a Back substitution.
Advertisements

4/22/ LU Decomposition Electrical Engineering Majors Authors: Autar Kaw Transforming.
Linear Systems LU Factorization CSE 541 Roger Crawfis.
1 Linear Triangular System L – lower triangular matrix, nonsingular Lx=b L: nxn nonsingular lower triangular b: known vector b(1) = b(1)/L(1,1) For i=2:n.
MATH 685/ CSI 700/ OR 682 Lecture Notes
Scientific Computing Linear Systems – Gaussian Elimination.
Linear Systems of Equations
Chapter 8 Numerical Technique 大葉大學 資訊工程系 黃鈴玲 Linear Algebra.
1.5 Elementary Matrices and a Method for Finding
LU Factorization LU-factorization Matrix factorization Forward substitution Back substitution.
Major: All Engineering Majors Authors: Autar Kaw
SOLVING SYSTEMS OF LINEAR EQUATIONS. Overview A matrix consists of a rectangular array of elements represented by a single symbol (example: [A]). An individual.
Lecture 9: Introduction to Matrix Inversion Gaussian Elimination Sections 2.4, 2.5, 2.6 Sections 2.2.3, 2.3.
Chapter 9.1 = LU Decomposition MATH 264 Linear Algebra.
Solution of linear system of equations
Lecture 11 - LU Decomposition
Part 3 Chapter 10 LU Factorization PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill Companies,
Chapter 10 LU Decomposition.
ECIV 520 Structural Analysis II Review of Matrix Algebra.
Thomas algorithm to solve tridiagonal matrices
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 18 LU Decomposition and Matrix Inversion.
1 Systems of Linear Equations Gauss-Jordan Elimination and LU Decomposition.
LU Decomposition 1. Introduction Another way of solving a system of equations is by using a factorization technique for matrices called LU decomposition.
Engineering Analysis ENG 3420 Fall 2009
Scientific Computing Linear Systems – LU Factorization.
Copyright © 2011 Pearson, Inc. 7.3 Multivariate Linear Systems and Row Operations.
Linear Systems Gaussian Elimination CSE 541 Roger Crawfis.
Chap. 2 Matrices 2.1 Operations with Matrices
Using LU Decomposition to Optimize the modconcen.m Routine Matt Tornowske April 1, 2002.
Numerical Computation Lecture 7: Finding Inverses: Gauss-Jordan United International College.
Yasser F. O. Mohammad Assiut University Egypt. Previously in NM Introduction to NM Solving single equation System of Linear Equations Vectors and Matrices.
MA/CS 375 Fall MA/CS 375 Fall 2003 Lecture 19.
Lecture 8 Matrix Inverse and LU Decomposition
Chapter 5 MATRIX ALGEBRA: DETEMINANT, REVERSE, EIGENVALUES.
Lesson 3 CSPP58001.
ECE 530 – Analysis Techniques for Large-Scale Electrical Systems Prof. Hao Zhu Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
1/18/ LU Decomposition Industrial Engineering Majors Authors: Autar Kaw Transforming.
Linear Systems Dinesh A.
Part 3 Chapter 9 Gauss Elimination PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill Companies,
3/1/ LU Decomposition Computer Engineering Majors Authors: Autar Kaw Transforming.
Unit #1 Linear Systems Fall Dr. Jehad Al Dallal.
Autar Kaw Benjamin Rigsby Transforming Numerical Methods Education for STEM Undergraduates.
2 - 1 Chapter 2A Matrices 2A.1 Definition, and Operations of Matrices: 1 Sums and Scalar Products; 2 Matrix Multiplication 2A.2 Properties of Matrix Operations;
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
Numerical Methods.  LU Decomposition is another method to solve a set of simultaneous linear equations  For most non-singular matrix [A] that one could.
Lecture 9 Numerical Analysis. Solution of Linear System of Equations Chapter 3.
Numerical Computation Lecture 6: Linear Systems – part II United International College.
1 Numerical Methods Solution of Systems of Linear Equations.
LU Decomposition ● In Gauss elimination; Forward elimination Backward substitution Major computational effort Low computational effort can be used for.
Chapter 8 Numerical Technique
Spring Dr. Jehad Al Dallal
Choi, Jong-In Lee, Ho-Keun Shim, Yoon-Sik
Linear Equations.
Linear Algebra Lecture 15.
Chapter 10: Solving Linear Systems of Equations
Major: All Engineering Majors Authors: Autar Kaw
RECORD. RECORD Gaussian Elimination: derived system back-substitution.
Chemical Engineering Majors Authors: Autar Kaw
Numerical Analysis Lecture14.
Numerical Computation and Optimization
Part 3 Chapter 10 LU Factorization
Numerical Analysis Lecture10.
Linear Systems Numerical Methods.
Major: All Engineering Majors Authors: Autar Kaw
LU Decomposition.
Lecture 8 Matrix Inverse and LU Decomposition
Linear Systems of Equations: solution and applications
Ax = b Methods for Solution of the System of Equations:
Ax = b Methods for Solution of the System of Equations (ReCap):
Major: All Engineering Majors Authors: Autar Kaw
Presentation transcript:

6. LU Factorization 2005010211 Kim Hong Soo 2003010478 Kim Jin Soo 2003010481 Choi Jang Won 분산시스템 연구실

Contents LU Factorization from Gaussian Elimination LU Factorization of Tridiagonal Matrices LU Factorization with Pivoting Direct LU Factorization Application of LU Factorization Matlab’s Method 분산시스템 연구실

Example. Circuit Analysis Application Solve by LU Factorization of coefficient matrix Flow around the left loop 20 ( i - i ) + 10 ( i - i ) = 1 2 1 3 Flow around upper loop 25 i + 10 ( i - i ) + 20 ( i - i ) = 2 2 3 2 1 Flow around lower loop 30 i + 10 ( i - i ) + 10 ( i - i ) = 200 3 3 2 3 1 분산시스템 연구실

6.1 LU Factorization from Gaussian Elimination 분산시스템 연구실

LU Factorization from Gaussian Elimination - Example 6.1 Example 6.1 Three-By-Three System , , Step 1: , , Step 2: , , Multiply L by U, and Verify the result: . LU = = = A 분산시스템 연구실

LU Factorization from Gaussian Elimination - Example 6.2 Example 6.2 Four-By-Four System Step 1: Row 1 is unchanged, and rows 2-4 are modified to give 분산시스템 연구실

LU Factorization from Gaussian Elimination - Example 6.2 Example 6.2 Four-By-Four System Step 2: Row 1 and 2 are unchanged, row 3 and 4 are transformed, yielding Step 3: The fourth row is modified to complete the forward elimination stage: 분산시스템 연구실

LU Factorization from Gaussian Elimination - Example 6.2 Example 6.2 Four-By-Four System Multiply L by U to verify the result: . = L . U = A 분산시스템 연구실

LU Factorization from Gaussian Elimination - MATLAB Function for LU Factorization Using Gaussian Elimination function [L, U] = LU_Factor(A) % LU factorization of matrix A % using Gaussian elimination without pivoting % Input : A  n-by-n matrix % Output L ( lower triangular ) and % U (upper triangular ) [n, m] = size(A); L = eye(n); % initialize matrices U = A; for j = 1 : n for I = j + 1 : n L( i , j ) = U( i, j ) / U( j, j ); U( i , : ) = U( i, j ) / L( j, j ) * U( j, : ); end % display L and U L U % verify results B = L * U A 분산시스템 연구실

LU Factorization from Gaussian Elimination - MATLAB Function for LU Factorization >> LU_factor(A); L = 1.0000 0 0 0 0.2500 1.0000 0 0 0 0 1.0000 0 0 0 0 1.0000 0.5000 0 1.0000 0 0.7500 0 0 1.0000 0.5000 0.7500 1.0000 0 0.7500 0.5000 0 1.0000 L = 1.0000 0 0 0 0.2500 1.0000 0 0 0.5000 0.7500 1.0000 0 0.7500 0.5000 0.2500 1.0000 U = 4 12 8 4 0 4 16 8 0 0 4 12 0 0 0 4 B = 1 7 18 9 2 9 20 20 3 11 15 14 A = 분산시스템 연구실

LU Factorization from Gaussian Elimination - Example 6.3 Example 6.3 LU Factorization for Circuit Analysis Example Step 1: The matrices after the first stage of Gaussian elimination are , Step 2: The matrices after the second stage of Gaussian elimination are , 분산시스템 연구실

LU Factorization from Gaussian Elimination - Discussion . = Here, d12 = ca11+a21, d22=ca12+a22, and d32 = ca13+a32. We write this as CA = D We also need the inverse of the matrix C . = , or C-1 . C = I . 분산시스템 연구실

LU Factorization from Gaussian Elimination - Discussion . = M1-1 . M1 = I . . = M2-1 . M2 = I . . = M1-1 . M2-1 = I . 분산시스템 연구실

6.2 LU Factorization of Tridiagonal Matrix 분산시스템 연구실

LU Factorization of Tridiagonal Matrix LU Factorization of a tridiagonal matrix T less computation less computer memory 6.2.1 Matlab function for LU Factorization of a Tridiagonal Matrix 분산시스템 연구실

LU Factorization of Tridiagonal Matrix function [dd, bb] = LU_tridiag(a, d, b) % LU factorization of a tridiagonal matrix T % Input % a vector of elements above main diagonal, a(n) = 0 % d diagonal of matrix T % b vector of elements below main diagonal, b(1) = 0 % The factorization of T consists of % Lower bidiagonal matrix, % 1’s on main diagonal; lower diagonal is bb % Upper bidiagonal matrix, % main diagonal is dd; upper diagonal is a N = length(d) bb(1) = 0; dd(1) = d(1); for i = 2 : n bb(i) = b(i) / dd(i-1); dd(i) = d(i) – bb(i) * a(i-1); end 분산시스템 연구실

LU Factorization of Tridiagonal Matrix Example 6.4 Example 6.4 LU Factorization of Tridigonal System four-by-four tridigonal matrix Consider again the four-by-four tridigonal matrix from Example 3.7, , , , 분산시스템 연구실

LU Factorization of Tridiagonal Matrix Example 6.4 For i = 2, dd1 = d1 = 2, a1 = -1 bb2 = b2/dd1 = -1/2 dd2 = d2 – bb2a1 = 2-(-1/2)(-1) = 3/2 For i = 3, a2 = -1 bb3 = b3/dd2 = -1/(3/2) = -2/3 dd3 = d3 - bb3a2 = 2-(-2/3)(-1) = 4/3 분산시스템 연구실

LU Factorization of Tridiagonal Matrix Example 6.4 For i = 4, a3 = -1 bb4 = b4/dd2 = -1/(4/3) = -3/4 dd4 = d4 - bb4a3 = 2-(-3/4)(-1) = 5/4 분산시스템 연구실

6.3 LU Factorization with pivoting 분산시스템 연구실

6.3.1 Why pivoting? 분산시스템 연구실

6.3.2 Theory for pivoting 1/2 한 쪽에 A행렬, 다른 한쪽에 I행렬을 놓는다. (A: LU 분해 할 NxN행렬, I: NxN 단위행렬) A행렬을 가우스 소거법을 이용해 상삼각 행렬로 변환하면서 A행렬에 가하는 행렬 연산을 기록한다. (Nx: 소거, Px: 교환) 분산시스템 연구실

6.3.2 Theory for pivoting 2/2 Nx 행렬을 좌측으로 빼면서 N’x로 변환한다. 좌측 N’x들의 역행렬을 I행렬에 곱한다. 분산시스템 연구실

6.3.3 pivoting example 1/2 분산시스템 연구실

6.3.3 pivoting example 2/2 분산시스템 연구실

6.3.4 pivoting procedure 분산시스템 연구실

6.3.5 pivoting code Function [L, U, P] = LU_pivot(A) [n, n1] = size(A); L=eye(n); P=eye(n); U=A; For j = 1:n [pivot m] = max(abs(U(j:n, j))); m = m+j-1; if m ~= j % interchange rows m and j in U % interchange rows m and j in P if j >= 2 % interchange rows m and j in columns 1:j-1 of L end for i = j+1:n L(i, j) = U(i, j) / U(j, j); U(i, :) = U(i, :) – L(i, j)*U(j, :); 분산시스템 연구실

6.4 Direct LU Factorization 분산시스템 연구실

6.4.1 Theory for Direct LU factorization 분산시스템 연구실

6.4.2 Type of Direct LU factorization 변수의 수= N(N+1)/2 + N(N+1)/2 = N^2+N Doolittle 방식 L의 대각 원소가 1 Crout 방식 U의 대각 원소가 1 Cholesky 방식 L과 U의 같은 위치 대각 원소끼리 같음 분산시스템 연구실

6.4.3 Doolittle example 분산시스템 연구실

6.4.4 Doolittle code Function [L, U] = Doolittle(A) [n, m] = size(A); U = zeros(n, m); L = eye(n); for k = 1:n U(k, k) = A(k, k) – L(k, 1:k-1)*U(1:k-1, k); for j = k+1:n U(k, j) = A(k, j) – L(k, 1:k-1)*U(1:k-1, j); L(j,k)= (A(j,k)– L(j, 1:k-1)*U(1:k-1, k))/U(k,k); end 분산시스템 연구실

6.4.5 Cholesky example 분산시스템 연구실

6.4.6 Cholesky code Function [L, U] = Cholesky(A) % A is assumed to be symmetric. % L is computed, and U = L’ [n, m] = size(A); L = zeros(n, n); for k = 1:n L(k, k) = sqrt( A(k,k) – L(k, 1:k-1)*L(k, 1:k-1)’ ); for i = k+1:n L(i, k) = (A(i,k) – L(i, 1:k-1)*L(k, 1:k-1)’)/L(k, k); end 분산시스템 연구실

6.5 Applications of LU Factorization 분산시스템 연구실

Contents 6.5 Applications of LU Factorization 6.6 MATLAB’s Methods Linear Equations Tridiagonal System Determinant of a Matrix Inverse of a Matrix 6.6 MATLAB’s Methods lu, chol, det, inv 분산시스템 연구실

6.5.1 Solving Systems of Linear Equations Ax = b → LUx = b → Ly = b A = LU, Ux = y Solve the system Ly = b for y Forward substitution y1 → y2 → …… yn Solve the system Ux = y for x Backward substitution xn → xn-1 → …… x1 If pivoting has been used Ax=b → PAx=Pb, where PA=LU, Pb=c 분산시스템 연구실

Ex 6.8 Solving Electrical Circuit for Several Voltages 분산시스템 연구실

Ex 6.8 Solving Electrical Circuit for Several Voltages 분산시스템 연구실

MATLAB Function to Solve the Linear System LUx=b function x = LU_Solve(L, U, b) % Function to solve the equation L U x = b % L --> Lower triangular matrix (with 1's on diagonal) % U --> Upper triangular matrix % b --> Right-hand side vector [n m] = size(L); z = zeros(n,1); x = zeros(n,1); % Solve L z = b using forward substitution z(1) = b(1); for i = 2:n z(i) = b(i) - L(i, 1:i-1) * z(1:i-1); end % Solve U x = z using back substitution x(n) = z(n) / U(n, n); for i = n-1 : -1 : 1 x(i) = (z(i) - U(i,i+1:n) * x(i+1:n)) / U(i, i); 분산시스템 연구실

6.5.2 Solving a Tridiagonal System Ex 6.9 분산시스템 연구실

MATLAB Function for Solving a Tridiagonal System function x = LU_tridiag_solve(a, d, b, r) % Function to solve the eqquation A x = r % LU factorization of A is expressed as % Lower bidiagonal matrix: % diagonal is 1s, lower diagonal is b; b(1) = 0. % Upper bidiagonal matrix: diagonal is d, upper diagonal is a % Right-hand-side vector is r % Solve L z = r using forward substitution n = length(d); z(1) = r(1); for i = 2:n z(i) = r(i) - b(i) * z(i-1); end % Solve U x = z using back substitution x(n) = z(n) / d(n); for i = n-1 : -1 : 1 x(i) = (z(i) - a(i) * x(i+1)) / d(i); 분산시스템 연구실

6.5.3 Determinant of a Matrix Ex 6.10 분산시스템 연구실

The inverse of an n-by-n matrix A Axi=ei (i=1, … ,n) 6.5.4 Inverse of a Matrix The inverse of an n-by-n matrix A Axi=ei (i=1, … ,n) ei=[0 0 … 1 … 0 0]’, where the 1 appears in the ith position X whose columns are the solution vectors x1, … , xn is A-1 분산시스템 연구실

Ex 6.11 Finding a Matrix Inverse Using LU Factorization 분산시스템 연구실

Ex 6.11 Finding a Matrix Inverse Using LU Factorization 분산시스템 연구실

MATLAB Function function x = LU_Solve_Gen(L, U, B) % Function to solve the equation L U x = B % L --> Lower triangular matrix (1's on diagonal) % U --> Upper triangular matrix % B --> Right-hand-side matrix [n n2] = size(L); [m1 m] = size(B); % Solve L z = B using forward substitution for j = 1:m z(1, j) = b(1, j); for i = 2 : n z(i,j) = B(i,j) - L(i, 1:i-1) * z(1:i-1, j); end % Solve U x = z using back substitution x(n, j) = z(n, j) / U(n, n); for i = n-1 : -1 : 1 x(i,j) = (z(i,j)-U(i,i+1:n)*x(i+1:n,j)) / U(i,i); 분산시스템 연구실

6.6 MATLAB’s Method 분산시스템 연구실

4 built-in functions 6.6 MATLAB’s Method LU decomposition of a square matrix A [L, U] = lu(A), [L, U, P] = lu(A) Cholesky factorization chol Determinant of a matrix det Inverse of a matrix inv 분산시스템 연구실