MATH 3511 Lecture 1. Solving Linear Systems 1

Similar documents
Linear Algebra Section 2.6 : LU Decomposition Section 2.7 : Permutations and transposes Wednesday, February 13th Math 301 Week #4

2.1 Gaussian Elimination

Direct Methods for Solving Linear Systems. Matrix Factorization

Matrix decompositions

AMS526: Numerical Analysis I (Numerical Linear Algebra)

1 Multiply Eq. E i by λ 0: (λe i ) (E i ) 2 Multiply Eq. E j by λ and add to Eq. E i : (E i + λe j ) (E i )

MATRICES. a m,1 a m,n A =

Solving Linear Systems Using Gaussian Elimination. How can we solve

Gaussian Elimination and Back Substitution

Direct Methods for Solving Linear Systems. Simon Fraser University Surrey Campus MACM 316 Spring 2005 Instructor: Ha Le

Matrix decompositions

Lecture 12 (Tue, Mar 5) Gaussian elimination and LU factorization (II)

CHAPTER 6. Direct Methods for Solving Linear Systems

MATH2210 Notebook 2 Spring 2018

Lectures on Linear Algebra for IT

Linear Algebra Linear Algebra : Matrix decompositions Monday, February 11th Math 365 Week #4

April 26, Applied mathematics PhD candidate, physics MA UC Berkeley. Lecture 4/26/2013. Jed Duersch. Spd matrices. Cholesky decomposition

Linear Algebraic Equations

Scientific Computing

. =. a i1 x 1 + a i2 x 2 + a in x n = b i. a 11 a 12 a 1n a 21 a 22 a 1n. i1 a i2 a in

CS412: Lecture #17. Mridul Aanjaneya. March 19, 2015

Numerical Linear Algebra

System of Linear Equations

CS227-Scientific Computing. Lecture 4: A Crash Course in Linear Algebra

Topics. Vectors (column matrices): Vector addition and scalar multiplication The matrix of a linear function y Ax The elements of a matrix A : A ij

ANALYTICAL MATHEMATICS FOR APPLICATIONS 2018 LECTURE NOTES 3

LU Factorization. Marco Chiarandini. DM559 Linear and Integer Programming. Department of Mathematics & Computer Science University of Southern Denmark

Linear Systems of n equations for n unknowns

Elementary maths for GMT

MTH 464: Computational Linear Algebra

Numerical Linear Algebra

Program Lecture 2. Numerical Linear Algebra. Gaussian elimination (2) Gaussian elimination. Decompositions, numerical aspects

Numerical Methods I Solving Square Linear Systems: GEM and LU factorization

9. Numerical linear algebra background

Linear Algebra and Matrix Inversion

SOLVING LINEAR SYSTEMS

Finite Math - J-term Section Systems of Linear Equations in Two Variables Example 1. Solve the system

AMS 209, Fall 2015 Final Project Type A Numerical Linear Algebra: Gaussian Elimination with Pivoting for Solving Linear Systems

LU Factorization a 11 a 1 a 1n A = a 1 a a n (b) a n1 a n a nn L = l l 1 l ln1 ln 1 75 U = u 11 u 1 u 1n 0 u u n 0 u n...

Math 4377/6308 Advanced Linear Algebra

MODULE 7. where A is an m n real (or complex) matrix. 2) Let K(t, s) be a function of two variables which is continuous on the square [0, 1] [0, 1].

Review of Basic Concepts in Linear Algebra

Hani Mehrpouyan, California State University, Bakersfield. Signals and Systems

Math 2331 Linear Algebra

Illustration of Gaussian elimination to find LU factorization. A = a 11 a 12 a 13 a 14 a 21 a 22 a 23 a 24 a 31 a 32 a 33 a 34 a 41 a 42 a 43 a 44

Scientific Computing: Dense Linear Systems

A Review of Matrix Analysis

Maths for Signals and Systems Linear Algebra for Engineering Applications

Roundoff Analysis of Gaussian Elimination

POLI270 - Linear Algebra

CS513, Spring 2007 Prof. Amos Ron Assignment #5 Solutions Prepared by Houssain Kettani. a mj i,j [2,n] a 11

Solving Linear Systems of Equations

Review of matrices. Let m, n IN. A rectangle of numbers written like A =

Chapter 4 No. 4.0 Answer True or False to the following. Give reasons for your answers.

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 6

Chapter 7. Tridiagonal linear systems. Solving tridiagonal systems of equations. and subdiagonal. E.g. a 21 a 22 a A =

The following steps will help you to record your work and save and submit it successfully.

Chapter 3. Linear Equations. Josef Leydold Mathematical Methods WS 2018/19 3 Linear Equations 1 / 33

Basic Concepts in Linear Algebra

Pivoting. Reading: GV96 Section 3.4, Stew98 Chapter 3: 1.3

Components and change of basis

Matrices and systems of linear equations

Linear Equations in Linear Algebra

Gaussian Elimination without/with Pivoting and Cholesky Decomposition

9. Numerical linear algebra background

Computational Methods. Systems of Linear Equations

Linear Algebra review Powers of a diagonalizable matrix Spectral decomposition

Computational Linear Algebra

Numerical Methods I: Numerical linear algebra

Review Questions REVIEW QUESTIONS 71

Gaussian Elimination -(3.1) b 1. b 2., b. b n

Next topics: Solving systems of linear equations

Fundamentals of Engineering Analysis (650163)

Since the determinant of a diagonal matrix is the product of its diagonal elements it is trivial to see that det(a) = α 2. = max. A 1 x.

Chapter 2. Solving Systems of Equations. 2.1 Gaussian elimination

Chapter 5. Linear Algebra. A linear (algebraic) equation in. unknowns, x 1, x 2,..., x n, is. an equation of the form

Linear System of Equations

Math 4377/6308 Advanced Linear Algebra

Chapter 9: Gaussian Elimination

Linear Equations and Matrix

Numerical Linear Algebra

Linear Algebra. Solving Linear Systems. Copyright 2005, W.R. Winfrey

18.06 Problem Set 2 Solution

Matrix Algebra for Engineers Jeffrey R. Chasnov

1.4 Gaussian Elimination Gaussian elimination: an algorithm for finding a (actually the ) reduced row echelon form of a matrix. A row echelon form

Linear Algebra I Lecture 8

MAC1105-College Algebra. Chapter 5-Systems of Equations & Matrices

MTH 464: Computational Linear Algebra

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and

CSE 160 Lecture 13. Numerical Linear Algebra

22A-2 SUMMER 2014 LECTURE 5

ORIE 6300 Mathematical Programming I August 25, Recitation 1

Engineering Computation

Solution of Linear Systems

A matrix is a rectangular array of. objects arranged in rows and columns. The objects are called the entries. is called the size of the matrix, and

Solution of Linear Equations

MIDTERM 1 - SOLUTIONS

Section Gaussian Elimination

Draft. Lecture 12 Gaussian Elimination and LU Factorization. MATH 562 Numerical Analysis II. Songting Luo

Introduction to Mathematical Programming

Transcription:

MATH 3511 Lecture 1 Solving Linear Systems 1 Dmitriy Leykekhman Spring 2012 Goals Review of basic linear algebra Solution of simple linear systems Gaussian elimination D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 1

Linear System of Equations Linear system of m equations with n unknowns x 1, x 2,, x n we write as a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2 a m1 x 1 + a m2 x 2 + + a mn x n = b m, where a ij R and b i R, 1 i m, 1 j n D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 2

Linear System of Equations From the coefficients a ij we form a matrix a 11 a 12 a 1n a 21 a 22 a 2n A = a m1 a m2 a mn We also define vectors b and x b = b 1 b 2 b m, x = x 1 x 2 x n Notice that A R m n, x R n, and b R m D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 3

Matrix-Vector Multiplication Let A R m n and x R n The i-th component of the matrix-vector product y = Ax is defined by y i = n a ij x j (1) j=1 ie, y i is the dot product (inner product) of the i-th row of A with the vector x y i = a i1 a i2 a in x 1 x 2 x n D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 4

Matrix-Vector Multiplication Another useful point of view is to look at entire vector y = Ax y 1 y i y m = a 11 a 12 a 1n a i1 a i2 a in a m1 a m2 a mn x 1 x 2 x n = x 1 a 11 a i1 a m1 + x 2 a 12 a i2 a m2 + + x n a 1n a in a mn Thus, y is a linear combination of the columns of matrix A D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 5

Definitions Let v 1,, v n be some vectors in R n and c 1,, c n be some numbers An expression of the form c 1 v 1 + + c n v n is called a linear combination of v 1,, v n A set of all possible linear combinations of vectors v 1,, v n is called a linear span of v 1,, v n Vectors v 1,, v n are linearly dependent if there exist numbers c 1,, c n not all zeros such that c 1 v 1 + + c n v n = 0 If such numbers do not exist we say that vectors v 1,, v n are linearly independent D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 6

Solution of Linear Systems Let A R m n and x R n Then Ax is a linear combination of the columns of A Hence Ax = b has a solution if b R m can be written as a linear combination of the columns of A Solvability: Ax = b is solvable for every b R m iff the columns of A span R m (necessary n m) Uniqueness: If Ax = b has a solution, then the solution is unique iff the columns of A are linearly independent (necessary n m) Hence, for any b R m, the system Ax = b has a unique solution iff n = m and the columns of A are linearly independent D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 7

Solution of Triangular Systems A matrix L R n n is called lower triangular matrix if all matrix entries above the diagonal are equal to zero, ie, if l ij = 0 for j > i A matrix U R n n is called upper triangular matrix if all matrix entries below the diagonal are equal to zero, ie, if l ij = 0 for i > j A Linear system with lower (upper) triangular matrix can be solved by forward substitution (backward substitution) D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 8

Solution of Triangular Systems Example Consider the system Forward substitution gives 2 0 0 1 4 0 4 3 3 x 1 x 2 x 3 = x 1 = 4/2 = 2, x 2 = (2 1 2)/4 = 0, x 3 = (5 4 2 3 0)/3 = 1 4 2 5 D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 9

Solution of Triangular Systems Example Consider the system 2 4 2 0 2 4 0 0 3 Backward substitution gives x 1 x 2 x 3 = x 3 = 6/3 = 2, x 2 = (2 4 2)/( 2) = 3, x 1 = (4 2 2 4 3)/2 = 6 4 2 6 D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 10

Solution of Triangular Systems Back substitution Solution of Upper Triangular Systems (Row-Oriented Version) Input: Upper triangular matrix U R n n, right hand side vector b R n Output: Solution x R n of Ux = b Mathematically, x i = b i n u ij x j /u ii, if u ii 0 j=i+1 MATLAB code that overwrites b with the solution to Ux = b if all(diag(u)) == 0 disp( the matrix is singular ) else b(n) = b(n)/u(n,n); for i = n-1:-1:1 b(i)= (b(i) - U(i,i+1:n)*b(i+1:n))/U(i,i); end end D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 11

Solution of Triangular Systems Back substitution Solution of Upper Triangular Systems (Column-Oriented Version) Input: Upper triangular matrix U R n n, right hand side vector b R n Output: Solution x R n of Ux = b MATLAB code that overwrites b with the solution to Ux = b if all(diag(u)) == 0 disp( the matrix is singular ) else for end j = n:-1:2 b(j) = b(j)/u(j,j) ; b(1:j-1) = b(1:j-1) - b(j)*u(1:j-1,j); end b(1) = b(1)/u(1,1); D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 12

Gaussian Elimination Gaussian elimination for the solution of a linear system transforms the system Ax = b into an equivalent system with upper triangular matrix This is done by applying three types of transformations to the augmented matrix (A b) Type 1: Replace an equation with the sum of the same equation and a multiple of another equation; Type 2: Interchange two equations; and Type 3: Multiply an equation by a nonzero number Once the augmented matrix (A b) is transformed into (U y), where U is an upper triangular matrix, we can use the techniques discussed previously to solve this transformed system Ux = y D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 13

Gaussian Elimination (cont) Consider a linear system Ax = b with A = 1 2-1 2 1 0, b = 0 2-1 2 2 1 The augmented system is 2 1 0 2 1 2-1 0-1 2 2 1 Step 1 1 2-1 0 0-3 2 2 0 4 1 1 (1) (2) (2) 2 (1) (3) (3) + 1 (2) D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 14

Gaussian Elimination (cont) Consider a linear system Ax = b with A = 1 2-1 2 1 0, b = 0 2-1 2 2 1 The augmented system is 2 1 0 2 1 2-1 0-1 2 2 1 Step 2 1 2-1 0 0-3 2 2 0 0 11/3 11/3 (1) (2) (3) (3) + 4/3 (2) Solving the triangular system we obtain x 3 = 1, x 2 = 0, x 1 = 1 D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 14

Gaussian Elimination We need to modify Gaussian elimination for two reasons: improve numerical stability (change how we perform pivoting) make it more versatile (leads to LU-decomposition) D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 15

Gaussian Elimination (cont) Partial pivoting: In step i, find row j with j > i such that a ji a ki for all k > i and exchange rows i and j Such numbers a ji we call pivots Again consider the augmented system 1 2-1 0 2 1 0 2-1 2 2 1 Step 1 2 1 0 2 1 2-1 0-1 2 2 1 (1) (2) (2) (1) (3) D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 16

Gaussian Elimination (cont) Partial pivoting: In step i, find row j with j > i such that a ji a ki for all k > i and exchange rows i and j Such numbers a ji we call pivots Again consider the augmented system 1 2-1 0 2 1 0 2-1 2 2 1 Step 2 2 1 0 2 0 3/2-1 -1 0 5/2 2 2 (1) (2) (2) 1/2 (1) (3) (3) ( 1/2) (2) D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 16

Gaussian Elimination (cont) Partial pivoting: In step i, find row j with j > i such that a ji a ki for all k > i and exchange rows i and j Such numbers a ji we call pivots Again consider the augmented system 1 2-1 0 2 1 0 2-1 2 2 1 Step 3 2 1 0 2 0 5/2 2 2 0 3/2-1 -1 (1) (2) (3) (3) (2) D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 16

Gaussian Elimination (cont) Partial pivoting: In step i, find row j with j > i such that a ji a ki for all k > i and exchange rows i and j Such numbers a ji we call pivots Again consider the augmented system 1 2-1 0 2 1 0 2-1 2 2 1 Step 4 2 1 0 2 0 5/2 2 2 0 0 11 8 11 8 (1) (2) (3) (3) 3/2 5/2 (2) Solving the triangular system we obtain x 3 = 1, x 2 = 0, x 1 = 1 D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 16

Gaussian Elimination Why do we need partial pivoting? It doesn t matter if we use exact arithmetic Without partial pivoting with floating point arithmetic the method can be unstable How expensive is Gaussian elimination? Using n j 2 = j=1 n(n + 1)(2n + 1) 6 we can calculate that for large n the number of flops in the Gaussian elimination with partial pivoting approximately equal to 2n 3 /3 D Leykekhman - MATH 3511 Introduction to Computational Mathematics Linear Systems 1 17