Transcript A= M

Linear Equation
Ax  b ; x  ?
A : m x n matrix
b : m - vector
x : n - vector
Example
R1
R2
i1
V1
i2
R3
i3
R4
R5
V2
i R  i  i R  i  i R  V
i  i R  i  i R  V
1
1
1
i
3
2
2
1
2
2
1
2
3
3
3
5
1
2
 i R  i R  i  i R
1
3
3
4
3
2
5
0
0
0
R  R  R
 R

  R
1
2
3
2
3
R
R R
R
2
2
5
5
R
 i   V 
 i    V 
R
   
R  R  R  i   0 
3
4
3
1
5
2
5
3
1
2
Existence & Uniqueness
Existence and Uniqueness of a solution Ax=b
depend on whether the matrix A is singular or
nonsingular.
Nonsingular Matrix satisfies the following:
•A has an inverse, i.e., A-1 such that AA-1=I
•Det(A) 0
•Rank(A)=n
•For any vector z 0, Az 0
Jika matriks A adalah nonsingular, maka A
punya inverse A-1, dan Ax=b selalu
mempunyai solusi unik, untuk setiap b
Jika matriks A adalah singular, maka solusi
Ax=b bergantung pada b, bisa ada atau
bisa tidak ada solusi.
Example 1
2 x  3x  b
1
2
1
5x  4 x  b
1
2
2
 2 3  x   b 
Ax  


b





5 4  x  b 
1
1
2
2
Solusi x adalah unik karena A adalah nonsingular,
berapapun b.
Example 2
2 x  3x  b
1
2
1
4x  6x  b
1
2
2
2 3  x  b 
Ax  


b





4 6  x  b 
1
1
2
2
x
Karena A adalah singular, solusi mungkin ada
mungkin tidak !, bergantung pada b.
Kalaupun ada solusi, pasti solusinya tidak unik
Jika b=[4 7]T, tidak ada solusi untuk x.
Jika b=[4 8]T, maka solusinya:



x

4  2  / 3
Problem Transformations
Ax  b ; x  A b
1
MAz  Mb -  Transforma si
z  MA Mb  A M Mb  A b
1
1
1
zx
Transformasi tidak mengubah solusi, malah
bahkan bisa mempermudah menemukan solusi
1
Example: Permutation
0 0 1   v   v 
1 0 0 v    v 

   
0 1 0 v  v 
1
3
2
1
3
2
P
Matrik permutasi P selalu nonsingular, dan berlaku P-1 = PT.
APz  b
z  AP  b  P A b  P x
x  Pz
1
1
1
1
Example: Diagonal Scaling
Matriks diagonal D= {dij} : semua elemen dij= 0 untuk ij.
ADz  b
z  AD  b  D A b  D x
x  Dz
1
1
1
1
Triangular Linear Systems
2  x   3 
1 2
0  4  6   x     6 

   
0 0  1  x   1 
1
2
3
Triangular Matrix
x3=-1; x2=3; x1=-1
Jika A adalah matrix triangular, solusi lebih mudah ditemukan !
Lakukan transformasi matrik A menjadi matriks triangular !
Triangular Matrix Types
• Lower Triangular Matrix L={lij}: semua
elemen diatas elemen diagonal bernilai nol,
yaitu lij = 0 untuk i < j
• Upper Triangular Matrix U={lij}: semua
elemen dibawah elemen diagonal bernilai nol,
yaitu lij = 0 untuk i > j
NB: Matrix L dan U dapat dipermutasikan
menjadi U dan L dengan matrix permutasi
yang sesuai
Forward Substitution
• Dilakukan dalam memecahkan problem Lx = b dengan
persamaan berikut:
x b /l
1
1
11

i 1

x  b  l x / l
i
i
j 1
ij
j
ii
i  2,,n.
-------------------------Pseudocode------------------------------for j = 1 to n
{loop over columns}
if ljj =0 then stop {stop if matrix is singular}
xj=bj / ljj
{compute solution component}
for i=j+1 to n
bi=bi – lij xj
{update right-hand side}
end
end
Backward Substitution
• Dilakukan dalam memecahkan problem Ux = b dengan
persamaan berikut:
x b /l
n
n
nn

n

x  b  u x / u
i
i
j i 1
ij
j
ii
i  n  1,,1.
-------------------------Pseudocode------------------------------for j = n to 1
{loop over columns}
if uij =0 then stop {stop if matrix is singular}
xj=bj / ujj
{compute solution component}
for i=1 to j-1
bi=bi – uij xj {update right-hand side}
end
end
Elementary Elimination Matrix
(Gaussian Transformation)
Dipakai untuk mentransformasi sembarang matriks menjadi
matriks triangular
1


0
M a
0


0
m a /a
k
i
i
0  0  a   a 


        
   

1
0  0  a   a 
    
 m
1  0  a   0 


        
   
  m 0  1  a   0 
, i  k  1, ,n disebut multiplier

k
0
1
1
k
k
k 1
k 1
n
n
Properties of M
• Mk : lower triangular matrix, nonsingular
• Mk=I-mekT, dimana m=[0,…,0,mk+1,..,mn]T (multiplier
vector) dan ek adalah kolom ke k matriks identitas
• Mk-1 = I+mekT adalah sama dg Mk kecuali tanda elemenelemen di bawah diagonal adalah dibalik
• Jika Mj, j>k, adalah matrik elementer yang lain sbgmn
Mk,dengan multiplier vector t, maka
MkMj=I-mekT -tekT +mekT tekT =I-mekT -mekT
Note : ekTt= 0;
Example
a  2 4  2
T
Cari M1 dan M2 !
1 0

Ma 2 1

 1 0
1 0
M a  0 1

0 0.5
1
2
0  2   2





0 4  0
   
1  2 0
0  2   2
0  4    4
   
1  2 0
L M
1
1
1
; L M
2
1
2
0 0
0
0
1
1
M M    2 1 0 ; L L   2
1
0




 1 0.5 1
 1  0.5 1
1
2
1
2
Gaussian Elimination
Jika matrix Gaussian Elimination sudah ditemukan, maka
Ax=b bisa dengan mudah ditransformasi menjadi bentuk
upper triangular
M1Ax=M1b  Kolom PERTAMA matrix A bernilai nol
semua kecuali baris pertama
M2M1Ax=M2M1b  Kolom KEDUA matrix M1A bernilai nol
semua kecuali baris kedua
M3M2M1Ax=M3M2M1b  Kolom KETIGA matrix M2M1A
bernilai nol semua kecuali baris ketiga
MAx=Mn-1…M3M2M1Ax=Mn-1...M3M2M1b
M=Mn-1…M3M2M1
M-1=L
U=MA -> A= M-1U
A=LU
LU Factorization
A=LU
Ax=b  LUx=b  x=?
Forward substitution:
Ly=b
Barkward substitution:
Ux=y
Algorithm of LU Factorization
for k=1 to n-1
if akk=0 then stop
for i=k+1 to n
mik=aik/akk
end
for j=k to n
for i=k+1 to n
aij=aij-mikakj
end
end
end
{Loop over columns}
{stop if pivot is zero}
{compute multipliers
for current column}
{apply transformation
to remaining submatrix}
Example
x
4x
 2x
 4x
2
 2x
 2x


4x
 6x
2
 4x
 10
1
1
1
2
3
3
3
Cari M1, M2 dan M3 lalu temukan L dan U, kemudian
pecahkan x1,x2,dan x3 !
3
6
Problem of LU Factorization
(LUF)
Metode LUF tidak bisa dipakai jika elemen
diagonal matrix A bernilai nol/sangat kecil,
meskipun A adalah nonsingular.
Masalah ini diatasi dengan melakukan
pivoting, yaitu menukar baris matrix yang
elemen diagonalnya nol/sangat kecil dgn
baris yang lain yang elemen diagonalnya
tidak nol./besar
Example 1
0 1 
A

1
0


non-singular BUT
no LU factorization
1 1 1 0 1 1
A

 LU




1 1 1 1 0 0
non-singular and
has LU factorization
Example 2
 1
A

1 1
0<< mach
0
 1
 1 0
M
;
L




 1 /  1
1 /  1
1  
1 

U



0 1  1 /   0  1 /  
In floating-point arithmetic !
1   1 
 1 0  
LU  

A




1 /  1 0  1 /  1 0
Example 2 (contd.)
 1
A

1 1
1 1
A 


1


c
 1 0
1 0
M
;
L




  1
 1 
1  1
1  1 1
1
U





0 1    0 1    0 1
In floating-point arithmetic !
1 0 1 1 1 1
LU  

A




 1 0 1  1
c
Ax=b
1 2 2   x   3 
 4 4 2  x    6 

   
4 6 2  x  10
1
2
3
0 1 0 
P  1 0 0


0 0 1
1
 4 4 2  x   6 
P Ax  1 2 2  x    3   P b

   
4 6 4  x  10
1
1
2
3
1
0 1 0 
M  1 0 0


0 0 1
1
4 4 2   x   6 
M P Ax  0 1 1.5  x   1.5  M P b

   
0 2 2   x   4 
1
1
1
2
3
1
1
1 0 0
P  0 0 1 


0 1 0
2
4 4 2   x   6 
P M P Ax  0 2 2   x    4   P M P b

   
0 1 1.5  x  1.5
1
2
1
1
2
3
2
1
1
0 1 0 
M  1 0 0


0 0 1
2
4 4 2   x   6 
M P M P Ax  0 2 2   x    4   M P M P b

  

0 0 0.5  x   0.5
1
2
2
1
1
2
3
2
2
1
1
L  M  M P M P   P L P L
1
1
2
2
0.25 0.5 1


 1
0 0


1 0
 1
1
1
T
1
T
1
2
2
0.25 0.5 1 4 4 2 




LU  1
0 0 0 2 2 A



1 0 0 0 0.5
 1
LU Factorization by Gaussian Elimination
with Partial Pivoting
for k=1 to n-1
find index p such that
|apk| > |aik| for k ≤ i ≤ n
if p ≠ k then
interchange rows k and p
if akk=0 then
continue with next k
for i=k+1 to n
mik=aik/akk
end
for j=k to n
for i=k+1 to n
aij=aij-mikakj
end
end
end
{Loop over columns}
{search for pivot
current column}
{interchange rows,
if necessary}
{skip current column
if it’s zero already}
{compute multipliers
for current column}
{apply transformation
to remaining submatrix}
Cholesky Factorization
for k=1 to n
akk = sqrt(akk)
for i=k+1 to n
aik=aik/akk
end
for j=k+1 to n
for i=k+1 to n
aij=aij-aikajk
end
end
end
{Loop over columns}
Banded System
d1=b1
for i=2 to n
mi=ai/di-1
di=bi-mici-1
end