{VERSION 3 0 "SUN SPARC SOLARIS" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 1 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 3" -1 258 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "R3 Font 4" -1 259 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 5 " -1 260 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 6" -1 261 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 7" -1 262 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 8" -1 263 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Fo nt 9" -1 264 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 10" -1 265 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 11" -1 266 1 {CSTYLE "" -1 -1 "Helvetica" 1 12 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 1 " " }{TEXT 256 11 "keyfitz.mws" }{TEXT -1 62 " Key fitz US Population data (Example 4.3 , p 56) of Caswell\n" }}{PARA 0 " > " 0 "" {MPLTEXT 1 0 44 "with(linalg): with(plots): readlib(polar): " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 357 "A:=matrix(10,10,\n[[0, 0.00102,0.08515,0.30574,0.40002,0.28061,0.15260,0.06420,0.01483,0.0008 9],\n[0.99670,0,0,0,0,0,0,0,0,0], [0,0.99837,0,0,0,0,0,0,0,0],\n[0,0,0 .99780,0,0,0,0,0,0,0], [0,0,0,0.99672,0,0,0,0,0,0],\n[0,0,0,0,0.99607, 0,0,0,0,0], [0,0,0,0,0,0.99472,0,0,0,0],\n[0,0,0,0,0,0,0.99240,0,0,0], [0,0,0,0,0,0,0,0.98867,0,0], [0,0,0,0,0,0,0,0,0.98274,0]]);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "eigsys:=eigenvects(A):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 192 "\nThese eigenvalues correspond to Example 4.3 (p 56) in Caswell. Find maximum eigenvalue = lambda = p opulation growth rate. Find index to corresponding eigenvector = stab le age distribution." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 188 "ES:= seq( \+ eigsys[i][3], i = 1 .. 10): # eigenvectors (output printing suppressed )\nEV:= seq( eigsys[i][1], i = 1 .. 10); # eigenvalues\nEM:= seq( eigs ys[i][2], i = 1 .. 10); # multiplicities" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "mags:=op( map( abs, [EV] )); # magnitudes of eigenval ues" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "lambda:=max(mags);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "member( lambda, [mags], 'position '); location:= position;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 68 "Transpose matrix to get reproductive valu e eigenvalue & eigenvector." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "AT:= transpose(A); eigsysT:=eigenvects(AT):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 121 "\nFind maximum eigenvalue and index to corresponding eig envector; this eigenvector is the reproductive value distribution." }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 196 "EST:= seq( eigsysT[i][3], i = 1 .. 10 ): # eigenvectors (output printing suppressed)\nEVT:= seq( eigsysT [i][1], i = 1 .. 10 ); # eigenvalues\nEMT:= seq( eigsysT[i][2], i = 1 \+ ..10 ); # multiplicities" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "magsT:= op( map( abs , [EVT] )); # magnitudes of eigenvalues " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "mu:=max( magsT);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "member(mu, [magsT], 'position'); indexT:= position;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 76 "Convert eigenvector lists to actual vectors for use in se nsitivity analysis." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "v:=op( EST[i ndexT] ); # stable reproductive value distribution" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 48 "w:=op( ES[location] ); # stable age distribution" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "IP:= innerprod( w , v );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "\nSensitivity to fecundity: equ ation 6.8 (p121) of Caswell." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "sen sitivity_to_fecundity:=[ seq( w[j] * v[1] / IP , j = 1 .. 10 ) ]; " }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "logsf:=evalf( map(log10,%) );" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 57 "\nSensitivity to survival: equatio n 6.8 (p121) of Caswell." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "sensiti vity_to_survival:= [seq( v[i] * w[i-1] / IP , i = 2 .. 10 ) ];" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "logss:= evalf( map(log10, %) );" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "\nReproductive value distribution : equation 4.18 (p 62) of Caswell." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "reproductive_value:= [ seq( w[i] / w[1] , i = 1 .. 10) ] ;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 107 "\nPlot sensitivity of lambda to c hanges in fertility and survival probability: figure 6.1 (p122) of Cas well." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 122 "plot( \{ [ [t, logsf[t] ] $ t= 1 .. 9 ], [ [t, logss[t] ] $ t = 1.. 9 ] \}, style = point, symb ol =circle, ytickmarks = 2 );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "Next we plot the (complex) eigenvalues. This works much better in Re lease 4 than it did in Release 3." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "polar(EV[1]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "N:= nops([EV]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 89 " pts:= seq( [op(polar(EV[k]))], k=1 .. N ); # convert eigenvalues to po lar, strip 'polar' " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "pola rplot( [pts], style = point, symbol = circle, color = red);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "polarplot( [pts], style = po int, symbol = circle, color = red);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 260 "\nAlternatively we can plot the complex eigenvalues directly. \+ Unfortunately conformal does not seem to accept a set or list of point s as an argument, so we are forced to create a sequence of individual \+ point plots which then are overlaid on top of one another. " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 183 "### WARNING: the definition of the type `symbol` has changed'; see help page for details\ndisplay (\{seq(conformal(z, z= EV[k] .. EV[k],style=point, symbol=box, color=b lue), k=1 .. N)\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 99 "\nFinally, we can decompose into real and imaginary parts, merge the two lists, \+ and plot the points." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "pts := seq( [Re(EV[j]), Im(EV[j])], j = 1 .. N);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 151 "### WARNING: the definition of the type `symbol ` has changed'; see help page for details\nplot( [pts] , style = point , symbol = diamond, color = blue );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}}{MARK "29" 0 }{VIEWOPTS 1 1 0 1 1 1803 }