Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1 ANS Please answer Q2 and SHOW thepython code (working proof) with a picture as well Q2. (LU decomposition) Write a python code for solving

image

Q1 ANS

image

Please answer Q2 and SHOW thepython code (working proof) with a picture as well

Q2. (LU decomposition) Write a python code for solving a system of linear equations by LU decomposition. Written in matrix form, a system of linear equations is expressed as Ax = b. The pivoted LU decomposition on A gives A = PLU. Then, the equations become PLUX = b. We can firstly solve Lz PTb for z by the forward substitution, and finally solve Uxz for x by the backward substitution. 1. Define a function plu_decomposition (A) which takes in A, does pivoted LU decomposition by scipy.linalg.lu(), and returns the permutation matrix P, the lower triangular matrix L and the upper triangular matrix U. 2. Define a function forward_subs (L, Pb) which takes in L and Pb, does forward substitution, and returns the result after forward substitution z. 3. Define a function solve_by_lu_decomp (A, b) which takes in A and b, does LU decomposition by calling plu_decomposition (A) defined in Q2.1, print out the result of LU decomposition (i.e., P. L and U), does forward substitution by calling forward_subs() defined in Q2.2 on L and PTb and returns z, does backward_substitution by calling backward_subs() defined in Q1.2 on U and z and returns the solution x. 4. Apply the function solve_by_lu_decomp (A, b) defined in Q2.3 to solve the following equations: 3 2 30-6 = 1-4 -1 1 31 5. Solve the same equations in Q2.4 by scipy.linalg.solve() directly. (25 marks) 9 -12

Step by Step Solution

3.48 Rating (145 Votes )

There are 3 Steps involved in it

Step: 1

The code in the image provided does not correspond to the LU decomposition task described Instead th... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

College Mathematics for Business Economics Life Sciences and Social Sciences

Authors: Raymond A. Barnett, Michael R. Ziegler, Karl E. Byleen

12th edition

321614003, 978-0321614001

More Books

Students also viewed these Programming questions

Question

Find the slope of the graph of equation. -x + 8y = 4

Answered: 1 week ago