9.5. Eigenvalues and Eigenvectors#

import numpy as np
from numpy import linalg

9.5.1. Eigenvalues and Eigenvectors#

This section introduces eigenvalues and eigenvectors of a square matrix and explores some of their applications. The goal of this section is to dissect the action of linear maps into elements that are easy to visualize.

9.5.2. Motivation#

Consider a linear map T:RnRm defined by xAx. Although T moves x in a variety of directions, there are some vectors on which the action of T is easy to understand. For example, suppose A=[3210], u=[21]. Let’s compute Au

A = np.array([[3,-2], [1,0]])
u = np.array([2,1])

A @ u
array([4, 2])

We can see that the image of u=[21] is

Au=[42]=2[21]=2u

In fact, A streches u.

import matplotlib.pyplot as plt


def plot_map(vector, matrix):
    x1 = vector[0]
    y1 = vector[1]
    
    x2 = (A @ vector)[0]
    y2 = (A @ vector)[1]

    ax = plt.axes()
    
    ax.arrow(0, 0, x1, y1, head_width = 0.2,head_length = 0.2, fc ='b', ec ='b')
    ax.arrow(0, 0, x2, y2, head_width = 0.2,head_length = 0.2, fc ='r', ec ='r')

    ax.text(x1,y1 - 0.5,'$X$')
    ax.text(x2,y2-0.5,'$AX$')

    z = max(np.abs(x1), np.abs(x2), np.abs(y1),np.abs(y2))
            
    ax.set_xticks(np.arange(-z-2, z+2, step = 1))
    ax.set_yticks(np.arange(-z-2, z+2, step = 1))
    ax.set_aspect('equal')

    ax.set_xlabel("X")
    ax.set_ylabel("Y")
    
    plt.grid()
    plt.show()


plot_map(u, A)
../../_images/e0e63cb0dfc621c91bf21a7e4016483eb0e90dd78115b891d2c1d146307eb1b0.png

We are interested in such special vectors that when transformed by matrix A, result in a scalar multiple of themselves. More generally, let A be an n×n matrix. We seek non-trivial solutions to equations of the form:

Ax=λxfor some λR

If u0 is a solution for some λ, we call λ an eigenvalue and u an eigenvector of A corresponding to λ.

Example 1

Consider the matrix equation:

Au=[42]=2[21]=2u

Observe that λ=2 is an eigenvalue of A and u is the corresponding eigenvector.

a. Is v=[11] also an eigenvector of A?

b. Is λ=4 an eigenvalue?

c. Show that λ=1 is an eigenvalue and find an eigenvector for it.

Solution:

(a) Let’s compute Av:

v = np.array([1, -1])

A @ v
array([5, 1])

If there were a λ such that Av=λv, we would have obtained:

[11]=λ[51]

Which is not possible for any value of λ, and as can be seen in the figure below, the vector v does not satisfy the eigenvalue equation.

plot_map(v, A)
../../_images/fdb74ace03d9928ffd7c2a079f11cb6bb135e064c4f832aabf377601730ab28f.png

(b) No. λ=4 is a eigenvalue for A if and only if Ax=4x has a non-trivial solution. Let’s reformulate this problem in terms of a homogenous equation which is easier to deal with:

Ax=4x(A4I2)x=0

The homogeneous equation (A4I2)x=0 has a non-trivial solution if and only if it has a free variable (a non-pivot column).

# identity matrix I_2
I_2 = np.eye(2)

A - 4*I_2
array([[-1., -2.],
       [ 1., -4.]])

Clearly, the columns of A4I are linearly independent; as a result, there is no free variable and the system has only the trivial solution x=0.

(c) λ=1 is a eigenvalue for A if and only if Ax=1x has a non-trivial solution.

Ax=x(AI2)x=0
A - I_2
array([[ 2., -2.],
       [ 1., -1.]])

Since the columns of (AI2) are linearly independent, there is a free variable and λ=1 is an eigenvalue of A. To find a corresponding eigenvector u we solve

(AI2)x=0

Let’s set up the augmented matrix:

# the augmented vector
b = np.array([[0],[0]])

# add to the matrix
M = np.concatenate((A - I_2, b), axis = 1) 
M
array([[ 2., -2.,  0.],
       [ 1., -1.,  0.]])

Let’s recall the row operations:

def swap(matrix, row1, row2):
    
    copy_matrix=np.copy(matrix).astype('float64') 
  
    copy_matrix[row1,:] = matrix[row2,:]
    copy_matrix[row2,:] = matrix[row1,:]
    
    return copy_matrix

# Replacing a row by the sum of itself and a multiple of another 

def replace(matrix, row1, row2, scalar):
    copy_matrix=np.copy(matrix).astype('float64')
    copy_matrix[row1] = matrix[row1]+ scalar * matrix[row2] 
    return copy_matrix
M1 = swap(M, 0, 1)
M1
array([[ 1., -1.,  0.],
       [ 2., -2.,  0.]])
M2 = replace(M1, 1, 0, -2)
M2
array([[ 1., -1.,  0.],
       [ 0.,  0.,  0.]])

A general solution for (AI2)x=0 is

[x1x2]=[x2x2]=x2[11],

and the set of all solutions is

span( [11] )

each non-zero element of this set is an eigenvector corresponding to λ=1.

The above simple example leads to a general case:

Theorem 17

Let A be an n×n matrix and λ be a scalar. The following statements are equivalent:

  1. λ is an eigenvalue of A.

  2. (AλIn)x=0 has non-trivial solution.

  3. det(AλIn)=0

9.5.3. Eigenspace and characteristic polynomial#

null(AλIn) is a subspace of Rn and contains the zero vector and all eigenvectors corresponding to λ. This subspace is known as the eigenspace of A corresponding to λ, and is denoted by Eλ. Intuitively, a matrix acts as dilations on its eigenspaces.

Example 2

The set

span( [11] )

Which we found in Example 1, is in fact the eigenspace E1 of A corresponding to λ=1. And any vector uE1 is preserved under the action of A (dilations factor = 1):

Au=u

The polynomial P(λ)=det(AλIn) is called the characteristic polynomial of A. The zeros of this polynomial are precisely the eigenvalues of A. Thus, the polynomial can be factorized as:

P(λ)=(λλ0)m0(λλ1)m1(λλk)mk

For each λi, where 0ik, the power mi is known as the algebraic multiplicity of λi.

Example 3

Suppose

A=[416016008].

We will find all eigenvalues and their multiplicities of A by finding its characteristic polynomial.

Solution:

The characteristic polynomial is given by:

det(AλI3)=|4λ1601λ6008λ|=0

Expanding the determinant, we obtain the characteristic polynomial:

P(λ)=(4λ)(1λ)(8λ),

The zeros of this polynomial (the eigenvalues of A) are λ=4 with multiplicity 1, λ=1 with multiplicity 1, and λ=8 with multiplicity 1.

Example 4

Let A be the matrix given in Example 2. For each eigenvalue that we found in Example 2, find the corresponding eigenspace together with its dimension.

Solution:

The eigenspace corresponding to λ=4:

E4=null(A4I)={x:   (A4I)x=0}=
{ [xyz]:   [016036004][xyz]=0 }={ [xyz]:   [y+6z3y+6z4z]=[000] }

Therefore,

E4={ [x00]:xR }=span( [100] )anddim(E4)=1

The eigenspace corresponding to λ=1:

E1=null(AI)={x:   (AI)x=0}=
{ [xyz]:   [316006007][xyz]=0 }={ [xyz]:   [3xy+6z6z7z]=[000] }

Therefore,

E1={[x3x0]:xR}=span([130])anddim(E1)=1

The eigenspace corresponding to λ=8

E8=null(A8I)={x:   (A8I)x=0}=
{ [xyz]:   [416076000][xyz]=0 }={ [xyz]:   [4xy+6z7y+6z0]=[000] }

Therefore,

E8={[64176]:yR}=span([967])anddim(E8)=1

Before we move on to the next topic, let us check our calculation using numpy.linalg.eig from NumPy linear algebra:

A = np.array([[4, -1, 6], [0, 1, 6], [0, 0, 8]])

evalues , evectors = np.linalg.eig(A)

for i in range(evalues.shape[0]):
    print(evalues[i], ' is an eigenvector with ', evectors[:,i], ' as the corresponding eigenvectors')
4.0  is an eigenvector with  [1. 0. 0.]  as the corresponding eigenvectors
1.0  is an eigenvector with  [0.31622777 0.9486833  0.        ]  as the corresponding eigenvectors
8.0  is an eigenvector with  [0.69853547 0.46569032 0.54330537]  as the corresponding eigenvectors

Note that numpy.linalg.eig returns the unit vector of eigenvalues, and that is why we see different eigen vectors. To check that let’s normalize the eigenvector [967] corresponding to λ=8:

v = np.array([9,6,7])

#normalizing v 
e_v = v/np.linalg.norm(v)
e_v
array([0.69853547, 0.46569032, 0.54330537])

Let’s have another look at Example 2. The eigenvalues are the entries on the main diagonal. This is always true for triangular matrices and can be proved by induction:

Theorem 3

Let A be a square triangular matrix. Then the eigenvalues of A are the entries on the diagonal.

Numerical Notes

  1. Example 3 provides a method for manually computing eigenvectors in simple cases. In practical situations, using matrix program and row reduction method to find an eigenspace (for a specified eigenvalue) may not be entirely reliable. Roundoff error can occasionally lead to a reduced echelon form with the wrong number of pivots. The best computer programs compute approximations for eigenvalues and eigenvectors simultaneously, to any desired degree of accuracy, for matrices that are not too large.

  2. Some software such as Mathematica and Maple can use symbolic calculations to find the characteristic polynomial of a moderate-sized matrix. But there is no formula or finite algorithm to solve the characteristic equation of a general  matrix n×n for n5. The best numerical methods for finding eigenvalues avoid the characteristic polynomial entirely. In fact, MATLAB finds the characteristic polynomial of a matrix A by first computing the eigenvalues λ1,λ2,,λn of A and then expanding the product

(λλ1)(λλ2)(λλn)

Exercises#

Exercises

  1. If v is an eigenvector of A corresponding to λ, what is A3v?

  2. If A is an n×n matrix and 2 is an eigenvalue of A, show that 4 is an eigenvalue of 2A.

  3. If A is an invertible matrix with eigenvalue λ show that A1 has eigenvalue 1/λ.

  4. Let

A=[133353331].

a. Find the eigenvalues of A and their multiplicities.

b. For each eigenvalue in part (a) find the corresponding eigenspace.

c. Find the dimension of each eigenspace in part (b) by finding a basis for it. How this result is related to your answer to part (a)?

9.5.4. Diagonalization#

This section introduces diagonalization and characterizes diagonalizability. Diagonalization is a useful factorization of a matrix A based on its eigenvalue–eigenvector information. This factorization allows us to quickly access properties that are invariant under similarity, such as rank, invertibility, and eigenvalues. It also enables us to calculate powers of A for large k, which is a fundamental concept in various applications, including discrete dynamical systems.

Computing powers of a matrix#

Let’s consider the matrix A=[7241]. We wish to compute Ak for an arbitrary kN, given that A=PAP1, where P=[1112], and D=[5003].

Using this decomposition, we have:

Ak=(PDP1)(PDP1)(PDP1)=PDkP.

Since D is diagonal, Dk=[5k003k]. Additionally, P1=[2111]. Therefore,

Ak=[1112][5k003k][2111]=[2×5k3k5k3k2×3k2×5k2×3k5k].

This decomposition, known as diagonalization, enables us to compute Ak easily for large values of k. Without such factorization, computing Ak for large matrices and large k can be a time-consuming task. Therefore, it is beneficial to find such decomposition before calculating the power of A.

Unfortunately, this decomposition doesn’t exist for all matrices. The goal of this section is to characterize matrices that admit such a factorization.

Diagonalization#

An n×n matrix A is called diagonalizable if it is similar to a diagonal matrix. More precisely, there exists an invertible n×n matrix P and an n×n diagonal matrix D such that A=PDP1.

It turns out an n×n matrix is diagonalizable if we can form a basis Rn using eigenvectors of A:

Theorem 18

An n×n matrix A is diagonalizable if and only if A has n linearly independent eigenvectors.

In fact, suppose λ1,λ2,,λn are eigenvalues of A, and {v1,v2,,vn} is the linearly independent set of eigenvectors of A. If we form the matrix P by taking the eigenvectors as columns, and D is a diagonal matrix with eigenvalues λ1,λ2,,λn on the diagonal, then we have A=PDP1.

Finding eigenvectors in general is not an easy task, and is not clear how to check which n×n matrices have n linearly independent eigenvectors. The next theorem partially addresses this issue.

Theorem 19

The eigenvectors corresponding to distinct eigenvalues are linearly independent.

Combining Theorem 18 and Theorem 19, we obtain the following corollary:

Corollary 1

An n×n matrix with n distinct eigenvalues is diagonalizable.

Example 1

Is

A=[132353331]

diagonalizable? If yes find a diagonalization for it.

Solution

To determine if A is diagonalizable we need to find eigenvalues and to check if it admits 3 linearly independent eigenvectors.

  • Step 1

we use linalg.eigvas to find the eigenvalues and eigenvectors of A:

A = np.array([[1,3,3],[-3,-5,3],[3,3,1]])
# find evalues and evectors
evalues, evectors = linalg.eig(A)

print("eigenvalues = ",  evalues)
eigenvalues =  [-5. -2.  4.]

A has three distinct eigenvalues and therefore it is diagonalizable by Corollary 1.

  • Step 2: Constructing the diagonal matrix D

lambda_1 = evalues[0]
lambda_2 = evalues[1]
lambda_3 = evalues[2]

D = np.array([[lambda_1, 0, 0], [0, lambda_2, 0], [0, 0, lambda_3]]) 
D
array([[-5.,  0.,  0.],
       [ 0., -2.,  0.],
       [ 0.,  0.,  4.]])
  • Step 3 : Finding the matrix P whose ith column is an eigenvector corresponding to λi for i{1, 2, 3}:

# set up the invirtible matrix P
P = evectors
  • Step 4: compute the inverse of matrix P

# compute the inverse of P

Q = linalg.inv(P)
  • Step 5 (sanity check): Now that we have D, P, Q=P1, lets check if A=PDQ

P @ D @ Q
array([[ 1.,  3.,  3.],
       [-3., -5.,  3.],
       [ 3.,  3.,  1.]])

Example 2

Is

A=[132353331]

diagonalizable? If yes find a diagonalization for it.

Solution:

  • Step 1: Finding eigenvalues and eigenvectors of A:

A = np.array([[1,3,3],[-3,-5,-3],[3,3,1]])

# find evalues and evectors
evalues, evectors = linalg.eig(A)

print("eigenvalues = ",  evalues)
eigenvalues =  [ 1. -2. -2.]

A has 2 eigenvalues: λ1=1 with multiplicity 1 and λ2=2 with multiplicity 2. Note that we cannot use Corollary 1 anymore because eigenvalues are not distinct. To check if A is diagonalizable, we need to find three linearly independent eigenvectors of A. Lets have a look at our eigenvectors:

# A matrix whose columns are eigenvectors:
P = evectors

# computes the rank of P
np.linalg.matrix_rank(P)
3

Since rank(P)=3 the columns of P are linearly independents. Thus, A is diagonalizable by Theorem 1.

  • Step 2: Finding the diagonal matrix D

lambda_1 = evalues[0]
lambda_2 = evalues[1]
lambda_3 = evalues[2]

D = np.array([[lambda_1, 0, 0], [0, lambda_2, 0], [0, 0, lambda_3]]) 
D
array([[ 1.,  0.,  0.],
       [ 0., -2.,  0.],
       [ 0.,  0., -2.]])
  • Step 3: Finding the matrix P whose ith column is an eigenvector corresponding to λi for i{1, 2, 3}. We already have this matrix so we go to the next step.

  • Step 4: Computing the inverse of P

# computing the inverse of P

Q = np.linalg.inv(P)
Q
array([[-1.73205081, -1.73205081, -1.73205081],
       [ 0.89919543,  2.75763333,  1.8584379 ],
       [-0.6541932 ,  0.5254512 ,  1.1796444 ]])
  • Step 5 (sanity check): lets check if A=PDQ

# check A = PDQ 
P @ D @ Q
array([[ 1.,  3.,  3.],
       [-3., -5., -3.],
       [ 3.,  3.,  1.]])

The next theorem provides another way to characterize the diagonalizability of matrices based on the multiplicity of eigenvalues. Before stating the theorem, we need the following definition:

Suppose A is a square matrix and λ is an eigenvalue of A. The dimension of the corresponding eigenspace Eλ=null(AλI) is called the geometric multiplicity of λ.

Theorem 20

A square matrix A is diagonalizable if and only if the algebraic multiplicity of each eigenvalue is equal to its geometric multiplicity. More formally, if λ1,λ2,,λp are eigenvalues of A with algebraic multiplicities m1,m2,,mp, respectively, then

mi=dim(Eλi)i{1,2,,p}

Recall that dim(Eλi) = dim null(AλiI) = the number of non-pivot columns in (AλiI)

Example 3

Is M=[110011002]

diagonalizable? If so, find a diagonalization for it.

Solution:

M is an upper triangular matrix, and its eigenvalues are on the diagonal: λ1=1 with algebraic multiplicity 2 and λ2=2 with algebraic multiplicity 1.

Since we don’t have distinct eigenvalues, Corollary 1 doesn’t apply here. Let’s take a look at our eigenvectors:

import numpy as np
from numpy import linalg


M = np.array([[1, 1, 0], [0, 1, 1], [0, 0, 2]])

evalues, evectors  = np.linalg.eig(M)
p = evectors

np.linalg.matrix_rank(p)
2

Observe that the rank of matrix P is two, which means we don’t have three linearly independent eigenvectors in M. However, using Theorem 3, we can confirm that this is not the case, and consequently, M is not diagonalizable. In fact, it is straightforward to check that the geometric multiplicity of λ=1 is 1 (dim(E1)=1), while the algebraic multiplicity is 2. Thus, M is not diagonalizable.

Diagonalization as a change of basis#

Recall that similar matrices represent the same linear map under two different choices of a pair of bases for Rn and Rm. More precisely, suppose A=PCP1 (C is not necessarily diagonal), then the matrix representation of T with respect to the basis B (formed by the columns of P) is C. Conversely, changing the basis of Rn leads to a matrix representation of T that is similar to A (section 3.4). This particularly applies to diagonalizable matrices because a matrix is diagonalizable if it is similar to a diagonal matrix.

Theorem 20 (Diagonal Matrix Representation)

Suppose T:RnRn and A is the standard matrix representation of T that is diagonalizable. Let A=PDP1 be a diagonalization of A where D is an n×n diagonal matrix, and P is an invertible n×n matrix. If B is the basis for Rn formed by the columns of P, then D is the matrix representation of the transformation T:(Rn,B)(Rn,B).

Example 3 Let T:R2R2 and

A=[7242]

be the standard matrix representation of T. Find a basis B for T such that the matrix representation of T with respect to B is diagonal.

Solution:

From Example 1, we know that A=PAP1 where P=[1112] and D=[5003].

The columns of P are eigenvectors of A, and they form a basis B for R2. By Theorem 2, D is the matrix representation of T with respect to B. In fact, the mappings xAx and xDx describe the same linear transformation, relative to different bases.

Exercises#

  1. Suppose

M=[243463331].

a. Is M diagonalizable? If yes find a diagonalization for it.

b. Use this diagonalization to compute M100

  1. Suppose

C=[3010003000003000032000002].

Is C diagonalizable?

  1. Let A be a 5×5 matrix, with two eigenvalues. One eigenspace is three-dimensional, and the other is two-dimensional. Is A diagonalizable?

  2. Compute A200 where

A=[4321].

9.5.5. Discrete Dynamical Systems#

In this section, we will explore the application of diagonalization to discrete dynamical systems, focusing on their long-term behavior.

Modeling Dynamical Systems as sequence of linear systems#

In many fields (e.g., ecology, biology, economics, etc.), we wish to mathematically model and study a dynamic system that changes over time. We are usually given several features of the system that are measured at (discrete) different time intervals which can be viewed as a sequence of vectors

x0,x1,x2,

We interpret xi as the state of a system at time t=i. We also assume that there is a matrix A such that

xn=Axn1n=1,2,3,()

Our goal is to develop a formula for xn and describe what can happen when n approaches to infinity.

Let’s consider the movement of populations or groups of people from one region to another. We want a simple model that considers the changes in the population of a city and its surrounding suburbs over a period of years. Let’s say the initial year is 2020 and denote the population of the city and suburbs by c0 and s0, respectively. Now we can form the initial vector population x0=[c0r0]. Similarly, for 2021 and subsequent years, denote the populations of the city and suburbs by the vectors

x1=[c1s1], x2=[c2s2], x3=[c3s3], 

How can be these vectors mathematically related?

Suppose demographic studies show that each year about 5% of the city’s population moves to the suburbs (and 95% remains in the city), while 3% of the suburban population moves to the city (and 97% remains in the suburbs). With this information, we can find the vector population x1 based on the initial population x0. After the first year, c095% remain in the city and c00.05 move to the suburbs. Additionally, s0.97% remain in the suburbs and s00.03 move to the city. Therefore,

[c1s1]=c0[0.950.05]+s0[0.030.97]=[0.950.030.970.05][c0s0].

The matrix M=[0.950.030.970.05] is called the migration matrix. Consequently, we can write

xn=Mxn1n=1,2,3,

and the sequence

x0,x1,x2,

describes the population of the city/suburbs over a period of years.

Example 1

Compute the population of the region just described for the years 2021 and 2022, given that the initial population in 2020 was 600,000 in the city and 40,000 in the suburbs.

Solution:

import numpy as np

# migration matrix
M = np.array([[0.95, 0.03] ,[0.05, 0.097]])


# initial population vector x_0
x_0 = np.array([600000, 40000])

# population vector x_1
x_1 = M @ x_0

print('the population of city in 2021 was = ', x_1[0],'\n')
print('the population of suburbs in 2021 was = ', x_1[1], '\n\n')

# population vector x_2

x_2 = M @ x_1

print('the population of the city in 2022 was = ', x_2[0],'\n')
print('the population of suburbs in 2022 was = ', x_1[1], '\n\n')
the population of city in 2021 was =  571200.0 

the population of suburbs in 2021 was =  33880.0 


the population of the city in 2022 was =  543656.4 

the population of suburbs in 2022 was =  33880.0 

Long-term behavior of dynamical systems#

Eigenvalues and eigenvectors can be used to understand the long-term behavior or evolution of a dynamical system described by an equation in the form of xk+1=Axk. We assume that A is diagonalizable with n linearly independent eigenvectors {v1,v2,,vn} and corresponding eigenvalues λ1,λ2,,λn. For convenience, let’s assume the eigenvectors are arranged such that |λ1||λ2||λn|. Since {v1,v2,,vn} forms a basis for Rn, any initial vector x0 can be expressed uniquely as:

x0=c1v1+c2v2++cnvn

By applying A to both sides, we have:

x1=Ax0=c1λ1v1+c2λ2v2++cnλnvn

And in general:

xk=Axk1=c1(λ1)kv1+c2(λ2)kv2++cn(λn)kvn()

The above equation represents the evolution of the system over time. It shows that each component of the vector xk is a linear combination of the eigenvectors vi, scaled by the corresponding eigenvalues λi raised to the power of k.

As an example, let’s consider a predator-prey system involving owls and wood rats. The population vectors xk at time k are given by:

xk=[OkRk]

where Ok is the population of owls and Rk is the population of rats (measured in thousands). The populations evolve according to the following equations:

Ok+1=(0.5)Ok+(0.4)RkRk+1=pOk+(1.1)Rk

Here, the coefficient 0.5 in the first equation says that, without wood rats for food, only half of the owls will survive each month. The coefficient 1.1 in the second equation says that, in the absence of owls as predators, the rat population will grow by 10% each month. The parameter p is a positive value to be specified.

To determine the evolution of this system, we can compute the eigenvalues and eigenvectors of the coefficient matrix A, and then apply equation (). For p=0.104, lets find the evolution of this system:

# coefficient matrix
A = np.array([[0.5, 0.4],[-0.104, 1.1]])

# Computing the eigenvalues and eigenvectors of A
np.linalg.eigvals(A)
array([0.58, 1.02])

Note that |λ1|1 and |λ2|1. A straightforward calculation shows that the corresponding eigenvectors are v1=[51] and v2=[1013], respectively. The initial vector x0 can be expressed as a linear combination of the eigenvectors:

x0=d1v1+d2v2=[v1,v2][d1d2]

Therefore, according to equation (), we have:

xk=d1(λ1)kv1+d2(λ2)kv2

As k, the term (λ1)kv1 approaches zero, allowing us to approximate:

xkd2(λ2)kv2

Furthermore, observe that:

xk+1d2(λ2)k+1v2=λ2xk=1.02xk

The above approximation shows that both the number of owls and rats grow by an approximate factor of 1.02 each month.

let’s calculate some population vectors, assuming the initial population vector is [1020].

import numpy as np

# A matrix whose columns are eigenvectors
evectors = np.array([[5, 10], [1, 13]])

# Initial vector
x_0 = np.array([1, 2])

# Solving the equation for d_1 and d_2
d = np.linalg.solve(evectors, x_0)

# Extracting d_2
d_2 = d[1]

# Eigenvalues corresponding to the eigenvectors
evalues = np.array([10, 20])  # Replace with the actual eigenvalues

# Iterating over the range
for k in range(10):
    # Calculating the population using the eigenvalues, eigenvectors, and d_2
    population = d_2 * pow(evalues[1], k+1) * evectors[1]
    print('At month', k+1, 'the owl population is', population[0],' and ', 'the rat population is', population[1],'\n')
At month 1 the owl population is 3.2727272727272725  and  the rat population is 42.54545454545454 

At month 2 the owl population is 65.45454545454545  and  the rat population is 850.9090909090909 

At month 3 the owl population is 1309.090909090909  and  the rat population is 17018.181818181816 

At month 4 the owl population is 26181.81818181818  and  the rat population is 340363.63636363635 

At month 5 the owl population is 523636.36363636365  and  the rat population is 6807272.7272727275 

At month 6 the owl population is 10472727.272727273  and  the rat population is 136145454.54545456 

At month 7 the owl population is 209454545.45454547  and  the rat population is 2722909090.909091 

At month 8 the owl population is -27786072.436363637  and  the rat population is -361218941.6727273 

At month 9 the owl population is 147091381.52727273  and  the rat population is 1912187959.8545456 

At month 10 the owl population is 130576309.52727273  and  the rat population is 1697492023.8545456 

Note that if the absolute values of both eigenvalues are less than 1, then both populations will tend towards zero for large values of k. If λ1=1 and λ2<1, then

xkd1(λ1)v1

Finally, if λ1=1 and λ21, then

xk=d1(λ1)v1+d2(λ2)kv2

Exercise#

Exercises

  1. Let A be a 2×2 matrix with eigenvalues 5 and 15 and corresponding eigenvectors

[11]and[11].

Let xk be a solution of xk+1=Axk, x0=[91] .

a. Compute x1=Ax0

b. Find a formula for xk involving k and the eigenvectors of A.

c. Describe what happens when k.