4. (Applying LU and LUP decompositions) In this problem, we'll use the LU/LUP decomposition to solve...

80.2K

Verified Solution

Question

Advance Math

4. (Applying LU and LUP decompositions) In this problem, we'lluse the LU/LUP decomposition to solve a linear system ofequations.

a) For A = [12 -8 13 -1 13;14 11 -5 -5 -7;1 -8 -9 10 8;-11 10 -83 8;-11 -8 4 2 -4] find matrices P, L, and U so that PA = LU usingMatlab's lu function. Based on your results: did Matlab usepivoting during the lu-computation?

b) For b = [4;-4;-5;3;7] solve Ax = b using the LU decompositionas follows. Solving Ax = b is the same as solving PAx = Pb. (With Pfrom a). Since PA = LU, we need to solve LUx = Pb, and we can splitthat into two triangular systems as follows: Ly = Pb, and Ux = y.Solve both of these systems using Matlab's linsolve, state x and yexplicitly.

c) Compare the quality of the x you found in b to the solutionof Ax = b you get from using linsolve. (As in 2d, work with thedifferences Ax - b).

d) You want so solve Ax = b for various vectors b, so youcollect them into a single matrix B. So your goal is to find amatrix X so that AX = B (one column in X for each column in B).Working with P, L, and U from parts a/b we see that this amounts tosolving two systems: LY = PB and UX = Y. For B = [18 -7 -14 10 -14-2 13 12 -15 -15;-15 -14 4 -2 13 -16 15 -3 -15 14;3 12 -10 -17 2 19-17 17 15 5;-1 -8 6 -11 20 -20 -4 -13 3 -6;-20 1 8 17 -17 11 -10-10 2 1] solve these two equations using Matlab's linsolve.

First find Y in LY = PB, and then use that to find X in UX = Y.Check that AX - B is close to the zero matrix.

For this last problem, work with format short (or even formatcompact) so that the matrices don't use up too muchscreenspace.

Answer & Explanation Solved by verified expert
3.5 Ratings (431 Votes)
Matlab code for solving linear systemclear allclose allA matrixA 12 8 13 1 1314 11 5 5 71 8 9 10 811 10 8 3 8118 4 2 4fprintfA matrix is dispvpaA3LU of ALUP luAfprintfLU for A dispvpaLU3fprintfYes partial pivoting done for LU decompositionb    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students