Graphics Programs Reference
In-Depth Information
the lower triangular portion of the coefficient matrix anyway, its contents are
irrelevant.
Back substitution phase After Gauss elimination the augmented coefficient ma-
trix has the form
A 11 A 12 A 13
···
A 1 n
b 1
0
A 22 A 23
···
A 2 n
b 2
A
b
00 A 33
···
A 3 n
b 3
=
.
.
.
.
.
000
···
A nn
b n
The last equation, A nn x n =
b n , is solvedfirst, yielding
x n =
b n /
A nn
(2.9)
x k + 1 have been
already been computed (in thatorder), and we are abouttodetermine x k from the k th
equation
Considernow the stageofback substitutionwhere x n
,
x n 1
,...,
A kk x k
+
A k , k + 1 x k + 1
+···+
A kn x n
=
b k
The solutionis
b k
A kj x j 1
n
x k =
A kk , k
=
n
1
,
n
2
,...,
1
(2.10)
j
=
k
+
1
The corresponding algorithm forback substitutionis:
fork=n:-1:1
b(k) = (b(k) - A(k,k+1:n)*b(k+1:n))/A(k,k);
end
gauss
The function gauss combines the elimination and the back substitutionphases.Dur-
ing back substitution b isoverwrittenbythe solutionvector x ,sothat b contains the
solutionupon exit.
function [x,det] = gauss(A,b)
%SolvesA*x=bbyGausseliminationandcomputesdet(A).
% USAGE: [x,det] = gauss(A,b)
if size(b,2) > 1; b = b'; end
% b must be column vector
n = length(b);
Search WWH ::




Custom Search