Question: Please answer Q3 and SHOW the python code(working proof) with a picture as well Q1. (Gaussian elimination) Write a python code for solving a system

 Please answer Q3 and SHOW the python code(working proof) with a

picture as well Q1. (Gaussian elimination) Write a python code for solving

Please answer Q3 and SHOW the python code(working proof) with a picture as well

Q1. (Gaussian elimination) Write a python code for solving a system of linear equations by Gaussian elimination. Written in matrix form, a system of linear equations is expressed as Ax=b. 1. Define a function forward_elim(A, b) which takes in A and b, does forward elimination, and returns the new A and b after foward elimination. 2. Define a function backward_subs(A, b) which takes in the A and b obtained by foward elimination, does backward substitution, and returns the solution x. 3. Define a function gaussian_elim(a, b) which takes in the initial A and b and returns the solution x. In this function, we need to call the two functions defined in Q1.1 and 21.2. 4. Apply the function gaussian_elim(A, b) defined in Q1.3 to solve the following equations: 2 2 (3 1) ) -(0) (25 marks) 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) Q1. (Gaussian elimination) Write a python code for solving a system of linear equations by Gaussian elimination. Written in matrix form, a system of linear equations is expressed as Ax=b. 1. Define a function forward_elim(A, b) which takes in A and b, does forward elimination, and returns the new A and b after foward elimination. 2. Define a function backward_subs(A, b) which takes in the A and b obtained by foward elimination, does backward substitution, and returns the solution x. 3. Define a function gaussian_elim(a, b) which takes in the initial A and b and returns the solution x. In this function, we need to call the two functions defined in Q1.1 and 21.2. 4. Apply the function gaussian_elim(A, b) defined in Q1.3 to solve the following equations: 2 2 (3 1) ) -(0) (25 marks) 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

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!