Hi Mathoverflow


I hope you bear with me that my linear algebra knowledge is a little rusty, but I have a question that might potentially very easy to answer. Nevertheless it's been bugging me for a good 3 hours now.


I'm trying to find the LU decomposition of a matrix in order to find the determinant. This would be a straightforward process if it weren't for the fact that my matrix library (Meshcach) only gives me back one matrix when use their LU factor method (together with a pivot). So when I have the matrix A:



```
Matrix: 3 by 3
2              4              1
4            -10              2 
1              2              4 

```

and I call LUfactor, I get the pivot p: 



```
Permutation: size: 3
0->0 1->1 2->2

```

and the matrix LU:



```
Matrix: 3 by 3
2              4              1 
2            -18              0 
0.5           -0            3.5

```

My question is: How do I find the upper matrix from LU? It seems that the library stores the upper and lower matrix as one single matrix, but I can't figure out how to separate them.


The true upper and lower matrices should be:



```
Lower matrix
1              0              0 
0.5            1              0 
0.25         0.5              1

Upper matrix
4            -10              2 
0             -9              0 
0              0            3.5

```

But I'm not sure how the output of meschach would be used to obtain them. I'm aware that this might partly be an algorithm question and could be argued to belong in stackoverflow instead, but I really think there is a higher chance of running in to somebody math-savy who can figure out what's going on, than there is of running in to a programmer who dealt with exactly this problem before.


I hope somebody can help



Finding the determinant of a matrix with LU composition
The factorization you give at the end ("the true upper and lower matrices") is incorrect. To see why, just check the (1,1) element in your original matrix. Multiplying your $L$ by your $U$ gives 4 for that element, but your original matrix has a 2 there.


Meshcach's factorization is correct. The right $L$ and $U$ matrices are 



```

L =   1 0 0 
      2 1 0
    0.5 0 1

```


```

U = 2   4   1
    0 -18   0 
    0   0 3.5

```

You should be able to read that off of Meshcach's output pretty easily.


