# LU factorization

Basically what I need to do is this:

Write an algorithm that finds the LU factorization of the following matrix. The algorithm should perform the necessary elementary row operations to reduce A to U, and store the various multipliers in each step. The output of the program should be two matrices: L and U.

A={{3,1,2}{6,3,4},{3,1,5}}


I can't use any of the built in code for LU or partial pivoting or any of that stuff that will finish it off with one function. I just need a little help getting started being as how I'm still new to programming. I know how I would do it all manually but writing the code for a general algorithm is eluding me. I'll obviously need to use for loops to test if

A[[2,1]]=0, A[[3,1]]=0


And that is about as far as I am. Any help would be greatly appreciated.

• Dupe? – J. M.'s ennui Oct 30 '15 at 3:21
• In any case, you'll want to look up Golub and Van Loan; there's a nice discussion there on how to implement this. – J. M.'s ennui Oct 30 '15 at 3:22
• Problems with your matrix? Check using PseudoInverse[{{3, 1, 2} {6, 3, 4}, {3, 1, 5}}] – thils Oct 30 '15 at 7:03
• @thils, for somebody just starting to understand Gaussian elimination, SVD is like handing a toddler a mountain bike. – J. M.'s ennui Oct 30 '15 at 8:16
• @JM What I am trying to convey is that LU factorization will run into problems for matrices with no inverse or near singular matrices. – thils Oct 30 '15 at 9:05