Graphics Programs Reference
In-Depth Information
A(i,k) = lambda;
end
end
end
Solution phase Considernow the procedurefor solving Ly
=
b by forward substi-
tution. The scalar form of the equations is(recall that L ii =
1)
y 1
=
b 1
L 21 y 1 +
y 2 =
b 2
.
L k 1 y 1 +
L k 2 y 2 +···+
L k , k 1 y k 1 +
y k =
b k
.
Solving the k th equation for y k yields
k
1
y k =
b k
=
,
,...,
L kj y j , k
2
3
n
(2.14)
j
=
1
Letting y overwrite b , weobtain the forward substitutionalgorithm:
fork=2:n
y(k)= b(k) - A(k,1:k-1)*y(1:k-1);
end
The back substitutionphase for solving Ux
=
y is identicaltothat usedinthe
Gauss eliminationmethod.
LUsol
Thisfunction carries out the solutionphase (forward and back substitutions). It is
assumed that the original coefficient matrix has beendecomposed,sothat the input
is A
=
\
.
The contents of b are replacedby y during forward substitution. Similarly,
back substitution overwrites y with the solution x
[ L
U ]
.
functionx=LUsol(A,b)
% Solves L*U*b = x, where A contains both L and U;
%thatis,Ahastheform[L\U].
%USAGE:x=LUsol(A,b)
Search WWH ::




Custom Search