CS 322 Homework 4 Solutions

Similar documents
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.

Find the solution set of 2x 3y = 5. Answer: We solve for x = (5 + 3y)/2. Hence the solution space consists of all vectors of the form

Math 21b: Linear Algebra Spring 2018

2. Every linear system with the same number of equations as unknowns has a unique solution.

Math 407: Linear Optimization

1. What is the determinant of the following matrix? a 1 a 2 4a 3 2a 2 b 1 b 2 4b 3 2b c 1. = 4, then det

The QR Factorization

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

Orthogonal Transformations

MATH 20F: LINEAR ALGEBRA LECTURE B00 (T. KEMP)

18.06 Problem Set 3 Solution Due Wednesday, 25 February 2009 at 4 pm in Total: 160 points.

Lecture # 5 The Linear Least Squares Problem. r LS = b Xy LS. Our approach, compute the Q R decomposition, that is, n R X = Q, m n 0

Math 4A Notes. Written by Victoria Kala Last updated June 11, 2017

AMS526: Numerical Analysis I (Numerical Linear Algebra for Computational and Data Sciences)

Least Squares. Tom Lyche. October 26, Centre of Mathematics for Applications, Department of Informatics, University of Oslo

MAT Linear Algebra Collection of sample exams

Dot product and linear least squares problems

ft-uiowa-math2550 Assignment OptionalFinalExamReviewMultChoiceMEDIUMlengthForm due 12/31/2014 at 10:36pm CST

Orthonormal Transformations

Row Space, Column Space, and Nullspace

Notes on Householder QR Factorization

Math 265 Midterm 2 Review

Review 1 Math 321: Linear Algebra Spring 2010

Orthonormal Transformations and Least Squares

Math 2174: Practice Midterm 1

Linear Algebra Massoud Malek

MA 265 FINAL EXAM Fall 2012

Stability of the Gram-Schmidt process

Applied Mathematics 205. Unit II: Numerical Linear Algebra. Lecturer: Dr. David Knezevic

1. Let m 1 and n 1 be two natural numbers such that m > n. Which of the following is/are true?

Solutions to Final Practice Problems Written by Victoria Kala Last updated 12/5/2015

The definition of a vector space (V, +, )

7. Dimension and Structure.

AMS526: Numerical Analysis I (Numerical Linear Algebra)

Jim Lambers MAT 610 Summer Session Lecture 1 Notes

Notes on Eigenvalues, Singular Values and QR

Lecture 22: Section 4.7

Linear Algebra, part 3 QR and SVD

Orthogonality. 6.1 Orthogonal Vectors and Subspaces. Chapter 6

Math 224, Fall 2007 Exam 3 Thursday, December 6, 2007

Linear algebra I Homework #1 due Thursday, Oct Show that the diagonals of a square are orthogonal to one another.

4 ORTHOGONALITY ORTHOGONALITY OF THE FOUR SUBSPACES 4.1

Vector Spaces, Orthogonality, and Linear Least Squares

Section 6.2, 6.3 Orthogonal Sets, Orthogonal Projections

Math 369 Exam #2 Practice Problem Solutions

EE731 Lecture Notes: Matrix Computations for Signal Processing

The Singular Value Decomposition and Least Squares Problems

MA 527 first midterm review problems Hopefully final version as of October 2nd

18.06SC Final Exam Solutions

YORK UNIVERSITY. Faculty of Science Department of Mathematics and Statistics MATH M Test #1. July 11, 2013 Solutions

EXAM. Exam #2. Math 2360 Summer II, 2000 Morning Class. Nov. 15, 2000 ANSWERS

Chap 3. Linear Algebra

18.06 Professor Johnson Quiz 1 October 3, 2007

REVIEW FOR EXAM III SIMILARITY AND DIAGONALIZATION

MATH 323 Linear Algebra Lecture 12: Basis of a vector space (continued). Rank and nullity of a matrix.

Chapter 6 - Orthogonality

MTH 362: Advanced Engineering Mathematics

σ 11 σ 22 σ pp 0 with p = min(n, m) The σ ii s are the singular values. Notation change σ ii A 1 σ 2

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

P = A(A T A) 1 A T. A Om (m n)

Answer Key for Exam #2

Section 4.4 Reduction to Symmetric Tridiagonal Form

ELE/MCE 503 Linear Algebra Facts Fall 2018

Linear Systems. Carlo Tomasi

GEOMETRY OF MATRICES x 1

1. Select the unique answer (choice) for each problem. Write only the answer.

9. Numerical linear algebra background

Final Review Written by Victoria Kala SH 6432u Office Hours R 12:30 1:30pm Last Updated 11/30/2015

Computational math: Assignment 1

Math 18, Linear Algebra, Lecture C00, Spring 2017 Review and Practice Problems for Final Exam

Course Notes: Week 1

Instructions Please answer the five problems on your own paper. These are essay questions: you should write in complete sentences.

Designing Information Devices and Systems I Discussion 4B

Linear Algebra. Linear Algebra. Chih-Wei Yi. Dept. of Computer Science National Chiao Tung University. November 12, 2008

Matrix invertibility. Rank-Nullity Theorem: For any n-column matrix A, nullity A +ranka = n

Chapter 5 Eigenvalues and Eigenvectors

March 27 Math 3260 sec. 56 Spring 2018

18.06 Spring 2012 Problem Set 3

Index. book 2009/5/27 page 121. (Page numbers set in bold type indicate the definition of an entry.)

Chapter 2 Subspaces of R n and Their Dimensions

MATH 31 - ADDITIONAL PRACTICE PROBLEMS FOR FINAL

Homework 5. (due Wednesday 8 th Nov midnight)

What is A + B? What is A B? What is AB? What is BA? What is A 2? and B = QUESTION 2. What is the reduced row echelon matrix of A =

Lecture 23: 6.1 Inner Products

MATH 235: Inner Product Spaces, Assignment 7

May 9, 2014 MATH 408 MIDTERM EXAM OUTLINE. Sample Questions

Dimension and Structure

Math 308 Practice Test for Final Exam Winter 2015

(a) If A is a 3 by 4 matrix, what does this tell us about its nullspace? Solution: dim N(A) 1, since rank(a) 3. Ax =

Linear Algebra in A Nutshell

Numerical Methods I Non-Square and Sparse Linear Systems

MATH 304 Linear Algebra Lecture 20: Review for Test 1.

SUMMARY OF MATH 1600

Linear Algebra, part 3. Going back to least squares. Mathematical Models, Analysis and Simulation = 0. a T 1 e. a T n e. Anna-Karin Tornberg

Answer Key for Exam #2

x = t 1 x 1 + t 2 x t k x k

Linear Systems. Carlo Tomasi. June 12, r = rank(a) b range(a) n r solutions

Midterm 1 Review. Written by Victoria Kala SH 6432u Office Hours: R 12:30 1:30 pm Last updated 10/10/2015

Image Registration Lecture 2: Vectors and Matrices

Notes on Solving Linear Least-Squares Problems

Transcription:

CS 322 Homework 4 Solutions out: Thursday 1 March 2007 due: Wednesday 7 March 2007 Problem 1: QR mechanics 1 Prove that a Householder reflection is symmetric and orthogonal. Answer: Symmetry: H T = (I ρuu T ) T = I T ρ(u T ) T u T = I ρuu T = H Orthogonal: HH T = HH = ) ) = I 4uuT + u)u T 4u(uT () 2 = I 4uuT + 4uuT = I Since HH T = I, we can conclude that the matrix H is orthogonal. 2 Show that the Householder vector given on p. 147 in Moler produces a transformation that zeros out all but the k th element of x. Hx = ) u T x u = x 2uT x u = x 2uT x (x + x e k) ( ) = 1 2uT x u T x + x e k u 1

CS 322 Homework 4 Solutions 2 We note that the second vector will ( always ) be zero except for the k-th component. Thus, we just need to show that 1 2uT x = 0. In order to prove this, we note that: u T x = (x + x e k ) T x = x T x + x x k = x 2 + x x k and similarly = (x + x e k ) T (x + x e k ) = x T x + 2 x x k + x 2 = 2 x 2 + 2 x x k ( ) Substituting these expressions into 1 2uT x, we see that in fact 1 2( x 2 + x x k ) = 2 x 2 +2 x x k 1 1 = 0. Thus, Hx = 0x + x e k = x e k, which as we have already noted, is zero everywhere except possibly the k-th component. 3 Explain why Moler s recommendation for choosing the sign of σ improves accuracy. Answer: Suppose we chose σ to be the sign opposite of x k. Then the computation of the k-th component of u will be a subtraction instead of an addition. If these numbers are relatively close to each other (i.e. x lies close to e k ), then there is the possibility of massive cancellation in the k-th component of u. This is problematic due to the fixed number of mantissa bits in our floating point representation subtracting two similar numbers reduces the number of significant digits left in the answer. If the numbers are close to each other, then we may end up with only one significant digit left, greatly reducing the accuracy in the answer. Choosing the sign as we do preserves the number of significant digits in the k-th component of u and so improves the accuracy in the computed answer. 4 How many floating-point operations (flops) are required to multiply an m n matrix by a Householder reflection? Answer: We note that we can exploit the structure of the Householder transformation H to speed up multiplication:

CS 322 Homework 4 Solutions 3 ) HA = u T A u = A 2 uut A = A ρuu T A It will take 2m + 1 flops to compute ρ. Computing u T A is matrix-vector multiplication and will take 2mn flops. Computing ρu is scaling a vector and will take m flops. Computing (ρu)(u T A) is an outer product between two vectors, taking mn flops. Finally, subtracting the outer product from A takes mn flops, for a total of 4mn + 3m + 1 flops, or 4mn flops if we only care about the leading term. 5 What size matrices are updated by the n 1 steps of a QR factorization of an m by n matrix? Answer: Each step i updates the lower right (m i + 1) (n i + 1) portion of the matrix. This is due to both zeros in the Householder transform and in the already processed columns of the matrix. Thus, on the first step we update an m n matrix (i.e. the whole matrix), on the second step we update an (m 1) (n 1) matrix (everything but the first row and column), and so on. 6 If the Q factor is computed as part of the factorization, What size matrices are updated by the n 1 steps of that process? What factor of additional work does this add? Answer: Computing Q requires multiplying all of the n Householder transformations together. We can exploit the zero structure in the HH transform, but this will only allow us to reduce one of the dimensions of data we will update an (m i + 1) m matrix on each iteration. Using the answer from Part 4, we can compute the total cost of these multiplications by summing up the cost of each one as 4m(m i + 1) for i = 1 to n, obtaining 4m 2 n 2mn 2. The work in just computing R is 2mn 2 2 3 n3, or just 2mn 2 for large values of m relative to n. Thus, the total work done when computing both Q and R increases by a factor of roughly 1 + 2 m n 7 Time the Matlab operations qr(a); and [Q,R] = qr(a); using tic and toc, for matrices large enough to take a few seconds to factor. Is your answer to (6) borne out? Explain. Answer: We timed qr(a); and [Q, R] = qr(a); for various A = rand(1000*i, 1000*j) with i and j varying from 1 to 4. Below is the result of the times, where the table is showing the time of [Q, R] = qr(a); divided by the time of qr(a); n = 1000 2000 3000 4000 m = 1000 2.0235 1.3982 1.2494 1.1889 2000 4.2413 2.0014 1.5839 1.4006 3000 6.6932 2.9356 1.9973 1.6746 4000 10.7686 4.0557 2.6357 2.0965

CS 322 Homework 4 Solutions 4 And the table for the computed fraction of additional work 1 + 2m n n = 1000 2000 3000 4000 m = 1000 3.0000 2.0000 1.6667 1.5000 2000 5.0000 3.0000 2.3333 2.0000 3000 7.0000 4.0000 3.0000 2.5000 4000 9.0000 5.0000 3.6667 3.0000 We can see that we are a bit off, but we are definitely close to capturing a trend in the data. Possible explanations for this may include variation in the trials (we only timed each matrix once due to the length of time it was taking), but the primary reason is the fact that FLOP counts are not a terribly accurate way of measuring computation time. There are certainly memory transfer and cache hit/miss factors that are not accounted for in our performance analysis, and these can and do play a large role in overall performance. However, overall it appears as if our approximate calculations are supported by this experiment.

CS 322 Homework 4 Solutions 5 Problem 2: Subspaces Find the subspaces ran(a), ran(a), null(a), and null(a) for each of the following fullrank matrices. Give orthonormal bases for each subspace and explain how you computed them in your head or by using the QR factorization. Simpler bases found by reasoning are preferable to messier ones found by computation. Note: A single score was assigned to this problem; however, it was weighted by 5 when the final grade was computed. 1. 2. 3. 3 3 8 2 8 3 7 2 3 Answer: Because the matrix is full rank, we know that for any vector b R 3, there is some x such that Ax = b. Thus, it follows that ran(a) = R 3. An easy orthonormal basis for this subspace is the standard basis vectors e 1 = [1; 0; 0], e 2 = [0; 1; 0], e 3 = [0; 0; 1]. Because the range is R 3, there are no non-zero length vectors that are orthogonal, and so it follows that ran(a) = {0}, with the empty basis. Similarly, since A is nonsingular, the only vector x such that Ax = 0 is in fact x = 0. Thus, null(a) = {0}, with the empty basis. By the reverse of the argument used for ran(a), it follows that null(a) = R 3, and so an orthonormal basis for it is the canonical basis vectors e 1, e 2, and e 3. 1 6 7 8 5 4 2 3 9 0 0 0 0 0 0 Answer: Again, because the matrix is full rank, we can conclude that for any vector b = [d; e; f; 0; 0], there is some vector x such that Ax = b. As such, one simple orthonormal basis for ran(a) is {[1; 0; 0; 0; 0], [0; 1; 0; 0; 0], [0; 0; 1; 0; 0]}. A simple set of orthonormal basis vectors for ran(a) is then easily shown to be {[0; 0; 0; 1; 0], [0; 0; 0; 0; 1]}, since these are obviously orthonormal to ran(a). As for the null space, an argument identical to the one used in Part 1 shows that an orthonormal basis for null(a) is the empty basis, and an orthonormal basis for null(a) is {[1; 0; 0], [0; 1; 0], [0; 0; 1]}. 1 6 9 6 7 4 9 5 7 7 8 8 4 4 5 Answer: We cannot come up with a simple orthonormal basis for the range. As such, we need to resort to the QR factorization of A. The first three columns of Q

CS 322 Homework 4 Solutions 6 are orthonormal basis vectors for ran(a), and the last two columns are orthonormal basis vectors for ran(a). Running [Q,R] = qr(a); in MATLAB gives us 4. 5. 0.0739 0.7940 0.5056 0.4435 ran(a) = span 0.6653 0.5175, 0.2476 0.4851 0.2630, 0.7238 0.4266 0.0976 0.2957 0.0613 0.1703 0.2638 0.1973 ran(a) 0.4607 = span 0.2436 0.8050, 0.0759 0.2841 0.0741 0.1036 0.9323 We can, however, come up with a simple orthonormal basis for null(a) and null(a) by using the knowledge that the matrix is full rank. Much like in part 1 and 2, an identical argument shows that an orthonormal basis for null(a) is the empty basis, and an orthonormal basis for null(a) is {[1; 0; 0], [0; 1; 0], [0; 0; 1]}. 1 6 7 0 0 8 5 4 0 0 2 3 9 0 0 Answer: Because it is full rank, it follows from an argument similar to part 1 that ran(a) = span{[1; 0; 0], [0; 1; 0], [0; 0; 1]} and the orthonormal basis for ran(a) is the empty basis. Here, though, we have a nontrivial nullspace: any vector with zeros in the first three entries produces the zero vector. As such, it follows that null(a) = span{[0; 0; 0; 1; 0], [0; 0; 0; 0; 1]}. An orthogonal basis for the subspace perpendicular to these vectors is easy as well; null(a) = span{[1; 0; 0; 0; 0], [0; 1; 0; 0; 0], [0; 0; 1; 0; 0]}. 3 9 1 4 5 7 6 7 7 1 3 4 8 2 4 Answer: Much like part 4, because it is full rank an orthonormal basis for the range is trivial to compute, and it follows that ran(a) = span{[1; 0; 0], [0; 1; 0], [0; 0; 1]} and the orthonormal basis for ran(a) is the empty basis. We know we have a nontrivial nullspace of dimension 2 because any set of 5 vectors in R 3 must be linearly dependent, and we know the size of the subspace through the rank-nullity theorem. However, it is not easy to see what an orthonormal basis for the null space should be, and so we need to resort to the QR factorization of A T. If A T = QR, then A = R T Q T, and we can see that any linear combination of the last two rows in Q T (and thus the last two columns of Q) will be multiplied by zeros in R T and so will

CS 322 Homework 4 Solutions 7 result in the zero vector. Thus, the last two columns of Q is an orthonormal basis for the null space, and the first three columns are an orthonormal basis for null(a) T. Using MATLAB to compute the QR factorization, we obtain: 0.7428 0.3000 0.0611 null(a) = span 0.1433 0.6511, 0.5792 0.2271 0.3318 0.0062 0.6425 0.2611 0.4791 0.2459 null(a) 0.7833 = span 0.0870 0.3482, 0.2011 0.6695 0.3840, 0.0820 0.6871 0.4443 0.4352 0.3666 0.5131