Question: Implement QR factorization on the square matrix A with the Gram-Schmidt algorithm. Implement the factorization as a function in Python that only uses simple Numpy

Implement QR factorization on the square matrix A with the Gram-Schmidt algorithm. Implement the factorization as a function in Python that only uses simple Numpy functions, f.ex. numpy.dot and numpy.norm. Find the QR factorization of the matrix A = numpy.array([[1,2,0],[0,1,1],[1,0,1]]) with your code, and calculate the estimation error in the factorization, ||A - QR|| (it should be a number very close to zero).

Use the following code, and prove that it works on a couple of square matrices, both matrices with linearly dependent columns and linearly independent columns:

import numpy as np def qr(A): """ QR factorization input: square matrix A output: Q, R, b, where Q is a n x n matrix, with orthonormal column vectors, R n x n are the coefficients of the upper triangle matrix, so that A=QR b is True if the columns in A are linearly independent, else False """ n,k = A.shape # n is the number of rows, k is the number of columns assert(n == k) # A has to be a square matrix independent_columns = true # are the columns linearly independent? Q = np.zeros((n,n)) # starts with this initialized matrix R = np.zeros((n,n)) # triangle matrix, treated as complete matrix # enter code here # ... return Q,R,independent_columns

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!