why i am not getting the exact answer when i use lu built in function?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
A=[25 5 1;64 8 1;144 12 1];
C=[106.8;177.2;279.2];
[L,U] = lu(A)
L =
0.1736 1.0000 0
0.4444 0.9143 1.0000
1.0000 0 0
U =
144.0000 12.0000 1.0000
0 2.9167 0.8264
0 0 -0.2000
and the manual solution is
L=
1 0 0
2.56 1 0
5.76 3.5 1
U=
25 5 1
0 -4.8 -1.56
0 0 0.7
0 comentarios
Respuestas (1)
John D'Errico
el 16 de Nov. de 2017
Editada: John D'Errico
el 16 de Nov. de 2017
An LU factorization is not unique. ONE such solution is the one that you came up with, probably due to an un-pivoted LU. The 25 in the (1,1) element of U suggests that you did no pivoting. For reasons of numerical computation, pivoting should always be used. If you computed an un-pivoted LU, then it will be less stable.
READ THE HELP FOR LU. READ THE HELP. ALWAYS.
help lu
[L,U] = lu(A) stores an upper triangular matrix in U and a
"psychologically lower triangular matrix" (i.e. a product of lower
triangular and permutation matrices) in L, so that A = L*U. A can be
rectangular.
The "psychologically lower triangular" result is due to the need for pivoting for stability.
For example, your code, which seems to lack pivoting, will fail to produce a viable result for a matrix like this:
A =[ 0 5 1
64 8 1
144 12 1];
which is indeed non-singular. But the built-in LU will have no problem.
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!