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.