Q T A = R ))) ) = A n 1 R

Similar documents
Numerical Methods. Elena loli Piccolomini. Civil Engeneering. piccolom. Metodi Numerici M p. 1/??

Computational Methods. Least Squares Approximation/Optimization

9. Numerical linear algebra background

9. Numerical linear algebra background

Inverses. Stephen Boyd. EE103 Stanford University. October 28, 2017

Linear Least squares

STAT 309: MATHEMATICAL COMPUTATIONS I FALL 2018 LECTURE 9

Lecture 6. Numerical methods. Approximation of functions

Matrix decompositions

Lecture 3: QR-Factorization

Orthogonal Transformations

Linear Least-Squares Data Fitting

AMS526: Numerical Analysis I (Numerical Linear Algebra)

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.

Problem 1. CS205 Homework #2 Solutions. Solution

Lecture 6, Sci. Comp. for DPhil Students

MATH 3511 Lecture 1. Solving Linear Systems 1

be a Householder matrix. Then prove the followings H = I 2 uut Hu = (I 2 uu u T u )u = u 2 uut u

MATH 350: Introduction to Computational Mathematics

Review Questions REVIEW QUESTIONS 71

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

Orthogonalization and least squares methods

Cheat Sheet for MATH461

AM 205: lecture 8. Last time: Cholesky factorization, QR factorization Today: how to compute the QR factorization, the Singular Value Decomposition

Computational Linear Algebra

Matrices. Chapter What is a Matrix? We review the basic matrix operations. An array of numbers a a 1n A = a m1...

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

14.2 QR Factorization with Column Pivoting

Notes on Solving Linear Least-Squares Problems

2. Linear algebra. matrices and vectors. linear equations. range and nullspace of matrices. function of vectors, gradient and Hessian

POLI270 - Linear Algebra

The Full-rank Linear Least Squares Problem

ANALYTICAL MATHEMATICS FOR APPLICATIONS 2018 LECTURE NOTES 3

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

7. Dimension and Structure.

Algebra C Numerical Linear Algebra Sample Exam Problems

Linear Analysis Lecture 16

MATH 532: Linear Algebra

Stability of the Gram-Schmidt process

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

CSL361 Problem set 4: Basic linear algebra

ECEN 615 Methods of Electric Power Systems Analysis Lecture 18: Least Squares, State Estimation

Orthonormal Transformations and Least Squares

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

Lecture 9: Numerical Linear Algebra Primer (February 11st)

6.4 Krylov Subspaces and Conjugate Gradients

Basic Concepts in Linear Algebra

B553 Lecture 5: Matrix Algebra Review

MATH 22A: LINEAR ALGEBRA Chapter 4

12. Perturbed Matrices

Numerical Linear Algebra Homework Assignment - Week 2

Review of Basic Concepts in Linear Algebra

ENGG5781 Matrix Analysis and Computations Lecture 8: QR Decomposition

Preliminary/Qualifying Exam in Numerical Analysis (Math 502a) Spring 2012

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

MATH 167: APPLIED LINEAR ALGEBRA Least-Squares

The QR Factorization

Math 405: Numerical Methods for Differential Equations 2016 W1 Topics 10: Matrix Eigenvalues and the Symmetric QR Algorithm

Numerical Linear Algebra

Linear Algebra in Actuarial Science: Slides to the lecture

Linear Algebra and Matrices

IV. Matrix Approximation using Least-Squares

Orthonormal Bases; Gram-Schmidt Process; QR-Decomposition

1 9/5 Matrices, vectors, and their applications

Numerical Methods - Numerical Linear Algebra

13-2 Text: 28-30; AB: 1.3.3, 3.2.3, 3.4.2, 3.5, 3.6.2; GvL Eigen2

Next topics: Solving systems of linear equations

Applied Numerical Linear Algebra. Lecture 8

AMS526: Numerical Analysis I (Numerical Linear Algebra)

STAT 309: MATHEMATICAL COMPUTATIONS I FALL 2018 LECTURE 13

Midterm for Introduction to Numerical Analysis I, AMSC/CMSC 466, on 10/29/2015

Linear Algebra. The analysis of many models in the social sciences reduces to the study of systems of equations.

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

MS&E 318 (CME 338) Large-Scale Numerical Optimization

Linear Algebra, part 3 QR and SVD

Matrix Algebra for Engineers Jeffrey R. Chasnov

Least-Squares Systems and The QR factorization

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

This can be accomplished by left matrix multiplication as follows: I

Glossary of Linear Algebra Terms. Prepared by Vince Zaccone For Campus Learning Assistance Services at UCSB

Gaussian Elimination and Back Substitution

October 25, 2013 INNER PRODUCT SPACES

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

HW2 Solutions

Numerical Linear Algebra Primer. Ryan Tibshirani Convex Optimization /36-725

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

5 Selected Topics in Numerical Linear Algebra

LinGloss. A glossary of linear algebra

The QR Decomposition

Preliminary Examination, Numerical Analysis, August 2016

LU Factorization. LU factorization is the most common way of solving linear systems! Ax = b LUx = b

Lecture 4 Orthonormal vectors and QR factorization

Math 407: Linear Optimization

Chapter 1. Matrix Algebra

Matrix decompositions

Matrix & Linear Algebra

Data fitting. Ideal equation for linear relation

Practical Linear Algebra: A Geometry Toolbox

QR-decomposition. The QR-decomposition of an n k matrix A, k n, is an n n unitary matrix Q and an n k upper triangular matrix R for which A = QR

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

Transcription:

Q T A = R As with the LU factorization of A we have, after (n 1) steps, Q T A = Q T A 0 = [Q 1 Q 2 Q n 1 ] T A 0 = [Q n 1 Q n 2 Q 1 ]A 0 = (Q n 1 ( (Q 2 (Q 1 A 0 }{{} A 1 ))) ) = A n 1 R Since Q T A = R and Q T = Q 1 we have, after multiplying this expression by Q, QR = Q(Q T A) = (QQ T )A = A Exercise: Show that the operation count for this decomposition is twice that for the LU decomposition CSCD37H Analysis of Numerical Algorithms p55/183

SolvingAx = b whena = QR To solve the linear system Ax = b using QR we note that Q need not be explicitly computed it need only be represented by retaining the vectors u 1,u 2 u n 1 and the scalars u 1 2 2, u 2 2 2, u n 1 2 2 We observe that, A = QR = Q 1 Q 2 Q n 1 R, and this allows us to solve Ax = b as But QRx = b, or Rx = Q 1 b and we have that, Q 1 = Q T = Q n 1 Q n 2 Q 1 Rx = (Q n 1 (Q n 2 ( ( Q 1 b }{{} z 1 ) )) CSCD37H Analysis of Numerical Algorithms p56/183

Efficient Implementation ofqr This suggests the following efficient algorithm: -set z = b ; -for j = 1,2 (n 1) -set z = Q j z ( solve Q j z j = z j 1 ) -end -solve the triangular system Rx = z Exercise: Given that theq j are represented by the vectors,u j and the scalars u j 2 2, determine the operation count for the above algorithm and compare it with the that for the standard LU algorithm (Recall that computing Q j v for an arbitrary vector v can be done using fact that Q j v = v + γu j, where γ = 2 ut j v u j ) 2 2 CSCD37H Analysis of Numerical Algorithms p57/183

Error Bounds for the QR Method One can show (analogous to GE) that, if the above QR algorithm is implemented in floating point arithmetic, then the computed solution, x, will satisfy, and (A+E) x = b where E = (e i j ), e i j 102 max r=0,1 n 1 [ A r 2 ](2n 2 +n) Q 2 µ But Q 2 = 1 and A r 2 Q r 2 A r 1 2 = A r 1 2 for r = 1,2 (n 1), so max [ A r 2 ] = A 0 2 = A 2, r=0,1 n 1 and e i j 102 A 2 (2n 2 +2)µ CSCD37H Analysis of Numerical Algorithms p58/183

Linear Least Squares In many applications the linear systems of equations that arise do not have the same number of equations as unknowns We can then can solve the equations in a least squares sense The Basic Problem Given m linear equations in n unknowns, Ac b, A R m n, c R n, b R m Determine the vector c that minimises, Ac b 2 Note that other norms (, or 1 for example) are not differentiable and the corresponding minimisation problem is more difficult to analyse and the algorithms more complicated CSCD37H Analysis of Numerical Algorithms p59/183

An Example - Data Fitting Let the unkown vector be c R n, the coefficients defining a polynomial p n (s), p n (s) = c 1 +c 2 s +c n s n 1 Assume we wish to approximate a function f(s) by p n (s) and we know that f(s i ) f i for i = 1,2 m Let A R m n be defined by a i j = s j 1 i, i = 1,2 m, j = 1,2 n Then it is easy to see that if, s = (s 1,s 2 s m ) T, f = (f 1,f 2 f m ) T, p n (s 1 ) Ac = p n (s 2 ) p n (s m ) and therefore our task is to determine c such that, Ac f 2 is minimised This is a discrete least squares problem, CSCD37H Analysis of Numerical Algorithms p60/183

Data Fitting Ex (cont) If the s i are distinct then A has full rank A is a Vandermonde Matrix If m = n, A can be badly conditioned For the general LLSQ Problem we have 3 cases: m = n: Standard case with a unique solution if A has full rank, n, (use LU or QR) m > n: Overdetermined case (more equations than unknowns) A can have full rank (rank n), or it can be rank deficient (rank < n) m < n: Underdetermined case (fewer equations than unknowns) A can have full rank, m, or it can be rank deficient CSCD37H Analysis of Numerical Algorithms p61/183

The General Overdetermined LLSQ Let the unknown vector be x R n We wish to solve Ax b, where b R m, Ax = a 11 a 12 a 1n a 21 a 22 a 2n a m1 a m2 amn x 1 x 2 x n b 1 b 2 b m Let Φ(x) = Ax b 2 2 = (Ax b) T (Ax b) r T (x)r(x) = m i=1 r 2 i(x) CSCD37H Analysis of Numerical Algorithms p62/183

Overdetermined Systems (cont) From standard results in calculus we know that Φ(x) is a minimum when, Φ x j = 0 for Since Φ(x) = m i=1 r2 i (x) we have, Φ x j = = = 2 x j m i=1 m i=1 j = 1,2, n [ m ] ri(x) 2 i=1 x j (r 2 i(x)), But r i (x) = b i +a i 1 x 1 +a i 2 x 2 +a i n x n r i (x) r i(x) x j (= b i + inner product of i th row of A with x, which = b i +inner product of i th column of A T with x) CSCD37H Analysis of Numerical Algorithms p63/183

Overdetermined Systems (cont) Therefore we have, r i (x) x j = x j [Ax b] i, = (a i j ), for i = 1,2, m;j = 1,2, n It then follows that Φ m = 2 r i (x)a i j = 2 ( A T r ) x j j i=1 Therefore to achieve Φ x j = 0 for j = 1,2, n we must have, ( A T r ) = 0, for j = 1,2, n j This is equivalent to asking that, A T r = 0 or A T (Ax b) = 0 CSCD37H Analysis of Numerical Algorithms p64/183

Normal Equations Note that the matrix A T A is n n and nonsingular (if rank(a)=n) and we can solve our LLSQ problem with m > n by solving the linear system, A T Ax = A T b These are the Normal Equations We have shown that any solution to the LLSQ problem must be a solution to the Normal Equations The converse is also true (exercise) The (i,j) th entry of A T A = a T i a j = a T j a i A T A is symmetric (since (A T A) T = A T (A T ) T = A T A) The cost to determine A T A is [n+(n 2 n)/2]m = mn2 +mn 2 flops It can be shown that, once A T A has been formed, solving A T Ax = A T b can be accomplished in n3 6 +O(n2 ) flops CSCD37H Analysis of Numerical Algorithms p65/183

QR for Least Squares We will introduce a QR based algorithm that doesn t require the explicit computation of A T A Consider forming the QR factorization (or Schur decomposition) of the m n matrix A, A = QR = (Q 1 Q 2 Q n )R, where Q is an orthogonal matrix and R is an upper triangular matrix That is, we will determine Q as a product of n Householder reflections: QA = R Q T n(q T n 1 Q T 1A)) ) = R, where eachq i = Q T i is anm m Householder reflection andris anm n (rectangular) upper triangular matrix, CSCD37H Analysis of Numerical Algorithms p66/183

QR for Least Squares (cont) R = 0 0 0 0 0 0 0 0 0 R 0, and R is a square n n upper triangular matrix With such a factorization of A we have, A T A = (QR) T QR = R T Q T QR = R T R, CSCD37H Analysis of Numerical Algorithms p67/183

QR for Least Squares (cont) where R T R = 0 0 0 0 0 0 0 0 0 0 0 0 0 = [ R T 0 ] R 0 = R T R, an n n symmetric matrix CSCD37H Analysis of Numerical Algorithms p68/183

QR for Least Squares (cont) Now solving the Normal Equations to determine x can be done by solving the equivalent linear system, R T Rx = A T b This requires the computation of A T b ( at a cost of nm flops ) and two triangular linear systems (at a cost of n 2 flops) The cost of determining the QR factorization of A is n 2 m+o(nm) and therefore the total cost of this algorithm to determine x is n 2 m+o(nm) flops Note that in most applications m is much larger than n With this approach we have computed the LU (or Cholesky) decomposition of A T A (= R T R ) without forming A T A CSCD37H Analysis of Numerical Algorithms p69/183

Rank Deficient Problems Note that deficient rank implies that for overdetermined problems rank(a) = rank(a T A) < n, while for underdetermined problems rank(a) = rank(aa T ) < m In either case the R we obtain from the QR algorithm will have the same deficient rank In exact arithmetic the rank of a triangular matrix is the number of non-zeros on the diagonal In floating point arithmetic we don t expect to see an exact zero but a reliable indication of rank deficiency is to observe a large value for the ratio of the largest to smallest magnitudes of the diagonal entries In problems where rank deficiency is detected (using this idea) the algorithm can either exit with a warning or attempt to produce a solution to a nearby exactly rank deficient problem CSCD37H Analysis of Numerical Algorithms p70/183