0% found this document useful (0 votes)
121 views107 pages

Systems of Equations: Solutions and Methods

Uploaded by

Zambuk Tea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views107 pages

Systems of Equations: Solutions and Methods

Uploaded by

Zambuk Tea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Systems of Equations

• Given the two straight lines L1 and L2, one and only
one of the following may occur:
1. L1 and L2 intersect at exactly one point.
y
L1

Unique
y1 solution
(x1,
(x1, y1)
y1 )
x1 x
L2
Example:
A System of Equations With Exactly One Solution
• Consider the system
2x  y  1
3x  2 y  12

• Solving the first equation for y in terms of x, we


obtain y  2x 1
• Substituting this expression for y into the second
equation yields
3x  2(2 x  1)  12
3x  4 x  2  12
7 x  14
x2
Example:
A System of Equations With Exactly One Solution

• Finally, substituting this value of x into the


expression for y obtained earlier gives
y  2x 1
 2(2)  1
3

• Therefore, the unique solution of the system is given


by
x = 2 and y = 3.
Example:
A System of Equations With Exactly One Solution
• Geometrically, the two lines represented by the two
equations that make up the system intersect at the
point (2, 3):
y
6
5 2x  y  1
4
3 (2, 3)
2
1 3x  2 y  12

x
1 2 3 4 5 6
–1
Systems of Equations

• Given the two straight lines L1 and L2, one and only
one of the following may occur:
2. L1 and L2 are coincident.
y
L1, L2

Infinitely
many
solutions
x
Example:
A System of Equations With Infinitely Many Solutions
• Consider the system
2x  y  1
6x  3y  3
• Solving the first equation for y in terms of x, we obtain
• Substituting this expression
y for
2 xyinto
1 the second equation
yields

6 x  3(2 x  1)  3
6x  6x  3  3
which is a true statement.
• This result follows from the fact that 0 the
0 second equation is
equivalent to the first.
Example:
A System of Equations With Infinitely Many Solutions
• Thus, any order pair of numbers (x, y) satisfying the equation y =
2x – 1 constitutes a solution to the system.
• By assigning the value t to x, where t is any real number, we find
that y = 2t – 1 and so the ordered pair (t, 2t – 1) is a solution to
the system.
• The variable t is called a parameter.
• For example:
– Setting t = 0, gives the point (0, –1) as a solution of the system.
– Setting t = 1, gives the point (1, 1) as another solution of the
system.
Example:
A System of Equations With Infinitely Many Solutions
• Since t represents any real number, there are infinitely many
solutions of the system.
• Geometrically, the two equations in the system represent the
same line, and all solutions of the system are points lying on
the line:
y
6
5
2x  y  1
4 6x  3y  3
3
2
1

x
1 2 3 4 5 6
–1
Systems of Equations

• Given the two straight lines L1 and L2, one and only
one of the following may occur:
3. L1 and L2 are parallel.
y
L1
L2

No
solution

x
Example:
A System of Equations That Has No Solution
• Consider the system
2x  y  1
6 x  3 y  12
• Solving the first equation for y in terms of x, we obtain
y  2x 1
• Substituting this expression for y into the second equation yields

6 x  3(2 x  1)  12
6 x  6 x  3  12
which is clearly impossible.
0  9 of equations.
• Thus, there is no solution to the system
Example:
A System of Equations That Has No Solution
• To interpret the situation geometrically, cast both equations in
the slope-intercept form, obtaining
y = 2x – 1 and y = 2x – 4
which shows that the lines are parallel.
• Graphically: y
6
2x  y  1
5
6 x  3 y  12
4
3
2
1

x
1 2 3 4 5 6
–1
Systems of Linear Equations:
Unique Solutions
Direct solution Methods
• Gaussian Elimination
– Matrix A is transformed into an upper triangular matrix (all
elements below diagonal 0)
– Back substitution is used to solve the upper-triangular
system

Back substitution
 a11  a1i  a1n   x1   b1  a11  a1i  a1n   x1   b1 
                      
 
 ai1  aii  ain   xi    bi   0
~
 a~ii  a~in   xi    bi 
         
                    
~
an1  ani  ann   xn  bn   0  0  a~nn   xn  bn 

13
Gauss Elimination

1. Gauss Elimination
2. Gauss Elimination Pitfalls
3. Gauss Elimination with Partial Pivoting
4. Determinant of a Square Matrix
Using Gauss Elimination

14
1. Gaussian Elimination

A method to solve simultaneous linear equations


of the form [A][X]=[C]

Two steps
1. Forward Elimination
2. Back Substitution

15
Forward Elimination

The goal of forward elimination is to transform the coefficient


matrix into an upper triangular matrix

 25 5 1  x1  106.8 
 64 8 1  x   177.2 
   2  
144 12 1  x3  279.2

25 5 1   x1   106.8 
 0  4.8  1.56  x    96.21
   2  
 0 0 0.7   x3   0.735  16
Forward Elimination

A set of n equations and n unknowns


a11x1  a12 x2  a13 x3  ...  a1n xn  b1
a21x1  a22 x2  a23 x3  ...  a2n xn  b2
. .
. .
. .
an1x1  an 2 x2  an3 x3  ...  ann xn  bn

(n-1) steps of forward elimination

17
Forward Elimination

Step 1
For Equation 2, divide Equation 1 by a11 and
multiply by a21 .

 a21 
 a (a11x1  a12 x2  a13 x3  ...  a1n xn  b1 )
 11 
a21 a21 a21
a21x1  a12 x2  ...  a1n xn  b1
a11 a11 a11

18
Forward Elimination

Subtract the result from Equation 2.


a21x1  a22 x2  a23 x3  ...  a2 n xn  b2
a21 a21 a21
− a21x1  a a12 x2  ...  a a1n xn  a b1
_________________________________________________
11 11 11

 a21   a21  a21


 a22  a12  x2  ...   a2 n  a1n  xn  b2  b1
 a11   a11  a11

or a x  ...  a x  b
'
22 2
'
2n n
'
2

19
Forward Elimination

Repeat this procedure for the remaining


equations to reduce the set of equations as
a11x1  a12 x2  a13 x3  ...  a1n xn  b1
'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
'
a32 x2  a33
'
x3  ...  a3' n xn  b3'
. . .
. . .
. . .

an' 2 x2  an' 3 x3  ...  ann


'
xn  bn'

End of Step 1
20
Forward Elimination

Step 2
Repeat the same procedure for the 3rd term of
Equation 3.
a11x1  a12 x2  a13 x3  ...  a1n xn  b1
'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
"
a33 x3  ...  a3" n xn  b3"
. .
. .
. .

an" 3 x3  ...  ann


"
xn  bn"
End of Step 2 21
Forward Elimination

At the end of (n-1) Forward Elimination steps, the


system of equations will look like
a11 x1  a12 x2  a13 x3  ...  a1n xn  b1
'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
"
a33 x3  ...  a3" n xn  b3"
. .
. .
. .

 n 1 n 1 
ann xn  bn

End of Step (n-1)


22
Matrix Form at End of Forward
Elimination

a11 a12 a13  a1n   x1   b1 


 0 a' '
a '
 a2 n x2     b2' 
 22 23    
0 0 "
a
33  a3n   x3    b3 
" "

    
           
 0 0 0 (n1 )
   
0 ann   xn  bn 
(n-1 )

23
Back Substitution

Solve each equation starting from the last equation

25 5 1   x1   106.8 
 0  4.8  1.56  x    96.21
   2  
 0 0 0.7   x3   0.735 

Example of a system of 3 equations

24
Back Substitution Starting Eqns

a11 x1  a12 x2  a13 x3  ...  a1n xn  b1


'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
"
a33 x3  ...  an" xn  b3"
. .
. .
. .

 n 1 n 1 
ann xn  bn

25
Back Substitution

Start with the last equation because it has only one unknown
( n 1)
b
xn  n
( n 1)
a nn

26
Back Substitution
( n 1)
b
xn  n
( n 1)
a nn

bii 1  ai,ii11 xi 1  ai,ii12 xi  2  ...  ai,in1 xn


xi  i 1 for i  n  1,...,1
aii

i 1
  aiji 1 x j
n
bi
j i 1
xi  i 1 for i  n  1,...,1
a ii

27
Example

• Use the Gauss-Jordan elimination method to solve the system of


equations
3x  2 y  8 z  9
2 x  2 y  z  3
x  2 y  3z  8
Solution
1 0 0 3
 
0 1 0 4
 0 0 1 1 

• The solution to the system is thus x = 3, y = 4, and z = 1.


A System of Equations
with an Infinite Number of Solutions
• Solve the system of equations given by
x  2 y  3 z  2
3x  y  2 z  1
2 x  3 y  5 z  3

Solution
 1 0 1 0
 
0 1 1 1
0 0 0 0

• Observe that row three reads 0 = 0, which is true but


of no use to us.
A System of Equations That Has No Solution

• Solve the system of equations given by


x y z 1
3x  y  z  4
x  5 y  5z  1
Solution

1 1 1 1
 
0 4 4 1
0 0 0 1

• Observe that row three reads 0x + 0y + 0z = –1 or 0 = –1!


• We therefore conclude the system is inconsistent and has no
solution.
2. Gauss Elimination
Pitfalls

31
Pitfall#1. Division by zero
10 x2  7 x3  3
6 x1  2 x2  3x3  11
5 x1  x2  5 x3  9

0 10  7  x1   3 
6 2  
3 x2  11   
    
5  1 5   x3   9 

32
Is division by zero an issue here?

12 x1  10 x2  7 x3  15
6 x1  5 x2  3x3  14
5 x1  x2  5 x3  9

12 10  7  x1  15
6 5 3   x2   14
    
 5  1 5   x3   9 

33
Is division by zero an issue here? YES

12 x1  10 x2  7 x3  15
6 x1  5 x2  3x3  14
24 x1  x2  5 x3  28

12 10  7  x1  15 12 10  7  x1   15 


6 5 3   x2   14  0
     0 6.5  x2   6.5
    
24  1 5   x3  28 12  21 19   x3   2

Division by zero is a possibility at any step of


forward elimination 34
Pitfall#2. Large Round-off Errors
 20 15 10  x1   45 
 3  2.249 7   x   1.751
   2  
 5 1 3   x3   9 
Exact Solution

 x1  1
 x   1
 2  
 x3  1
35
Pitfall#2. Large Round-off Errors
 20 15 10  x1   45 
 3  2.249 7   x   1.751
   2  
 5 1 3   x3   9 

Solve it on a computer using 6 significant digits with chopping


 x1   0.9625 
 x    1.05 
 2  
 x3  0.999995
36
Pitfall#2. Large Round-off Errors
 20 15 10  x1   45 
 3  2.249 7   x   1.751
   2  
 5 1 3   x3   9 

Solve it on a computer using 5 significant digits with chopping


 x1   0.625 
 x    1.5 
 2  
 x3  0.99995
Is there a way to reduce the round off error? 37
Avoiding Pitfalls

Increase the number of significant digits


• Decreases round-off error
• Does not avoid division by zero

38
Avoiding Pitfalls

Gaussian Elimination with Partial Pivoting


• Avoids division by zero
• Reduces round off error

39
3. Gauss Elimination with Partial
Pivoting

40
Avoiding Pitfalls

Gaussian Elimination with Partial Pivoting


• Avoids division by zero
• Reduces round off error

41
What is Different About Partial
Pivoting?

At the beginning of the kth step of forward elimination,


find the maximum of

akk , ak 1,k ,................, ank


If the maximum of the values is a pk
in the p th row, k  p  n, then switch rows p and k.

42
Matrix Form at Beginning of 2nd Step of
Forward Elimination

a11 a12 a13  a1n   x1   b1 


 0 a' a '
 ' 
a2 n x2   ' 
b2
 22 23    
 0 a32'
a '
33  a3n   x3   b3 
' '

    
           
 0 a'n 2 a '
n3 a '
n4
'
   
ann   xn  bn 
'

43
Example (2nd step of FE)

6 14 5.1 3.7 6   x1   5 
0  7 6 1 2   x2   6
    
0 4 12 1 11  x3    8 
    
 0 9 23 6 8 x
   
4 9
0  17 12 11 43  x5   3 

Which two rows would you switch?


44
Example (2nd step of FE)

6 14 5.1 3.7 6   x1   5 
0  17 12 11 43  x   3 
  2   
0 4 12 1 11  x3    8 
    
 0 9 23 6 8 x
   
4 9
0  7 6 1 2   x5   6

Switched Rows
45
Gaussian Elimination
with Partial Pivoting
A method to solve simultaneous linear
equations of the form [A][X]=[C]

Two steps
1. Forward Elimination
2. Back Substitution

46
Forward Elimination

Same as Gauss elimination method except that we switch


rows before each of the (n-1) steps of forward
elimination.

47
Example: Matrix Form at Beginning of
2nd Step of Forward Elimination
a11 a12 a13  a1n   x1   b1 
 0 a' a'
 ' 
a2 n x2   ' 
b2
 22 23    
 0 a32'
a'
33  a3n   x3   b3 
' '

    
          
 0 a'n 2 an' 3 an' 4 '
ann   xn  bn' 

48
Matrix Form at End of Forward
Elimination
a11 a12 a13  a1n   x1   b1 
 0 a' a' '
 a2 n x2     b2' 
 22 23    
0 "
0 a33  a3n   x3    b3 
" "

    
          
 0 0 0 (n1 )
0 ann   xn  bn(n-1 ) 

49
Back Substitution Starting Eqns

a11 x1  a12 x2  a13 x3  ...  a1n xn  b1


'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
"
a33 x3  ...  an" xn  b3"
. .
. .
. .

 n 1 n 1 
ann xn  bn

50
Back Substitution

( n 1)
b
xn  n
( n 1)
a nn

i 1 n
i 1
bi   aij x j
j i 1
xi  i 1 for i  n  1,...,1
a ii

51
Example 2
Solve the following set of equations by
Gaussian elimination with partial
pivoting

 25 5 1  a1  106.8 
 64 8 1 a   177.2 
   2  
144 12 1  a3  279.2

52
Example 2 Cont.

 25 5 1  a1  106.8   25 5 1  106.8 
 64 8 1 a   177.2    
    2   64 8 1  177.2 
144 12 1  a3  279.2 144 12 1  279.2

1. Forward Elimination
2. Back Substitution

53
Forward Elimination

54
Number of Steps of Forward Elimination

Number of steps of forward elimination is (n


1)=(31)=2

55
Forward Elimination: Step 1
• Examine absolute values of first column, first row
and below.
25 , 64 , 144
• Largest absolute value is 144 and exists in row 3.
• Switch row 1 and row 3.

 25 5 1  106.8  144 12 1  279.2


 64 8 1  177.2    64 8 1  177.2 
   
144 12 1  279.2  25 5 1  106.8 

56
Forward Elimination: Step 1 (cont.)
144 12 1  279.2 Divide Equation 1 by 144 and
 64 8 1  177.2  64
  multiply it by 64,  0.4444 .
 25 5 1  106.8  144

144 12 1  279.2 0.4444  63.99 5.333 0.4444  124.1


.
Subtract the result from 64 8 1  177.2
Equation 2  63.99 5.333 0.4444  124.1
0 2.667 0.5556  53.10

Substitute new equation for 144 12 1  279.2


Equation 2  0 2.667 0.5556  53.10
 
 25 5 1  106.8  57
Forward Elimination: Step 1 (cont.)
144 12 1  279.2 Divide Equation 1 by 144 and
 0 2.667 0.5556  53.10 25
  multiply it by 25,  0.1736.
 25 5 1  106.8  144

144 12 1  279.2 0.1736  25.00 2.083 0.1736  48.47


.
25 5 1  106.8
Subtract the result from
Equation 3  25 2.083 0.1736  48.47
0 2.917 0.8264  58.33

Substitute new equation for 144 12 1  279.2


Equation 3  0 2.667 0.5556  53.10
 
 0 2.917 0.8264  58.3358
Forward Elimination: Step 2
• Examine absolute values of second column, second row
and below.
2.667 , 2.917
• Largest absolute value is 2.917 and exists in row 3.
• Switch row 2 and row 3.

144 12 1  279.2 144 12 1  279.2


 0 2.667 0.5556  53.10   0 2.917 0.8264  58.33
   
 0 2.917 0.8264  58.33  0 2.667 0.5556  53.10

59
Forward Elimination: Step 2 (cont.)
Divide Equation 2 by 2.917 and
144 12 1  279.2
 0 2.917 0.8264  58.33 multiply it by 2.667,
  2.667
 0 2.667 0.5556  53.10  0.9143.
2.917
0 2.917 0.8264  58.33 0.9143  0 2.667 0.7556  53.33

.
0 2.667 0.5556  53.10
Subtract the result from  0 2.667 0.7556  53.33
Equation 3
0 0  0.2   0.23

144 12 1  279.2 
Substitute new equation for  0 2.917 0.8264  58.33 
Equation 3  
 0 0  0.2   0.23
60
Back Substitution

61
Back Substitution

144 12 1  279.2  144 12 1   a1   279.2 


 0 2.917 0.8264  58.33    0 2.917 0.8264 a    58.33 
     2  
 0 0  0.2   0.23  0 0  0.2   a3   0.23

Solving for a3
 0.2a3  0.23
 0.23
a3 
 0.2
 1.15
62
Back Substitution (cont.)

144 12 1   a1   279.2 
 0 2.917 0.8264 a    58.33 
   2  
 0 0  0.2  a3   0.23

Solving for a2
2.917a2  0.8264a3  58.33
58.33  0.8264a3
a2 
2.917
58.33  0.8264 1.15

2.917
 19.67 63
Back Substitution (cont.)

144 12 1   a1   279.2 
 0 2.917 0.8264 a    58.33 
   2  
 0 0  0.2  a3   0.23

Solving for a1
144a1  12a2  a3  279.2
279.2  12a2  a3
a1 
144
279.2  12 19.67  1.15

144
 0.2917 64
Gaussian Elimination with Partial
Pivoting Solution

 25 5 1  a1  106.8 
 64 8 1 a   177.2 
   2  
144 12 1  a3  279.2

 a1  0.2917
a    19.67 
 2  
 a3   1.15 
65
Partial Pivoting: Example

Consider the system of equations


10 x1  7 x2  7
 3x1  2.099 x2  6 x3  3.901
5 x1  x2  5 x3  6
In matrix form
 10  7 0  x1   7 
 3 2.099 6  x  3.901
   2 =  
 5  1 5  x3   6 

Solve using Gaussian Elimination with Partial Pivoting using five


significant digits with chopping

66
Partial Pivoting: Example
Forward Elimination: Step 1
Examining the values of the first column
|10|, |-3|, and |5| or 10, 3, and 5
The largest absolute value is 10, which means, to
follow the rules of Partial Pivoting, we switch
row1 with row1.

Performing Forward Elimination


 10  7 0  x1   7  10 7 0  x1   7 
 3 2.099 6  x   3.901

 5
 2   
 1 5  x3   6 
  0  0.001 6  x   6.001

 0 2.5
 2   
5  x3   2.5 

67
Partial Pivoting: Example

Forward Elimination: Step 2


Examining the values of the first column
|-0.001| and |2.5| or 0.0001 and 2.5
The largest absolute value is 2.5, so row 2 is
switched with row 3

Performing the row swap


10 7 0  x1   7  10 7 0  x1   7 
 0  0.001 6  x   6.001

 0 2.5
 2   
5  x3   2.5 
 0
 2.5 5   x    2.5 
 2   
 0  0.001 6  x3  6.001

68
Partial Pivoting: Example

Forward Elimination: Step 2

Performing the Forward Elimination results in:

10  7 0   x1   7 
 0 2.5 5   x    2.5 
  2   
 0 0 6.002  x3  6.002

69
Partial Pivoting: Example

Back Substitution
Solving the equations through back substitution

6.002
10  7 0   x1   7  x3  1
 0 2.5 5   x    2.5  6.002
  2   
 0 0 6.002  x3  6.002 2.5  5 x3
x2   1
2.5

7  7 x 2  0 x3
x1  0
10
70
Partial Pivoting: Example

Compare the calculated and exact solution


The fact that they are equal is coincidence, but it
does illustrate the advantage of Partial Pivoting

 x1   0   x1   0 
X  calculated   x2    1 X  exact   x2    1
 x3   1   x3   1 

71
4. Determinant of a Square Matrix
Using Gauss Elimination

Example

72
Theorem of Determinants

If a multiple of one row of [A]nxn is added or


subtracted to another row of [A]nxn to result in
[B]nxn then det(A)=det(B)

73
Theorem of Determinants

The determinant of an upper triangular matrix


[A]nxn is given by

det A   a11  a22  ...  aii  ...  ann


n
  a ii
i 1

74
Forward Elimination of a
Square Matrix

Using forward elimination to transform [A]nxn to


an upper triangular matrix, [U]nxn.

Ann  U  nn

det  A  det U 

75
Example
Using Gaussian elimination find the
determinant of the following square matrix.

 25 5 1
 64 8 1
 
144 12 1

76
Forward Elimination

77
Forward Elimination: Step 1
 25 5 1
 64 8 1 Divide Equation 1 by 25 and
  multiply it by 64,
64
 2.56 .
144 12 1 25

25 5 1 2.56  64 12.8 2.56


. 64 8 1
Subtract the result from  64 12.8 2.56
Equation 2
0  4.8  1.56
 25 5 1 
Substitute new equation for  0  4.8  1.56
Equation 2  
144 12 1  78
Forward Elimination: Step 1 (cont.)
 25 5 1 
 0  4.8  1.56 Divide Equation 1 by 25 and
  multiply it by 144, 144  5.76 .
144 12 1  25
25 5 1 5.76  144 28.8 5.76
144 12 1
 144 28.8 5.76
.
Subtract the result from
Equation 3
0  16.8  4.76

25 5 1 
Substitute new equation for  0  4.8  1.56 
Equation 3  
 0  16.8  4.76
79
Forward Elimination: Step 2
Divide Equation 2 by −4.8
25 5 1 
 0  4.8  1.56  and multiply it by −16.8,
   16.8
 0  16.8  4.76  3. 5 .
 4.8
0  4.8  1.56  3.5  0  16.8  5.46
.

Subtract the result from


0  16.8  4.76
Equation 3  0  16.8  5.46
0 0 0.7

Substitute new equation for 25 5 1 


 0  4.8  1.56
Equation 3  
 0 0 0.7  80
Finding the Determinant

After forward elimination

 25 5 1 25 5 1 
 64 8 1   0  4.8  1.56
   
144 12 1  0 0 0.7 
.

det A   u11  u22  u33


 25   4.8 0.7
 84.00
81
5. Gaussian Elimination For
Tridiagonial System

82
Tridiagonal Systems I
* Introduction of Tridiagonal System?
 Special Linear System Arising in Application
 A general tridiagonal matrix is a matrix whose nonzero
elements are found only on the diagonal, subdiagonal, and
superdiagonal of the matrix.
 if |i – j | > 1 ,

83
Tridiagonal Systems II
 In Storage
 Only the diagonal, subdiagonal, and superdiagonal elements of
the general tridiagonal matrix are stored.
This is called tridiagonal storage mode.
 The elements of a general tridiagonal matrix, A, of order n
are stored in three one-dimensional arrays, C, D, and E, each
of length n.
 array C contains the subdiagonal elements, stored as follows:
C = (*, a21, a32, a43, ..., an,n-1)
 array D contains the main diagonal elements, stored as
follows: D = (a11, a22, a33, ..., ann)
 array E contains the superdiagonal elements, stored as
follows: E = (a12, a23, a34, ..., an-1,n, *)
 where "*" means you do not store an element in that position
in the array

84
Tridiagonal Systems III
* Example of Tridiagonal Matrix…

2x1 –x2 = 1,
-x1 +2x2 –x3 = 0,
-x2 +2x3 –x4 = 0,
-x3 +2x4 = 1.

 2 1 0 0 | 1
 1 2  1 0 | 0

 0 1 2 1 | 0
 
 0 0 1 2 | 1

85
Gaussian Elimination
for Tridiagonal Systems

2x1 – x2  1, x1 –
1
x2
1
 ,
2 2
- x1  2x2 – x3  0, 3 1
x2 – x3  ,
- x2  2x3 – x4  0, 2 2
- x2  2x3 – x4  0,
- x3  2x4  1. - x3  2x4  1.

x4  1; 1 1
x1 – x2  ,
1 3 2 2
x3   (– )(1)  1;
4 4 2 1
x2 – x3  ,
1 2 3 3
x2   (– )(1)  1;
3 3 3 1
 x3 – x4  ,
1 1 4 4
x1   (– )(1)  1.
2 2 x4  1.

86
Solving a Tridiagonal Systems
Using the Thomas Method I
d 1x1  a1x 2  r1,
b2 x1  d 2 x 2  a 2 x3 ....  r 2,
 bn  1xn  2  dn  1xn  1  an  1xn  rn  1,
 bnxn  1  dnxn  rn.

1. B1 and An are zero.


2. This algorithm takes advantage of the zero elements that are
already present in the coefficient matrix and avoids unnecessary arithmetic
operations.
Thus, we need to store only the new vectors a and r.

87
Solving a Tridiagonal Systems
Using the Thomas Method II
a1 r1
 Step 1 : For the first equation a1  , r1 
d1 d1
ai ri  biri  1
 Step 2 : For each of the equation ai  , ri 
di  biai  1 di  biai  1
rn  bnrn  1
 Step 3 : For the last equation rn 
dn  bnan  1
xn  rn,
 Step 4 : by back substitution xi  ri  aixi  1,
i  n  1, n  2, n  3,....,2,1.

88
Solving a Tridiagonal Systems
Using the Thomas Method III

2 x1  x 2  1,
 x1  2 x 2  x 3  0,
 x 2  2 x 3  x 4  0,
 x 3  2 x 4  1.
d  (2,2,2,2); a  (1,1,1,0);
b  (0,1,1,1); r  (1,0,0,1).

89
Solving a Tridiagonal Systems
Using the Thomas Method IV

a1 1 r1 1
a1    , r1   .
d1 2 d1 2
a2 1 2
a2    ,
d 2  b 2 a1 2  ( 1)( 1 / 2) 3

r 2  b 2 r1 0  ( 1)(1 / 2) 1
r2    .
d 2  b 2 a1 2  ( 1)( 1 / 2) 3

x 4  r 4  1,
x 3  r 3  a 3 x 4  1 / 4  ( 3 / 4)  1,
x 2  r 2  a 2 x 3  1 / 3  ( 2 / 3)(1)  1,
x1  r 1  a1 x 2  1 / 2  ( 1 / 2)(1)  1.
90
Discussion of Thomas method

* The required multiplications and divisions for Thomas method.


For the first equation, 2divisions are needed.
For each of the next n-2 equations, 2multiplications and 2 divisions are
needed.
For the last equation, 2 multiplications and 1 division are required.
The total for elimination is 5+4(n-2).
For the back substitution, n-1 multiplications are needed.

* The Thomas algorithm requires that d1  0 and di - biai - 1  0


for each i.

91
Using the Thomas Method for a System that Would
Require Pivoting for Gaussian Elimination I

2 x1  x 2  1,
 x1  2 x 2  x3  0,
2 4
 x 2  x3  x 4  ,
3 3
 x3  2 x 4  x5  0, 1 1
x1  x 2  ,
 x 4  2 x5  x 6  0, 2 2
2 1
 x 5  2 x 6  1.  x 2  x3  ,
3 3
 x4  1,
 x3  2 x 4  x5  0,
 x 4  2 x 5  x 6  0,
 x 5  2 x 6  1.
92
Using the Thomas Method for a System that Would
Require Pivoting for Gaussian Elimination II

1 1
x1  x2  ,
2 2
2 1
 x2  x3  ,
3 3
 x4  1( solve),
 x3  2 x 4  x5  0( skip for now),
 2 x5  x6  1(u sin gx 4  1),
 x 5  2 x 6  1.

93
Using the Thomas Method for a System that Would
Require Pivoting for Gaussian Elimination III

x 6  1,
1 1 1 1
x1  x 2  ,
2 2 x5   x 6  1,
2 1
2 2
 x 2  x3  , x 4  1,
3 3
 x4  1, x 3  2 x 4  x 5  1,
 x3  2 x4  x5  0,
1 2
1 1 x2   x 3  1,
x5  x6  , 3 3
2 2
x 6  1. 1 1
x1   x 2  1.
2 2

94
6. Gauss – Jordan Elimination

95
Gauss-Jordan
• Variation of Gauss elimination
• Primary motive for introducing this method is that
it provides a simple and convenient method for
computing the matrix inverse.
• When an unknown is eliminated, it is eliminated
from all other equations, rather than just the
subsequent one.
• All rows are normalized by dividing them by their
pivot elements
• Elimination step results in an identity matrix
Introduction
• For inverting a matrix, Gauss-Jordan elimination is about as
efficient as any other method. For solving sets of linear
equations, Gauss-Jordan elimination produces both the solution
of the equations for one or more right-hand side vectors b, and
also the matrix inverse A−1.
• However, its principal weaknesses are
– (i) that it requires all the right-hand sides to be stored and
manipulated at the same time, and
– (ii) that when the inverse matrix is not desired, Gauss-Jordan is
three times slower than the best alternative technique for solving a
single linear set
• The method’s principal strength is that it is as stable as any other
direct method, perhaps even a bit more stable when full pivoting
is used 97
Graphical depiction of Gauss-Jordan

a11 a12 a13 | c1 


a a ' '
a23 | c2' 
 21 22

a31 a32 a33 | c3 
'' ''

1 0 0 | c1n  
  n 
 0 1 0 | c2 
0 0 1 | c3 n  
Graphical depiction of Gauss-Jordan

a11 a12 a13 | c1  1 0 0 | c1n  


a a ' '
a23 | c2'   n 
 21 22
  0 1 0 | c2 
a31 a32 a33 | c3 
'' ''
0 0 1 | c3 n  

1 0 0 | c1n   x1  c1n 
  n 
 0 1 0 | c2 
x2  c2 n 
0 0 1 | c3 n  
x3  c3 n 
Gauss-Jordan Elimination
Let us consider the set of linearly independent equations.

 2 x  4 y  5z  36

  3x  5 y  7 z  7
5x  3 y  8z  31

Augmented matrix for the set is:

 2 4 5 36 
 3 5 7 7 
 
 5 3  8  31
100
Gauss-Jordan Elimination

Step 1: Eliminate x from the 2nd and 3rd equation.

 2 4 5 36   2 x  4 y  5z  36
 3 5 
7 7    3x  5 y  7 z  7
 
 5 3  8  31 5x  3 y  8 z  31

2  4 5 36   2 x  4 y  5z  36
0  1 14.5 
61    y  14.5z  61
 
0 13  20.5  121 13 y  20.5z  121

101
Gauss-Jordan Elimination

Step 2: Eliminate y from the 3rd equation.

2  4 5 36  2 x  4 y  5z  36
0  1 14.5 61  
    y  14.5z  61
0 0 168 672  168z  672
13R’2+R’3 R’’3 

Step 3:

0.5R’1 R’1 1  2 2.5 18   x  2 y  2.5z  18


0 1  14.5  61 
 y  14.5z  61
-R’2 R’’2    z4

(1/168)R’’3 R’’’3 0 0 1 4 

102
Gauss-Jordan Elimination
Step 4: Eliminate z from the 2nd equation

1  2 2.5 18   x  2 y  2.5z  18
0 1  14.5  61 
 y  14.5z  61
   z4

0 0 1 4 
( Row 3)  (14.5)  ( Row 2)

1  2 2.5 18   x  2 y  2.5 z  18
0 1   
 0 3  y  3
0 0 4   z4
1 
103
Gauss-Jordan Elimination
Step 5-1: Eliminate y from the 1st equation
1  2 2.5 18   x  2 y  2.5 z  18
0 1 0  3 
y  3

  
0 0 1 4   z4

( Row 2)  (2)  ( Row 1)  New Row 1

1 0 2.5 12   x  2.5 z  12
0 1 0  3 
   y  3
0 0 1 4   z4

104
Gauss-Jordan Elimination
Step 5-2: Eliminate z from the 1st equation
1 0 2.5 12   x  2.5 z  12
0 1 0  3 
 y  3
  
0 0 1 4   z4

( Row 3)  (2.5)  ( Row 1)  New Row 1

1 0 0 2   x2
0 1 0  3 
   y  3
0 0 1 4   z4

105
Example
Given the following, determine {x} for the two
different loads {c}
Ax  c
 2 1 1 
1 
A   2 6 3
  3 1  4
cT  1 2 3
c  4
T
 7 1

106
Solution
Ax  c
 2 1 1 
1 
A   2 6 3 {c}T = {1 2 3}
x1 = (2)(1) + (-1)(2) + (1)(3) = 3
  3 1  4 x2 = (-2)(1) + (6)(2) + (3)(3) = 19
c  1
T
2 3
x3 = (-3)(1) + (1)(2) + (-4)(3) = -13

cT  4  7 1
{c} T= {4 -7 1)
x1 = (2)(4) + (-1)(-7) + (1)(1)=16
x2 = (-2)(4) + (6)(-7) + (3)(1) = -47
x3 = (-3)(4) + (1)(-7) + (-4)(1) = -23

107

You might also like