{VERSION 2 3 "IBM INTEL NT" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "Linear Algebra Mth 341 Win ter 1998" }}{PARA 0 "" 0 "" {TEXT -1 28 "Example: Population Movement " }}{PARA 0 "" 0 "" {TEXT -1 13 "Bent Petersen" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 295 "This example deals with \+ population movements. The example involves only as much linear algebra as we studied in the first couple of lectures. Much more can be said \+ about population models, but more linear algebra is required -- in par ticular, matrix multiplication, eigenvalues and eigenvectors." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 576 "We suppo se that we have a population P distributed among 3 locales -- call the m L1, L2 and L3. Each year 5 percent of the population of L1 moves to \+ L2 and 8 percent moves to L3. Also each year 10 percent of the populat ion of L2 moves to L1 and 6 percent moves to L3. Finally each year 7 p ercent of the population of L3 moves to L2 and 2 percent moves to L1. \+ The percentages are relative to the populations at the beginning of th e year and we assume the process goes on year after year (with the sam e percentages). In addition we assume that the total population is con served. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "with(linalg):" }}{PARA 7 "" 1 "" {TEXT -1 32 "Warning , new definition for norm" }}{PARA 7 "" 1 "" {TEXT -1 33 "Warning, new definition for trace" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 366 "When we specify numbers with a decimal p oint Maple treats them as floating point numbers of limited precision. Since our percentages have only two digits we could get in trouble wi th roundoff. Since the progression of events in row reduction depends \+ on whether or not certain computed quantities are exactly 0, even a sm all amount of roundoff can cause big trouble. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 417 "Fortunately Maple does e xact arithmetic with rational numbers, so we avoid the necessity of st udying roundoff (in our calculations) by converting our data to ration al numbers. In reality of course the data are known only approximately , and so we should study (but we will not) how the solutions vary with small pertubations in the data. That almost amounts to studying the p ropogation of roundoff in the calculations!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 152 "Here's a Maple procedure to co nvert a floating point matrix to a rational matrix. There is no error \+ checking or other hand holding - so use it properly." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "ratmatrix := proc(A:matrix)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 " local j,k; " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 30 " for j from 1 to rowdim(A) do " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 32 " for k from 1 to coldim(A) d o" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 41 " A[j,k] := convert(A[j,k],` rational`);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "od; od; A; end:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 178 "L et x0, y0 and z0 be the start of the year populations of L1, L2 and L 3, respectively, and let x1, y1, z1 be the end of year populations.The n from the given data we clearly have" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "" 0 "" {TEXT -1 35 ".87 x0 + .10 y0 + .02 z0 = x1" }}{PARA 0 "" 0 "" {TEXT -1 35 ".05 x0 + .84 y0 + .07 z0 = y1" }} {PARA 0 "" 0 "" {TEXT -1 35 ".08 x0 + .06 y0 + .91 z0 = z1" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 99 "The coeff icient matrix A in these equations is called the transition matrix (o r migration matrix)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "A := matrix(3,3,[.87,.10,.02,.05,.84,.07, .08,.06,.91]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG-%'MATRIXG6#7% 7%$\"#()!\"#$\"#5F,$\"\"#F,7%$\"\"&F,$\"#%)F,$\"\"(F,7%$\"\")F,$\"\"'F ,$\"#\"*F," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 465 "Unfortunately we have not yet developed the tools to ask some really interesting questions such as, what is the long-term beha vior. However we can ask if there is a steady-state situation. That is , is there an initial distribution of the population which remains inv ariant under the population movements described above? Setting x=x0=x1 ,y= y0=y1 and z=z0=z1 above we obtain a homogeneous system of linear e quations for x, y and z, with coefficient matrix B given by" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "B := evalm(A-diag(1,1,1));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"BG-%' MATRIXG6#7%7%$!#8!\"#$\"#5F,$\"\"#F,7%$\"\"&F,$!#;F,$\"\"(F,7%$\"\")F, $\"\"'F,$!\"*F," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 133 "It is not really necessary for a proper discussion, but let us recall that the total population is P. Thus we have the ex tra equation" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 20 "x + y + z = P" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 190 "We can include this equation in our system by \+ using Maple's aptly named stack() command. Then we obtain an inhomogen eous system of 4 linear equations in 3 unknowns with coefficient matri x C" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "C := stack(B,matrix(1,3,[1,1,1]));" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%\"CG-%'MATRIXG6#7&7%$!#8!\"#$\"#5F,$\"\"#F,7%$\"\"& F,$!#;F,$\"\"(F,7%$\"\")F,$\"\"'F,$!\"*F,7%\"\"\"F@F@" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 21 "and inhom ogenous term" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "b := matrix(4,1,[0,0,0,P]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"bG-%'MATRIXG6#7&7#\"\"!F)F)7#%\"PG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 44 "We can as k Maple to solve this system for us" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "soln1 := linsolve(C,b);" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#>%&soln1G-%'MATRIXG6#7%7#,$%\"PG$\"+l Z[DG!#57#,$F+$\"+MRy(z#F.7#,$F+$\"+-8twVF." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 73 "If convert the entries in C to rational numbers first we get the solution" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "soln2 := li nsolve(ratmatrix(C),b);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%&soln2G-% 'MATRIXG6#7%7#,$%\"PG#\"$-\"\"$h$7#,$F+#\"$,\"F.7#,$F+#\"$e\"F." }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 210 "L et us check by how much these solutions differ. We will use 20 digits \+ precision to compute the difference since if we use the default precis ion used to compute the solutions, Maple will probably just return 0. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "evalf(evalm(soln1-soln2),20);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'MATRIXG6#7%7#,$%\"PG$\"+>rjqX!#?7#,$F)$\"+)fW*>[F,7# ,$F)$\"*$G=%4'F," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 138 "Since Maple defaults to 10 digits precision, thes e errors show that roundoff was not a problem. Before we get too cocky though let us note" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "rref(B);" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#-%'MATRIXG6#7%7%\"\"\"\"\"!F)7%F)F(F)7%F)F)F(" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 19 "rref(ratmatrix(B));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'MATRIXG6#7%7%\"\"\"\"\"!#!#^\"#z7%F)F(#!$,\"\"$e\"7% F)F)F)" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 504 "The first row reduction of B is not correct! If we had e lected to work directly with the homogenous system of linear equation s, solved for x, y and z with the thought that we would substitute int o x + y + z = P later, we would have obtained x=0, y=0 and z=0, and we would have been pretty confused! If we convert B to a rational matrix first this method does work. Since the matrices A and B are the ones \+ that one usually works with in problems of this type it is important t o be careful about roundoff." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 408 "Converting to rational numbers may seem silly \+ since it implies absolute precision in the data. However, the entries \+ in B are not arbitrary. Indeed the entries in each column must sum to \+ exactly 0 (why?). Converting to rational numbers enables us to preserv e exactly the consequences that follow from this property. Of course, \+ we should still study how the solution varies with small pertubations \+ in the data." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 68 " ======================= ADDENDUM ==================== =====" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 117 "We have not studied matrix multiplication yet, but we are about to do so. The rest of this note will then make sense!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 91 "Let's start with the enti re population in L1 and then let them do their thing for 50 years:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "pop0:=matrix(3,1,[P,0,0]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>% %pop0G-%'MATRIXG6#7%7#%\"PG7#\"\"!F+" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "evalm(A^50&*pop0);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #-%'MATRIXG6#7%7#,$%\"PG$\"+'))yd#G!#57#,$F)$\"+Yyl(z#F,7#,$F)$\"+wKcw VF," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 80 "Let us see also what happens if we start with the population ev enly distributed:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 32 "pop1:=matrix(3,1,[P/3,P/3,P/3]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%%pop1G-%'MATRIXG6#7%7#,$%\"PG#\"\"\"\"\"$F )F)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "evalm(A^50&*pop1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'MATRIXG6#7%7#,$%\"PG$\"+4=gDG!#57 #,$F)$\"+%QYxz#F,7#,$F)$\"+8=lwVF," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 52 "Recall the equilibrium solution that we found above:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "evalm(soln1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'MATRIXG6#7%7#,$%\"PG$\"+lZ[DG!#57#,$F)$\"+MRy(z#F,7# ,$F)$\"+-8twVF," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 202 "Do you suspect a theorem here? The fact is that our matrix A here is an example of a regular stochastic matrix. The key p roperty (which you guessed from the above) is theorem 18 on page 288 o f our text." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{MARK "29 0 0" 0 } {VIEWOPTS 1 1 0 1 1 1803 }