Leslie model : Matrix and vector operations (in python)

The above lines are magic spells. If you have any error massage, move to web site.
You can try the excercise on the web site.


Analysis of the Leslie matrix model

Input $ \bf L = \begin{bmatrix} 0 & 1 & 2 & 0 \\ 0.5 & 0 & 0 & 0 \\ 0 & 0.6 & 0 & 0 \\ 0 & 0 & 0.1 & 0\end{bmatrix}$, $ \; {\bf n}(0) = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0\end{bmatrix} $

Put the followings,


Calculate ${\bf n}(1)= {\bf L\: n}(0) $

$$ \begin{pmatrix} 0 & 1 & 2 & 0 \\ 0.5 & 0 & 0 & 0 \\ 0 & 0.6 & 0 & 0 \\ 0 & 0 & 0.1 & 0\end{pmatrix} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0\end{pmatrix} $$

Using ${\bf n}(1) = \begin{pmatrix} 1 \\ 0 \\ 0.6 \\ 0 \end{pmatrix}$ 、calculate ${\bf n}(2) = {\bf L}\,{\bf n}(1)$


Using ${\bf n}(0) = \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix}$ 、calculate ${\bf n}(2) = {\bf L}{\bf L} \,{\bf n}(0)$


${\bf L}{\bf L}$ is equibalint to ${\bf L}^2$

Compute ${\bf L}^t$ with arbitrary exponent $t$. For example $t=4$, ${\bf L}^4$.




Compute ${\bf n}(t)={\bf L}^{t}{\bf n}(0), \;\; t=0, \cdots $, and plot population number of each age.


Compute ${\bf L}^{100},{\bf L}^{101}$.

Refer to element of matrix L100 and L101, for example, see the element in the third row, third column.

Compute the ratio $\frac{{\mathrm L}101[2,2]}{{\mathrm L}100[2,2]}$

Compare ${\bf L}^{101}$and $1.03822433996517{\bf L}^{100}$.

We see that ${\mathrm L101} \approx 1.03822433996521\times{\mathrm L100}$.


Eigenvalues and the corresponding eigenvectors of matrix $\bf L$

Refering to the eigenvalues.

Show absolute value of the eigenvalues.

The largest eigenvalue is $\lambda_{max} = 1.0382$.


Refering to the eigenvectors.

Second colum of the matrix is the eigenvector corresponding to the largest eigenvalue $\lambda_{max} = 1.0382$.

Ingnore the minus sing of $ \begin{bmatrix}u_0\\u_1\\u_2\\u_3\end{bmatrix} \approx \begin{bmatrix}-0.8737\\-0.4208\\-0.2432\\-0.0234\end{bmatrix} $.

Compute $100 \times {\Large \frac {1}{\sum {u_i}}} \begin{bmatrix}u_0\\u_1\\u_2\\u_3\end{bmatrix}$.

$ \begin{bmatrix} n_0 \\n_1\\n_2\\n_3\end{bmatrix} \approx \;\;\; \begin{bmatrix}56.0 \%\\27.0\%\\15.6\%\\1.5\%\end{bmatrix} $