Upload
nguyenanh
View
224
Download
2
Embed Size (px)
Citation preview
Page 4 - 1
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Numerical Methods for Numerical Methods for Chemical EngineersChemical Engineers
Chapter 4: System of Linear Algebraic Chapter 4: System of Linear Algebraic EquationEquation
Saharudin Saharudin HaronHaron
Page 4 - 2
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
This chapter deals with the case of determining the values x1 , x2 , …, xn that simultaneously satisfy a set of equations:
a11x1 + a12x2 + . . . .+ a1nxn = b1a21x1 + a22x2 + . . . .+ a2nxn = b2
. .
. .an1x1 + an2x2 + . . . .+ annxn = bn
where the a’s are constant coefficients, b’s are constants and n is the number of equations.
System of Linear Algebraic EquationsSystem of Linear Algebraic Equations
Page 4 - 3
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Goals and ObjectivesBe able to solve problems involving linear algebraic equationsAppreciate the usage of linear algebraic equations in any field of engineeringMastering several techniques and their reliability
Naïve Gauss eliminationGauss-Jordan eliminationLU decompositionGauss Siedel
Be able to use a program to successfully solve systems of linearalgebraic equations
Page 4 - 4
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Naïve Gauss EliminationA systematic technique use to solve linear algebraic equations simultaneously with two steps:
a) Forward elimination- the equations were manipulated to eliminate all the elements
below the main diagonal of matrix A
b) Back Substitution- the elimination step result in one equation with one unknown.- the equation could be solved directly and the result back-
substituted into one of the original equations to solve the remaining unknown.
Page 4 - 5
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
The procedure of Naïve Gauss EliminationRepresenting the linear algebraic equations in an augmented matrix form.
a11x1 + a12x2 + a13x3 + .. + a1nxn = c1a21x1 + a22x2 + a23x3 + .. + a2nxn = c2a31x1 + a32x2 + a33x3 + .. + a3nxn = c3
: : : : : :an1x1 + an2x2 + an3x3 + .. + annxn = cn
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
=
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
nnnnnn
n
n
n
cccc
xxxx
aaaaaaaaaaaaaaaa
3
2
1
3
2
1
3321
3333231
2232221
1131211
........
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
4
3
2
1
321
3333231
2232221
1131211
..
..
..
..
cccc
aaaaaaaaaaaaaaaa
nnnnn
n
n
n Label as row or eqn. (1). - (1)
- (2)
- (3)
- (n)
Page 4 - 6
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Steps of Naïve Gauss Elimination (ex. 3 unknowns in 3 equations).A) Forward elimination
a) To eliminate the first unknown, x1, from the second through the nth row/eqn.- row/eqn (1) is called the pivot equation, and a11 is called pivot element.
)3()2()1(
3
2
1
333231
232221
131211
−−−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
ccc
aaaaaaaaa
(i) (1) x a21/a11 ⇒ (1a)(ii) (2) – (1a) ⇒ (2')(iii) (1) x a31/a11 ⇒ (1b)(iv) (3) – (1b) ⇒ (3')
)3()2()1(
3
2
1
3332
2322
131211
′−
′−−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′
′′′′
ccc
aaaaaaa
the prime ' indicates that the elements have been modified.
Page 4 - 7
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Steps of Naïve Gauss Elimination (ex. 3 unknowns in 3 equations).
b) To eliminate the second unknown, x2, from the third through the nth row/eqn.- row/eqn (2') is called the pivot equation.
)3()2()1(
3
2
1
3332
2322
131211
′−
′−−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′
′′′′
ccc
aaaaaaa
(i) (2') x a'32/a'22 ⇒ (2'a)
(ii) (3') – (2'a) ⇒ (3'')
)3()2()1(
3
2
1
33
2322
131211
′′−
′−−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′
′′′′
ccc
aaaaaa
the double prime '' indicates that the elements have been modified twice.
Page 4 - 8
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Steps of Naïve Gauss Elimination (ex. 3 unknowns in 3 equations).
B) Back Substitution
From equation (3'') : [a''33 c''33] ⇒ a''33x3 = c''3
∴ x3 = c''3/a''33
the result x3 can be back-substituted into eqn (2') and (1) to solve for x2 and x1.
1131321211
2232322
/)(/)(
axaxacxaxacx
−−=
′′−′=From equation (2') and (1)
Page 4 - 9
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Naïve Gauss Elimination(assignment in class)
Use Naïve Gauss elimination to solve the following equations.
x1 + x2 – x3 = -36x1 + 2x2 + 2x3 = 2-3x1 + 4x2 + x3 = 1
Page 4 - 10
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Gauss-Jordan EliminationSteps of Gauss-Jordan Elimination (ex. 3 unknowns in 3 equations).
a) Change the value of a11 to 1 and eliminate the other elements in the first column.
)3()2()1(
3
2
1
333231
232221
131211
−−−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
ccc
aaaaaaaaa
(i) (1) x 1/a11 ⇒ (1')(ii) (1') x a21 ⇒ (1'a)(iii) (2) – (1'a) ⇒ (2')(iv) (1') x a31 ⇒ (1'b)(v) (3) – (1'b) ⇒ (3')
)3()2()1(
001
3
2
1
3332
2322
1312
′−
′−
′−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′
′′′′′′
ccc
aaaaaa
the prime ' indicates that the elements have been modified.
Page 4 - 11
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Steps of Gauss-Jordan Elimination (ex. 3 unknowns in 3 equations).
b) Change the value of a'22 to 1 and eliminate the other elements in the second column.
)3()2()1(
001
3
2
1
3332
2322
1312
′−
′−
′−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′
′′′′′′
ccc
aaaaaa
(i) (2') x 1/a'22 ⇒ (2'')(ii) (2'') x a'12 ⇒ (2''a)(iii) (1') – (2''a) ⇒ (1'')(iv) (2'') x a'32 ⇒ (2''b)(v) (3') – (2''b) ⇒ (3'')
)3()2()1(
001001
3
2
1
33
23
13
′′−
′′−
′′−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′′′′
′′′′′′
ccc
aaa
the double prime '' indicates that the elements have been modified twice.
Page 4 - 12
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Steps of Gauss-Jordan Elimination (ex. 3 unknowns in 3 equations).
c) Change the value of a''33 to 1 and eliminate the other elements in the third column.
)3()2()1(
001001
3
2
1
33
23
13
′′−
′′−
′′−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′′′′
′′′′′′
ccc
aaa
(i) (3'') x 1/a''33 ⇒ (3′″)(ii) (3′″) x a''13 ⇒ (3′″a)(iii) (1'') – (3′″a) ⇒ (1′″)(iv) (3′″) x a''23 ⇒ (3′″b)(v) (2'') – (3′″b) ⇒ (2′″)
)3()2()1(
100010001
3
2
1
′′′−
′′′−
′′′−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′′′′′′′
ccc
the triple prime ′″ indicates that the elements have been modified three times.
Page 4 - 13
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Steps of Gauss-Jordan Elimination (ex. 3 unknowns in 3 equations).
d) The value of the unknowns can be determined directly without theback substitution step as in the naïve gauss elimination.
)3()2()1(
100010001
3
2
1
′′′−
′′′−
′′′−
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′′′′′′′
ccc
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
′′′′′′′′′
=⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
3
2
1
3
2
1
100010001
ccc
xxx
11 cx ′′′=
22 cx ′′′=
33 cx ′′′=
Page 4 - 14
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
The most commonly used iterative method for linear equations solving.The linear equations were derived so that the first equation can be solved for x1, the second can be solved for x2 and the third can be solved for x3.
a11x1 + a12x2 + a13x3 + .. + a1nxn = c1a21x1 + a22x2 + a23x3 + .. + a2nxn = c2a31x1 + a32x2 + a33x3 + .. + a3nxn = c3
: : : : : :an1x1 + an2x2 + an3x3 + .. + annxn = cn
Gauss Seidel Method
22
232312122 a
xaxaxacx nn−−−−=
L
x1 =
c1 − a12x2 − a13x3 −L− a1nxn
a11
33
323213133 a
xaxaxacx nn−−−−=
L
nn
mnmnnnn a
xaxaxacx −−−−=
L3322
Page 4 - 15
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Step for Gauss Seidel
x1 =
c1
a11
x3 =
(c3 − a31x1 − a32x2 )a33
x2 =
(c2 − a21x1 )a22
x1 =
(c1 − a12 x2 − a13x3 )a11
x2 =
(c2 − a21x1 − a23x3 )a22
x3 =
(c3 − a31x1 − a32x2 )a33
Second IterationFirst Iteration
εa ,i =
xij − xi
j−1
xij 100% < εs
convergence criteria where j and j -1 arethe present and previous iterations
Page 4 - 16
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Gauss Seidel (assignment in class)
Use the Gauss Seidel method to solve the following equations (εs = 5 %).
17x1 - 2x2 - 3x3 = 500-5x1 + 21x2 - 2x3 = 200-5x1 - 5x2 + 22x3 = 30
Page 4 - 17
Chemical Engineering Numerical Method© copyright PCS- FKKKSA, UTM
Gauss Seidel – assignment in classFigure 1.0 shows a chemical process consists of 3 reactors linked by pipes. The mass flowrateof a chemical (g/s) through each pipe is equal to its concentration in each reactor, c (g/m3) multiplied by the volume flowrate (m3/s) of the pipe. Assume the system is at a steady state, so that the transfer into each reactor will balance the transfer out. Develop mass-balance equations for the reactors, and solve the equations simultaneously for the unknown concentrations (c1, c2, c3) using Gauss-Siedel method with εs = 5%.
R1
R2 R3
(5 m3/s)(c1)(2 m3/s)(c2) (3 m3/s)(c3)
(2 m3/s)(c3)
(5 m3/s)(c2)(14 m3/s)(c2)
(7 m3/s)(c1)
200 g/s
(17 m3/s)(c3)30 g/s
Figure 1.0 (5 m3/s)(c1)
500 g/s