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
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