Maple Assignment #3 Solutions

advertisement
Maple Assignment #3 Solutions
> restart: with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
a.) Find the matrix A such that x(t+1)=Ax(t), assuming that the customer base remains unchanged.
Verify that A is a regular transition matrix by checking that the criteria in the definition hold. The
matrix A given below is a regular transition matrix since the entries are all positive and the columns
add up to one (.6+.2+.2)=(.1+.7+.2)=(.5+.1+.4)=1
> A:=matrix(3,3,[.6, .1, .5, .2, .7, .1, .2, .2, .4]);
0.6 0.1 0.5





A := 0.2 0.7 0.1




0.2
0.2
0.4


b.) Find the long term fraction of customers that will be using the services of each company. Your
answer should be for the general case where no initial conditions are specified and should be the exact
answer in the limit as time goes to infinity. We must find the eigenvector that has an eigenvalue of
one and then normalize it with respect to the sum of the components.
> data:=eigenvects(A);
data := [0.4999999999, 1, {[0.6699917097, -0.6699917094, -0.10 10 -8]}],
[0.9999999985, 1, {[0.7396002619, 0.6471502291, 0.4622501631 ]}],
[0.2000000007, 1, {[-1.076297285, 0.2690743206, 0.8072229621 ]}]
> v:=data[2][3][1];
v := [0.7396002619, 0.6471502291, 0.4622501631 ]
> sumv:=v[1]+v[2]+v[3];
sumv := 1.849000654
> vnormal:=evalm(v/sumv);
vnormal := [0.4000000001, 0.3500000001, 0.2499999998 ]
In the long term, 40% of the people use AT&T, 35% use MCI and 25% use Sprint.
c.) For the following three initial conditions, find the number of customers using each of the three
services after one month, one year and ten years.
First, we define the initial condition vectors. Then, we calculate the number of customers after one
month (Ax), one year (A^(12)x) and ten years (A^(120)x). We’ll look at the first two vectors together
as the total population in both cases is 600.
> x0_1:=matrix(3,1,[200,200,200]);
x0_2:=matrix(3,1,[600,0,0]);
x1_1:=evalm(A&*x0_1);
x1_2:=evalm(A&*x0_2);
x12_1:=evalm(A&^(12)&*x0_1);
x12_2:=evalm(A&^(12)&*x0_2);
x120_1:=evalm(A&^(120)&*x0_1);
x120_2:=evalm(A&^(120)&*x0_2);
 200





x0_1 :=  200




 200
 600




x0_2 :=  0




 0
240.0




x1_1 := 200.0




160.0
360.0





x1_2 := 120.0




120.0


240.0065102





x12_1 := 209.9934896




150.0000002
240.0390633




x12_2 := 209.9609373




149.9999994
240.0000000




x120_1 := 210.0000000




150.0000000
239.9999999





x120_2 := 210.0000000




150.0000000


Now, we’ll look at the case where the total population is 300.
> x0_3:=matrix(3,1,[100,100,100]);
x1_3:=evalm(A&*x0_3);
x12_3:=evalm(A&^(12)&*x0_3);
x120_3:=evalm(A&^(120)&*x0_3);
 100





x0_3 :=  100




 100
120.0




x1_3 := 100.0




 80.0 
120.0032551




x12_3 := 104.9967448




75.00000009
120.0000000





x120_3 := 105.0000000




75.00000000


d.) For the same three initial conditions as in part (c), find the number of customers using each of the
three services after a very, very long time. You should use your result from part (b) here. Here, we
use the fact that 40% use AT&T, 35% use MCI and 25% use Sprint. To calculate the long term
number of customers for each, we can multiply the long term state vector by the total population size
(600 in the first two examples and 300 in the third example).
> vlong:=matrix(3,1,[.4,.35,.25]);
xlong_1:=evalm(600*vlong);
xlong_2:=evalm(600*vlong);
xlong_3:=evalm(300*vlong);
 0.4 




vlong := 0.35




0.25
 240.0 





xlong_1 := 210.00




150.00


 240.0 





xlong_2 := 210.00




150.00
 120.0 





xlong_3 := 105.00




 75.00 
2a.)
> restart:with(linalg):
A:=matrix(6,6,[1,2,3,6,4,5,4,4,5,2,1,4,6,3,1,3,2,6,3,6,2,1,6,3,2,1
,4,5,5,1,5,5,6,4,3,2]);
Warning, the protected names norm and trace have been redefined and unprotected
 1
2
3
6
4
5




 4
4
5
2
1
4





 6
3
1
3
2
6

A := 

 3

6
2
1
6
3






 2

1
4
5
5
1




 5
5
6
4
3
2
b.) Calculate the following powers of your matrix: A^2, A^5, A^10, A^15.
> A2:=evalm(A&^2);
A5:=evalm(A&^5);
A10:=evalm(A&^10);
A15:=evalm(A&^15):
78 84 74 65 83
63




78 72 69 70 59

81






67 77 84 82 75

71


A2 := 

69 63 85 79 67

66






60 60 51 60 75

60




89 85 78 85 82 100
683940 683976 685226 685106 684488


668318 668296 668431 668232 667441



703459 703409 701652 701791 702912

A5 := 
663411 662787 660883 661360 662692



559530 559836 561285 561339 561078


805443 805797 806624 806273 805490
A10 :=
684252


668557


703160

663249


559485

805398
[2795540203544 , 2795539689004 , 2795536266374 , 2795536914226 , 2795539493144 ,
2795539600042]
[2729187739710 , 2729187604452 , 2729186493565 , 2729186341381 , 2729186412664 ,
2729187743307]
[2870039579131 , 2870040438185 , 2870045742330 , 2870044780882 , 2870040949893 ,
2870040415760]
[2705348713930 , 2705349856520 , 2705356943275 , 2705355755768 , 2705350998037 ,
2705349692573]
[2288646126387 , 2288645360847 , 2288641080123 , 2288642225454 , 2288645991558 ,
2288645314083]
[3291118615499 , 3291118029193 , 3291114452534 , 3291114960490 , 3291117132905 ,
3291118212436]
c.) Rewrite your matrix A as a product of a constant, k, and a regular transition matrix B. Your answer
should have the form A=kB, where B is a regular transition matrix. We notice that the sum of the
entries in each column is 1+2+3+4+5+6=21. So, if we let k=21 and B=A/21, we get the desired form.
> B:=evalm(A/21);
 1
2
1
2
4
5 


 21
21
7
7
21
21 





 4
4
5
2
1
4 

 21
21
21
21
21
21 





 2

1
1
1
2
2


 7
7
21
7
21
7 


B := 

 1
2
2
1
2
1 



 7
7
21
21
7
7 




 2

1
4
5
5
1




 21

21
21
21
21
21




 5
5
2
4
1
2 



 21
21
7
21
7
21 
d.) Did you see any sort of pattern arising in your calculations in part (b)? What seems to be
happening to the columns of each matrix as the power increases? Use the formula you wrote down in
part (c) and what you learned in class about transition matrices to explain what you see happening.
Write down a formula for A^t as t becomes very large.
You hopefully noticed that as t became larger, the columns of A^t approached the same column
vector. However, unlike a regular transition matrix the columns changed for every power of t.
Remember that A=21B where B is a regular transition matrix. As t gets very large we know that B^t
=> [w w w w w w] where w is an eigenvector of B with associated eigenvalue 1, and component sum
=> [w w w w w w] where w is an eigenvector of B with associated eigenvalue 1, and component sum
equal to one. Therefore A^t=(21B)^t=(21)^t(B^t) => (21)^t [w w w w w w]. So, the columns of A^t
should eventually be identical to one another and should equal 21^t w, where w is the eigenvector of B
with eigenvalue one and column sum equal to one.
Let’s check and make sure this is correct. I know that lambda=1 must be an eigenvalue, so I’ll go
ahead and find the kernel of (I-B) directly. (This saves us from having to look at all six eigenvalues
and eigenvectors of B which can be kind of messy.)
> Identity:=matrix(6,6,[1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,
0,0,0,0,0,0,1,0,0,0,0,0,0,1]):
Bnew:=evalm(B-Identity):
v:=nullspace(Bnew);
 50355 294959
5733 82449 177845 
 }
v := {
,
, 1,
,
,
 51697 310182
6082 103394 155091 
> vsum:=convert(v[1][1]+v[1][2]+v[1][3]+v[1][4]+v[1][5]+v[1][6],floa
t);
vsum := 5.811720216
The convert( ,float) command tells Maple to give the solution as a decimal number rather than a
fraction.
> vnormal:=evalm(v[1]/vsum);
vnormal :=
[0.1675994388, 0.1636214970, 0.1720660945, 0.1621925222, 0.1372098712, 0.1973105762 ]
As t gets very large we expect the columns of A^t to equal 21^t times the vector given above. Let’s
check this by dividing our matrices A^2, A^5, A^10 and A^15 by the appropriate powers of 21. I’ll
extract the first column from each matrix and write it as a row vector to save on space.
> B2:=transpose(delcols(convert(evalm(A2/21^2),float),2..6));
B5:=transpose(delcols(convert(evalm(A5/21^5),float),2..6));
B10:=transpose(delcols(convert(evalm(A10/21^10),float),2..6));
B15:=transpose(delcols(convert(evalm(A15/21^15),float),2..6));
B2 :=
[0.1768707483 , 0.1768707483 , 0.1519274376 , 0.1564625850 , 0.1360544218 , 0.2018140590 ]
B5 :=
[0.1674640270 , 0.1636389502 , 0.1722432917 , 0.1624374618 , 0.1370019987 , 0.1972142707 ]
B10 :=
[0.1675995295 , 0.1636215356 , 0.1720659508 , 0.1621923272 , 0.1372099795 , 0.1973106774 ]
B15 :=
[0.1675994388 , 0.1636214970 , 0.1720660946 , 0.1621925223 , 0.1372098711 , 0.1973105762 ]
We see that as t increases, we get closer and closer to the true eigenvector.
Download