Handout Materi
Handout Materi
diagonal tridiagonal
0 ∗ ∗ ∗ 1 0 ∗ ∗ ∗ 1
B ∗ ∗ C B ∗ ∗ ∗ C
B ∗ ∗ B ∗ ∗ ∗
C B C
B C C
B ∗ ∗ C B
∗ ∗ ∗
C
←
→ ...
B C B C
∗ 2c ∗ ∗ ∗ ∗
B C B C
B C B C
∗ ∗ ∗ ∗ ∗
B C B C
B C B C
∗ ∗ ∗ ∗ ∗
B C B C
B C B C
@
∗ ∗
A @ ∗ ∗ ∗ A
∗ ∗ ∗ ∗ ∗ ∗
• Of course, the following general rule also applies to numerical linear algebra:
Have a close look at the way a problem is posed before starting, because even the
simple term
y := A · B · C · D · x , A, B, C, D ∈ Rn , x ∈ Rn ,
y := (((A · B) · C) · D) · x
y := A · (B · (C · (D · x)))
Vector Norms
• Examples for vector norms relevant in our context (verify the above norm
attributes for every one):
Pn
– Manhattan norm: kxk1 := i=1 |xi |
n
pP
– Euclidean norm: kxk2 := 2
i=1 |xi | (the common vector length)
– maximum norm: kxk∞ := max1≤i≤n |xi |
Matrix Norms
• By extending the concept of vector norm, a matrix norm can be defined or rather
induced according to
kAk := max kAxk .
kxk=1
maxkxk=1 kAxk
κ(A) := .
minkxk=1 kAxk
– κ(A) indicates how strongly the norm sphere is deformed by the matrix A or
by the respective linear mapping.
– In case of the identity matrix I (ones in the diagonal, zeros everywhere else)
and for certain classes of matrices there are no deformations at all – in these
cases we have κ(A) = 1 .
– For non-singular A, we have
κ(A) = kAk · kA−1 k .
5. Direct Methods for Solving Systems of Linear Equations
Numerical Programming I (for CSE), Hans-Joachim Bungartz page 7 of 27
Preliminary Remarks Gaussian Elimination Choice of Pivot Applications
• Because it’s so nice and so important, once more the result we achieved for the
condition:
kδxk 2εκ(A)
≤ .
kxk 1 − εκ(A)
– The bigger the condition number κ(A) is, the bigger our upper bound on the
right for the effects on the result becomes, the worse the condition of the
problem “solve Ax = b” gets.
– The term “condition number” therefore is chosen reasonably – it represents a
measure for condition.
– Only if εκ(A) 1, which is restricting the order of magnitude of the
acceptable input perturbations, a numerical solution of the problem makes
sense. In this case, however, we are in control of the condition.
– At the risk of seeming obtrusive: This only has to do with the problem (i.e. the
matrix) and nothing to do with the rounding errors or approximate
calculations!
• Note: The condition of a problem can often be improved by adequate rearranging.
If the system matrix A in Ax = b is ill-conditioned, the condition of the new system
matrix M A in M Ax = M b might be improved by choosing a suitable prefactor M .
The Residual
r = b − Ax̃ ⇔ Ax̃ = b − r
shows that x̃ can be interpreted as exact result of slightly perturbed input data
(A original, instead of b now b − r) for small residual; therefore, x̃ is an
acceptable result in terms of chapter 2!
• We will mainly use the residual for the construction of iterative solving methods in
chapter 7: In contrast to the unknown error, the residual can easily be determined
in every iteration step.
• The classical solution method for systems of linear equations, familiar from linear
algebra, is Gaussian elimination, the natural generalization of solving two
equations with two unknowns:
– Solve one of the n equations (e.g. the first one) for one of the unknowns (e.g.
x1 ).
– Replace x1 by the resulting term (depending on x2 , . . . , xn ) in the other
n − 1 equations – therefore, x1 is eliminated from those.
– Solve the resulting system of n − 1 equations with n − 1 unknowns
analogously and continue until an equation only contains xn , which can
therefore be explicitly calculated.
– Now, xn is inserted into the elimination equation of xn−1 , so xn−1 can be
given explicitly.
– Continue until at last the elimination equation of x1 provides the value for x1
by inserting the values for x2 , . . . , xn (known by now).
• Simply spoken, the elimination means that A and b are modified such that there
are only zeros below a1,1 in the first column. Note that the new system (consisting
of the first equation and the remaining x1 -free equations), of course, is solved by
the same vector x as the old one!
5. Direct Methods for Solving Systems of Linear Equations
Numerical Programming I (for CSE), Hans-Joachim Bungartz page 11 of 27
Preliminary Remarks Gaussian Elimination Choice of Pivot Applications
The Algorithm
Gaussian elimination:
for j from 1 to n do
for k from j to n do r[j,k]:=a[j,k] od;
y[j]:=b[j];
for i from j+1 to n do
l[i,j]:=a[i,j]/r[j,j];
for k from j+1 to n do a[i,k]:=a[i,k]-l[i,j]*r[j,k] od;
b[i]:=b[i]-l[i,j]*y[j]
od
od;
for i from n downto 1 do
x[i]:=y[i];
for j from i+1 to n do x[i]:=x[i]-r[i,j]*x[j] od;
x[i]:=x[i]/r[i,i]
od;
initial system
1 2 −2 −1 1 −8 1 0 0 0 0
0 1 0 1 0 1
B 2 3 −3 2 3 C B −34 C B 0 1 0 0 0 C
1 2 5 3 −2 C , 43 C , 0 0 1 0 0
B C B C B C
B B B C
@ 3 −3 2 1 −2 A @ 19 A @ 0 0 0 1 0 A
1 2 3 −1 4 57 0 0 0 0 1
we have L · R = A
• Together with the matrix A, the matrices L and R appear in the algorithm of
Gaussian elimination. We have (cf. algorithm):
– In R, only the upper triangular part (inclusive the diagonal) is populated.
– In L, only the strict lower trianguler part is populated (without the diagonal).
– If filling the diagonal in L with ones, we get the fundamental relation
A = L·R.
Ax = LRx = L(Rx) = Ly = b.
LU Factorization
LU factorization:
for i from 1 to n do
for k from 1 to i-1 do
l[i,k]:=a[i,k];
for j from 1 to k-1 do l[i,k]:=l[i,k]-l[i,j]*u[j,k] od;
l[i,k]:=l[i,k]/u[k,k]
od;
for k from i to n do
u[i,k]:=a[i,k];
for j from 1 to i-1 do u[i,k]:=u[i,k]-l[i,j]*u[j,k] od
od
od;
for i from 1 to n do
y[i]:=b[i];
for j from 1 to i-1 do y[i]:=y[i]-l[i,j]*y[j] od
od;
for i from n downto 1 do
x[i]:=y[i];
for j from i+1 to n do x[i]:=x[i]-u[i,j]*x[j] od;
x[i]:=x[i]/u[i,i]
od;
Discussion of LU factorization
• To comprehend the first part (the decomposition into the factors L and R), start
with the general formula for the matrix product:
n
X
ai,k = li,j · uj,k .
j=1
• It is clear: If you fight your way through all variables with increasing row and
column indices (the way it’s happening in the algorithm, starting at i = k = 1),
every li,k and ui,k can be calculated one after the other – on the right hand side,
there is always something that has already been calculated!
• The forward substitution (second i-loop) follows and – as before at Gaussian
elimination – the backward substitution (third and last i loop).
• It can be shown that the two methods “Gauss elimination” and “LU factorization”
are identical in terms of carrying out the same operations (i.e. they particularly
have the same cost); only the order of the operations is different!
• In the special case of positive definite matrices A (A = AT and xT Ax > 0 for all
x 6= 0), this can be accomplished even cheaper than with the algorithm just
shown:
– decompose the factor U of A = LU into a diagonal matrix D and an upper
triangular matrix Ũ with ones at the diagonal (this is always possible):
AT = (L · D · Ũ )T = Ũ T · D · LT = L · D · Ũ = A ,
A = L · D · LT =: L̃ · L̃T ,
if splitting the diagonal factor D in equal shares into the triangular factors
√
( ui,i in both diagonals; the values ui,i are all positive because A is positive
definite).
• The method described above, with which the calculation of the ui,k , i 6= k, in the
LU factorization can be avoided and with that about half of the total computing
time and required memory, is called Cholesky factorization oder Cholesky
decomposition. We write A = LLT .
Cholesky factorization:
for k from 1 to n do
l[k,k]:=a[k,k];
for j from 1 to k-1 do l[k,k]:=l[k,k]-l[k,j]ˆ2 od;
l[k,k]:=(l[k,k])ˆ0.5;
for i from k+1 to n do
l[i,k]:=a[i,k];
for j from 1 to k-1 do l[i,k]:=l[i,k]-l[i,j]*l[k,j] od;
l[i,k]:=l[i,k]/l[k,k]
od
od;
• Of course, the algorithm above only delivers the triangular decomposition. As
before, forward and backward substitution still have to be carried out to solve the
system of linear equations Ax = b.
• From this, calculate L (i.e. the lower triangular part) column by column, starting in
every column with the diagonal element
v
k
X
u
u k−1
X
2 2 ,
ak,k = lk,j , lk,k := tak,k − lk,j
j=1 j=1
Pivot Search
holds, where Ei denotes the emissivity of the patches (how much light is
newly produced and emitted – especially important for light sources), %i the
absorption and Fij the form factor. In short: On patch i there is the light
which is produced (emitted) there or has arrived from other patches.
5. Direct Methods for Solving Systems of Linear Equations
Numerical Programming I (for CSE), Hans-Joachim Bungartz page 26 of 27
Preliminary Remarks Gaussian Elimination Choice of Pivot Applications
hold. Here, θi denotes the angle between the normal of patch i and the
vector of length r which connects the centers of the patches i and j. The
term Aj denotes the area of patch j, and Vij indicates the visibility (1 for free
sight from patch i to patch j, 0 else).
• The relation above obviously forms a system of linear equations – n equations
with n variables Bi .