math 612 computational methods for equation solving and
play

MATH 612 Computational methods for equation solving and function - PowerPoint PPT Presentation

MATH 612 Computational methods for equation solving and function minimization Week # 4 Instructor: Francisco-Javier Pancho Sayas Spring 2014 University of Delaware FJS MATH 612 1 / 35 Plan for this week Discuss any problems


  1. MATH 612 Computational methods for equation solving and function minimization – Week # 4 Instructor: Francisco-Javier ‘Pancho’ Sayas Spring 2014 – University of Delaware FJS MATH 612 1 / 35

  2. Plan for this week Discuss any problems you couldn’t solve previous lectures Read Lectures 8, 10, and 11 The first coding assignment is due Friday The other two coding assignments will be cut into smaller pieces Remember that... ... I’ll keep on updating, correcting, and modifying the slides until the end of each week. Important for next week The next collection of chapters of the book (Lectures 12 to 15) are better read than explained. You’ll have a lot of reading next week. FJS MATH 612 2 / 35

  3. MATLAB TIPS FJS MATH 612 3 / 35

  4. Vectorizing what’s not vectorized Imagine you have two row lists of numbers [ t 1 , . . . , t m ] , [ τ 1 , . . . , τ n ] and we want to compute the m × n matrix with values t i − τ j . Here’s how... >> t=[1 2 3]; tau=[0 2 4 6]; >> bsxfun(@minus,t’,tau) ans = 1 -1 -3 -5 2 0 -2 -4 3 1 -1 -3 FJS MATH 612 4 / 35

  5. Reading backwards? If you want to read the columns of a matrix from end to beginning, you can do this... >> A=[1 2 3 4;5 6 7 8;9 10 11 12] A = 1 2 3 4 5 6 7 8 9 10 11 12 >> A(:,end:-1:1) ans = 4 3 2 1 8 7 6 5 12 11 10 9 FJS MATH 612 5 / 35

  6. GRAM-SCHMIDT FJS MATH 612 6 / 35

  7. Review of the classical Gram-Schmidt method For j = 1 to the number of columns of A (assumed to be linearly independent), compute j − 1 j − 1 � � ( q ∗ q i q ∗ v j = a j − i a j ) q i = a j − i a j � �� � i = 1 i = 1 r ij j − 1 � q i q ∗ = ( I − i ) a j = P j a j i = 1 and then q j = 1 r jj = � v j � , v j . r jj FJS MATH 612 7 / 35

  8. Recycled pseudocode Remember that the goal is the reduced QR decomposition A = � Q � R for j = 1 : n % this loop runs on columns of Q and A v j = a j for i = 1 : j − 1 % this loop is the summation sign r ij = q ∗ i a j % the j-th column of R is computed v j = v j − r ij q i end r jj = � v j � 2 q j = 1 r jj v j end FJS MATH 612 8 / 35

  9. A pictorial representation of classical GS A Q R In blue the column of A we are using and the elements of Q and R we are computing. We are in the third go through the loop. The red elements of Q and R have been computed already. The green elements of A are not active in this step. FJS MATH 612 9 / 35

  10. An alternative version of the algorithm (not final yet) Observation j − 1 � P j = I − q i q ∗ i = ( I − q j − 1 q ∗ j − 1 ) ... ( I − q 2 q ∗ 2 )( I − q 1 q ∗ 1 ) i = 1 for j = 1 : n % this loop runs on columns of Q and A v j = a j for i = 1 : j − 1 % loop for progressive projections r ij = q ∗ i v j % we use v j instead of a j v j = v j − r ij q i end r jj = � v j � 2 q j = 1 r jj v j end FJS MATH 612 10 / 35

  11. The final version for j = 1 : n for j = 1 : n v j = a j v j = a j end end for j = 1 : n for i = 1 : n for i = 1 : j − 1 r ii = � v i � 2 q i = 1 r ij = q ∗ i v j r ii v i v j = v j − r ij q i for j = i + 1 : n end r ij = q ∗ i v j r jj = � v j � 2 v j = v j − r ij q i q j = 1 r jj v j end end end Once the vector q i is computed, the projection of all columns onto � q i � is subtracted. The matrix R is computed row-wise now. FJS MATH 612 11 / 35

  12. A pictorial representation of modified GS A Q R In blue the columns of A that are being used are using and the elements of Q and R we are computing. ( A was copied in V and is modified in each step.) We are in the third go through the loop. The red elements of Q and R have been computed already. The green elements of A are not active in this step and won’t be any longer. FJS MATH 612 12 / 35

  13. Operation count We count flops (sums, substractions, multiplications, and division). A norm and a dot-product need 2 m − 1 flops ( m is the number of elements of the vectors). Each run of the internal loop needs 2 m − 1 + 2 m ∼ 4 m flops. Each run of the external loop then needs ∼ 2 m − 1 + m + ( n − i ) 4 m ∼ 3 m + 4 m ( n − i ) and then the total count is n n � � i ∼ 2 mn 2 ∼ 3 mn + 4 m ( n − i ) = 3 mn + 4 m i = 1 i = 1 There’s an amazing geometric interpretation of the operation count in the book that you should really understand. It’s much simpler than this kind of bean counting. FJS MATH 612 13 / 35

  14. HOUSEHOLDER FJS MATH 612 14 / 35

  15. A new goal Given a matrix A with full column rank, compute a full QR decomposition A = QR , Q unitary , R upper triangular The basic idea Given x ∈ C m , we construct 1 u = ( x + σ � x � 2 e 1 ) , σ := sign ( x 1 ) � x + σ � x � 2 e 1 � 2 Then, the Householder reflector H u = I − 2 uu ∗ satisfies H u x = − σ e 1 H u y = y if y ⊥ u , y − 2 u ( u ∗ y ) H u y = for a general vector FJS MATH 612 15 / 35

  16. Householder’s method (rough pseudo-code) Start with A ( 1 ) = A . For increasing j , follow this process j -th column of A ( j ) , x j := c j := elements j to m of x j := sign of the first element of c j σ j 1 v j := ( c j + σ j � c j � 2 e 1 ) � c j + σ j � c j � 2 e 1 � 2 u j := add j − 1 zeros on top of v j A ( j + 1 ) j ) A ( j ) ( I − 2 u j u ∗ := The matrix R = A ( n + 1 ) = ( I − 2 u n u ∗ n ) . . . ( I − 2 u 1 u ∗ 1 ) A is upper triangular. FJS MATH 612 16 / 35

  17. Householder’s method: why it works In the first step, the first column of A ( 2 ) has its last m − 1 elements equal to zero In the second step, u 2 starts with a zero component, so 2 does not modify the first column of A ( 2 ) . H u 2 = I − 2 u 2 u ∗ The vector u 2 is chosen so that the last m − 2 elements of the second column of A ( 3 ) vanish. In the third step, u 3 starts with two zero elements, so H u 3 does not modify the first two columns of A ( 3 ) . The vector u 3 is chose so that the last m − 3 elements of the third column of A ( 4 ) vanish. Et cetera. FJS MATH 612 17 / 35

  18. Householder delivers QR The construction is R = ( I − 2 u n u ∗ n ) . . . ( I − 2 u 1 u ∗ 1 ) A and therefore A = QR , where Q = ( I − 2 u 1 u ∗ 1 ) . . . ( I − 2 u n u ∗ n ) = ( I − 2 u 1 u ∗ 1 ) . . . ( I − 2 u n u ∗ n ) I is a unitary matrix. FJS MATH 612 18 / 35

  19. A picture We are about to begin the fourth step. The elements in red will not be modified any longer. The column in blue is activated to create a short (4 components) reflection vector. All non-red elements will be modified in this step. Zeros (blanks) are untouched. FJS MATH 612 19 / 35

  20. A key point in the algorithm To compute A ( j + 1 ) := ( I − 2 u j u ∗ j ) A ( j ) = A ( j ) − 2 u j ( u ∗ j A ( j ) ) , note that: The first j − 1 columns will not be modified, so we do not need to operate with them. The first j − 1 rows will not be modified (think of each column vector as the sum of two vectors: one will remain the same, the other one will be modified). Instead of working with u j we can work with v j A similar point can be raised in the computation of Q , if this matrix is wanted at all. We can just store the vectors u j and an algorithm to multiply by Q , or, even better, the vectors v j ... FJS MATH 612 20 / 35

  21. LEAST SQUARES FJS MATH 612 21 / 35

  22. An optimization problem Let A be an m × n matrix and b ∈ C m . Find x ∈ C n minimizing � b − Ax � 2 . By x minimizing � b − Ax � 2 we mean ∀ z ∈ C n . � b − Ax � 2 ≤ � b − Az � 2 The vector r = b − Ax is called the residual. We will be able to solve this problem because the norm is the 2 − norm. With other norms this problem is actually quite complicated. The problem might have more than one of them. In principle, we care about having one solution. We also care about the vector Ax , where x is the solution of the minimization problem. FJS MATH 612 22 / 35

  23. An optimization problem (2) The problem of minimizing � b − Ax � 2 is equivalent to minimizing � Ax − b � 2 2 = ( Ax − b ) ∗ ( Ax − b ) It is called the least squares minimization problem . A solution of this problem is called a least squares solution of the system Ax = b . Remark A solution of Ax = b is automatically a least squares solution. A least squares solution might not be a solution though. (Think of the case when Ax = b is not solvable.) FJS MATH 612 23 / 35

  24. An argument leading to a theorem The cast. A matrix A ∈ C m × n , a vector b ∈ C m , the orthogonal projection y = Pb ∈ C m of b onto the range of A . (Here P is the orthogonal projector onto range ( A ) .) The plot. A bystander z ∈ range ( A ) enters the scene. Then b − z = b − y + y − z � �� � � �� � ∈ range ( A ) ⊥ ∈ range ( A ) and therefore (Pythagoras anyone?) � b − z � 2 2 = � b − y � 2 2 + � y − z � 2 2 ≥ � b − y � 2 2 . Denouement. We recognize y = Pb = Ax for some x ∈ C n (by definition of range of A ) and have shown that � b − Ax � 2 2 is minimized ⇐ ⇒ Ax = y = Pb . FJS MATH 612 24 / 35

  25. A chain of conclusions, à la Sherlock x is a least square solution ( x minimizes � b − Ax � 2 ) iff Ax is the projection of b onto range ( A ) iff b − Ax is orthogonal to range ( A ) iff b − Ax is orthogonal to the columns of A iff A ∗ ( Ax − b ) = 0 iff A ∗ Ax = A ∗ b FJS MATH 612 25 / 35

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend