Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello. I have this python code (bellow) and I need to solve, still in python , t

ID: 3855952 • Letter: H

Question

Hello. I have this python code (bellow) and I need to solve, still in python, the linear systems Va = y and Vb = y using algorithms created by factorization. 1. LU with and without pivoting, 2. by the polar decomposition of A and 3. QR with and without pivoting.

import random import numpy as np k = 2 # number of equally spaced elements space = 0.3 #value of the spacing between equally spaced elements x = [i"space for i in range(k)] #equally spaced xk elements for i in range(k,6): x.append(-1l+random.random0 ) #randomly spaced rest of the elements y = [np.exp(i) for i imx] #np.sinO, np.cos(), np.expl, np.log0, np.log100, np.logo can be used V = np.vander(x) #constructs vandermonde matrix of the vector X. U = np.vander(y) #constructs vandermonde matrix of the vector 'y.

Explanation / Answer

We denote in this paper the k th column of a matrix A by cAk. Similarly we shall use rAj to refer to the j th row of A. Furthermore we shall use || · || for the euclidian norm of a vector. The classical Schmidt algorithm consists of n steps. In each of them one cAk is used to produce a new column vector of Q. Consider the k th step. We already have k 1 orthonormal vectors cQ1 , . . . , cQk1 . We take cAk and compute the projections rikcQi with rik := cQT i cAk. Then we form the vector bk = cAk k X1 i=1 rikcQi (2) which is orthogonal to cQ1 , . . . , cQk1 and thus we get cQk := bk/||bk||. (3) This leads to the following algorithm where A is overwritten by Q: for k := 1 to n do begin for i := 1 to k 1 do begin s := 0 for j := 1 to m do s := s + aj,i aj,k; rik := s; end; for i := 1 to k 1 do begin to be left out for modified Gram-Schmidt. for j := 1 to m do ajk := aj,k aj,i ri,k; end; s := 0; for j := 1 to m do s := s + a 2 j,k; rkk := sqrt(s); for j := 1 to m do ajk := ajk/rk,k; end k If we look at Example 1 we see that the resulting matrix Q is not orthogonal at all. The algorithm is unstable. However the product QR equals A perfectly. This is not a special virtue at all since for any arbitrary given nonsingular matrix R we can easily compute a matrix Q row by row by forward substitution from R TQ T = A T . (4) 3 Of course we then have A = QR but in general QTQ 6= I. Notice that if we eliminate the three lines end; for i := 1 to k 1 do begin (5) of the above algorithm then we get a variant of the modified Gram Schmidt algorithm given by Schwarz and Rutishauser [7]. Assuming the existence of the QR decomposition of A one can derive the classical Schmidt algorithm by letting [8]: A = [cA1, . . . , cAn] = [cQ1 , . . . , cQn ] · R i.e. cAk = cQ1 r1k + cQ2 r2k + ... + cQk1 rk1,k + cQk rkk (6) for k := 1, . . . , n. If we suppose that Q and R are computed column by column, the unknown in (6) are r1k, ..., rkk and cQk . By multiplying (6) from the left with cQT i we get first cQT i cAk = rik, i = 1, . . . , k 1, and rkk, cQk are obtained as in (2), (3).