83 200
400
3 33
2 23
1 13
2 23
2 21
1 12
1 13
1 12
2 21
+ =
+ +
= +
= +
c Q
c Q
c Q
c Q
c Q
c Q
c Q
c Q
c Q
or collecting terms
200 400
3 33
2 23
1 13
2 23
21 1
12 2
21 1
13 12
= +
− −
= +
+ −
= −
+
c Q
c Q
c Q
c Q
Q c
Q c
Q c
Q Q
Substituting the values for the flows and expressing in matrix form
⎪⎭ ⎪
⎬ ⎫
⎪⎩ ⎪
⎨ ⎧
= ⎪⎭
⎪ ⎬
⎫ ⎪⎩
⎪ ⎨
⎧ ⎥
⎥ ⎦
⎤ ⎢
⎢ ⎣
⎡ −
− −
− 200
400 120
60 40
80 80
20 120
3 2
1
c c
c
A solution can be obtained with MATLAB as A = [120 -20 0;-80 80 0;-40 -60 120];
b = [400 0 200]; c = a\b
c = 4.0000
4.0000 5.0000
8.11 Equations for the amount of sand, fine gravel and coarse gravel can be written as
8000 50
. 35
. 38
. 5000
15 .
40 .
30 .
6000 35
. 25
. 32
.
3 2
1 3
2 1
3 2
1
= +
+ =
+ +
= +
+
x x
x x
x x
x x
x
where x
i
= the amount of gravel taken from pit i. MATLAB can be used to solve this system of equations for
A=[0.32 0.25 0.35;0.3 0.4 0.15;0.38 0.35 0.5]; b=[6000;5000;8000];
x=A\b x =
1.0e+003 7.0000
4.4000 7.6000
Therefore, we take 7000, 4400 and 7600 m
3
from pits 1, 2 and 3 respectively.
84
8.12 Substituting the parameter values the heat-balance equations can be written for the four
nodes as
4 200
2 .
2 4
2 .
2 4
2 .
2 4
2 .
2 40
4 3
4 3
2 3
2 1
2 1
= −
+ −
= −
+ −
= −
+ −
= −
+ −
T T
T T
T T
T T
T T
Collecting terms and expressing in matrix form
⎪ ⎭
⎪ ⎬
⎫ ⎪
⎩ ⎪
⎨ ⎧
= ⎪
⎭ ⎪
⎬ ⎫
⎪ ⎩
⎪ ⎨
⎧ ⎥
⎥ ⎥
⎦ ⎤
⎢ ⎢
⎢ ⎣
⎡ −
− −
− −
− 204
4 4
44 2
. 2
1 1
2 .
2 1
1 2
. 2
1 1
2 .
2
4 3
2 1
T T
T T
The solution can be obtained with MATLAB as A=[2.2 -1 0 0;-1 2.2 -1 0;0 -1 2.2 -1;0 0 -1 2.2]
b=[44 4 4 204] T=A\b
T = 50.7866
67.7306 94.2206
135.5548
85
CHAPTER 9
9.1
The flop counts for LU decomposition can be determined in a similar fashion as was done for Gauss elimination. The major difference is that the elimination is only implemented for
the left-hand side coefficients. Thus, for every iteration of the inner loop, there are n multiplicationsdivisions and n – 1 additionsubtractions. The computations can be
summarized as
Outer Loop k
Inner Loop i
AdditionSubtraction flops
MultiplicationDivision flops
1 2, n
n – 1n – 1 n – 1n
2 3, n
n – 2n – 2 n – 2n – 1
. .
. .
. .
k k + 1, n
n – kn – k n – kn + 1 – k .
. .
. .
. n – 1
n, n 11 12
Therefore, the total additionsubtraction flops for elimination can be computed as
[ ]
∑ ∑
− =
− =
+ −
= −
−
1 1
2 2
1 1
2
n k
n k
k nk
n k
n k
n Applying some of the relationships from Eq. 8.14 yields
[ ]
6 2
3 2
2 3
1 1
2 2
n n
n k
nk n
n k
+ −
= +
−
∑
− =
A similar analysis for the multiplicationdivision flops yields
3 3
1
3 1
1
n n
k n
k n
n k
− =
− +
−
∑
− =
[ ] [
]
3 3
1
2 3
2 3
3 2
3
n O
n n
O n
n O
n n
O n
+ =
⎥⎦ ⎤
⎢⎣ ⎡
+ +
+ −
+ Summing these results gives
6 2
3 2
2 3
n n
n −
− For forward substitution, the numbers of multiplications and subtractions are the same and
equal to
86 2
2 2
1
2 1
1
n n
n n
i
n i
− =
− =
∑
− =
Back substitution is the same as for Gauss elimination: n
2
2 – n2 subtractions and n
2
2 + n2 multiplicationsdivisions. The entire number of flops can be summarized as
MultDiv AddSubtr
Total Forward elimination
3 3
3
n n −
6 2
3
2 3
n n
n +
− 6
2 3
2
2 3
n n
n −
−
Forward substitution
2 2
2
n n −
2 2
2
n n −
n n
−
2
Back substitution
2 2
2
n n +
2 2
2
n n −
2
n
Total
3 3
2 3
n n
n −
+ 6
5 2
3
2 3
n n
n −
+ 6
7 2
3 3
2
2 3
n n
n −
+ The total number of flops is identical to that obtained with standard Gauss elimination.
9.2 Equation 9.6 is