Vous êtes sur la page 1sur 82

Soluciones Numéricas

Soluciones de Sistemas de Ecuaciones Lineales

Leer el capítulo 9 del Libro de Texto


Ecuaciones Lineales,
Vectores y Matrices
Solución de Sistemas Pequeños de
Ecuaciones (n≤3)
 MÉTODO GRAFICO
Para dos ecuaciones se puede obtener una solución al
graficarlas en coordenadas cartesianas con un eje que
corresponda a X1 y el otro a X2. debido a que en estos
sistemas lineales, cada ecuación se relaciona con una
línea recta, la cual se ilustra fácilmente mediante las
ecuaciones generales
Despejando X2

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 3


Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 4
VECTORES

Vector: es una matriz de números dimensional

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 3


6

MATRICES

Matrix : a two dimensiona l array of numbers


Examples :
0 0 0 1 0
zero matrix   identity matrix 0 1 
0 0 0  
1 0 0 0 1 2 0 0
0 4 
0 0  3 4 1 
0
diagonal  , Tridiagona l 
0 0 0 0 0 1 4 1
   
0 0 0 6 0 0 2 1

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 4


7

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 5


8

Determinant of a MATRICES

Defined for square matrices only


Examples :
 2 3  1
 
det  1 0 5   2
0 5 3 -1 3 -1
-1 -1
5 4 5 4 0 5
 1 5 4 
 2(25)  1(12  5)  1(15  0)  82

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 6


9

Adding and Multiplying Matrices

The addition of two matrices A and B


* Defined only if they have the same size
* C  A  B  cij  a ij  b ij i, j

Multiplica tion of two matrices A(n  m) and B(p  q)


* The product C  AB is defined only if m  p
m
* C  A B  cij   a ik b kj i, j
k 1

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 4


10

Systems of Linear Equations

A system of linear equations can be presented


in different forms

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 8


Solutions of Linear Equations

 x1  1
 x   2 is a solution t o the following equations :
 2  
x1  x2  3
x1  2 x2  5

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 11


Solutions of Linear Equations

 A set of equations is inconsistent if there exists no


solution to the system of equations:

x1  2 x2  3
2 x1  4 x2  5
These equations are inconsiste nt

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 12


Solutions of Linear Equations
 Some systems of equations may have infinite number
of solutions
x1  2 x2  3
2 x1  4 x2  6
have infinite number of solutions
 x1   a 
 x   0.5(3  a) is a solution for all a
 2  

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 13


14

Graphical Solution of Systems of


Linear Equations
x1  x2  3
x1  2 x2  5
Solution
x1=1, x2=2

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 12


15

Cramer’s Rule is Not Practical


Cramer' s Rule can be used to solve the system
3 1 1 3
5 2 1 5
x1   1, x2  2
1 1 1 1
1 2 1 2

Cramer' s Rule is not practical for large systems .


To solve N by N system requires (N  1)(N - 1)N! multiplica tions.
To solve a 30 by 30 system, 2.38  1035 multiplica tions are needed.
It can be used if the determinan ts are computed in efficient way

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 13


Lecture 13
Naive Gaussian
Elimination

 Naive Gaussian Elimination


 Examples
Naive Gaussian Elimination
 The method consists of two steps:
 Forward Elimination: the system is reduced to upper
triangular form. A sequence of elementary operations is
used.
 Backward Substitution: Solve the system starting from
the last variable.

 a11 a12 a13   x1   b1  a11 a12 a13   x1   b1 


a a23   x   b    0 a ' a '  x   b '
 21 a22  2  2  22 23   2   2
a31 a32 a33   x3  b3   0 0 a33 '  x3  b3 '

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 15


18

Elementary Row Operations

 Adding a multiple of one row to another

 Multiply any row by a non-zero constant

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 16


19

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 17


20

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

Summary of the Forward Eliminatio n :


 6 2 2 4   x1   16  6  2 2 4   x1   16 
 12  8 6 10   x   26  0  4 2 2   x    6
  2     2  
 3  13 9 3   x3    19  0 0 2  5  x3   9
           
 6 4 1  18  x4   34 0 0 0  3  x4    3

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 19


22

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 95
x4   1, x3   2
3 2
 6  2(2)  2(1) 16  2(1)  2(2)  4(1)
x2   1, x1  3
4 6

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 20


23

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  

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 21


24

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  

Continue until xn 1 is eliminated .

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 22


25

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 23


Lecture 14
Naive Gaussian
Elimination
 Summary of the Naive Gaussian Elimination
 Example
 Problems with Naive Gaussian Elimination
 Failure due to zero pivot element
 Error
 Pseudo-Code
Naive Gaussian Elimination

o The method consists of two steps


o Forward Elimination: the system is reduced to upper
triangular form. A sequence of elementary operations is
used.
 a11 a12 a13   x1   b1  a11 a12 a13   x1   b1 
a a23   x   b    0 a ' a '  x   b '
 21 a22  2  2  22 23   2   2
a31 a32 a33   x3  b3   0 0 a33 '  x3  b3 '

o Backward Substitution: Solve the system starting from the


last variable. Solve for xn ,xn-1,…x1.

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 27


28

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 26


29

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 27


30

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

The elementary operations do not affect the determinan t


Example :
1 2 3  1 2 3
A  2 3 2 Elementary   A'  0  1  4
  operations
3 1 2 0 0 13 
det (A)  det (A')  13

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 29


32

How Many Solutions Does a


System of Equations AX=B Have?
Unique No solution Infinite
det(A)  0 det(A)  0 det(A)  0
reduced matrix reduced matrix reduced matrix
has no zero rows has one or more has one or more
zero rows zero rows
correspond ing B correspond ing B
elements  0 elements  0

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 30


33

Examples

Unique No solution infinte # of solutions


1 2 1  1 2   2 1 2   2
3 4 X  2  2 4 X   3  2 4 X   4
           
  
1 2  1 1 2 2 1 2  2
0  2 X   1 0 0 X   1 0 0  X   0 
           
solution : No solution Infinite # solutions
0   
X   0  1 impossible! X  
0.5 1  . 5  

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 31


34

Pseudo-Code: Forward Elimination


Do k = 1 to n-1
Do i = k+1 to n
factor = ai,k / ak,k
Do j = k+1 to n
ai,j = ai,j – factor * ak,j
End Do
bi = bi – factor * bk
End Do
End Do

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 32


35

Pseudo-Code: Back Substitution

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 33


Lectures 15-16:
Gaussian Elimination
with Scaled Partial
Pivoting
 Problems with Naive Gaussian Elimination
 Definitions and Initial step
 Forward Elimination
 Backward substitution
 Example
37

Problems with Naive Gaussian


Elimination
o The Naive Gaussian Elimination may fail for very
simple cases. (The pivoting element is zero).
0 1  x1  1
1 1  x   2
   2  
o Very small pivoting element may result in serious
computation errors
10 10 1  x1  1
    
 1 1  x2  2

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 35


38

Example 2

Solve the following system using Gaussian Eliminati on


with Scaled Partial Pivoting :

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  

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 36


39

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

Why Index Vector?

 Index vectors are used because it is much easier to


exchange a single index element compared to
exchanging the values of a complete row.
 In practical problems with very large N, exchanging the
contents of rows may not be practical.

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 ]

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 39


42

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 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 40


43

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]

 al , 2   0.5 5.5 1.5 


Ratios :  i i  2,3,4    L  [ 41 3 2 ]
 S li   4 8 2 
Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.
44

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 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


45

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


Example 3

Solve the following sytstem using Gaussian Eliminatio n


with Scaled Partial Pivoting

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


47

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 ]

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


Example 3
Forward Elimination-- Step 1: eliminate x1
Update A and B
1  1 2 1  x1   1 
3 3 1 4 x   1 
  2   
5  8 6 3  x3   1 
     
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  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.


50

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 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


53

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 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


54

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


55

How Do We Know If a Solution is


Good or Not
Given AX=B
X is a solution if AX-B=0
Compute the residual vector R= AX-B
Due to rounding error, R may not be zero

The solution is acceptable if max ri  


i

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


56

How Good is the Solution?


1  1 2 1 x1   1   x1    1.8673 
3 2 1 x   1 
4  x   0.3469
  2     solution  2   
5  8 6 3 x3   1   x3   0.3980 
    
    
4 2 5 3 x4   1  x4   1.7245 
0.005
0.002
Residues : R   
0.003
 
 0.001

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


57

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.

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


Lecture 17
Tridiagonal & Banded
Systems
and Gauss-Jordan Method
 Tridiagonal Systems
 Diagonal Dominance
 Tridiagonal Algorithm
 Examples
 Gauss-Jordan Algorithm
Tridiagonal Systems
Tridiagonal Systems:
 The non-zero elements are in
the main diagonal,
5 1 0 0 0  x1   b1 
super diagonal and 3    
4 1 0 0  x2  b2  
subdiagonal. 
0 2 6 2 0  x3   b3 
 aij=0 if |i-j| > 1     
0 0 1 4 1  x4  b4 
0 0 0 1 6  x5  b5 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 59


Tridiagonal Systems

 Occur in many applications


 Needs less storage (4n-2 compared to n +n for the general cases)
2

 Selection of pivoting rows is unnecessary (under


some conditions)
 Efficiently solved by Gaussian elimination

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 60


Algorithm to Solve Tridiagonal
Systems
 Based on Naive Gaussian elimination.
 As in previous Gaussian elimination algorithms
 Forward elimination step
 Backward substitution step
 Elements in the super diagonal are not affected.
 Elements in the main diagonal, and B need updating

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 61


62

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 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


63

Diagonal Dominance

A matrix A is diagonally dominant if


n
a ii   a ij for (1  i  n)
j 1,
j i

The magnitude of each diagonal element is larger tha n


the sum of elements in the correspond ing row.

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


64

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


Diagonally Dominant Tridiagonal
System
 A tridiagonal system is diagonally dominant if

di  ci  ai 1 (1  i  n)
 Forward Elimination preserves diagonal dominance

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 65


Solving Tridiagonal System
Forward Eliminatio n
 ai 1 
d i  d i   ci 1
 d i 1 
 ai 1 
bi  bi   bi 1 2in
 d i 1 
Backward Substituti on
b
xn  n
dn

xi  bi  ci xi 1 
1
for i  n  1, n  2,...,1
di

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 66


Example
Solve
5 2   x1  12 5 1  2 12
1 5 2   x   9  5 1  2 9
  2      D   , A   , C   , B   
 1 5 2  x3   8  5 1  2 8
            
 1 5   x4   6  5     6
Forward Eliminatio n
 ai 1   ai 1 

di  di   
 ci 1 , bi  bi   bi 1 2i4
 d i 1   d i 1 
Backward Substituti on

xn  n , xi  bi  ci xi 1 
b 1
for i  3,2,1
dn di

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 67


Example
5 1  2 12
5 1  2 9
D   , A   , C   , B   
5 1  2 8
       
 
5     6
Forward Eliminatio n
a  1 2 a  112
d 2  d 2   1 c1  5   4.6, b2  b2   1 b1  9   6.6
 d1  5  d1  5
a  1 2 a  1  6 .6
d 3  d 3   2 c2  5   4.5652, b3  b3   2 b2  8   6.5652
 d2  4.6  d2  4.6
a  1 2 a  1 6.5652
d 4  d 4   3 c3  5   4.5619, b4  b4   3 b3  6   4.5619
 d3  4.5652  d3  4.5652

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 68


69

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


70

Gauss-Jordan Method

 The method reduces the general system of equations


AX=B to IX=B where I is an identity matrix.

 Only Forward elimination is done and no backward


substitution is needed.

 It has the same problems as Naive Gaussian elimination


and can be modified to do partial scaled pivoting.

 It takes 50% more time than Naive Gaussian method.

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O.


Gauss-Jordan Method
Example

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 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 71


Gauss-Jordan Method
Example

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 

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 72


Gauss-Jordan Method
Example

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  

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 73


Gauss-Jordan Method
Example

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

Solve the following systems of linear equations

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 76


Method No. 2

1. Write equations in matrix form. 1 2


2. Divide the Vector of known quantities
between the coefficient matrix.
3. Get the results.

System of linear equations


x1  x2  x3  x4  10 x1  2 3 4
2 x1  x2  3 x4  4 x4  9 x2  3
3 x1  2 x2  1x3  5 x4  13 x3  4
x1  3x2  2 x3  4 x4  4 x4  1

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 77


Method No. 3
Using the function RREF
(Reduced Row Echelon Form)
1. Invoke the RREF function.
2. Enter the augmented matrix
3. Press Enter

System of linear equations

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 78


Method No. 5
Use function Simult
(Simultaneals Linear Equations)
1. Invoke the Simult function.
2. Provide the coefficient matrix.
3. Provide column matrix of constants.
4. Press Enter

System of linear equations

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

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 79


Solution of a system of 6 simultaneals equations

Using RREF
command

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 80


Solution of a system of 6 simultaneals equations

Using Simult
Command

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 81


Determinant of a Matrix

Using the Det command.


1. Write down the matrix
2. Invoke the det command.
3. Press Enter.

Defined for square matrices only


Examples :
 2 3  1
det  1 0 5   2
0 5 3 -1 3 -1
-1 -1
5 4 5 4 0 5
 1 5 4 
 2(25)  1(12  5)  1(15  0)  82

Universidad Tecnológica de Panamá - Ing. Elio M. Saldaña O. 82

Vous aimerez peut-être aussi