SOLVING LINEAR SYSTEMS



Similar documents
Solution of Linear Systems

Direct Methods for Solving Linear Systems. Matrix Factorization

Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix multiplication).

7 Gaussian Elimination and LU Factorization

6. Cholesky factorization

Operation Count; Numerical Linear Algebra

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

7. LU factorization. factor-solve method. LU factorization. solving Ax = b with A nonsingular. the inverse of a nonsingular matrix

Factorization Theorems

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Solving Systems of Linear Equations

General Framework for an Iterative Solution of Ax b. Jacobi s Method

10.2 ITERATIVE METHODS FOR SOLVING LINEAR SYSTEMS. The Jacobi Method

Systems of Linear Equations

1.2 Solving a System of Linear Equations

The Characteristic Polynomial

Solving Linear Systems, Continued and The Inverse of a Matrix

Notes on Determinant

Solving Linear Systems of Equations. Gerald Recktenwald Portland State University Mechanical Engineering Department

Torgerson s Classical MDS derivation: 1: Determining Coordinates from Euclidean Distances

Using row reduction to calculate the inverse and the determinant of a square matrix

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

Solution to Homework 2

Solving Systems of Linear Equations

Methods for Finding Bases

Eigenvalues and Eigenvectors

by the matrix A results in a vector which is a reflection of the given

Matrix Differentiation

CS3220 Lecture Notes: QR factorization and orthogonal transformations

Lecture 3: Finding integer solutions to systems of linear equations

1 Determinants and the Solvability of Linear Systems

Data Mining: Algorithms and Applications Matrix Math Review

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = i.

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

1 Introduction to Matrices

Lecture 1: Systems of Linear Equations

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

Matrix Multiplication

LINEAR ALGEBRA. September 23, 2010

Elementary Matrices and The LU Factorization

Linear Equations and Inequalities

1 Solving LPs: The Simplex Algorithm of George Dantzig

8 Square matrices continued: Determinants

MAT188H1S Lec0101 Burbulla

Introduction to Matrix Algebra

Typical Linear Equation Set and Corresponding Matrices

University of Lille I PC first year list of exercises n 7. Review

Practical Guide to the Simplex Method of Linear Programming

MATRICES WITH DISPLACEMENT STRUCTURE A SURVEY

Notes on Cholesky Factorization

Numerical Methods I Solving Linear Systems: Sparse Matrices, Iterative Methods and Non-Square Systems

Matrix Algebra. Some Basic Matrix Laws. Before reading the text or the following notes glance at the following list of basic matrix algebra laws.

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

Unit 18 Determinants

Linear Programming. March 14, 2014

Continued Fractions and the Euclidean Algorithm

Linear Equations ! $ & " % & " 11,750 12,750 13,750% MATHEMATICS LEARNING SERVICE Centre for Learning and Professional Development

9.2 Summation Notation

1 VECTOR SPACES AND SUBSPACES

Lecture 2 Matrix Operations

Numerical Methods for Solving Systems of Nonlinear Equations

Solving Systems of Linear Equations Using Matrices

Math 312 Homework 1 Solutions

Similar matrices and Jordan form

Vector and Matrix Norms

Least-Squares Intersection of Lines

We shall turn our attention to solving linear systems of equations. Ax = b

NOTES ON LINEAR TRANSFORMATIONS

AN INTRODUCTION TO NUMERICAL METHODS AND ANALYSIS

Applied Linear Algebra I Review page 1

Logistic Regression. Jia Li. Department of Statistics The Pennsylvania State University. Logistic Regression

Lecture notes on linear algebra

Chapter 6. Orthogonality

Orthogonal Bases and the QR Algorithm

MATH APPLIED MATRIX THEORY

MAT 242 Test 2 SOLUTIONS, FORM T

Sequences. A sequence is a list of numbers, or a pattern, which obeys a rule.

A Direct Numerical Method for Observability Analysis

SECOND DERIVATIVE TEST FOR CONSTRAINED EXTREMA

Numerical Analysis Lecture Notes

Linear Threshold Units

Section Inner Products and Norms

Reciprocal Cost Allocations for Many Support Departments Using Spreadsheet Matrix Functions

F Matrix Calculus F 1

Iterative Methods for Solving Linear Systems

Linear Algebra Notes for Marsden and Tromba Vector Calculus

SOLVING COMPLEX SYSTEMS USING SPREADSHEETS: A MATRIX DECOMPOSITION APPROACH

The Determinant: a Means to Calculate Volume

DATA ANALYSIS II. Matrix Algorithms

K80TTQ1EP-??,VO.L,XU0H5BY,_71ZVPKOE678_X,N2Y-8HI4VS,,6Z28DDW5N7ADY013

A linear combination is a sum of scalars times quantities. Such expressions arise quite frequently and have the form

26. Determinants I. 1. Prehistory

Overview of Violations of the Basic Assumptions in the Classical Normal Linear Regression Model

Solutions to Math 51 First Exam January 29, 2015

Derivative Approximation by Finite Differences

Mathematics Course 111: Algebra I Part IV: Vector Spaces

Matrices 2. Solving Square Systems of Linear Equations; Inverse Matrices

Transcription:

SOLVING LINEAR SYSTEMS Linear systems Ax = b occur widely in applied mathematics They occur as direct formulations of real world problems; but more often, they occur as a part of the numerical analysis of some other problem As examples of the latter, we have the numerical solution of systems of nonlinear equations, ordinary and partial differential equations, integral equations, and the solution of optimization problems There are many ways of classifying linear systems Size: Small, moderate and large This of course varies with the machine you are using Most PCs are now being sold with a memory of 64 to 18 megabytes (MB), my own HP workstation has 768 MB, and the Weeg computer center s SGI shared memory parallel computer has a memory of gigabytes (GB)

For a matrix A of order n n, it will take 8n bytes to store it in double precision Thus a matrix of order 4000 will need around 18 MB of storage The latter would be too large for most present day PCs, if the matrix was to be stored in the computer s memory Sparse vs Dense Many linear systems have a matrix A in which almost all the elements are zero These matrices are said to be sparse For example, it is quite common to work with tridiagonal matrices A = a 1 c 1 0 0 b a c 0 0 b 3 a 3 c 3 0 b n a n in which the order is 10 4 or much more For such matrices, it does not make sense to store the zero elements; and the sparsity should be taken into account when solving the linear system Ax = b Also, the sparsity need not be as regular as in this example

Special properties: Often the matrix will have some other special properties For example, A might be symmetric, tridiagonal, banded, or positive definite, a i,j =0 for i j >p (Ax, x) > 0 for all x C n,x = 0 All of these properties can be used to develop more efficient and accurate methods for solving Ax = b

METHODS OF SOLUTION There are two general categories of numerical methods for solving Ax = b Direct Methods: These are methods with a finite number of steps; and they end with the exact solution x, provided that all arithmetic operations are exact The most used of these methods is Gaussian elimination, which we will begin with There are other direct methods, and we will study them later in connection with solving the matrix eigenvalue problem Iteration Methods: These are used in solving all types of linear systems, but they are most commonly used with large sparse systems, especially those produced by discretizing partial differential equations This is an extremely active area of research

SOLVING LINEAR SYSTEMS We want to solve the linear system Ax = b: a 1,1 a 1,n a n,1 a n,n x 1 x n = b 1 b n This will be done by the method used in beginning algebra, by successively eliminating unknowns from equations, until eventually we have only one equation in one unknown This process is known as Gaussian elimination To help us keep track of the steps of this process, we will denote the initial system by A (1) x = b (1) : a (1) 1,1 a(1) 1,n a (1) n,1 a(1) n,n x 1 x n = b (1) 1 b (1) n Initially we will make the assumption that every pivot element will be nonzero; and later we remove this assumption

Step 1 We will eliminate x 1 from equations thru n Begin by defining the multipliers m i,1 = a(1) i,1 a (1) 1,1, i =,, n Here we are assuming the pivot element a (1) 1,1 0 Then in succession, multiply m i,1 times row 1 (called the pivot row) and subtract the result from row i This yields new matrix elements a () i,j = a(1) i,j m i,1a (1) 1,j, j =,, n b () i = b (1) i m i,1 b (1) 1 for i =,, n Note that the index j does not include j =1 The reason is that with the definition of the multiplier m i,1, it is automatic that a () i,1 = a(1) i,1 m i,1a (1) 1,1 =0, i =,, n

The linear system is now denoted by A () x = b () : a (1) 1,1 a(1) 1, a(1) 1,n 0 a (), a (),n 0 a () n, a() n,n x 1 x x n = b (1) 1 b () b () n Step k: Assume that for i =1,, k 1 the unknown x i has been eliminated from equations i +1 thru n We have the system A (k) x = b (k) a (1) 1,1 a(1) 1, a (1) 1,n 0 a (), a (),n 0 a (k) k,k 0 0 a (k) n,k a(k) k,n a(k) n,n x 1 x x n = b (1) 1 b () b (k) ḳ b (k) n We want to eliminate unknown x k from equations k +1thrun

Begin by defining the multipliers m i,k = a(k) i,k a (k) k,k, i = k +1,, n The pivot element is a (k) k,k, and we assume it is nonzero Using these, we eliminate x k from equations k +1 thru n Multiply m i,k times row k (the pivot row) and subtract from row i, fori = k +1 thrun a (k+1) i,j = a (k) i,j m i,ka (k) k,j, b (k+1) i for i = k +1,, n A (k) x = b (k) : = b (k) i j = k +1,, n m i,k b (k) k This yields the linear system

a (1) 1,1 a (1) 1,n 0 a (k) k,k a (k) k,k+1 a (k) k,n 0 a (k+1) k+1,k+1 a (k+1) k+1,n 0 0 a (k+1) n,k+1 a (k+1) n,n = x 1 x k x k+1 x n b (1) 1 b (k) k b (k+1) k+1 b (k+1) n Doing this for k =1,,, n leads to an upper triangular system of linear equations A (n) x = b (n) : a (1) 1,1 a(1) 1,n 0 0 0 a (n) n,n x 1 x n = b (1) 1 b (n) n

At each step, we have assumed for the pivot element that a (k) k,k 0 Later we remove this assumption For now, we consider the solution of the upper triangular system A (n) x = b (n) To avoid the superscripts, and to emphasize we are now solving an upper triangular system, denote this system by Ux = g u 1,1 u 1,n 0 0 0 u n,n x 1 x n = g 1 g n This is the linear system u 1,1 x 1 + u 1, x + + u 1,n 1 x n 1 + u 1,n x n = g 1 u n 1,n 1 x n 1 + u n 1,n x n = g n 1 u n,n x n = g n

u 1,1 x 1 + u 1, x + + u 1,n 1 x n 1 + u 1,n x n = g 1 u n 1,n 1 x n 1 + u n 1,n x n = g n 1 u n,n x n = g n We solve for x n, then x n 1, and backwards to x 1 This process is called back substitution x n = g n u n,n u k = g k { } u k,k+1 x k+1 + + u k,n x n u k,k for k = n 1,, 1 Examples of the process of producing A (n) x = b (n) and of solving Ux = g are given in the text They are simply a more carefully defined and methodical version of what you have done in high school algebra

QUESTIONS How do we remove the assumption on the pivot elements? How many operations are involved in this procedure? How much error is there in the computed solution due to rounding errors in the calculations? Later (if there is time), how does the machine architecture affect the implementation of this algorithm Before doing this, we consider a result on factoring matrices that is associated with Gaussian elimination

THE LU FACTORIZATION Using the multipliers from Gaussian elimination, define the lower triangular matrix L = 1 0 0 0 m,1 1 0 m 3,1 m 3, 1 m n,1 m n, m n,n 1 1 Recall the upper triangular matrix U = A (n) Then A = LU This is called the LU-factorization of the matrix A

Proof The proof is obtained by looking at the (i, j) element of LU, (LU) i,j = [ m i,1,, m i,i 1, 1, 0,, 0 ] u 1,j u j,j 0 We consider separately the cases of i j and i>j With the first case, we have more nonzero elements in the column U,j than in the row L i, Thus (LU) i,j = m i,1 u 1,j + + m i,i 1 u i 1,j + u i,j The elements u i,j are given by u i,j = a (i) i,j, j = i,, n, i =1,, n 0

Recall that a () i,j = a(1) i,j m i,1a (1) 1,j, j =,, n for i =,, n Then Similarly, m i,1 u 1,j = m i,1 a (1) 1,j = a(1) i,j a() i,j m i, u,j = m i, a (),j = a () m i,i 1 u i 1,j = m i,i 1 a (i 1) i 1,j = a (i 1) i,j Combining these results, i,j a(3) i,j a (i) i,j (LU) i,j = m i,1 u 1,j + + m i,i 1 u i 1,j + u i,j = ( a (1) ) i,j a() i,j + + = a (1) i,j = a i,j + ( a (i 1) i,j ( a () ) i,j a(3) i,j ) a (i) i,j + a (i) i,j The second case, in which i>j, is given in the text

EXAMPLE In the text, we consider the linear system 1 1 3 1 3 0 Gaussian elimination leads to x 1 x x 3 = 0 3 with multipliers 1 1 0 1 0 0 1 x 1 x x 3 = 0 3 1 m,1 =, m 3,1 = 1, m 3, = 1 Then 1 0 0 1 0 1 1 1 1 1 0 1 0 0 1 = 1 1 3 1 3 0

In Matlab, you can find the LU factorization of a matrix using the function lu For example, [L U P]=lu(A) yields a lower triangular matrix L, an upper triangular matrix U, andapermuation matrix P,forwhich LU = PA The reason for this arises in a modification of Gaussian elimination, one which eliminates our assumption regarding the pivot elements being nonzero and simultaneously improves the error behaviour of Gaussian elimination

AN OPERATIONS COUNT How many operations are expended in solving Ax = b using Gaussian elimination? To calculate this, we must return to the formal definitions, of both A (k) x = b (k) and the solution of Ux = g Step 1 Multipliers: n 1 divisions A (1) A () :(n 1) additions and multiplications [Note that we consider additions and subtractions as the same type of operation] b (1) b () : n 1 additions and multiplications Step Multipliers: n divisions A () A (3) :(n ) additions and multiplications b () b (3) : n additions and multiplications

Step n 1 Multipliers: 1 division A (n) A (n 1) : 1 addition and multiplication b (n 1) b (n) : 1 addition and multiplication Thus we have the following totals for the transformation of A to U = A (n) Divisions (n 1) + (n ) + +1 Additions (n 1) +(n ) + +1 Multiplications (n 1) +(n ) + +1 To add these up, we need the following general formulas p j=1 j = p(p +1) p j=1 j = p(p + 1)(p +1) 6 These can proven using mathematical induction

With these, the number of operations for A U are as follows n(n 1) Divisions n(n 1)(n 1) Additions 6 n(n 1)(n 1) Multiplications 6 Similarly, we can calulate the cost of b (1) b (n) as Additions Multiplications The cost of solving Ux = g is n(n 1) n(n 1) Divisions Additions Multiplications n n(n 1) n(n 1)

On some machines, the cost of a division is much more than that of a multiplication; whereas on others there is not any important difference For this last case, we usually combine the additions and subtractions to obtain the following costs MD(A U) = n ( n 1 ) MD(b (1) g) = 3 n(n 1) MD(Find x) = n(n +1) For additions and subtractions, we have AS(A U) = AS(b (1) g) = AS(Find x) = n(n 1)(n 1) 6 n(n 1) n(n 1)

Summarizing, the cost of factoring the matrix A into L and U involves approximately 1 3 n3 multiplications and divisions, and approximately 1 3 n3 additions and subtractions The total number of arithmetic operationsisapproximately 3 n3 Thus as the size of a linear system is doubled, the cost of factoring the matrix increases by a factor of about 8 Once the matrix has been factored, the cost of modifying the right side b to g, and of then solving for x, is MD(b x) = n AS(b x) = n(n 1) = n Thus the principal cost is the solution of a linear system Ax = b is in the factorization of the matrix A into LU; and the subsequent solving for x is much smaller if n is a moderately large number

We often wish to solve linear systems Ax = b with varying vectors b, and A unchanged For such cases, it is important to keep the information used in producing L and U, as this this is the costly portion of the solution process In the machine, store the elements u i,j and m i,j into the portions of A with the same subscripts This can be done, as those positions are no longer being changed; and for the portion below the diagonal, those elements are being set to zero in A To solve m systems Ax (l) = b (l), l =1,, m for m different right hand vectors b (l), the operations cost will be MD = n ( n 1 ) + mn = 1 3 3 n 3 + mn n(n 1)(n 1) AS = + mn(n 1) = 1 3 n3 + mn

CALCULATING AN INVERSE To find the inverse of a matrix A amounts to solving the equation In partioned form, AX = I A[X,1,, X,n ]= [ e (1),, e (n)] which yields the n equivalent linear systems AX,k = e (k), k =1,, n Thus the cost of calculating the inverse X = A 1 is approximately 3 n3 +n 3 = 8 3 n3 This is only around 4 times the cost of solving a single system Ax = b