Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 = Q'b 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_gr_decomp (A, b) which takes in A and b, does QR decomposition by calling gr_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 Q'b and returns the solution x. 3. Apply the function solve_by_9r_decomp(A, b) defined in Q3.2 to solve the following equations: 13 2 3 1 -44 -1 22 0.9 7 1 4. Solve the same equations in 23.3 by scipy.linalg. solve directly. (25 marks)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started