Académique Documents
Professionnel Documents
Culture Documents
MATRICES
MATRICES
Examples :
1 2 1 3
2 1 1 0 0
symmetric 1 0 5 , upper tria ngular
4 1
0 0 4 1
1 5 4
0 0 0 1
Determinant of a MATRICES
2 x1 4 x2 3 x3 3 2 4 3 x1 3
2.5 x1 x2 3 x3 5 2.5 1 3 x2 5
x1 6 x3 7 1 0 6 x3 7
Standard form Matrix form
x1 1
x 2 is a solution t o the following equations :
2
x1 x2 3
x1 2 x2 5
x1 2 x2 3
2 x1 4 x2 5
These equations are inconsiste nt
Example
Forward Elimination
6 2 2 4 x1 16
12 8
6 10 x2 26
3 13 9 3 x3 19
6 4 1 18 x4 34
Part 1 : Forward Eliminatio n
Step1 : Eliminate x1 from equations 2, 3, 4
6 2 2 4 x1 16
0 4 2 2 x 6
2
0 12 8 1 x3 27
0 2 3 14 4 18
x
Example
Forward Elimination
Step2 : Eliminate x2 from equations 3, 4
6 2 2 4 x1 16
0 4 2 2 x 6
2
0 0 2 5 x3 9
0 0 4 13 4
x 21
Step3 : Eliminate x3 from equation 4
6 2 2 4 x1 16
0 4 2 2 x 6
2
0 0 2 5 x3 9
0 0 0 3 x4 3
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 18
21
Example
Forward Elimination
Example
Backward Substitution
6 2 2 4 x1 16
0 4 2 2 x 6
2
0 0 2 5 x3 9
0 0 0 3 x4 3
Solve for x4 , then solve for x3 ,... solve for x1
3 95
x4 1, x3 2
3 2
6 2(2) 2(1) 16 2(1) 2(2) 4(1)
x2 1, x1 3
4 6
Forward Elimination
ai1
aij aij a1 j (1 j n )
a11
To eliminate x1 2 i n
a
bi bi i1 b1
a11
ai 2
aij aij a 2 j (2 j n)
a 22
To eliminate x2 3 i n
a
bi bi i 2 b2
a 22
Forward Elimination
aik
aij aij a kj (k j n)
a kk
To eliminate xk k 1 i n
aik
bi bi bk
a kk
Backward Substitution
bn
xn
a n ,n
bn 1 a n 1,n xn
xn 1
a n 1,n 1
bn 2 a n 2,n xn a n 2,n 1 xn 1
xn 2
a n 2, n 2
n
bi ai , j x j
j i 1
xi
a i ,i
Example 1
Solve using Naive Gaussian Eliminatio n :
Part 1 : Forward Eliminatio n ___ Step1 : Eliminate x1 from equations 2, 3
x1 2 x2 3 x3 8 eq1 unchanged ( pivot equation)
2
2 x1 3 x2 2 x3 10 eq 2 eq 2 eq1
1
3
3 x1 x2 2 x3 7 eq3 eq3 eq1
1
x1 2 x2 3 x3 8
x2 4 x3 6
5 x2 7 x3 17
Example 1
Part 1 : Forward Eliminatio n Step2 : Eliminate x2 from equation 3
x1 2 x2 3 x3 8 eq1 unchanged
x2 4 x3 6 eq 2 unchanged ( pivot equation)
5
5 x2 7 x3 17 eq3 eq3 eq 2
1
x1 2 x2 3 x3 8
x2 4 x3 6
13 x3 13
Example 1
Backward Substitution
b3 13
x3 1
a3,3 13
b2 a2,3 x3 6 4 x3
x2 2
a2, 2 1
b1 a1, 2 x2 a1,3 x3 8 2 x2 3 x3
x1 1
a1,1 a1,1
x1 1
The solution is x 2
2
x3 1
28
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.
31
Determinant
Examples
xn = bn / an,n
Do i = n-1 downto 1
sum = bi
Do j = i+1 to n
sum = sum – ai,j * xj
End Do
xi = sum / ai,i
End Do
Example 2
1 1 2 1 x1 1
3 2 1 4 x 1
2
5 8 6 3 x3 1
4 2 3 x 1
5 4
Example 2
Initialization step
Scale vector:
1 1 1 x1 1
2 disregard sign
3 2
4 x2 1
1 find largest in
magnitude in
each row
5 8 3 x3 1
6
4 2 3 x4 1
5
Scale vector S 2 4 8 5
Index Vector L 1 2 3 4
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 37
40
38
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.
41
Example 2
Forward Elimination-- Step 1: eliminate x1
Selection of the pivot equation
1 1 2 1 x1 1
3 2 4 x 1
1 2 S [2 4 8 5]
5 8 6 3 x3 1 L [1 2 3 4 ]
4 2 5 3 x4 1
al ,1 1 3 5 4
Ratios i
i 1,2,3,4 , , , max correspond s to l4
Sli 2 4 8 5
equation 4 is the first pivot equation Exchange l4 and l1
L [4 2 3 1 ]
Example 2
Forward Elimination-- Step 1: eliminate x1
Update A and B
1 1 2 1 x1 1
3 2 1 4 x 1
2 First pivot
5 8 6 3 x3 1
equation
4 2 5 3 x4 1
0 1.5 0.75 0.25 x1 1.25
0 0.5 2.75 1.75 x 1.75
2
0 5.5 0.25 0.75 x3 2.25
4 2 5 3 x4 1
Example 2
Forward Elimination-- Step 2: eliminate x2
Selection of the second pivot equation
0 1.5 0.75 0.25 x1 1.25
0 0.5 2.75 1.75 x 1.75
2
0 5.5 0.25 0.75 x3 2.25
4 2 5 3 x4 1
S [2 4 8 5 ] L[ 4 2 3 1]
Example 2
Forward Elimination-- Step 3: eliminate x3
Third pivot
0 1.5 0.75 0.25 x1 1.25
0 x 2.1667 equation
0 2.5 1.8333 2
0 0 0.25 1.6667 x3 6.8333
4 2 5 3 4
x 1
L [ 4 1 2 3]
0 1.5 0.75 0.25 x1 1.25
0 0 2.5 1.8333 x 2.1667
2
0 0 0 2 x3 9
4 2 5 3 4
x 1
Example 2
Backward Substitution
0 1.5 0.75 0.25 x1 1.25 L [ 4 1 2 3]
0 0 2.5 1.8333 x 2.1667
2
0 0 0 2 x3 9
4 3 x 1
2 5 4
b3 9 b2 a2,4 x4 2.1667 1.8333x4
x4 4.5, x3 2.4327
a3,4 2 a 2,3 2.5
b1 a1,4 x4 a1,3 x3 1.25 0.25 x4 0.75 x3
x2 1.1333
a1,2 1.5
b4 a4,4 x4 a4,3 x3 a4,2 x2 1 3 x 4 5 x3 2 x 2
x1 7.2333
al1 ,1 4
1 1 2 1 x1 1
3 2 1 4 x 1
2
5 8 6 3 x3 1
4 2 5 3 x4 1
Example 3
Initialization step
1 1 2 1 x1 1
3 2 1
4 x2 1
5 8 6 3 x3 1
4 2 5 3 x4 1
Scale vector S 2 4 8 5
Index Vector L 1 2 3 4
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.
48
Example 3
Forward Elimination-- Step 1: eliminate x1
Selection of the pivot equation
1 1 2 1 x1 1
3 2 1 4 x 1
2 S [2 4 8 5]
5 8 6 3 x3 1 L [1 2 3 4 ]
4 2 5 3 x4 1
al ,1 1 3 5 4
i
Ratios i 1,2,3,4 , , , max correspond s to l4
Sli 2 4 8 5
equation 4 is the first pivot equation Exchange l4 and l1
L [4 2 3 1 ]
Example 3
Forward Elimination-- Step 2: eliminate x2
Selection of the second pivot equation
0 1.5 0.75 0.25 x1 1.25
0 0.5 2.75 1.75 x 1.75
2
0 10.5 0.25 0.75 x3 2.25
4 2 5 3 x4 1
S [2 4 8 5] L[ 4 2 3 1 ]
al , 2
i 0.5 10.5 1.5
Ratios : i 2,3,4 L [ 4 3 2 1]
Sli 4 8 2
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.
51
Example 3
Forward Elimination-- Step 2: eliminate x2
Updating A and B
0 1.5 0.75 0.25 x1 1.25
0 0.5 2.75 1.75 x 1.75
2
0 10.5 0.25 0.75 x3 2.25
4 2 5 3 x4 1
L [ 4 1 3 2]
0 0 0.7857 0.3571 x1 0.9286
0 0 - 2.7619 1.7143 x 1.8571
2
0 10.5 0.25 0.75 x3 2.25
4 2 5 3 x4 1
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.
52
Example 3
Forward Elimination-- Step 3: eliminate x3
Selection of the third pivot equation
0 0 0.7857 0.3571 x1 0.9286
0 0 2.7619 1.7143 x 1.8571
2
0 10.5 0.25 0.75 x3 2.25
4 2 5 3 x4 1
S [2 4 8 5 ] L[ 4 3 2 1 ]
al ,3 2.7619 0.7857
Ratios : i
i 3,4 L [ 4 3 2 1]
Sli 4 2
Example 3
Forward Elimination-- Step 3: eliminate x3
0 0 0.7857 0.3571 x1 0.9286
0 0 2.7619 1.7143 x 1.8571
2
0 10.5 0.25 0.75 x3 2.25
4 2 5 3 4
x 1
L [ 4 3 2 1]
0 0 0 0.8448 x1 1.4569
0 0 2.7619 1.7143 x 1.8571
2
0 10.5 0.25 0.75 x3 2.25
4 2 5 3 x4 1
Example 3
Backward Substitution
0 0 0 0.8448 x1 1.4569 L [ 4 3 2 1]
0 0 2.7619 1.7143 x2 1.8571
0 10.5 0.25 0.75 x3 2.25
4
2 5 3 x4 1
bl4 1.4569 bl3 al3 ,4 x4 1.8571 1.7143x4
x4 1.7245, x3 0.3980
al4 ,4 0.8448 a l3 ,3 2.7619
bl2 al2 ,4 x4 al2 ,3 x3
x2 0.3469
al2 , 2
bl1 al1 ,4 x4 al1 ,3 x3 al1 ,2 x2 1 3 x 4 5 x3 2 x 2
x1 1.8673
al1 ,1 4
Remarks:
We use index vector to avoid the need to move the rows
which may not be practical for large problems.
If we order the equation as in the last value of the index
vector, we have a triangular form.
Scale vector is formed by taking maximum in magnitude
in each row.
Scale vector does not change.
The original matrices A and B are used in checking the
residuals.
Tridiagonal System
All the a elements will be zeros, need to update the d and b elements
The c elements are not updated
d1 c1 x1 b1 d1 c1 x1 b1
a d c2 x b d 2' c2 x b '
1 2
2 2 2 2'
a2 d3 x3 b3 d 3' x3 b3
cn 1 cn 1
'
'
an 1 d n xn bn d n xn bn
Diagonal Dominance
Diagonal Dominance
Examples :
3 0 1 3 0 1
1 6 1 2 3 2
1 2 5 1 2 1
Diagonally dominant Not Diagonally dominant
di ci ai 1 (1 i n)
Forward Elimination preserves diagonal dominance
xi bi ci xi 1
1
for i n 1, n 2,...,1
di
xn n , xi bi ci xi 1
b 1
for i 3,2,1
dn di
Example
Backward Substitution
After the Forward Elimination:
DT 5 4.6 4.5652 4.5619, BT 12 6.6 6.5652 4.5619
Backward Substitution:
b4 4.5619
x4 1,
d 4 4.5619
b3 c3 x4 6.5652 2 1
x3 1
d3 4.5652
b2 c2 x3 6.6 2 1
x2 1
d2 4.6
b1 c1 x2 12 2 1
x1 2
d1 5
Gauss-Jordan Method
2 2 2 x1 0
4 2 1 x 7
2
2 2 4 x3 2
Step 1 Eleminate x1 from equations 2and 3
eq1 eq1 / 2
1 1 1 x1 0
4
eq 2 eq 2 eq1 0 6 5 x2 7
1
0 0 2 x3 2
2
eq3 eq3 eq1
1
1 1 1 x1 0
0 6 5 x 7
2
0 0 2 x3 2
Step 2 Eleminate x 2 from equations 1 and 3
eq 2 eq 2 / 6
1 0 0.1667 x1 1.1667
1
eq1 eq1 eq 2 0 1 0.8333 x 1.1667
2
1
0 0 2 x3 2
0
eq3 eq3 eq 2
1
1 0 0.1667 x1 1.1667
0 1 0.8333 x 1.1667
2
0 0 2 x3 2
Step 3 Eleminate x 3 from equations 1 and 2
eq3 eq3 / 2
1 0 0 x1 1
0.1667 x 2
eq1 eq1 eq 3
0 1 0 2
1 0 0 1 x 1
0.8333 3
eq 2 eq 2 eq3
1
2 2 2 x1 0
4 2 1 x 7
2
2 2 4 x3 2
is transformed to
1 0 0 x1 1 x1 1
0 1 0 x 2 solution is x 2
2 2
0 0 1 x3 1 x3 1
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 74
Using the HP Prime
solving linear systems
equations
Using the HP Prime
2 x y 3z 1
2 x 6 y 8z 3
6 x 8 y 18 z 5
Method 1 2
1. Select Apps.
2. Select Linear Solver.
3. Enter the coefficients.
4. Get the results. 1
x1 10 x2 7 x3 3 x4 47 x1 7
2 x1 8 x4 2 x2 2
4 x1 8 x2 7 x3 5 x4 30 x3 4
2 x1 10 x2 9 x4 12 x4 2
x1 10 x2 7 x3 3 x4 47 x1 7
2 x1 8 x4 2 x2 2
4 x1 8 x2 7 x3 5 x4 30 x3 4
2 x1 10 x2 9 x4 12 x4 2
Using RREF
command
Using Simult
Command