Math 22AL Lab #4. 1 Objectives. 2 Header. 0.1 Notes

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

GAUSSIAN ELIMINATION AND LU DECOMPOSITION (SUPPLEMENT FOR MA511)

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

18.06 Problem Set 3 - Solutions Due Wednesday, 26 September 2007 at 4 pm in

Handout 1 EXAMPLES OF SOLVING SYSTEMS OF LINEAR EQUATIONS

Matrix Factorization Reading: Lay 2.5

7.6 The Inverse of a Square Matrix

Review for Exam Find all a for which the following linear system has no solutions, one solution, and infinitely many solutions.

MIDTERM 1 - SOLUTIONS

INVERSE OF A MATRIX [2.2]

MAT 343 Laboratory 3 The LU factorization

If A is a 4 6 matrix and B is a 6 3 matrix then the dimension of AB is A. 4 6 B. 6 6 C. 4 3 D. 3 4 E. Undefined

Linear Systems of n equations for n unknowns

Section 5.6. LU and LDU Factorizations

22A-2 SUMMER 2014 LECTURE 5

MAC Module 2 Systems of Linear Equations and Matrices II. Learning Objectives. Upon completing this module, you should be able to :

MODEL ANSWERS TO THE THIRD HOMEWORK

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

Numerical Linear Algebra

Finite Mathematics Chapter 2. where a, b, c, d, h, and k are real numbers and neither a and b nor c and d are both zero.

18.06 Problem Set 2 Solution

Math 1553 Introduction to Linear Algebra

30.3. LU Decomposition. Introduction. Prerequisites. Learning Outcomes

Math 344 Lecture # Linear Systems

Lecture 9: Elementary Matrices

MATLAB Project: LU Factorization

Extra Problems: Chapter 1

Review Let A, B, and C be matrices of the same size, and let r and s be scalars. Then

Linear Algebra: Lecture notes from Kolman and Hill 9th edition.

Math 414 Lecture 1. Reading assignment: Text: Pages 1-29 and Scilab Users Guide: Sections 1-3.

Math Computation Test 1 September 26 th, 2016 Debate: Computation vs. Theory Whatever wins, it ll be Huuuge!

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

Chapter 1 Linear Equations. 1.1 Systems of Linear Equations

Chapter 2 Notes, Linear Algebra 5e Lay

MATH 3511 Lecture 1. Solving Linear Systems 1

Next topics: Solving systems of linear equations

Chapter 2: Matrices and Linear Systems

0.1 Eigenvalues and Eigenvectors

Math 313 Chapter 1 Review

1 Last time: inverses

1 GSW Sets of Systems

MODEL ANSWERS TO THE FIRST QUIZ. 1. (18pts) (i) Give the definition of a m n matrix. A m n matrix with entries in a field F is a function

Solution Set 3, Fall '12

Topic 15 Notes Jeremy Orloff

4 Elementary matrices, continued

Fall Inverse of a matrix. Institute: UC San Diego. Authors: Alexander Knop

Example: 2x y + 3z = 1 5y 6z = 0 x + 4z = 7. Definition: Elementary Row Operations. Example: Type I swap rows 1 and 3

Linear Equations and Matrix

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].

MATH2210 Notebook 2 Spring 2018

Review. Example 1. Elementary matrices in action: (a) a b c. d e f = g h i. d e f = a b c. a b c. (b) d e f. d e f.

Section 4.5. Matrix Inverses

CHAPTER 6. Direct Methods for Solving Linear Systems

Section 3.3. Matrix Rank and the Inverse of a Full Rank Matrix

MATH 2030: ASSIGNMENT 4 SOLUTIONS

Cheat Sheet for MATH461

MATH 2331 Linear Algebra. Section 2.1 Matrix Operations. Definition: A : m n, B : n p. Example: Compute AB, if possible.

MATH.2720 Introduction to Programming with MATLAB Vector and Matrix Algebra

CHAPTER 8: Matrices and Determinants

18.06 Spring 2012 Problem Set 3

INVERSE OF A MATRIX [2.2] 8-1

Computer Assignment 2

MATLAB Project 2: MATH240, Spring 2013

MATH 2030: MATRICES. Example 0.2. Q:Define A 1 =, A. 3 4 A: We wish to find c 1, c 2, and c 3 such that. c 1 + c c

Linear Algebra Math 221

Math 343 Midterm I Fall 2006 sections 002 and 003 Instructor: Scott Glasgow

Linear Algebra and Matrix Inversion

Section 2.2: The Inverse of a Matrix

Lecture 2 Systems of Linear Equations and Matrices, Continued

Name: MATH 3195 :: Fall 2011 :: Exam 2. No document, no calculator, 1h00. Explanations and justifications are expected for full credit.

Math 102, Winter Final Exam Review. Chapter 1. Matrices and Gaussian Elimination

Direct Methods for Solving Linear Systems. Matrix Factorization

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

LINEAR SYSTEMS, MATRICES, AND VECTORS

Math 403 Linear Algebra

POLI270 - Linear Algebra

4 Elementary matrices, continued

Gaussian Elimination without/with Pivoting and Cholesky Decomposition

. =. 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

Chapter 4. Solving Systems of Equations. Chapter 4

Reduction to the associated homogeneous system via a particular solution

MTH 464: Computational 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 )

Numerical Linear Algebra

Linear Algebra. Chapter Linear Equations

The matrix will only be consistent if the last entry of row three is 0, meaning 2b 3 + b 2 b 1 = 0.

Methods for Solving Linear Systems Part 2

CS 323: Numerical Analysis and Computing

Section 3.5 LU Decomposition (Factorization) Key terms. Matrix factorization Forward and back substitution LU-decomposition Storage economization

3.4 Elementary Matrices and Matrix Inverse

Matrices and Matrix Algebra.

Gaussian Elimination and Back Substitution

The Solution of Linear Systems AX = B

Numerical Linear Algebra

MA2501 Numerical Methods Spring 2015

Applied Matrix Algebra Lecture Notes Section 2.2. Gerald Höhn Department of Mathematics, Kansas State University

Numerical Linear Algebra

Inverting Matrices. 1 Properties of Transpose. 2 Matrix Algebra. P. Danziger 3.2, 3.3

Review Questions REVIEW QUESTIONS 71

8-15. Stop by or call (630)

Transcription:

Math 22AL Lab #4 0.1 Notes Green typewriter text represents comments you must type. Each comment is worth one point. Blue typewriter text represents commands you must type. Each command is worth one point. MATLAB is case-sensitive, so commands are case-sensitive as well. Beware of typos! Also, do not copy and paste commands. Special characters are sometimes used (e.g. the left quote character) which MATLAB does not like. 1 Objectives In this lab, you will explore the following topics using MATLAB: Matrix inverses. Properties of invertible matrices. LU factorization. 2 Header Enter your information: % [your first name] % [your last name] % [the date, in any format] 1

3 Matrix inverses 3.1 Theory Let A be a square matrix. The inverse of A (if it exists) is denoted by A 1 and is defined to be a matrix such that AA 1 = A 1 A = I (I is the identity matrix). The following facts about matrix inverses appear in Mathematics 22A. Please review them before doing the lab, especially if your 22A class has not covered them yet. Not all square matrices have inverses. For example, the zero matrix has no inverse. A square matrix with an inverse is called invertible or nonsingular. A square matrix with no inverse is called non-invertible or singular. The inverse exists if and only if elimination produces n pivots. The inverse of an invertible matrix is unique a matrix cannot have two different inverses. If A is invertible, the system of equations Ax = b has only one solution: x = A 1 b. If there exists a nonzero vector x such that Ax = 0, then A is non-invertible. If A and B are invertible matrices, then so is AB: (AB) 1 = B 1 A 1. [ ] a b A 2 2 matrix is invertible if and only if ad bc 0. c d A diagonal matrix is invertible if and only if no diagonal entries are zero. A triangular matrix is invertible if and only if no diagonal entries are zero. The right-inverse of a square matrix is always equal to the left-inverse: if BA = I and AC = I then B = C. If a matrix doesn t have n pivots, elimination will lead to a zero row. An invertible matrix can t have a zero row! The Gauss-Jordan method solves AA 1 = I to find the n columns of A 1. 2

3.2 Basic properties of the inverse Type: A = [2 1-1; -4 1 4; 5-6 -8] Type: inv(a) Type: inv(inv(a)) % [an explanation of what happened in the previous line] Type: rref(a) What kind of matrix is rref(a)? % [the type of matrix that AR is] Is this true for all invertible matrices? If all invertible matrices have this kind of rref, If not, Type: s3a1 = yes Type: s3a1 = no Define a matrix B as follows. Type: B(:,1) = A(:,1) Type: B(:,2) = A(:,2) Type: B(:,3) = A(:,1) + A(:,2) Note that the first two columns of B are equal to the first two columns of A, while the last column of B is the sum of the first two columns of A. Compute the reduced-row echelon form of B. Type: rref(b) Do you see a row of zeros? Type: inv(b) Does the inverse of B exist? If B is invertible, If B is singular, Type: s3a2 = yes Type: s3a2 = no 3.3 The inverse of a diagonal matrix Type: C = [3 0 0 0; 0 2 0 0; 0 0 5 0; 0 0 0 4] Type: inv(c) Type: format rat Type: inv(c) Type: D = [3 0 0; 0 8 0; 0 0 5] Type: inv(d) Type: E = [1 0 0; 0 3 0; 0 0 7] Without using MATLAB, guess the inverse of E. Type your answer into MATLAB, starting with EI = Type: E*EI If you did not get an identity matrix, try again until you get it right. 3

3.4 The Inverse of a Block Matrix Type: F = [ 6 5 0 0; 7 6 0 0; 0 0 3 2; 0 0 4 3] Type: inv(f) Do you see anything interesting about inv(f)? % [something interesting about inv(f)] Type: inv([6 5; 7 6]) Type: inv([3 2; 4 3]) % [the relationship of the last two inverses with inv(f)] Type: G1 = 5 * eye(4) - 1 Type: inv(g1) Type: G2 = 6 * eye(5) - 1 Type: inv(g2) Type: G3 = 3 * eye(2) - 1 Type: inv(g3) Generalize your observation: Let I n and O n be the n n identity matrices and matrices of ones, respectively. The inverse of (n + 1)I n O n will be in the form k(i n + O n ) for some k dependent upon n. What is k? % [the value of k, in terms of n] 3.5 The Inverse of a Matrix Product Type: A = [1 3 1; 2 3 0; -1-2 1] Type: B = [6 3-5; 2 2 1; -2 1 2] Type: AB = A * B Type: ABI = inv(a * B) Type: ABI2 = inv(a) * inv(b) Type: ABI3 = inv(b) * inv(a) If A and B are invertible matrices, is it always true that (AB) 1 = A 1 B 1? If it is true, If it is false, Type: s3a3 = yes Type: s3a3 = no If A and B are invertible matrices, is it always true that (AB) 1 = B 1 A 1? If it is true, If it is false, Type: s3a4 = yes Type: s3a4 = no If A and B are matrices, is it always true that (AB) 1 = B 1 A 1? If it is true, If it is false, Type: s3a5 = yes Type: s3a5 = no Is there a multiplicative group of matrices (a set of matrices G such that every matrix in the group has an inverse, and the set is closed under multiplication) in which for any 4

given matrices A and B in that group, (AB) 1 = A 1 B 1? If such a group exists, If no such group exists, Type: s3a6 = yes Type: s3a6 = no 4 Using Gauss-Jordan Elimination to Invert Matrices You can find the inverse of an invertible n n matrix A by finding the reduced-row echelon form of K = [A I]. If A is invertible, then rref(k) will be [I A 1 ]. Type: A = [2 7; 1 3] Type: I = eye(2) Type: AIR = rref([a I]) Type: AI = AIR(:, 3:end) Type: inv(a) Note that AI = A 1. Type: B = [2 1 0; 1 2 1; 0 1 2] Type: BIR = rref([b eye(3)]) Type: BI = BIR(:, 4:end) Type: inv(b) Note that BI = B 1. Type: C = [1 3-5; 3 2 1; 0 1 2] Type: CIR = rref([c eye(3)]) Type: CI = CIR(:, 4:end) Type: inv(c) Note that CI = C 1. 5

5 LU Factorization 5.1 Theory Using Gaussian elimination, we can express any square matrix as the product of a permutation matrix (which reorders the rows and columns), a lower triangular matrix, and an upper triangular matrix: A = P LU. If A is invertible, usually we choose the lower triangular matrix L to have a diagonal consisting of ones. If we want both L and U to have diagonals consisting of ones, then we need a diagonal matrix in the middle; the decomposition becomes A = P LDU, which is unique. One of the applications of LU decomposition is solving linear systems of the form Ax = b. Substituting P LU for A, we have P LUx = b. This can be rewritten (P 1 b is easy to compute) as L(Ux) = P 1 b. Note that Ux is a column vector. Since L is triangular, the system Ly = P 1 b can be solved easily for y; Ux = y can then be solved for x. 5.2 LU Factorization in MATLAB To get the LU decomposition of a matrix in MATLAB, use the lu command. There are two versions of lu: one with two outputs [L U] (L is a permutation of a lower triangular matrix), and one with three outputs [L U P]. Type: M = [2 1 0; 1 3 1; 0 1 2] Type: [L U] = lu(m) Type: [L U P] = lu(m) Type: P * L * U The output of that last command should be equal to M. Type: N = [1 3 0; 3 11 4; 0 4 9] Type: [L U P] = lu(n) Type: [L U] = lu(n) Note that L is a permuted lower triangular matrix. End of Lab 4 6