Professional Documents
Culture Documents
Palm ch6
Palm ch6
A=
3 4
6 10
Thus
x=A
1
x=
6
"
"
b=
10 4
6 3
#"
5
2
5
2
"
7
4
A=
3 4
6 8
"
b=
5
2
But |A| = 3(8) 6(4) = 0, so the inverse of A does not exist. Thus there is no unique
solution. (These two equations are represented by parallel lines.)
The Matlab session is
A = [3,-4;6,-8];
b = [5;2];
x = inv(A)*b
Warning: Matrix is singular to working precision.
6-1
x =
Inf
Inf
Thus no solution exists.
T6.3-1 Cramers determinants are
4 b
D=
3
6
"
D1 =
5 b
3
6
"
D2 =
4 5
3 3
6-2
These numbers are the right hand side of the equations. Thus the answer x = 1.0204,
y = 0.5940, z = 0.1332 is correct. Because the ranks are 3 and equal the number of
unknowns, the solution is unique.
T6.4-2 The Matlab session is
A = [1,3,2;1,1,1];
b = [2;4];
rank(A)
ans =
2
rank([A b])
ans =
2
pinv(A)*b
ans =
4.3333
-1.6667
1.3333
x = A\b
x =
5.0000
-1.0000
0
Because the ranks are 2 and less than the number of unknowns, the solution is not unique.
The minimum-norm solution is x = 4.3333, y = 1.6667, z = 1.333. The left-division
solution is x = 5, y = 1, z = 0.
T6.4-3 The Matlab session is
A = [3,5,6;8,-1,2;5,-6,-4];
b = [6;1;-5];
rank(A)
ans =
2
rank([A b])
ans =
2
rref([A b])
ans =
1.0000 0 0.3721 0.2558
0 1.0000 0.9767 1.0465
0 0 0 0
6-3
x = pinv(A)*b
x =
0.0571
0.5249
0.5340
x = A\b
Warning: Matrix is singular to working precision.
x =
Inf
Inf
Inf
Because the ranks are less than the number of unknowns, an infinite number of solutions
exists. The reduced row echelon form gives the following solutions:
x = 0.3721z + 0.2558
y = 0.9767z + 1.0465
where z can have any value.
The pseudoinverse solution is x = 0.0571, y = 0.5249, z = 0.534.
T6.4-4 The Matlab session is
A = [3,5,6;8,-1,2;5,-6,-4];
b = [6;1;-5];
rank(A)
ans =
2
rank([A b])
ans =
2
rref([A b])
ans =
1.0000 0 -0.2727 5.2727
0 1.0000 1.3636 -2.3636
x = pinv(A)*b
x =
4.8394
-0.1972
-1.5887
x = A\b
x =
4.8000
6-4
0
-1.7333
Because the ranks are equal but less than the number of unknowns, an infinite number of
solutions exists. These are given by the reduced row echelon form:
x = 0.2727z + 5.2727
y = 1.3636z 2.3636
where z can have any value.
T6.5-1 The Matlab session is
A = [1,-3;3,5;70,-28];
b = [2;7;153];
rank(A)
ans =
2
rank([A b])
ans =
2
x = A\b
x =
2.2143
0.0714
Because the ranks are equal to the number of unknowns, a unique solution exists, which is
given by the left division method.
T6.5-2 The Matlab session is
A = [1,-3;3,5;5,-2];
b = [2;7;-4];
rank(A)
ans =
2
rank([A b])
ans =
3
Because the ranks are unequal, no exact solution exists.
6-5
End-of-Chapter Problems
1. (a) x = 2, y = 4 (b) The equations represent parallel lines; thus, no solution exists. (c)
Dividing the second equation by 4 gives the first equation. Thus there is only one equation,
which can be solved for y in terms of x as follows: y = 3 + 2x. (d) The equations represent
parallel lines; thus, no solution exists.
2. x = 3, y = 5, z = 2
3. x = 2, y = 3, z = 5
4. (a) The solution is: x = (4r + 5)/(2r 1), y = (2r 8)/(2r 1), z = 14/(2r 1). (b)
The denominator in the solution is 0 if r = 1/2. Thus, no solution exists if r = 1/2.
5. (a) The session is
A=[2,1;3,-9];b=[5;2];A\b
ans =
2.2381
0.5238
(b) The session is
A=[-8,-5;-2,7];b=[4;10];A\b
ans =
-1.1818
1.0909
(c) The session is
A=[12,-5,0;-3,4,7;6,2,3];b=[11;-3;22];A\b
ans =
3.0000
5.0000
-2.0000
(d) The session is
A=[6,-3,4;12,5,-7;-5,2,6];b=[41;-26;14];A\b
ans =
2
-3
5
6-6
ans =
19.0000
7.0000
20.0000
-75.0000
Because the product A*x gives b, the answer x1 = 2, x2 = 10, x3 = 3, x4 = 5 is correct.
7. There are 7 equations in terms of six variables. Note that i6 appears in only 2 of the
equations. Thus we can use equations 1, 2, 3, 5, and 6 to solve for the five currents i1
through i5 , then use the solution to find i6 from either the fourth or seventh equation. The
script file using the values given in part (b) is
R=[1,5,2,10,5]*1000;
v = 100;
A=[0,-R(2),0,-R(4),0;R(1),-R(2),R(3),0,0;0,0,-R(3),- R(4),R(5);
0,1,1,-1,0;1,0,-1,0,-1];
b=[-v;0;0;0;0];
current = A\b
The answers are in amperes. The current i6 is found from the fourth equation: i6 = i1 +i2 =
0.0189 + 0.0049 = 0.0238.
8. (a) Rearrange the equations by bringing all the unknowns to the left side.
R1 q1 + p1 = pa
R2 q2 p1 = pb
R3 q3 p1 = pc
q1 q2 q3 = 0
6-8
A=
R1
0
0
1
0 R2
0 1
0
0 R3 1
1 1 1
0
b=
pa
pb
pc
0
x=
q1
q2
q3
p1
(1)
(2)
(3)
6-9
Equations (1), (2), and (3) can be rearranged into the following set:
t3f a1 + t4f a2 + t5f a3 = 1 (tf ) 1 (0)
3t2f a1 + 4t3f a2 + 5t4f a3 = 0
6tf a1 + 12t2f a2 + 20t3f a3 = 0
This set has the form Ax = b where
t3f
2
A = 3tf
6tf
t4f
4t3f
12t2f
t5f
5t4f
20t3f
1 (tf ) 1 (0)
0
b=
a1
x = a2
a3
The solution vector x contains a1 , a2 , a3 . The equations for the coefficents b1 , b2 , b3 are
identical to the above equations, except that 1 (tf ) 1 (0) is replaced with 2 (tf ) 2 (0).
(b) For tf = 2, 1 (0) = 19 , and 1 (tf ) = 43 ,
8 16 32
A = 12 32 80
12 48 160
43 (19)
62
0
b=
= 0
0
0
2
1.5
1
0.5
0
Start
0.5
0
6-11
=
=
=
=
=
The results are T = [19.7596, 7.0214, 9.7462] C and q = 6.6785 watts/meter2 . Thus the
heat loss in watts is 10(6.6785) = 66.785.
11. Rearrange the four equations by bringing all the unknowns to the left and clearing the
fractions to obtain
3T1 T2 T3 = Ta
T1 2T2 + T4 = 0
T1 2T3 + T4 = 0
T2 + T3 3T4 = Tb
Thus the equations have the matrix form Ax = b where
A=
3 1 1
0
1 2
0
1
1
0 2
1
0
1
1 3
b=
6-12
Ta
0
0
Tb
x=
T1
T2
T3
T4
= (Ta + T2 + T4 )/3
= (T2 + T6 )/2
= (T2 + T4 + T6 + T8 )/4
= (T4 + T8 )/2
= (T6 + T8 + Tb )/3
T2
T4
T6
T8
= (T1 + T3 + T5 )/3
= (T1 + T5 + T7 )/3
= (T3 + T5 + T9 )/3
= (T7 + T5 + T9 )/3
Rearrange these equations by bringing all the unknowns to the left and clearing the fractions.
The equations have the matrix form Ax = b where
A=
3 1
0 1
0
0
0
0
0
1 3
1
0
1
0
0
0
0
0
1 2
0
0
1
0
0
0
1
0
0 3
1
0
1
0
0
0
1
0
1 4
1
0
1
0
0
0
1
0
1 3
0
0
1
0
0
0
1
0
0 2
1
0
0
0
0
0
1
0
1 3
1
0
0
0
0
0
1
0
1 3
b=
Ta
0
0
0
0
0
0
0
Tb
x=
T1
T2
T3
T4
T5
T6
T7
T8
T9
Because of the large size of A it is better to use a script file rather than an interactive
session to enter the elements. A script file allows for easier editing of mistakes. The script
file using Ta = 150 and Tb = 20 is shown below.
A = [3,-1,0,-1,0,0,0,0,0;
1,-3,1,0,1,0,0,0,0;
0,1,-2,0,0,1,0,0,0;
1,0,0,-3,1,0,1,0,0;
0,1,0,1,-4,1,0,1,0;
0,0,1,0,1,-3,0,0,1;
6-13
0,0,0,1,0,0,-2,1,0;
0,0,0,0,1,0,1,-3,1;
0,0,0,0,0,1,0,1,-3];
b = [150;0;0;0;0;0;0;0;-20];
x = A\b
When this file is run, it produces the result
x =
112.8571
94.2857
85
94.2857
85
75.7143
85
75.7143
57.1429
Thus T1 = 112.8571, T2 = 94.2857, T3 = 85, T4 = 94.2857, T5 = 85, T6 = 75.7143, T7 = 85,
T8 = 75.7143, and T9 = 57.1429 C.
13. For y(x) = a3 x3 + a2 x2 + a1 x + a0 , y(0) = 100 gives a0 = 100. For zero slope at x = 0,
a1 = 0. Thus y(x) = a3 x3 + a2 x2 + 100 and s(x) = 3a3 x2 + 2a2 x. For y(120) = 10, we have
1203 a3 + 1202 a2 + 100 = 10, or
1203 a3 + 1202 a2 = 90
For the slope at x = 120 to be tan 30 , we have
3(1202 )a3 + 2(120)a2 = tan 30
We can use Matlab to solve these two equations. The script file is:
A = [120^3,120^2;3*120^2,240];
b = [-90;tan(30*pi/180)];
x = A\b
a0 = 100
a1 = 0
a2 = x(2)
a3 = x(1)
xp = [0:0.1:120];
y = polyval([a3,a2,a1,a0],xp);
plot(xp,y),xlabel(x (feet)),ylabel(y (feet))
6-14
The solutions are a2 = 0.0236 and a3 = 1.4426 104 . The profile is shown in the figure.
No undesired behavior (such as a large change in slope) is observed.
100
90
80
70
y (feet)
60
50
40
30
20
10
20
40
60
x (feet)
80
100
6-15
120
14. Create the following function file to solve the two linear equations.
function [V, L] = mix(p)
A = [1,1;0.684,0.4];
b = [1;0.01*p];
x = A\b;
V = x(1);
L = x(2);
Typing [V,L] = mix(50) gives the results: V = 0.3521 and L = 0.6479.
15. (a) The solution is C = B1 (A1 B A). (b) The session to evaluate C using this
solution is
A = [3,9;-2,4];B = [2,-3;7,6];
C = inv(B)*(inv(A)*B-A)
C =
-0.6212 -2.3636
1.1970 2.1576
16. a) The inverse A1 is
"
0.4286
0.0476
0.1429 0.0952
x=A
b=
0.4286
0.0476
0.1429 0.0952
#"
5
2
"
2.2381
0.5238
x=A
b=
0.1061 0.0758
0.0303
0.1212
#"
4
10
6-16
"
1.1818
1.0909
6 1
6 1
1
1
= 6
=2
y=
D
Cramers determinant for Problem 1(b) is
2 1
D=
2 1
5 6
1
6
=0
=4
2 1
D=
3 9
5
2
1
9
47
D
21
Cramers determinant for Problem 5(b) is
x=
8
D=
2
x=
4
10
5
7
D
5
7
13
11
= 21
y=
2
3
5
2
D
11
21
= 66
y=
8 4
2 10
12
11
20. Because rank(A) and rank([A b]) both equal 2, which is less than the number of
unknowns, there is no unique solution. Using the rref command, the session is
A = [7,9,-9;3,2,-4;1,5,-1];b = [22;12;-2];
rank(A)
ans =
2
rank([A b])
ans =
2
rref([A b])
ans =
1.0000 0 -1.3846 4.9231
0 1.0000 0.0769 -1.3846
0 0 0 0
Thus the reduced row echelon form gives the solution x = 1.3846z + 4.9231, y = 0.0769z
1.3846, where z can have any value.
21. (a) The equations for the number of hours used per week are, for reactor A,
6x + 2y + 10z = 35
and for reactor B,
3x + 5y + 2z = 40
A session to check the ranks and find the reduced row echelon form is shown below.
6-18
A=[6,2,10;3,5,2];b=[35;40];
rank(A)
ans =
2
rank([A b])
ans =
2
rref([A b])
ans =
1.0000 0 1.9167 3.9583
0 1.0000 -0.7500 5.6250
Because the ranks are equal but one less than the number of unknowns, we can determine
two of the unknowns in terms of a third unknown. The set of equations corresponding to
the reduced row echelon form is
x = 3.9583 1.9167z
y = 5.625 + 0.75z
(b) From the equation for x, we see that x 0 implies that 3.9583 1.9167z 0, or
z 3.9583/1.9167 = 2.0652. Also, x 3.9583 if z 0. Thus the resulting range for x is
0 x 3.9583.
From the equation for y note that y 5.625 if z 0. Thus the allowable range for z is
0 z 2.0652, and the resulting range for y is y 5.625.
(c) The profit P is P = 200x + 300y + 100z. Substituting the expressions for x and y in
to this expression, and collecting terms, we obtain
P = 200(3.9583 1.9167z) + 300(5.625 + 0.75z) + 100z = 2479.16 58.34z
Thus the profit decreases with increasing z, so to maximize profit we should choose z = 0
(that is, not make any of product 3). Thus, x = 3.9583 and y = 5.625 tons per week.
(d) The profit P is P = 200x + 500y + 100z. Substituting the expressions for x and y
in to this expression, and collecting terms, we obtain
P = 200(3.9583 1.9167z) + 500(5.625 + 0.75z) + 100z = 3604.16 + 91.66z
Thus the profit increases with increasing z, so to maximize profit we should choose z equal
to its maximum possible value, which from part (b) is z = 2.0652. Substituting this value
into the equations for x and y, we obtain x = 0 and y = 7.1739 tons per week.
22. Equating the flow in to the flow out at each intersection, we obtain the following
equations:
100 + 200 = f1 + f3
6-19
f1 + 300 = f2 + f4
f2 + f5 = 100 + 500
f3 + f6 = 100 + 300
f4 + f7 = f6 + 200
200 + 400 = f5 + f7
Rearrange these equations by bringing all the unknowns to the left. The equations have
the matrix form Ax = b where
A=
1
0 1
0 0
0 0
1 1 0 1 0
0 0
0
1 0
0 1
0 0
0
0 1
0 0
1 0
0
0 0
1 0 1 1
0
0 0
0 1
0 1
b=
300
300
600
400
200
600
x=
f1
f2
f3
f4
f5
f6
Because of the large size of A it is better to use a script file rather than an interactive
session to enter the elements. A script file allows for easier editing of mistakes. The script
file is shown below.
A = [1,0,1,0,0,0,0;
1,-1,0,-1,0,0,0;
1,-1,0,-1,0,0,0;
0,1,0,0,1,0,0;
0,0,1,0,0,1,0;
0,0,0,1,0,-1,1;
0,0,0,0,1,0,1];
b=[300;-300;600;400;200;600];
rankA = rank(A)
rankAb = rank([A b])
rref([A b])
When this file is run, it produces the result
rankA =
5
rankAb =
5
ans =
1 0 0 0 0 -1 0 -100
0 1 0 0 0 0 -1 0
0 0 1 0 0 1 0 400
6-20
0 0 0 1 0 -1 1 200
0 0 0 0 1 0 1 600
0 0 0 0 0 0 0 0
Because the ranks are equal but 2 less than the number of unknowns, we can express 5 of
the unknowns in terms of the remaining 2 unknowns. The reduced row echelon form given
by the rref command is
f1 = f6 100
f2 = f7
f3 = 400 f6
f4 = f6 f7 + 200
f5 = 600 f7
Thus if we install sensors to measure the traffic flows f6 and f7 , we will be able to use
the above equations to compute the flows on all the streets. Of course, we could choose to
install sensors on any two streets, but the preceding equations would need to be rewritten.
23. Because rank(A) and rank([A b]) both equal 2, which is equal to the number of
unknowns, there is a unique solution, which can be found by left division. The session is
A = [1,-3;1,5;4,-6];b = [2;18;20];
A\b
ans =
8.0000
2.0000
Thus x = 8 and y = 2.
24. Because rank(A) is 2 and rank([A b]) is 3, there is no exact solution. The least squares
solution can be found with the left division method. The session is
A = [1,-3;1,5;4,-6];b = [2;18;10];
A\b
ans =
6.0928
2.2577
Thus the least squares solution is x = 6.0928 and y = 2.2577.
25. (a) Substituting the values of x and y into ax2 + bx + c = y for each point gives the
three equations:
a+b+c=4
6-21
16a + 4b + c = 73
25a + 5b + c = 120
These equations have the form Ax = b where
1 1 1
A = 16 4 1
25 5 1
b = 73
120
x= b
c
Because rank(A) and rank([A b]) both equal 3, which is equal to the number of unknowns,
there is a unique solution, which can be found by left division. The session is
A = [1,1,1;16,4,1;25,5,1];b = [4;73;120];
A\b
ans =
6.0000
-7.0000
5.0000
Thus a = 6, b = 7, and c = 5. The curve given by y = 6x2 7x + 5 passes through all
three points.
(b) Substituting the values of x and y into ax3 + bx2 + cx + d = y for each point gives the
three equations:
a+b+c+d= 4
64a + 16b + 4c + d = 73
125a + 25b + 5c + d = 120
These equations have the form Ax = b where
1 1 1 1
A = 64 16 4 1
125 25 5 1
b = 73
120
x=
a
b
c
d
Because rank(A) and rank([A b]) both equal 3, which is less than the number of unknowns,
there is no exact solution. The least squares solution can be found by left division. The
session is
A = [1,1,1,1;64,16,4,1;125,25,5,1];b = [4;73;120];
A\b
ans =
0.2414
3.5862
0
0.1724
6-22
120
100
Data
Quadratic
Cubic
80
60
40
20
0
1
1.5
2.5
3
x
3.5
4.5
6-23