- #1

- 64

- 0

[tex]Ax = b[/tex]

For this purpose, I'm writing a C++ code. I have written both routines for decomposing A matrix to L and U matrices, and for calculating inverse of A matrix.

I may multiply both sides with A

^{-1}:

[tex]Ax = b[/tex]

[tex]A^{-1}Ax = A^{-1}b[/tex]

[tex]x = A^{-1}b[/tex]

Or, I can use LU decomposition:

[tex]Ax = b[/tex]

[tex]A = LU[/tex]

[tex]Ax = LUx = Ly = b[/tex]

[tex]Solve\,\,\,\,\, Ly = b\,\,\,\,\, for\,\,\,\,\, y[/tex]

[tex]Solve\,\,\,\,\, Ux = y\,\,\,\,\, for\,\,\,\,\, x[/tex]

LU decomposition method is said to be faster. But, I'm not sure if these rumors are true for all cases. I have a feeling that the first method (matrix inversion method) would be faster for smaller A matrices.

My question is, how do I prefer which method to use?