LU Decomposition is also sometimes called LU factorization. It seems to pop up frequently in
college-level classes in
math,
numerical methods and
computer science, but far fewer are examples sighted. And since there are more explanations of just the
theory (as above) than you can shake a stick at, I'll only bore you with a sample work-through.
Sorry about the <PRE>s, folks, but this is matrix math, after all.
We start with the matrix
A=
| 2 1 0 -4 |
| 1 0 0.25 -1 |
| -2 -1.1 0.25 6.2 |
| 4 2.2 0.3 -2.4 |
with solutions b=
| -3 |
| -1.5 |
| 5.6 |
| 2.2 |
Now, we're looking to create two matrices, U and L. To do so, we "zero out" entries below the diagonals using row operations to add a multiple of one row to another.
Blah blah blah. Here's what that means: We want an upper triangular matrix which looks like this:
| X X X X |
| 0 X X X |
| 0 0 X X |
| 0 0 0 X |
This is what U is supposed to look like when we're done. To have a matrix in this form allows back substitution which means you can find out what the 'bottom' one is and work backward from there. But getting back on track, we want to add a multiple of the first row to the second to make the first column of the second row a zero. We'll use the multiple of one-half, so we subtract one half of the first row from the second, giving us:
| 2 1 0 -4 |
| 0 -0.5 0.25 1 |
| -2 -1.1 0.25 6.2 |
| 4 2.2 0.3 -2.4 |
for U and as such we insert 0.5 into our L matrix:
| 1 0 0 0 |
| 0.5 1 0 0 |
| ? ? 1 0 |
| ? ? ? 1 |
We subtract -1 times the first row from the third (i.e. add it), and 2 times it from the fourth, giving us U1=
| 2 1 0 -4 |
| 0 -0.5 0.25 1 |
| 0 -0.1 0.25 2.2 |
| 0 0.2 0.3 5.6 |
and L1=
| 1 0 0 0 |
| 0.5 1 0 0 |
| -1 ? 1 0 |
| 2 ? ? 1 |
Let's zero out the second column. To do this, we utilize the second row, subtracting 0.2 times it from the third and 0.4 times it from the fourth, giving us
U2=
| 2 1 0 -4 |
| 0 -0.5 0.25 1 |
| 0 0 0.2 2 |
| 0 0 0.4 6 |
and L2=
| 1 0 0 0 |
| 0.5 1 0 0 |
| -1 0.2 1 0 |
| 2 0.4 ? 1 |
Leaving us with the third column to zero out, a multiple of twice the third row subtracted from the fourth, giving us
a final U=
| 2 1 0 -4 |
| 0 -0.5 0.25 1 |
| 0 0 0.2 2 |
| 0 0 0 2 |
and L=
| 1 0 0 0 |
| 0.5 1 0 0 |
| -1 0.2 1 0 |
| 2 0.4 2 1 |
So what do you do with them now? We solve Ax=b by making it LUx=b (after all, LU=A) and then find a vector z from Lz=b and then solving Ux=z and (I'll save you the further matrix stuff) then we get x=
| 0.5 |
| 2 |
| -2 |
| 1.5 |
And that's it. If you've got more questions, if I've made a
mistake, or anything like that, /msg me.