ludcmp() fails to find the inverse of a 6x6 matrix


Tobor==Robot^-1
05-16-2005, 01:30 AM
I have been attempting, for about a day now, to get ludcmp to give the correct inverse of the included 6x6 matrix. All results are included below; the decomposition and back-substitution code was not hand-typed. The routine for matrix inversion is the method mentioned in the book, line-by-line. The results were compared with those of a TI-86 calculator and found to be wrong. Thoughts please.

This is the matrix:

|9.0 0.0 0.0 0.0 0.0 0.0 |
|0.0 8.8 0.0 0.0 0.0 -0.4 |
|0.0 0.0 8.8 0.0 0.4 0.0 |
|0.0 0.0 0.0 1.0 0.0 0.0 |
|0.0 0.0 0.4 0.0 1.2 0.0 |
|0.0 -0.4 0.0 0.0 0.0 1.2 |



This is the output of the program:

matrix
9.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 8.800000 0.000000 0.000000 0.000000 -0.400000
0.000000 0.000000 8.800000 0.000000 0.400000 0.000000
0.000000 0.000000 0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 0.400000 0.000000 1.200000 0.000000
0.000000 -0.400000 0.000000 0.000000 0.000000 1.200000

ludcmp(matrix)
9.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 8.800000 0.000000 0.000000 0.000000 -0.400000
0.000000 0.000000 8.800000 0.000000 0.400000 0.000000
0.000000 0.000000 0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 0.045455 0.000000 1.181818 0.000000
0.000000 -0.045455 0.000000 0.000000 0.000000 1.181818

invert(matrix)
0.111111 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.113636 0.000000 0.000000 0.000000 0.038462
0.000000 0.000000 0.113636 0.000000 -0.038462 0.000000
0.000000 0.000000 0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.846154 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.846154

matrix pivot index
1 2 3 4 5 6

Saul Teukolsky
05-18-2005, 09:03 AM
I am unable to reproduce your results. I agree on the output of ludcmp. However, lubksb gives a different matrix inverse than the one you found, and in fact the correct one.

Saul Teukolsky

Tobor==Robot^-1
05-18-2005, 09:07 AM
Thanks Saul for taking the time to try it out. I decided to use Gauss Jordan elimination for my purposes, but your independent verification gives me reason to go back and confirm that everything is indeed in order.