CoCalc Public Filestmp / Mark This Lab3.sagews
Authors: Harald Schilly, ℏal Snyder, William A. Stein

# Lab 3

This lab contains 2 parts. The first is about the use of matrices to realize geometric transformations, the second shows how to use matrices to model population growth.

### Name and surname 3 : Yassine Nassiri

##Geometric transformations We investigate how some usual geometric transformation in the plan can be obtained by the use of matrices and vectors. For this, we will plot two letters, namely $FN$, by specifying the coordinates of some points, and joining them wit¡h lines. Then, we will apply some transformations to the letters.

typeset_mode(true)
F=[(2,2),(2,4),(2,5),(3,4),(7/2,5)]
N=[(4,2),(4,5),(11/2,2),(11/2,5)]
show(F)
show(N)


$\left[\left(2, 2\right), \left(2, 4\right), \left(2, 5\right), \left(3, 4\right), \left(\frac{7}{2}, 5\right)\right]$
$\left[\left(4, 2\right), \left(4, 5\right), \left(\frac{11}{2}, 2\right), \left(\frac{11}{2}, 5\right)\right]$

### Translation

FVect = [vector(F[j]) for j in range(5)]
show(FVect)
NVect = [vector(N[i]) for i in range (4)]
show(NVect)

$\left[\left(2,\,2\right), \left(2,\,4\right), \left(2,\,5\right), \left(3,\,4\right), \left(\frac{7}{2},\,5\right)\right]$
$\left[\left(4,\,2\right), \left(4,\,5\right), \left(\frac{11}{2},\,2\right), \left(\frac{11}{2},\,5\right)\right]$
$\left[\left(7,\,4\right), \left(7,\,6\right), \left(7,\,7\right), \left(8,\,6\right), \left(\frac{17}{2},\,7\right)\right]$
$\left[\left(9,\,4\right), \left(9,\,7\right), \left(\frac{21}{2},\,4\right), \left(\frac{21}{2},\,7\right)\right]$

### Rotation

Here we will investigate what is the effect of the transformation that takes a vector $\begin{bmatrix}x\\y\end{bmatrix}$ into the result of the multiplication $\begin{bmatrix}\cos t & -\sin t\\ \sin t& \cos t\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix}$.

For this sake, create a variable $t$, that will become a parameter, as well as a matrix $M =\begin{bmatrix}\cos t & -\sin t\\ \sin t& \cos t\end{bmatrix}$.

• To begin, let us fix a value for $t$, choose $t\in ]0,2\pi[$.
• Apply the transformation represented by $M$ to the letters $FN$ given above. For this, you need to transform every coordinate pair into a vector, and then create the new points, obtained by simply multiplying the vectors by the matrix $M$. Finaly, create the corresponding lines to see the final result.
• In one single figure, plot the original letters, in blue, and the new ones, in red.
typeset_mode(true)
var('t')
def R(t):
return matrix(2, [cos(t), -sin(t),sin(t),cos(t)])
show(R(t))

$t$
$\left(\begin{array}{rr} \cos\left(t\right) & -\sin\left(t\right) \\ \sin\left(t\right) & \cos\left(t\right) \end{array}\right)$
$\left(\begin{array}{rr} \frac{1}{2} \, \sqrt{2} & -\frac{1}{2} \, \sqrt{2} \\ \frac{1}{2} \, \sqrt{2} & \frac{1}{2} \, \sqrt{2} \end{array}\right)$

Let us arbitrarily set $t$ as equal to $\pi/4$,

R=R(t).subs(t=pi/4)
show(R)

$\left(\begin{array}{rr} \frac{1}{2} \, \sqrt{2} & -\frac{1}{2} \, \sqrt{2} \\ \frac{1}{2} \, \sqrt{2} & \frac{1}{2} \, \sqrt{2} \end{array}\right)$
$\left[\left(2,\,2\right), \left(2,\,4\right), \left(2,\,5\right), \left(3,\,4\right), \left(\frac{7}{2},\,5\right)\right]$
$\left[\left(4,\,2\right), \left(4,\,5\right), \left(\frac{11}{2},\,2\right), \left(\frac{11}{2},\,5\right)\right]$
RotFVect = [ FVect[j] * R for j in range(5) ]
RotNVect = [ NVect[i] * R for i in range(4) ]
show(RotFVect)
show(RotNVect)

$\left[\left(2 \, \sqrt{2},\,0\right), \left(3 \, \sqrt{2},\,\sqrt{2}\right), \left(\frac{7}{2} \, \sqrt{2},\,\frac{3}{2} \, \sqrt{2}\right), \left(\frac{7}{2} \, \sqrt{2},\,\frac{1}{2} \, \sqrt{2}\right), \left(\frac{17}{4} \, \sqrt{2},\,\frac{3}{4} \, \sqrt{2}\right)\right]$
$\left[\left(3 \, \sqrt{2},\,-\sqrt{2}\right), \left(\frac{9}{2} \, \sqrt{2},\,\frac{1}{2} \, \sqrt{2}\right), \left(\frac{15}{4} \, \sqrt{2},\,-\frac{7}{4} \, \sqrt{2}\right), \left(\frac{21}{4} \, \sqrt{2},\,-\frac{1}{4} \, \sqrt{2}\right)\right]$

Anwer to the following questions :_

• What is the transformation represented by $M$, in terms of $t$?
• What should be the result of the transformation represented by $M^2$?

Let $M$ be the rotation matrix with respect to parameter $t$. $M$ is equal to

$t$
$\left(\begin{array}{rr} \cos\left(t\right) & -\sin\left(t\right) \\ \sin\left(t\right) & \cos\left(t\right) \end{array}\right)$

where $t$ is equal to the angle of rotation, in the following problem in radiants.

Let $X$ be the vector $\begin{bmatrix}x\\y\end{bmatrix}$,

$\left(x, y\right)$

$X'$ corresponds to the resultant vector after a rotation of M(t). $X'$ is equal to

$\left(\begin{array}{r} x \cos\left(t\right) - y \sin\left(t\right) \\ y \cos\left(t\right) + x \sin\left(t\right) \end{array}\right)$

Let us consider the cartesian coordinates of $F$ and $N$,

$\left[\left(2,\,2\right), \left(2,\,4\right), \left(2,\,5\right), \left(3,\,4\right), \left(\frac{7}{2},\,5\right)\right]$
$\left[\left(4,\,2\right), \left(4,\,5\right), \left(\frac{11}{2},\,2\right), \left(\frac{11}{2},\,5\right)\right]$

Performing an $M$ to the cartesian coordinates of $F$ and $N$, we obtain orderly

$\left[\left(2 \, \cos\left(t\right) + 2 \, \sin\left(t\right),\,2 \, \cos\left(t\right) - 2 \, \sin\left(t\right)\right), \left(2 \, \cos\left(t\right) + 4 \, \sin\left(t\right),\,4 \, \cos\left(t\right) - 2 \, \sin\left(t\right)\right), \left(2 \, \cos\left(t\right) + 5 \, \sin\left(t\right),\,5 \, \cos\left(t\right) - 2 \, \sin\left(t\right)\right), \left(3 \, \cos\left(t\right) + 4 \, \sin\left(t\right),\,4 \, \cos\left(t\right) - 3 \, \sin\left(t\right)\right), \left(\frac{7}{2} \, \cos\left(t\right) + 5 \, \sin\left(t\right),\,5 \, \cos\left(t\right) - \frac{7}{2} \, \sin\left(t\right)\right)\right]$
$\left[\left(4 \, \cos\left(t\right) + 2 \, \sin\left(t\right),\,2 \, \cos\left(t\right) - 4 \, \sin\left(t\right)\right), \left(4 \, \cos\left(t\right) + 5 \, \sin\left(t\right),\,5 \, \cos\left(t\right) - 4 \, \sin\left(t\right)\right), \left(\frac{11}{2} \, \cos\left(t\right) + 2 \, \sin\left(t\right),\,2 \, \cos\left(t\right) - \frac{11}{2} \, \sin\left(t\right)\right), \left(\frac{11}{2} \, \cos\left(t\right) + 5 \, \sin\left(t\right),\,5 \, \cos\left(t\right) - \frac{11}{2} \, \sin\left(t\right)\right)\right]$

The Matrix $M$ is defined as $M =\begin{bmatrix}\cos t & -\sin t\\ \sin t& \cos t\end{bmatrix}$.

$t$
$\left(\begin{array}{rr} \cos\left(t\right) & -\sin\left(t\right) \\ \sin\left(t\right) & \cos\left(t\right) \end{array}\right)$
$\left(\begin{array}{rr} \cos\left(t\right)^{2} - \sin\left(t\right)^{2} & -2 \, \cos\left(t\right) \sin\left(t\right) \\ 2 \, \cos\left(t\right) \sin\left(t\right) & \cos\left(t\right)^{2} - \sin\left(t\right)^{2} \end{array}\right)$
$\left(\begin{array}{rr} 2 \, \cos\left(t\right)^{2} - 1 & -2 \, \cos\left(t\right) \sin\left(t\right) \\ 2 \, \cos\left(t\right) \sin\left(t\right) & 2 \, \cos\left(t\right)^{2} - 1 \end{array}\right)$
$\left(\begin{array}{rr} \cos\left(2 \, t\right) & -\sin\left(2 \, t\right) \\ \sin\left(2 \, t\right) & \cos\left(2 \, t\right) \end{array}\right)$

Therefore, when squared, the matrix, i.e. $M^2$, will equal to

$\left(\begin{array}{rr} \cos\left(2 \, t\right) & -\sin\left(2 \, t\right) \\ \sin\left(2 \, t\right) & \cos\left(2 \, t\right) \end{array}\right)$

Let now $t=\pi/12$, and $M$ be the corresponding matrix.

• What are $M^3$, $M^6$, and $M^{12}$?.
• Without computing, can you say what is the inverse of $M$?
• Can you guess a quick method to find the result of $M^{2014}$?
$\left(n, t\right)$

So, this is the rotation matrix $M$, with $t=\pi/12$,

$M$

$t$
$\left(\begin{array}{rr} \frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} + 3\right)} & \frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} - 3\right)} \\ -\frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} - 3\right)} & \frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} + 3\right)} \end{array}\right)$
• The rotation matrices $M^n$ to the exponent $n$ for $n = {3,6,12}$ are orderly

$M^3$

$\left(\begin{array}{rr} \frac{1}{6} \, \sqrt{6} \sqrt{3} & -\frac{1}{6} \, \sqrt{6} \sqrt{3} \\ \frac{1}{6} \, \sqrt{6} \sqrt{3} & \frac{1}{6} \, \sqrt{6} \sqrt{3} \end{array}\right)$

$M^6$

$\left(\begin{array}{rr} 0 & -1 \\ 1 & 0 \end{array}\right)$

$M^{12}$

$\left(\begin{array}{rr} -1 & 0 \\ 0 & -1 \end{array}\right)$
• The inverse of the rotation matrix corresponds to the identity matrix, that is $M^{12}$, divided by $M$, from which we obtain $M^{11}$ and that is the inverse of our matrix $M$. In other words, $M^{1}$ * $M^{11} = M^{12} = I$
$\left(\begin{array}{rr} -\frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} + 3\right)} & \frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} - 3\right)} \\ -\frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} - 3\right)} & -\frac{1}{12} \, \sqrt{6} {\left(\sqrt{3} + 3\right)} \end{array}\right)$
• We can rapidly compute $M^{2014}$ by determining the number of times the identity matrix is reached within the respective value of the exponent and from the remainder, that is the number of iterations subsequent the attainemnt of the final identity within the exponential value, we can compute the matrix value of $M^{2014}$.

Let us determine the remainder of exponent operation $2014/12$, knowing that the identity matrix, $I$, is attained after $12$ multiplicative iterations of $M$ (exponent of matrix is equal to $12$).

$10$

Therefore $M^{2014}$ is equal to $M^{10}$, which gives numerically with a set value of $\pi/12$ for $t$.

$\left(\begin{array}{rr} -\frac{1}{2} \, \sqrt{3} & -\frac{1}{2} \\ \frac{1}{2} & -\frac{1}{2} \, \sqrt{3} \end{array}\right)$

And that is the value of the matrix $M^{2014}$.

### Reflections

We now investigate te transformation that takes a vector $\begin{bmatrix}x\\y\end{bmatrix}$ into the result of the multiplication $\begin{bmatrix}\cos 2t & \sin 2t\\ \sin 2t& -\cos 2t\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix}$.

For this sake, create a variable $t$, that will become a parameter, as well as a matrix $R =\begin{bmatrix}\cos 2t & \sin 2t\\ \sin 2t& -\cos 2t\end{bmatrix}$.

$t$

Plot the result of this transformation applied to the letters $FN$, in the following cases :

• $t=0$
• $t=\pi / 4$
• $t=3\pi/4$

Plot three figures. In each you should have the original letter $FN$ in blue, and the transformed letters in red.

Can you guess what is the transformation represented by the matrix $R$, for an arbitrary value of $t$.

$\left[\left(2,\,-2\right), \left(2,\,-4\right), \left(2,\,-5\right), \left(3,\,-4\right), \left(\frac{7}{2},\,-5\right)\right]$
$\left[\left(4,\,-2\right), \left(4,\,-5\right), \left(\frac{11}{2},\,-2\right), \left(\frac{11}{2},\,-5\right)\right]$
$\left[\left(2,\,2\right), \left(4,\,2\right), \left(5,\,2\right), \left(4,\,3\right), \left(5,\,\frac{7}{2}\right)\right]$
$\left[\left(2,\,4\right), \left(5,\,4\right), \left(2,\,\frac{11}{2}\right), \left(5,\,\frac{11}{2}\right)\right]$
$\left[\left(-2,\,-2\right), \left(-4,\,-2\right), \left(-5,\,-2\right), \left(-4,\,-3\right), \left(-5,\,-\frac{7}{2}\right)\right]$
$\left[\left(-2,\,-4\right), \left(-5,\,-4\right), \left(-2,\,-\frac{11}{2}\right), \left(-5,\,-\frac{11}{2}\right)\right]$

### Shears

We now investigate te transformation that takes a vector $\begin{bmatrix}x\\y\end{bmatrix}$ into the result of the multiplication $\begin{bmatrix}1 & k\\ 0& 1\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix}$. For this sake, create a variable $k$, that will become a parameter, as well as a matrix $S =\begin{bmatrix}1 & k\\ 0& 1\end{bmatrix}$.

Plot the result of this transformation applied to the letters $FN$, in the following cases :

• $k=-1/10$
• $k=1/10$
• $k=3/2$

Plot three figures. In each one you should have the original letter $FN$ in blue, and the transformed letters in red.

typeset_mode(true)
var('k')
def Sh(k):
return matrix(2, [1, k, 0, 1])

$k$
FVect = [vector(F[j]) for j in range(5)]
aShF = [ Sh(-1/10) * FVect[j] for j in range(5) ]
aShN = [ Sh(-1/10) * NVect[i] for i in range(4) ]

show(aShF)
show(aShN)

$\left[\left(\frac{9}{5},\,2\right), \left(\frac{8}{5},\,4\right), \left(\frac{3}{2},\,5\right), \left(\frac{13}{5},\,4\right), \left(3,\,5\right)\right]$
$\left[\left(\frac{19}{5},\,2\right), \left(\frac{7}{2},\,5\right), \left(\frac{53}{10},\,2\right), \left(5,\,5\right)\right]$
FVect = [vector(F[j]) for j in range(5)]
bShF = [ Sh(1/10) * FVect[j] for j in range(5) ]
bShN = [ Sh(1/10) * NVect[i] for i in range(4) ]

show(bShF)
show(bShN)

$\left[\left(\frac{11}{5},\,2\right), \left(\frac{12}{5},\,4\right), \left(\frac{5}{2},\,5\right), \left(\frac{17}{5},\,4\right), \left(4,\,5\right)\right]$
$\left[\left(\frac{21}{5},\,2\right), \left(\frac{9}{2},\,5\right), \left(\frac{57}{10},\,2\right), \left(6,\,5\right)\right]$
FVect = [vector(F[j]) for j in range(5)]
cShF = [ Sh(3/2) * FVect[j] for j in range(5) ]
cShN = [ Sh(3/2) * NVect[i] for i in range(4) ]

show(cShF)
show(cShN)

$\left[\left(5,\,2\right), \left(8,\,4\right), \left(\frac{19}{2},\,5\right), \left(9,\,4\right), \left(11,\,5\right)\right]$
$\left[\left(7,\,2\right), \left(\frac{23}{2},\,5\right), \left(\frac{17}{2},\,2\right), \left(13,\,5\right)\right]$

## Dilatations

We now investigate te transformation that takes a vector $\begin{bmatrix}x\\y\end{bmatrix}$ into the result of the multiplication $\begin{bmatrix}k_1 &0 \\ 0& k_2\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix}$. For this sake, create two variables $k_1,k_2$, as well as a matrix $D =\begin{bmatrix}k_1 & 0\\ 0&k_2 \end{bmatrix}$.

Plot the result of this transformation applied to the letters $FN$, in the following cases :

• $k_1 = k_1 = 3/2$
• $k_1 = 1, k_2=2$

As before, do two figures. In each one you should have the original letter $FN$ in blue, and the transformed letters in red.

### Dilatations

We now investigate te transformation that takes a vector $\begin{bmatrix}x\\y\end{bmatrix}$ into the result of the multiplication $\begin{bmatrix}k_1 &0 \\ 0& k_2\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix}$. For this sake, create two variables $k_1,k_2$, as well as a matrix $D =\begin{bmatrix}k_1 & 0\\ 0&k_2 \end{bmatrix}$.

Plot the result of this transformation applied to the letters $FN$, in the following cases :

• $k_1 = k_1 = 3/2$
• $k_1 = 1, k_2=2$

As before, do two figures. In each one you should have the original letter $FN$ in blue, and the transformed letters in red.

Let $k_1$ and $k_2$ be respectively $k$ and $q$:

$k$
$q$
$\left(\begin{array}{rr} k & 0 \\ 0 & q \end{array}\right)$
$\left[\left(3,\,3\right), \left(3,\,6\right), \left(3,\,\frac{15}{2}\right), \left(\frac{9}{2},\,6\right), \left(\frac{21}{4},\,\frac{15}{2}\right)\right]$
$\left[\left(6,\,3\right), \left(6,\,\frac{15}{2}\right), \left(\frac{33}{4},\,3\right), \left(\frac{33}{4},\,\frac{15}{2}\right)\right]$
$\left[\left(2,\,4\right), \left(2,\,8\right), \left(2,\,10\right), \left(3,\,8\right), \left(\frac{7}{2},\,10\right)\right]$
$\left[\left(4,\,4\right), \left(4,\,10\right), \left(\frac{11}{2},\,4\right), \left(\frac{11}{2},\,10\right)\right]$

## Population Growth

### Exercise #44

First, we have the initial number of woodland caribou represented by the following matrix:

x = vector([10,2,8,5,12,0,1])
x0 = x.column()
show(x0)

$\left(\begin{array}{r} 10 \\ 2 \\ 8 \\ 5 \\ 12 \\ 0 \\ 1 \end{array}\right)$

Then, we have the following information for the following years:

Every two years:

Number of caribou aged 0-2 = 0.4 * number of caribou aged 2-4 + 1.8 * number of caribou aged 4-6 + 1.8 * number of caribou aged 6-8 + 1.8 * number of caribou %md aged 8-10 + 1.6 * number of caribou aged 10-12 + 0.6 * number of caribou aged 12-14

Number of caribou aged 2-4 = 0.3 * number of caribou aged 0-2

Number of caribou aged 4-6 = 0.7 * number of caribou aged 2-4

Number of caribou aged 6-8 = 0.9 * number of caribou aged 4-6

Number of caribou aged 8-10 = 0.9 * number of caribou aged 6-8

Number of caribou aged 10-12 = 0.9 * number of caribou aged 8-10

Number of caribou aged 12-14 = 0.6 * number of caribou aged 10-12

Therefore, the Leslie matrix for this population is the following matrix:

$\left(\begin{array}{rrrrrrr} 0 & \frac{2}{5} & \frac{9}{5} & \frac{9}{5} & \frac{9}{5} & \frac{8}{5} & \frac{3}{5} \\ \frac{3}{10} & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & \frac{7}{10} & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & \frac{9}{10} & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & \frac{9}{10} & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & \frac{9}{10} & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & \frac{3}{5} & 0 \end{array}\right)$

We can then apply the rule $\mathbf{x}_n = L^n \mathbf{x}_0$. Since the begining year is 1990, then for 1992, $n=1$, and for 1994, $n=2$, because the population changes every two years. So the population of the woodland caribou in 1992 is represented by the following matrix:

$\left(\begin{array}{r} \frac{232}{5} \\ 3 \\ \frac{7}{5} \\ \frac{36}{5} \\ \frac{9}{2} \\ \frac{54}{5} \\ 0 \end{array}\right)$

And the population of the woodland caribou in 1994 is represented by the following matrix:

$\left(\begin{array}{r} \frac{2103}{50} \\ \frac{348}{25} \\ \frac{21}{10} \\ \frac{63}{50} \\ \frac{162}{25} \\ \frac{81}{20} \\ \frac{162}{25} \end{array}\right)$

Now, we can project the population for the years 2010 and 2020. For the years 2010, we have the following graph relating the population with time in years. Please note that the x-axis does not represent the number of years after 1990, but rather the "number of years / 2". Therefore, at x=10, the year is 2010 since 20 years / 2 = 10. The principle is the same for the other graphs.

x0 = vector([10,2,8,5,12,0,1])
L=matrix(QQ,[[0,0.4,1.8,1.8,1.8,1.6,0.6],[0.3,0,0,0,0,0,0],[0,0.7,0,0,0,0,0],[0,0,0.9,0,0,0,0],[0,0,0,0.9,0,0,0],[0,0,0,0,0.9,0,0],[0,0,0,0,0,0.6,0]])
TotalData = L.iterates(x0, 11,rows=False)
A = [(j, TotalData[0,j]) for j in range(11)]
B = [(j, TotalData[1,j]) for j in range(11)]
C = [(j, TotalData[2,j]) for j in range(11)]
D = [(j, TotalData[3,j]) for j in range(11)]
E = [(j, TotalData[4,j]) for j in range(11)]
F = [(j, TotalData[5,j]) for j in range(11)]
G = [(j, TotalData[6,j]) for j in range(11)]
Aline = line(A, color='red')
Bline= line(B, color='blue')
Cline = line(C, color='green')
Dline = line(D, color='yellow')
Eline = line(E, color='orange')
Fline = line(F, color='purple')
Gline = line(G, color='pink')
show(Aline + Bline + Cline + Dline + Eline + Fline + Gline,figsize=4)



And we have the following graph relating the percent of population with time in years.

x0 = vector([10,2,8,5,12,0,1])
L=matrix(QQ,[[0,0.4,1.8,1.8,1.8,1.6,0.6],[0.3,0,0,0,0,0,0],[0,0.7,0,0,0,0,0],[0,0,0.9,0,0,0,0],[0,0,0,0.9,0,0,0],[0,0,0,0,0.9,0,0],[0,0,0,0,0,0.6,0]])
TotalData = L.iterates(x0, 11,rows=False)
Totals = [ sum(TotalData.column(j)) for j in range(11)]
A = [(j, TotalData[0,j]/Totals[j]) for j in range(11)]
B = [(j, TotalData[1,j]/Totals[j]) for j in range(11)]
C = [(j, TotalData[2,j]/Totals[j]) for j in range(11)]
D = [(j, TotalData[3,j]/Totals[j]) for j in range(11)]
E = [(j, TotalData[4,j]/Totals[j]) for j in range(11)]
F = [(j, TotalData[5,j]/Totals[j]) for j in range(11)]
G = [(j, TotalData[6,j]/Totals[j]) for j in range(11)]
Aline = line(A, color='red', legend_label='0-2 years')
Bline = line(B, color='blue',legend_label='2-4 years')
Cline = line(C, color='green',legend_label='4-6 years')
Dline = line(D, color='yellow',legend_label='6-8 years')
Eline = line(E, color='orange',legend_label='8-10 years')
Fline = line(F, color='purple',legend_label='10-12 years')
Gline = line(G, color='pink',legend_label='12-14 years')
show(Aline + Bline + Cline + Dline + Eline + Fline + Gline,figsize=5)


For the years 2020, we have the following graph relating the population with time in years.

x0 = vector([10,2,8,5,12,0,1])
L=matrix(QQ,[[0,0.4,1.8,1.8,1.8,1.6,0.6],[0.3,0,0,0,0,0,0],[0,0.7,0,0,0,0,0],[0,0,0.9,0,0,0,0],[0,0,0,0.9,0,0,0],[0,0,0,0,0.9,0,0],[0,0,0,0,0,0.6,0]])
TotalData = L.iterates(x0, 16,rows=False)
A = [(j, TotalData[0,j]) for j in range(16)]
B = [(j, TotalData[1,j]) for j in range(16)]
C = [(j, TotalData[2,j]) for j in range(16)]
D = [(j, TotalData[3,j]) for j in range(16)]
E = [(j, TotalData[4,j]) for j in range(16)]
F = [(j, TotalData[5,j]) for j in range(16)]
G = [(j, TotalData[6,j]) for j in range(16)]
Aline = line(A, color='red')
Bline= line(B, color='blue')
Cline = line(C, color='green')
Dline = line(D, color='yellow')
Eline = line(E, color='orange')
Fline = line(F, color='purple')
Gline = line(G, color='pink')
show(Aline + Bline + Cline + Dline + Eline + Fline + Gline,figsize=4)


And we have the following graph relating the percent of population with time in years.

From the graph of the percent of population, by looking at it, we can therefore conclude that in the long run, approximately 53% of the population will be caribou aged 0-2 years, 14% caribou aged 2-4 years, 9% caribou aged 4-6 years, 8% caribou aged 6-8 years, 7% caribou aged 8-10 years, 6% caribou aged 10-12 years, 3% caribou aged 12-14 years. From the graph of the population, we can see that the total population appears to be increasing over time, but from the graph of the percent of population, we can see that the percentage of each population stabilizes, which is what we were expecting.