Question: Q3. (QR decomposition) Write a python code for solving a system of linear equations by QR decomposition. Written in matrix form, a system of linear

 Q3. (QR decomposition) Write a python code for solving a system

Q3. (QR decomposition) Write a python code for solving a system of linear equations by QR decomposition. Written in matrix form, a system of linear equations is expressed as Ax b. The QR decomposition on A gives A = QR. Then, the equations become QRx = b. We can solve Rx = Qb for x by the backward substitution. 1. Define a function qr_decomposition(A) which takes in A, does QR decomposition by scipy.linalg.qr(), and returns the orthogonal matrix Q and the upper triangular matrix R. 2. Define a function solve_by_ar_decomp (A, b) which takes in A and b, does QR decomposition by calling qr_decomposition(A) defined in Q3.1, print out the result of QR decomposition (i.e., Q and R), does backward_substitution by calling backward_subs() defined in Q1.2 on R and Qb and returns the solution x. 3. Apply the function solve_by_ar_decomp (A, b) defined in Q3.2 to solve the following equations: 13 2 -3 X 1 -44 0.9 1 1 4. Solve the same equations in Q3.3 by scipy.linalg. solve() directly. C 1 -1

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!