why i am not getting the exact answer when i use lu built in function?

11 次查看(过去 30 天)
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

回答(1 个)

John D'Errico
John D'Errico 2017-11-16
编辑:John D'Errico 2017-11-16
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.
  1 个评论
Eliza
Eliza 2017-11-16
yes ,you are right .I intentionally solve it as un-pivoting LU .Could I solve it also by MATLAB by using LU without pivoting ? because I wanna solve it for this matrix only as checking of my manually solution .

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by